Skip to content

Commit 9d755cd

Browse files
committed
(WIP) added edit routes and load data
1 parent 141ac68 commit 9d755cd

File tree

3 files changed

+94
-10
lines changed

3 files changed

+94
-10
lines changed

client/src/components/pipelines/list.vue

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,27 @@
5858
<v-btn
5959
elevation="2"
6060
fab
61+
small
62+
class="ma-2"
63+
color="grey lighten-2"
6164
@click="deletePipeline(item.name)"
6265
>
6366
<v-icon dark>
6467
mdi-delete
6568
</v-icon>
6669
</v-btn>
70+
<v-btn
71+
elevation="2"
72+
fab
73+
small
74+
class="ma-2"
75+
color="grey lighten-2"
76+
:href="'#/pipeline/'+item.name"
77+
>
78+
<v-icon dark>
79+
mdi-pencil
80+
</v-icon>
81+
</v-btn>
6782
</v-col>
6883

6984
</v-row>
@@ -112,6 +127,9 @@ export default {
112127
console.log(error);
113128
});
114129
},
130+
editPipeline(app) {
131+
this.$router.push({ name: 'Edit Pipeline', params: { name: app } });
132+
},
115133
},
116134
}
117135
</script>

client/src/components/pipelines/new.vue

Lines changed: 70 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
:rules="nameRules"
2222
:counter="60"
2323
label="Pipeline name *"
24+
:disabled="!newPipeline"
2425
required
2526
></v-text-field>
2627
</v-col>
@@ -43,12 +44,12 @@
4344
md="8"
4445
>
4546
<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>
4950
<!--<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>
5253
</v-tabs>
5354
</v-col>
5455
</v-row>
@@ -64,7 +65,7 @@
6465
:counter="60"
6566
:items="gitrepoItems"
6667
label="Repository *"
67-
:disabled="repository_status.connected"
68+
:disabled="repository_status.connected || !newPipeline"
6869
required
6970
></v-combobox>
7071
</v-col>
@@ -160,12 +161,22 @@
160161
>
161162
<v-btn
162163
color="primary"
164+
v-if="newPipeline"
163165
elevation="2"
164-
@click="saveForm()"
166+
@click="createPipeline()"
165167
:disabled="!valid
166168
|| !gitrepo
167169
|| !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>
169180
</v-col>
170181
</v-row>
171182
</v-container>
@@ -175,7 +186,14 @@
175186
<script>
176187
import axios from "axios";
177188
export default {
189+
props: {
190+
pipeline: {
191+
type: String,
192+
default: "new"
193+
}
194+
},
178195
data: () => ({
196+
newPipeline: true,
179197
repotab: 'github', //selected tab
180198
buildpack: undefined,
181199
buildpackList: [],
@@ -270,6 +288,7 @@ export default {
270288
this.listRepositories();
271289
this.listBuildpacks();
272290
this.loadRepository();
291+
this.loadPipeline();
273292
},
274293
methods: {
275294
updateBuildpack(buildpack) {
@@ -412,7 +431,27 @@ export default {
412431
this.repository_status.statusTxt = "Failed to connect to repository API";
413432
});
414433
},
415-
saveForm() {
434+
loadPipeline() {
435+
if (this.pipeline !== 'new') {
436+
axios.get(`/api/pipelines/${this.pipeline}`)
437+
.then(response => {
438+
this.newPipeline = false;
439+
const p = response.data;
440+
this.pipelineName = p.name;
441+
this.domain = p.domain;
442+
this.gitrepo = p.git.repository.ssh_url;
443+
this.phases = p.phases;
444+
this.reviewapps = p.reviewapps;
445+
this.git = p.git;
446+
this.dockerimage = p.dockerimage;
447+
this.deploymentstrategy = p.deploymentstrategy;
448+
this.buildpack = p.buildpack;
449+
}).catch(error => {
450+
console.log(error);
451+
});
452+
}
453+
},
454+
createPipeline() {
416455
417456
// fake the minimal requirements to create a pipeline if the repo is not connectedd
418457
if (!this.repository_status.connected) {
@@ -448,7 +487,28 @@ export default {
448487
.catch(error => {
449488
console.log(error);
450489
});
451-
}
490+
},
491+
updatePipeline() {
492+
axios.put(`/api/pipelines/${this.pipeline}`, {
493+
pipelineName: this.pipelineName,
494+
domain: this.domain,
495+
gitrepo: this.gitrepo,
496+
phases: this.phases,
497+
reviewapps: this.reviewapps,
498+
git: this.git,
499+
dockerimage: '',
500+
deploymentstrategy: "git",
501+
buildpack: this.buildpack,
502+
})
503+
.then(response => {
504+
this.pipelineName = '';
505+
console.log(response);
506+
this.$router.push({path: '/'});
507+
})
508+
.catch(error => {
509+
console.log(error);
510+
});
511+
},
452512
},
453513
}
454514
</script>

client/src/router/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ export default new VueRouter({
3333
component: AppsNew,
3434
props: true
3535
},
36+
{
37+
path: "/pipeline/:pipeline",
38+
name: "Edit Pipeline",
39+
component: PipelineNew,
40+
props: true
41+
},
3642
{
3743
path: "/pipeline/:pipeline/:phase/:app",
3844
name: "Edit App",

0 commit comments

Comments
 (0)