|
21 | 21 | :rules="nameRules" |
22 | 22 | :counter="60" |
23 | 23 | label="Pipeline name *" |
| 24 | + :disabled="!newPipeline" |
24 | 25 | required |
25 | 26 | ></v-text-field> |
26 | 27 | </v-col> |
|
43 | 44 | md="8" |
44 | 45 | > |
45 | 46 | <v-tabs icons-and-text v-model="repotab" color="#8560A9" @change="loadRepository"> |
46 | | - <v-tab href="#github" :disabled="this.repositoriesList.github == false">Github <v-icon>mdi-github</v-icon> </v-tab> |
47 | | - <v-tab href="#gitea" :disabled="this.repositoriesList.gitea == false">Gitea <v-icon class="gitea"></v-icon></v-tab> |
48 | | - <v-tab href="#gitlab" :disabled="this.repositoriesList.gitlab == false">Gitlab <v-icon>mdi-gitlab</v-icon></v-tab> |
| 47 | + <v-tab href="#github" :disabled="this.repositoriesList.github == false || !newPipeline">Github <v-icon>mdi-github</v-icon> </v-tab> |
| 48 | + <v-tab href="#gitea" :disabled="this.repositoriesList.gitea == false || !newPipeline">Gitea <v-icon class="gitea"></v-icon></v-tab> |
| 49 | + <v-tab href="#gitlab" :disabled="this.repositoriesList.gitlab == false || !newPipeline">Gitlab <v-icon>mdi-gitlab</v-icon></v-tab> |
49 | 50 | <!--<v-tab href="#onedev" disabled>oneDev <v-icon class="onedev"></v-icon></v-tab>--> |
50 | | - <v-tab href="#gogs" :disabled="this.repositoriesList.gogs == false">Gogs <v-icon class="gogs"></v-icon></v-tab> |
51 | | - <v-tab href="#bitbucket" :disabled="this.repositoriesList.bitbucket == false">Bitbucket <v-icon>mdi-bitbucket</v-icon></v-tab> |
| 51 | + <v-tab href="#gogs" :disabled="this.repositoriesList.gogs == false || !newPipeline">Gogs <v-icon class="gogs"></v-icon></v-tab> |
| 52 | + <v-tab href="#bitbucket" :disabled="this.repositoriesList.bitbucket == false || !newPipeline">Bitbucket <v-icon>mdi-bitbucket</v-icon></v-tab> |
52 | 53 | </v-tabs> |
53 | 54 | </v-col> |
54 | 55 | </v-row> |
|
64 | 65 | :counter="60" |
65 | 66 | :items="gitrepoItems" |
66 | 67 | label="Repository *" |
67 | | - :disabled="repository_status.connected" |
| 68 | + :disabled="repository_status.connected || !newPipeline" |
68 | 69 | required |
69 | 70 | ></v-combobox> |
70 | 71 | </v-col> |
|
160 | 161 | > |
161 | 162 | <v-btn |
162 | 163 | color="primary" |
| 164 | + v-if="newPipeline" |
163 | 165 | elevation="2" |
164 | | - @click="saveForm()" |
| 166 | + @click="createPipeline()" |
165 | 167 | :disabled="!valid |
166 | 168 | || !gitrepo |
167 | 169 | || !buildpack" |
168 | | - >Sumbit</v-btn> |
| 170 | + >Create</v-btn> |
| 171 | + <v-btn |
| 172 | + color="primary" |
| 173 | + v-if="!newPipeline" |
| 174 | + elevation="2" |
| 175 | + @click="updatePipeline()" |
| 176 | + :disabled="!valid |
| 177 | + || !gitrepo |
| 178 | + || !buildpack" |
| 179 | + >Update</v-btn> |
169 | 180 | </v-col> |
170 | 181 | </v-row> |
171 | 182 | </v-container> |
|
175 | 186 | <script> |
176 | 187 | import axios from "axios"; |
177 | 188 | export default { |
| 189 | + props: { |
| 190 | + pipeline: { |
| 191 | + type: String, |
| 192 | + default: "new" |
| 193 | + } |
| 194 | + }, |
178 | 195 | data: () => ({ |
| 196 | + newPipeline: true, |
| 197 | + resourceVersion: undefined, |
179 | 198 | repotab: 'github', //selected tab |
180 | 199 | buildpack: undefined, |
181 | 200 | buildpackList: [], |
@@ -270,6 +289,7 @@ export default { |
270 | 289 | this.listRepositories(); |
271 | 290 | this.listBuildpacks(); |
272 | 291 | this.loadRepository(); |
| 292 | + this.loadPipeline(); |
273 | 293 | }, |
274 | 294 | methods: { |
275 | 295 | updateBuildpack(buildpack) { |
@@ -412,7 +432,29 @@ export default { |
412 | 432 | this.repository_status.statusTxt = "Failed to connect to repository API"; |
413 | 433 | }); |
414 | 434 | }, |
415 | | - saveForm() { |
| 435 | + loadPipeline() { |
| 436 | + if (this.pipeline !== 'new') { |
| 437 | + axios.get(`/api/pipelines/${this.pipeline}`) |
| 438 | + .then(response => { |
| 439 | + this.newPipeline = false; |
| 440 | + const p = response.data; |
| 441 | +
|
| 442 | + this.resourceVersion = p.resourceVersion; |
| 443 | + this.pipelineName = p.name; |
| 444 | + this.domain = p.domain; |
| 445 | + this.gitrepo = p.git.repository.ssh_url; |
| 446 | + this.phases = p.phases; |
| 447 | + this.reviewapps = p.reviewapps; |
| 448 | + this.git = p.git; |
| 449 | + this.dockerimage = p.dockerimage; |
| 450 | + this.deploymentstrategy = p.deploymentstrategy; |
| 451 | + this.buildpack = p.buildpack; |
| 452 | + }).catch(error => { |
| 453 | + console.log(error); |
| 454 | + }); |
| 455 | + } |
| 456 | + }, |
| 457 | + createPipeline() { |
416 | 458 |
|
417 | 459 | // fake the minimal requirements to create a pipeline if the repo is not connectedd |
418 | 460 | if (!this.repository_status.connected) { |
@@ -448,7 +490,29 @@ export default { |
448 | 490 | .catch(error => { |
449 | 491 | console.log(error); |
450 | 492 | }); |
451 | | - } |
| 493 | + }, |
| 494 | + updatePipeline() { |
| 495 | + axios.put(`/api/pipelines/${this.pipeline}`, { |
| 496 | + resourceVersion: this.resourceVersion, |
| 497 | + pipelineName: this.pipelineName, |
| 498 | + domain: this.domain, |
| 499 | + gitrepo: this.gitrepo, |
| 500 | + phases: this.phases, |
| 501 | + reviewapps: this.reviewapps, |
| 502 | + git: this.git, |
| 503 | + dockerimage: '', |
| 504 | + deploymentstrategy: "git", |
| 505 | + buildpack: this.buildpack, |
| 506 | + }) |
| 507 | + .then(response => { |
| 508 | + this.pipelineName = ''; |
| 509 | + console.log(response); |
| 510 | + this.$router.push({path: '/'}); |
| 511 | + }) |
| 512 | + .catch(error => { |
| 513 | + console.log(error); |
| 514 | + }); |
| 515 | + }, |
452 | 516 | }, |
453 | 517 | } |
454 | 518 | </script> |
|
0 commit comments