|
@@ -4,14 +4,16 @@ import github from '../../assets/github.png';
|
|
|
import info from '../../assets/info.svg';
|
|
import info from '../../assets/info.svg';
|
|
|
|
|
|
|
|
import api from '../../shared/api';
|
|
import api from '../../shared/api';
|
|
|
-import { RepoType } from '../../shared/types';
|
|
|
|
|
|
|
+import { RepoType, ChartType } from '../../shared/types';
|
|
|
import { Context } from '../../shared/Context';
|
|
import { Context } from '../../shared/Context';
|
|
|
|
|
|
|
|
import Loading from '../../components/Loading';
|
|
import Loading from '../../components/Loading';
|
|
|
import BranchList from './BranchList';
|
|
import BranchList from './BranchList';
|
|
|
import ContentsList from './ContentsList';
|
|
import ContentsList from './ContentsList';
|
|
|
|
|
+import NewGHAction from './NewGHAction';
|
|
|
|
|
|
|
|
type PropsType = {
|
|
type PropsType = {
|
|
|
|
|
+ chart: ChartType | null,
|
|
|
forceExpanded?: boolean,
|
|
forceExpanded?: boolean,
|
|
|
selectedRepo: RepoType | null,
|
|
selectedRepo: RepoType | null,
|
|
|
selectedBranch: string,
|
|
selectedBranch: string,
|
|
@@ -26,6 +28,9 @@ type StateType = {
|
|
|
loading: boolean,
|
|
loading: boolean,
|
|
|
error: boolean,
|
|
error: boolean,
|
|
|
repos: RepoType[]
|
|
repos: RepoType[]
|
|
|
|
|
+ branchGrID: number,
|
|
|
|
|
+ dockerfileSelected: boolean,
|
|
|
|
|
+ imageURL: string,
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
export default class RepoSelector extends Component<PropsType, StateType> {
|
|
export default class RepoSelector extends Component<PropsType, StateType> {
|
|
@@ -33,20 +38,65 @@ export default class RepoSelector extends Component<PropsType, StateType> {
|
|
|
isExpanded: this.props.forceExpanded,
|
|
isExpanded: this.props.forceExpanded,
|
|
|
loading: true,
|
|
loading: true,
|
|
|
error: false,
|
|
error: false,
|
|
|
- repos: [] as RepoType[]
|
|
|
|
|
|
|
+ repos: [] as RepoType[],
|
|
|
|
|
+ branchGrID: null as number,
|
|
|
|
|
+ dockerfileSelected: false,
|
|
|
|
|
+ imageURL: null as string,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
componentDidMount() {
|
|
|
- let { currentProject, currentCluster } = this.context;
|
|
|
|
|
|
|
+ let { currentProject } = this.context;
|
|
|
|
|
|
|
|
// Get repos
|
|
// Get repos
|
|
|
api.getGitRepos('<token>', {
|
|
api.getGitRepos('<token>', {
|
|
|
}, { project_id: currentProject.id }, (err: any, res: any) => {
|
|
}, { project_id: currentProject.id }, (err: any, res: any) => {
|
|
|
if (err) {
|
|
if (err) {
|
|
|
this.setState({ loading: false, error: true });
|
|
this.setState({ loading: false, error: true });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ var allRepos: any = [];
|
|
|
|
|
+ let counter = 0;
|
|
|
|
|
+ for (let i = 0; i < res.data.length; i++) {
|
|
|
|
|
+ var grid = res.data[i].id;
|
|
|
|
|
+ api.getGitRepoList('<token>', {}, { project_id: currentProject.id, git_repo_id: grid }, (err: any, res: any) => {
|
|
|
|
|
+ if (err) {
|
|
|
|
|
+ console.log(err);
|
|
|
|
|
+ this.setState({ loading: false, error: true });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ res.data.forEach((repo: any, id: number) => {
|
|
|
|
|
+ repo.GHRepoID = grid;
|
|
|
|
|
+ })
|
|
|
|
|
+ allRepos = allRepos.concat(res.data);
|
|
|
|
|
+ this.setState({ repos: allRepos, loading: false, error: false });
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ createGHAction = () => {
|
|
|
|
|
+ let { currentProject, currentCluster } = this.context;
|
|
|
|
|
+ let path = this.props.subdirectory + '/Dockerfile';
|
|
|
|
|
+ if (path[0] === '/') {
|
|
|
|
|
+ path = path.substring(1, path.length);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ api.createGHAction('<token>', {
|
|
|
|
|
+ git_repo: this.props.selectedRepo.FullName,
|
|
|
|
|
+ image_repo_uri: this.state.imageURL,
|
|
|
|
|
+ dockerfile_path: path,
|
|
|
|
|
+ git_repo_id: this.props.selectedRepo.GHRepoID,
|
|
|
|
|
+ }, {
|
|
|
|
|
+ project_id: currentProject.id,
|
|
|
|
|
+ CLUSTER_ID: currentCluster.id,
|
|
|
|
|
+ RELEASE_NAME: this.props.chart.name,
|
|
|
|
|
+ RELEASE_NAMESPACE: this.props.chart.namespace,
|
|
|
|
|
+ }, (err: any, res: any) => {
|
|
|
|
|
+ if (err) {
|
|
|
|
|
+ console.log(err);
|
|
|
|
|
+ this.setState({ error: true });
|
|
|
} else {
|
|
} else {
|
|
|
console.log(res.data);
|
|
console.log(res.data);
|
|
|
- this.setState({ repos: res.data, loading: false, error: false });
|
|
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
@@ -96,38 +146,81 @@ export default class RepoSelector extends Component<PropsType, StateType> {
|
|
|
<div>
|
|
<div>
|
|
|
<ExpandedWrapperAlt>
|
|
<ExpandedWrapperAlt>
|
|
|
<BranchList
|
|
<BranchList
|
|
|
- setSelectedBranch={(branch: string) => setSelectedBranch(branch)}
|
|
|
|
|
|
|
+ grid={selectedRepo.GHRepoID}
|
|
|
|
|
+ setSelectedBranch={(branch: string) => {
|
|
|
|
|
+ this.setState({ branchGrID: selectedRepo.GHRepoID });
|
|
|
|
|
+ setSelectedBranch(branch);
|
|
|
|
|
+ }}
|
|
|
repoName={selectedRepo.FullName.split('/')[1]}
|
|
repoName={selectedRepo.FullName.split('/')[1]}
|
|
|
|
|
+ owner={selectedRepo.FullName.split('/')[0]}
|
|
|
selectedBranch={selectedBranch}
|
|
selectedBranch={selectedBranch}
|
|
|
/>
|
|
/>
|
|
|
</ExpandedWrapperAlt>
|
|
</ExpandedWrapperAlt>
|
|
|
- <BackButton
|
|
|
|
|
- width='130px'
|
|
|
|
|
- onClick={() => setSelectedRepo(null)}
|
|
|
|
|
- >
|
|
|
|
|
- <i className="material-icons">keyboard_backspace</i>
|
|
|
|
|
- Select Repo
|
|
|
|
|
- </BackButton>
|
|
|
|
|
|
|
+ <ButtonTray>
|
|
|
|
|
+ <BackButton
|
|
|
|
|
+ width='130px'
|
|
|
|
|
+ onClick={() => setSelectedRepo(null)}
|
|
|
|
|
+ >
|
|
|
|
|
+ <i className="material-icons">keyboard_backspace</i>
|
|
|
|
|
+ Select Repo
|
|
|
|
|
+ </BackButton>
|
|
|
|
|
+ </ButtonTray>
|
|
|
</div>
|
|
</div>
|
|
|
);
|
|
);
|
|
|
|
|
+ } else if (this.state.dockerfileSelected) {
|
|
|
|
|
+ return (
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <ExpandedWrapperAlt>
|
|
|
|
|
+ <NewGHAction
|
|
|
|
|
+ repoName={selectedRepo.FullName}
|
|
|
|
|
+ dockerPath={subdirectory + '/Dockerfile'}
|
|
|
|
|
+ grid={this.state.branchGrID}
|
|
|
|
|
+ chart={this.props.chart}
|
|
|
|
|
+ imgURL={this.state.imageURL}
|
|
|
|
|
+ setURL={(x: string) => this.setState({ imageURL: x })}
|
|
|
|
|
+ />
|
|
|
|
|
+ </ExpandedWrapperAlt>
|
|
|
|
|
+ <ButtonTray>
|
|
|
|
|
+ <BackButton
|
|
|
|
|
+ width='130px'
|
|
|
|
|
+ onClick={() => this.setState({ dockerfileSelected: false })}
|
|
|
|
|
+ >
|
|
|
|
|
+ <i className='material-icons'>keyboard_backspace</i>
|
|
|
|
|
+ Select Dockerfile
|
|
|
|
|
+ </BackButton>
|
|
|
|
|
+ <BackButton
|
|
|
|
|
+ width='146px'
|
|
|
|
|
+ onClick={() => this.createGHAction()}
|
|
|
|
|
+ >
|
|
|
|
|
+ <i className='material-icons'>play_circle_outline</i>
|
|
|
|
|
+ Create Github Action
|
|
|
|
|
+ </BackButton>
|
|
|
|
|
+ </ButtonTray>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ )
|
|
|
}
|
|
}
|
|
|
return (
|
|
return (
|
|
|
<div>
|
|
<div>
|
|
|
<ExpandedWrapperAlt>
|
|
<ExpandedWrapperAlt>
|
|
|
<ContentsList
|
|
<ContentsList
|
|
|
|
|
+ grid={this.state.branchGrID}
|
|
|
setSubdirectory={(subdirectory: string) => setSubdirectory(subdirectory)}
|
|
setSubdirectory={(subdirectory: string) => setSubdirectory(subdirectory)}
|
|
|
repoName={selectedRepo.FullName.split('/')[1]}
|
|
repoName={selectedRepo.FullName.split('/')[1]}
|
|
|
|
|
+ owner={selectedRepo.FullName.split('/')[0]}
|
|
|
selectedBranch={selectedBranch}
|
|
selectedBranch={selectedBranch}
|
|
|
subdirectory={subdirectory}
|
|
subdirectory={subdirectory}
|
|
|
|
|
+ setDockerfile={() => this.setState({ dockerfileSelected: true })}
|
|
|
/>
|
|
/>
|
|
|
</ExpandedWrapperAlt>
|
|
</ExpandedWrapperAlt>
|
|
|
- <BackButton
|
|
|
|
|
- onClick={() => setSelectedBranch('')}
|
|
|
|
|
- width='140px'
|
|
|
|
|
- >
|
|
|
|
|
- <i className="material-icons">keyboard_backspace</i>
|
|
|
|
|
- Select Branch
|
|
|
|
|
- </BackButton>
|
|
|
|
|
|
|
+ <ButtonTray>
|
|
|
|
|
+ <BackButton
|
|
|
|
|
+ onClick={() => {setSelectedBranch(''); setSubdirectory(''); this.setState({ imageURL: '' })}}
|
|
|
|
|
+ width='140px'
|
|
|
|
|
+ >
|
|
|
|
|
+ <i className="material-icons">keyboard_backspace</i>
|
|
|
|
|
+ Select Branch
|
|
|
|
|
+ </BackButton>
|
|
|
|
|
+ </ButtonTray>
|
|
|
</div>
|
|
</div>
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
@@ -209,6 +302,14 @@ const BackButton = styled.div`
|
|
|
}
|
|
}
|
|
|
`;
|
|
`;
|
|
|
|
|
|
|
|
|
|
+const ButtonTray = styled.div`
|
|
|
|
|
+ margin-top: 10px;
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ flex-direction: row;
|
|
|
|
|
+ justify-content: space-between;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+`;
|
|
|
|
|
+
|
|
|
const RepoName = styled.div`
|
|
const RepoName = styled.div`
|
|
|
display: flex;
|
|
display: flex;
|
|
|
width: 100%;
|
|
width: 100%;
|