Browse Source

Merge branch 'dev' of HuangKaiSheng/seecoder-devcloud-frontend into master

ZhaoXingRui 5 years ago
parent
commit
e04058588b
1 changed files with 26 additions and 18 deletions
  1. 26 18
      src/views/Project/Pipeline.vue

+ 26 - 18
src/views/Project/Pipeline.vue

@@ -242,9 +242,9 @@
       >
       >
         <template #title>
         <template #title>
           <span>创建流水线</span>
           <span>创建流水线</span>
-          <span class="button-group">
-            <ElButton type="text">模板详解</ElButton>
-          </span>
+<!--          <span class="button-group">-->
+<!--            <ElButton type="text">模板详解</ElButton>-->
+<!--          </span>-->
         </template>
         </template>
         <ElForm
         <ElForm
           :model="createPipelineForm"
           :model="createPipelineForm"
@@ -355,6 +355,7 @@ import { APITestAPI, PipelineAPI } from '@/api';
 
 
 import { formatter } from '@/utils/time';
 import { formatter } from '@/utils/time';
 import { copy } from '@/utils/clipboard';
 import { copy } from '@/utils/clipboard';
+import { ElMessage } from 'element-plus';
 
 
 export default {
 export default {
   data() {
   data() {
@@ -518,21 +519,28 @@ export default {
       this.loading = false;
       this.loading = false;
     },
     },
     async handlePipelineCreateConfirm() {
     async handlePipelineCreateConfirm() {
-      this.confirmLoading = true;
-      this.$refs.createPipelineForm.validate(async (valid) => {
-        if (valid) {
-          await PipelineAPI.createPipeline({
-            projectId: this.$store.state.workspace.currentProjectId,
-            name: this.createPipelineForm.name,
-            templateName: this.createPipelineForm.template,
-          });
-          this.showPipelineCreateModal = false;
-          this.confirmLoading = false;
-          this.loading = true;
-          this.pipelines = await PipelineAPI.getPipelinesByProjectId(this.$store.state.workspace.currentProjectId);
-          this.loading = false;
-        }
-      });
+      const regExp = /^[a-z]([a-z]|-){2,29}/;
+      if (this.createPipelineForm.name.length < 3 || this.createPipelineForm.name.length > 30) {
+        ElMessage.warning('流水线名称长度必须在3-30之间!');
+      } else if (!regExp.test(this.createPipelineForm.name)) {
+        ElMessage.warning('流水线名称必须是以小写字母开头且由小写字母和-组成的字符串!');
+      } else if (this.createPipelineForm.template.length === 0) {
+        ElMessage.warning('还未选择模板!');
+      } else {
+        this.$refs.createPipelineForm.validate(async (valid) => {
+          if (valid) {
+            await PipelineAPI.createPipeline({
+              projectId: this.$store.state.workspace.currentProjectId,
+              name: this.createPipelineForm.name,
+              templateName: this.createPipelineForm.template,
+            });
+            this.showPipelineCreateModal = false;
+            this.loading = true;
+            this.pipelines = await PipelineAPI.getPipelinesByProjectId(this.$store.state.workspace.currentProjectId);
+            this.loading = false;
+          }
+        });
+      }
     },
     },
     open(url, target) {
     open(url, target) {
       window.open(url, target);
       window.open(url, target);