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

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

View File

@ -23,6 +23,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;
@ -145,4 +146,9 @@ public class ProjectController {
public void updateMember(@RequestBody WorkspaceMemberDTO memberDTO) {
projectService.updateMember(memberDTO);
}
@GetMapping("/getOwnerProjectIds")
public Collection<String> getOwnerProjectIds() {
return checkPermissionService.getUserRelatedProjectIds();
}
}

View File

@ -39,7 +39,7 @@ public class CheckPermissionService {
}
}
private Set<String> getUserRelatedProjectIds() {
public Set<String> getUserRelatedProjectIds() {
List<String> groupIds = Objects.requireNonNull(SessionUtils.getUser()).getGroups()
.stream()
.filter(g -> StringUtils.equals(g.getType(), UserGroupType.PROJECT))

View File

@ -126,7 +126,7 @@ export default {
//1
//hashTreeID
let scenarioId = "";
if (item.scenario !== null) {
if (item.scenario) {
let scenarioArr = JSON.parse(item.scenario);
if (scenarioArr.length > 1) {
let scenarioIdArr = scenarioArr[0].split("_");
@ -160,7 +160,7 @@ export default {
if (i === nodeArray.length - 2) {
idIsPath = false;
let childId = "";
if (children[j].value != null && children[j].value.scenario !== null) {
if (children[j].value && children[j].value.scenario) {
let scenarioArr = JSON.parse(children[j].value.scenario);
if (scenarioArr.length > 1) {
let childArr = scenarioArr[0].split("_");

View File

@ -136,6 +136,7 @@
<el-col :span="4">
<env-popover :disabled="scenarioDefinition.length < 1" :env-map="projectEnvMap"
:project-ids="projectIds" @setProjectEnvMap="setProjectEnvMap" :result="envResult"
:show-config-button-with-out-permission="showConfigButtonWithOutPermission"
:isReadOnly="scenarioDefinition.length < 1" @showPopover="showPopover"
:project-list="projectList" ref="envPopover"/>
</el-col>
@ -317,6 +318,7 @@ export default {
data() {
return {
enableContinues: false,
showConfigButtonWithOutPermission:false,
props: {
label: "label",
children: "hashTree"

View File

@ -7,6 +7,7 @@
@show="showPopover"
trigger="click">
<env-select :project-ids="projectIds" :env-map="envMap" @close="visible = false" :result="result"
: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,12 +5,12 @@
<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"
<el-button class="ms-scenario-button" v-if="isShowConfirmButton(pe.id)" size="mini" type="primary"
@click="openEnvironmentConfig(pe.id, pe['selectEnv'])">
{{ $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, pe['selectEnv'])">
{{ $t('api_test.environment.environment_config') }}
@ -41,6 +41,12 @@ export default {
envMap: Map,
projectIds: Set,
projectList: Array,
showConfigButtonWithOutPermission:{
type: Boolean,
default() {
return true;
}
},
result: {
type: Object,
default() {
@ -54,12 +60,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();
}
let arr = [];
this.projectIds.forEach(id => {
const project = this.projectList.find(p => p.id === id);
@ -86,6 +113,11 @@ export default {
})
return arr;
},
getUserPermissionProjectIds(){
this.$get('/project/getOwnerProjectIds/', res => {
this.permissionProjectIds = res.data;
})
},
open() {
this.data = [];
if (this.projectIds.size > 0) {