|
@@ -128,13 +128,27 @@
|
|
|
<span>编辑流水线配置</span>
|
|
<span>编辑流水线配置</span>
|
|
|
</template>
|
|
</template>
|
|
|
<ElSteps :active="activeStep">
|
|
<ElSteps :active="activeStep">
|
|
|
- <ElStep v-for="(stage, index) in stages" :key="index" :title="stage.title" :description="stage.description">
|
|
|
|
|
|
|
+ <ElStep
|
|
|
|
|
+ v-for="(config, index) in pipelineConfig"
|
|
|
|
|
+ :key="index"
|
|
|
|
|
+ :title="getStage(config.name).title"
|
|
|
|
|
+ :description="getStage(config.name).description"
|
|
|
|
|
+ >
|
|
|
</ElStep>
|
|
</ElStep>
|
|
|
</ElSteps>
|
|
</ElSteps>
|
|
|
- <div class="edit-pipeline-form" v-for="(stage, index) in stages" :key="index" v-show="activeStep === index">
|
|
|
|
|
- <ElForm label-width="80px">
|
|
|
|
|
- <ElFormItem v-for="(item, index) in stage.config" :key="index" :label="item.name">
|
|
|
|
|
- <ElInput :disabled="!item.editable" v-model="item.value"></ElInput>
|
|
|
|
|
|
|
+ <div class="edit-pipeline-form" v-for="(config, index) in pipelineConfig" :key="index" v-show="activeStep === index">
|
|
|
|
|
+ <ElForm label-width="160px">
|
|
|
|
|
+ <div style="margin: 20px 0 20px 160px;">
|
|
|
|
|
+ <ElCheckbox
|
|
|
|
|
+ :disabled="!getStage(config.name).skippable"
|
|
|
|
|
+ v-model="config.active"
|
|
|
|
|
+ >启用该阶段</ElCheckbox>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <ElFormItem v-for="(val, key) in config.configs" :key="key" :label="key">
|
|
|
|
|
+ <ElInput
|
|
|
|
|
+ :disabled="!getStage(config.name).configs.find((config) => config.name === key).editable"
|
|
|
|
|
+ v-model="config.configs[key]"
|
|
|
|
|
+ ></ElInput>
|
|
|
</ElFormItem>
|
|
</ElFormItem>
|
|
|
</ElForm>
|
|
</ElForm>
|
|
|
</div>
|
|
</div>
|
|
@@ -275,6 +289,19 @@ export default {
|
|
|
isLastStep() {
|
|
isLastStep() {
|
|
|
return this.activeStep === this.stages.length - 1;
|
|
return this.activeStep === this.stages.length - 1;
|
|
|
},
|
|
},
|
|
|
|
|
+ stageConfigsBase() {
|
|
|
|
|
+ return this.stages.map((stage) => ({
|
|
|
|
|
+ name: stage.name,
|
|
|
|
|
+ active: true,
|
|
|
|
|
+ configs: stage.configs.map(({ name, value, editable }) => ({
|
|
|
|
|
+ [name]: value,
|
|
|
|
|
+ editable,
|
|
|
|
|
+ })).reduce((prev, curr) => Object.assign(prev, curr), {}),
|
|
|
|
|
+ }));
|
|
|
|
|
+ },
|
|
|
|
|
+ stageConfigs() {
|
|
|
|
|
+ return this.stageConfigsBase;
|
|
|
|
|
+ },
|
|
|
},
|
|
},
|
|
|
async mounted() {
|
|
async mounted() {
|
|
|
this.pipelines = await PipelineAPI.getPipelinesByProjectId(this.$store.state.workspace.currentProjectId);
|
|
this.pipelines = await PipelineAPI.getPipelinesByProjectId(this.$store.state.workspace.currentProjectId);
|
|
@@ -315,11 +342,11 @@ export default {
|
|
|
case 'edit': {
|
|
case 'edit': {
|
|
|
this.showPipelineEditModal = true;
|
|
this.showPipelineEditModal = true;
|
|
|
this.editingPipelineId = id;
|
|
this.editingPipelineId = id;
|
|
|
- // TODO: stage与config进行合并生成form-model用于渲染和更改
|
|
|
|
|
- this.pipelineConfig = await PipelineAPI.getPipeline({
|
|
|
|
|
|
|
+ const config = (await PipelineAPI.getPipeline({
|
|
|
projectId: this.$store.state.workspace.currentProjectId,
|
|
projectId: this.$store.state.workspace.currentProjectId,
|
|
|
pipelineId: id,
|
|
pipelineId: id,
|
|
|
- }).configJson || '{}';
|
|
|
|
|
|
|
+ })).configJson;
|
|
|
|
|
+ this.pipelineConfig = JSON.parse(config || '{}');
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
case 'delete': {
|
|
case 'delete': {
|
|
@@ -338,7 +365,7 @@ export default {
|
|
|
await PipelineAPI.updatePipeline({
|
|
await PipelineAPI.updatePipeline({
|
|
|
projectId: this.$store.state.workspace.currentProjectId,
|
|
projectId: this.$store.state.workspace.currentProjectId,
|
|
|
pipelineId: this.editingPipelineId,
|
|
pipelineId: this.editingPipelineId,
|
|
|
- configJson: JSON.stringify(JSON.parse(this.pipelineConfig)),
|
|
|
|
|
|
|
+ configJson: JSON.stringify(this.pipelineConfig),
|
|
|
});
|
|
});
|
|
|
this.showPipelineEditModal = false;
|
|
this.showPipelineEditModal = false;
|
|
|
},
|
|
},
|
|
@@ -361,6 +388,9 @@ export default {
|
|
|
async deleteProduction(id) {
|
|
async deleteProduction(id) {
|
|
|
await PipelineAPI.deleteInstance(id);
|
|
await PipelineAPI.deleteInstance(id);
|
|
|
},
|
|
},
|
|
|
|
|
+ getStage(stageName) {
|
|
|
|
|
+ return this.stages.find((stage) => stage.name === stageName);
|
|
|
|
|
+ },
|
|
|
},
|
|
},
|
|
|
};
|
|
};
|
|
|
</script>
|
|
</script>
|