refactor(系统设置): 创建环境时全局前后置脚本不展示变更历史

This commit is contained in:
junhong 2022-02-15 16:16:24 +08:00 committed by 刘瑞斌
parent 861ebc2e37
commit b9983880ea
2 changed files with 18 additions and 4 deletions

View File

@ -7,7 +7,7 @@
:env-add-permission="['PROJECT_ENVIRONMENT:READ+CREATE']" :env-add-permission="['PROJECT_ENVIRONMENT:READ+CREATE']"
:data="environments" :item-operators="environmentOperators" :add-fuc="addEnvironment" :data="environments" :item-operators="environmentOperators" :add-fuc="addEnvironment"
:delete-fuc="deleteEnvironment" @itemSelected="environmentSelected" ref="environmentItems"/> :delete-fuc="deleteEnvironment" @itemSelected="environmentSelected" ref="environmentItems"/>
<environment-edit :environment="currentEnvironment" ref="environmentEdit" @close="close" :is-read-only="isReadOnly"/> <environment-edit :if-create="ifCreate" :environment="currentEnvironment" ref="environmentEdit" @close="close" :is-read-only="isReadOnly"/>
</el-container> </el-container>
</el-dialog> </el-dialog>
</template> </template>
@ -50,7 +50,8 @@
permissions: ['PROJECT_ENVIRONMENT:READ+DELETE'] permissions: ['PROJECT_ENVIRONMENT:READ+DELETE']
} }
], ],
selectEnvironmentId: '' selectEnvironmentId: '',
ifCreate: false, //
} }
}, },
computed: { computed: {
@ -67,6 +68,7 @@
listenGoBack(this.close); listenGoBack(this.close);
}, },
deleteEnvironment(environment, index) { deleteEnvironment(environment, index) {
this.ifCreate = false;
if (environment.id) { if (environment.id) {
this.result = this.$get('/api/environment/delete/' + environment.id, () => { this.result = this.$get('/api/environment/delete/' + environment.id, () => {
this.$success(this.$t('commons.delete_success')); this.$success(this.$t('commons.delete_success'));
@ -78,6 +80,7 @@
} }
}, },
copyEnvironment(environment) { copyEnvironment(environment) {
this.ifCreate = false;
this.currentEnvironment = environment; this.currentEnvironment = environment;
if (!environment.id) { if (!environment.id) {
this.$warning(this.$t('commons.please_save')); this.$warning(this.$t('commons.please_save'));
@ -110,6 +113,7 @@
return name; return name;
}, },
addEnvironment() { addEnvironment() {
this.ifCreate = true;
let newEnvironment = new Environment({ let newEnvironment = new Environment({
projectId: this.projectId projectId: this.projectId
}); });
@ -147,6 +151,9 @@
getEnvironment(environment) { getEnvironment(environment) {
parseEnvironment(environment); parseEnvironment(environment);
this.currentEnvironment = environment; this.currentEnvironment = environment;
if(this.currentEnvironment.name){
this.ifCreate = false;
}
}, },
close() { close() {
this.$emit('close'); this.$emit('close');

View File

@ -7,7 +7,7 @@
:data="environments" :item-operators="environmentOperators" :add-fuc="addEnvironment" :data="environments" :item-operators="environmentOperators" :add-fuc="addEnvironment"
:env-add-permission="ENV_CREATE" :env-add-permission="ENV_CREATE"
:delete-fuc="deleteEnvironment" @itemSelected="environmentSelected" ref="environmentItems"/> :delete-fuc="deleteEnvironment" @itemSelected="environmentSelected" ref="environmentItems"/>
<environment-edit :project-id="projectId" :environment="currentEnvironment" ref="environmentEdit" :is-read-only="isReadOnly" <environment-edit :if-create="ifCreate" :project-id="projectId" :environment="currentEnvironment" ref="environmentEdit" :is-read-only="isReadOnly"
@close="close"/> @close="close"/>
</el-container> </el-container>
</el-dialog> </el-dialog>
@ -53,7 +53,8 @@
['PROJECT_ENVIRONMENT:READ+DELETE'] : ['WORKSPACE_PROJECT_ENVIRONMENT:READ+DELETE'] ['PROJECT_ENVIRONMENT:READ+DELETE'] : ['WORKSPACE_PROJECT_ENVIRONMENT:READ+DELETE']
} }
], ],
selectEnvironmentId: '' selectEnvironmentId: '',
ifCreate: false, //
} }
}, },
props: { props: {
@ -88,6 +89,7 @@
listenGoBack(this.close); listenGoBack(this.close);
}, },
deleteEnvironment(environment, index) { deleteEnvironment(environment, index) {
this.ifCreate = false;
if (environment.id) { if (environment.id) {
this.result = this.$get('/api/environment/delete/' + environment.id, () => { this.result = this.$get('/api/environment/delete/' + environment.id, () => {
this.$success(this.$t('commons.delete_success')); this.$success(this.$t('commons.delete_success'));
@ -99,6 +101,7 @@
} }
}, },
copyEnvironment(environment) { copyEnvironment(environment) {
this.ifCreate = false;
// //
this.environmentSelected(environment); this.environmentSelected(environment);
this.currentEnvironment = environment; this.currentEnvironment = environment;
@ -133,6 +136,7 @@
return name; return name;
}, },
addEnvironment() { addEnvironment() {
this.ifCreate = true;
let newEnvironment = new Environment({ let newEnvironment = new Environment({
projectId: this.projectId projectId: this.projectId
}); });
@ -170,6 +174,9 @@
getEnvironment(environment) { getEnvironment(environment) {
parseEnvironment(environment); parseEnvironment(environment);
this.currentEnvironment = environment; this.currentEnvironment = environment;
if(this.currentEnvironment.name){
this.ifCreate = false;
}
}, },
close() { close() {
this.$emit('close'); this.$emit('close');