fix: 修复跨项目引用场景时不同用户权限引起的缺陷

场景中存在引用无权限的项目,展开运行环境直接报错。现在改为没有权限的用户环境展开时只能进行选择,不能进行配置
This commit is contained in:
song-tianyang 2021-06-10 16:18:48 +08:00 committed by 刘瑞斌
parent 3f8bc94378
commit b14abedb88
4 changed files with 46 additions and 4 deletions

View File

@ -17,6 +17,7 @@
</el-form-item>
<el-form-item v-if="form.type === 'projectEnv'" :label="$t('test_track.case.updated_attr_value')">
<env-popover :env-map="projectEnvMap" :project-ids="projectIds" @setProjectEnvMap="setProjectEnvMap"
:show-config-button-with-out-permission="showConfigButtonWithOutPermission"
:project-list="projectList" ref="envPopover"/>
</el-form-item>
<el-form-item v-else :label="$t('test_track.case.updated_attr_value')" prop="value">
@ -61,6 +62,7 @@
data() {
return {
dialogVisible: false,
showConfigButtonWithOutPermission:false,
form: {},
size: 0,
rules: {

View File

@ -7,6 +7,7 @@
@show="showPopover"
trigger="click">
<env-select :project-ids="projectIds" :env-map="envMap" @close="visible = false"
:show-config-button-with-out-permission="showConfigButtonWithOutPermission"
ref="envSelect" @setProjectEnvMap="setProjectEnvMap" :project-list="projectList"/>
<el-button type="primary" slot="reference" size="mini" style="margin-top: 2px;">
{{ $t('api_test.definition.request.run_env') }}
@ -25,6 +26,12 @@ export default {
envMap: Map,
projectIds: Set,
projectList: Array,
showConfigButtonWithOutPermission:{
type: Boolean,
default() {
return true;
}
},
isReadOnly: {
type: Boolean,
default() {

View File

@ -5,11 +5,11 @@
<el-option v-for="(environment, index) in pe.envs" :key="index"
:label="environment.name"
:value="environment.id"/>
<el-button class="ms-scenario-button" size="mini" type="primary" @click="openEnvironmentConfig(pe.id)">
<el-button class="ms-scenario-button" v-if="isShowConfirmButton(pe.id)" size="mini" type="primary" @click="openEnvironmentConfig(pe.id)">
{{ $t('api_test.environment.environment_config') }}
</el-button>
<template v-slot:empty>
<div class="empty-environment">
<div v-if="isShowConfirmButton(pe.id)" class="empty-environment">
<el-button class="ms-scenario-button" size="mini" type="primary" @click="openEnvironmentConfig(pe.id)">
{{ $t('api_test.environment.environment_config') }}
</el-button>
@ -38,6 +38,12 @@ export default {
props: {
envMap: Map,
projectIds: Set,
showConfigButtonWithOutPermission:{
type: Boolean,
default() {
return true;
}
},
projectList: Array
},
data() {
@ -46,12 +52,33 @@ export default {
result: {},
projects: [],
environments: [],
permissionProjectIds:[],
dialogVisible: false,
isFullUrl: true,
};
},
methods: {
isShowConfirmButton(projectId){
if(this.showConfigButtonWithOutPermission === true){
return true;
}else{
if(this.permissionProjectIds){
if(this.permissionProjectIds.indexOf(projectId)<0){
return false;
}else {
return true;
}
}else{
return false;
}
}
},
init() {
//ID
if(this.permissionProjectIds.length === 0){
this.getUserPermissionProjectIds();
}
this.projectIds.forEach(id => {
const project = this.projectList.find(p => p.id === id);
if (project) {
@ -138,7 +165,12 @@ export default {
},
environmentConfigClose() {
// todo
}
},
getUserPermissionProjectIds(){
this.$get('/project/getOwnerProjectIds/', res => {
this.permissionProjectIds = res.data;
})
},
}
};
</script>

View File

@ -8,8 +8,8 @@
<el-input :placeholder="$t('api_test.definition.request.select_case')" @blur="search"
@keyup.enter.native="search" class="search-input" size="small" v-model="condition.name"/>
</el-col>
<env-popover :env-map="projectEnvMap" :project-ids="projectIds" @setProjectEnvMap="setProjectEnvMap"
:show-config-button-with-out-permission="showConfigButtonWithOutPermission"
:project-list="projectList" ref="envPopover" class="env-popover"/>
</el-row>
</template>
@ -92,6 +92,7 @@
data() {
return {
result: {},
showConfigButtonWithOutPermission:false,
condition: {},
currentScenario: {},
schedule: {},