|
|
@@ -66,7 +66,8 @@ export default class ContentsList extends Component<PropsType, StateType> {
|
|
|
fetchContents = () => {
|
|
|
let { currentProject } = this.context;
|
|
|
const { actionConfig, branch } = this.props;
|
|
|
- if (actionConfig.gitlab_integration_id > 0) {
|
|
|
+
|
|
|
+ if (actionConfig.kind === "gitlab") {
|
|
|
return api.getGitlabFolderContent(
|
|
|
"<token>",
|
|
|
{ dir: this.state.currentDir || "./" },
|
|
|
@@ -78,10 +79,31 @@ export default class ContentsList extends Component<PropsType, StateType> {
|
|
|
branch: branch,
|
|
|
}
|
|
|
);
|
|
|
- } else {
|
|
|
- return api.getBranchContents(
|
|
|
+ }
|
|
|
+ return api.getBranchContents(
|
|
|
+ "<token>",
|
|
|
+ { dir: this.state.currentDir || "./" },
|
|
|
+ {
|
|
|
+ project_id: currentProject.id,
|
|
|
+ git_repo_id: actionConfig.git_repo_id,
|
|
|
+ kind: "github",
|
|
|
+ owner: actionConfig.git_repo.split("/")[0],
|
|
|
+ name: actionConfig.git_repo.split("/")[1],
|
|
|
+ branch: branch,
|
|
|
+ }
|
|
|
+ );
|
|
|
+ };
|
|
|
+
|
|
|
+ detectBuildpacks = () => {
|
|
|
+ let { currentProject } = this.context;
|
|
|
+ let { actionConfig, branch } = this.props;
|
|
|
+
|
|
|
+ if (actionConfig.kind === "github") {
|
|
|
+ return api.detectBuildpack(
|
|
|
"<token>",
|
|
|
- { dir: this.state.currentDir || "./" },
|
|
|
+ {
|
|
|
+ dir: this.state.currentDir || ".",
|
|
|
+ },
|
|
|
{
|
|
|
project_id: currentProject.id,
|
|
|
git_repo_id: actionConfig.git_repo_id,
|
|
|
@@ -92,12 +114,44 @@ export default class ContentsList extends Component<PropsType, StateType> {
|
|
|
}
|
|
|
);
|
|
|
}
|
|
|
+
|
|
|
+ return new Promise((_res, reject) => reject(new Error("Not implemented")));
|
|
|
};
|
|
|
|
|
|
- updateContents = () => {
|
|
|
+ fetchProcfileContent = (procfilePath: string) => {
|
|
|
let { currentProject } = this.context;
|
|
|
let { actionConfig, branch } = this.props;
|
|
|
+ if (actionConfig.kind === "github") {
|
|
|
+ return api.getProcfileContents(
|
|
|
+ "<token>",
|
|
|
+ {
|
|
|
+ path: procfilePath,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ project_id: currentProject.id,
|
|
|
+ git_repo_id: actionConfig.git_repo_id,
|
|
|
+ kind: "github",
|
|
|
+ owner: actionConfig.git_repo.split("/")[0],
|
|
|
+ name: actionConfig.git_repo.split("/")[1],
|
|
|
+ branch: branch,
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
|
|
|
+ return api.getGitlabProcfileContents(
|
|
|
+ "<token>",
|
|
|
+ { path: procfilePath },
|
|
|
+ {
|
|
|
+ project_id: currentProject.id,
|
|
|
+ integration_id: actionConfig.gitlab_integration_id,
|
|
|
+ owner: actionConfig.git_repo.split("/")[0],
|
|
|
+ name: actionConfig.git_repo.split("/")[1],
|
|
|
+ branch: branch,
|
|
|
+ }
|
|
|
+ );
|
|
|
+ };
|
|
|
+
|
|
|
+ updateContents = () => {
|
|
|
// Get branch contents
|
|
|
this.fetchContents()
|
|
|
.then((res) => {
|
|
|
@@ -123,21 +177,7 @@ export default class ContentsList extends Component<PropsType, StateType> {
|
|
|
this.setState({ loading: false, error: true });
|
|
|
});
|
|
|
|
|
|
- api
|
|
|
- .detectBuildpack(
|
|
|
- "<token>",
|
|
|
- {
|
|
|
- dir: this.state.currentDir || ".",
|
|
|
- },
|
|
|
- {
|
|
|
- project_id: currentProject.id,
|
|
|
- git_repo_id: actionConfig.git_repo_id,
|
|
|
- kind: "github",
|
|
|
- owner: actionConfig.git_repo.split("/")[0],
|
|
|
- name: actionConfig.git_repo.split("/")[1],
|
|
|
- branch: branch,
|
|
|
- }
|
|
|
- )
|
|
|
+ this.detectBuildpacks()
|
|
|
.then(({ data }) => {
|
|
|
this.setState({
|
|
|
autoBuildpack: data,
|
|
|
@@ -155,23 +195,9 @@ export default class ContentsList extends Component<PropsType, StateType> {
|
|
|
let ppath =
|
|
|
this.props.procfilePath ||
|
|
|
`${this.state.currentDir ? this.state.currentDir : "."}/Procfile`;
|
|
|
- api
|
|
|
- .getProcfileContents(
|
|
|
- "<token>",
|
|
|
- {
|
|
|
- path: ppath,
|
|
|
- },
|
|
|
- {
|
|
|
- project_id: currentProject.id,
|
|
|
- git_repo_id: actionConfig.git_repo_id,
|
|
|
- kind: "github",
|
|
|
- owner: actionConfig.git_repo.split("/")[0],
|
|
|
- name: actionConfig.git_repo.split("/")[1],
|
|
|
- branch: branch,
|
|
|
- }
|
|
|
- )
|
|
|
- .then((res) => {
|
|
|
- this.setState({ processes: res.data });
|
|
|
+ this.fetchProcfileContent(ppath)
|
|
|
+ .then(({ data }) => {
|
|
|
+ this.setState({ processes: data });
|
|
|
})
|
|
|
.catch((err) => {
|
|
|
console.log(err);
|