fix: 修复跨项目引用场景时不同用户权限引起的缺陷
场景中存在引用无权限的项目,展开运行环境直接报错。现在改为没有权限的用户环境展开时只能进行选择,不能进行配置
This commit is contained in:
parent
4380f26f5e
commit
3f8bc94378
|
@ -23,6 +23,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
@ -145,4 +146,9 @@ public class ProjectController {
|
||||||
public void updateMember(@RequestBody WorkspaceMemberDTO memberDTO) {
|
public void updateMember(@RequestBody WorkspaceMemberDTO memberDTO) {
|
||||||
projectService.updateMember(memberDTO);
|
projectService.updateMember(memberDTO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/getOwnerProjectIds")
|
||||||
|
public Collection<String> getOwnerProjectIds() {
|
||||||
|
return checkPermissionService.getUserRelatedProjectIds();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class CheckPermissionService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<String> getUserRelatedProjectIds() {
|
public Set<String> getUserRelatedProjectIds() {
|
||||||
List<String> groupIds = Objects.requireNonNull(SessionUtils.getUser()).getGroups()
|
List<String> groupIds = Objects.requireNonNull(SessionUtils.getUser()).getGroups()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(g -> StringUtils.equals(g.getType(), UserGroupType.PROJECT))
|
.filter(g -> StringUtils.equals(g.getType(), UserGroupType.PROJECT))
|
||||||
|
|
|
@ -126,7 +126,7 @@ export default {
|
||||||
//运行场景中如果连续将1个场景引入多次,会出现运行结果合并的情况。
|
//运行场景中如果连续将1个场景引入多次,会出现运行结果合并的情况。
|
||||||
//为了解决这种问题,在转hashTree的时候给场景放了个新ID,前台加载解析的时候也要做处理
|
//为了解决这种问题,在转hashTree的时候给场景放了个新ID,前台加载解析的时候也要做处理
|
||||||
let scenarioId = "";
|
let scenarioId = "";
|
||||||
if (item.scenario !== null) {
|
if (item.scenario) {
|
||||||
let scenarioArr = JSON.parse(item.scenario);
|
let scenarioArr = JSON.parse(item.scenario);
|
||||||
if (scenarioArr.length > 1) {
|
if (scenarioArr.length > 1) {
|
||||||
let scenarioIdArr = scenarioArr[0].split("_");
|
let scenarioIdArr = scenarioArr[0].split("_");
|
||||||
|
@ -160,7 +160,7 @@ export default {
|
||||||
if (i === nodeArray.length - 2) {
|
if (i === nodeArray.length - 2) {
|
||||||
idIsPath = false;
|
idIsPath = false;
|
||||||
let childId = "";
|
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);
|
let scenarioArr = JSON.parse(children[j].value.scenario);
|
||||||
if (scenarioArr.length > 1) {
|
if (scenarioArr.length > 1) {
|
||||||
let childArr = scenarioArr[0].split("_");
|
let childArr = scenarioArr[0].split("_");
|
||||||
|
|
|
@ -136,6 +136,7 @@
|
||||||
<el-col :span="4">
|
<el-col :span="4">
|
||||||
<env-popover :disabled="scenarioDefinition.length < 1" :env-map="projectEnvMap"
|
<env-popover :disabled="scenarioDefinition.length < 1" :env-map="projectEnvMap"
|
||||||
:project-ids="projectIds" @setProjectEnvMap="setProjectEnvMap" :result="envResult"
|
:project-ids="projectIds" @setProjectEnvMap="setProjectEnvMap" :result="envResult"
|
||||||
|
:show-config-button-with-out-permission="showConfigButtonWithOutPermission"
|
||||||
:isReadOnly="scenarioDefinition.length < 1" @showPopover="showPopover"
|
:isReadOnly="scenarioDefinition.length < 1" @showPopover="showPopover"
|
||||||
:project-list="projectList" ref="envPopover"/>
|
:project-list="projectList" ref="envPopover"/>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
@ -317,6 +318,7 @@ export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
enableContinues: false,
|
enableContinues: false,
|
||||||
|
showConfigButtonWithOutPermission:false,
|
||||||
props: {
|
props: {
|
||||||
label: "label",
|
label: "label",
|
||||||
children: "hashTree"
|
children: "hashTree"
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
@show="showPopover"
|
@show="showPopover"
|
||||||
trigger="click">
|
trigger="click">
|
||||||
<env-select :project-ids="projectIds" :env-map="envMap" @close="visible = false" :result="result"
|
<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"/>
|
ref="envSelect" @setProjectEnvMap="setProjectEnvMap" :project-list="projectList"/>
|
||||||
<el-button type="primary" slot="reference" size="mini" style="margin-top: 2px;">
|
<el-button type="primary" slot="reference" size="mini" style="margin-top: 2px;">
|
||||||
{{ $t('api_test.definition.request.run_env') }}
|
{{ $t('api_test.definition.request.run_env') }}
|
||||||
|
@ -25,6 +26,12 @@ export default {
|
||||||
envMap: Map,
|
envMap: Map,
|
||||||
projectIds: Set,
|
projectIds: Set,
|
||||||
projectList: Array,
|
projectList: Array,
|
||||||
|
showConfigButtonWithOutPermission:{
|
||||||
|
type: Boolean,
|
||||||
|
default() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
},
|
||||||
isReadOnly: {
|
isReadOnly: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default() {
|
default() {
|
||||||
|
|
|
@ -5,12 +5,12 @@
|
||||||
<el-option v-for="(environment, index) in pe.envs" :key="index"
|
<el-option v-for="(environment, index) in pe.envs" :key="index"
|
||||||
:label="environment.name"
|
:label="environment.name"
|
||||||
:value="environment.id"/>
|
: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'])">
|
@click="openEnvironmentConfig(pe.id, pe['selectEnv'])">
|
||||||
{{ $t('api_test.environment.environment_config') }}
|
{{ $t('api_test.environment.environment_config') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
<template v-slot:empty>
|
<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"
|
<el-button class="ms-scenario-button" size="mini" type="primary"
|
||||||
@click="openEnvironmentConfig(pe.id, pe['selectEnv'])">
|
@click="openEnvironmentConfig(pe.id, pe['selectEnv'])">
|
||||||
{{ $t('api_test.environment.environment_config') }}
|
{{ $t('api_test.environment.environment_config') }}
|
||||||
|
@ -41,6 +41,12 @@ export default {
|
||||||
envMap: Map,
|
envMap: Map,
|
||||||
projectIds: Set,
|
projectIds: Set,
|
||||||
projectList: Array,
|
projectList: Array,
|
||||||
|
showConfigButtonWithOutPermission:{
|
||||||
|
type: Boolean,
|
||||||
|
default() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
},
|
||||||
result: {
|
result: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default() {
|
default() {
|
||||||
|
@ -54,12 +60,33 @@ export default {
|
||||||
// result: {},
|
// result: {},
|
||||||
projects: [],
|
projects: [],
|
||||||
environments: [],
|
environments: [],
|
||||||
|
permissionProjectIds:[],
|
||||||
dialogVisible: false,
|
dialogVisible: false,
|
||||||
isFullUrl: true,
|
isFullUrl: true,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
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() {
|
init() {
|
||||||
|
//获取当前用户有权限的ID
|
||||||
|
if(this.permissionProjectIds.length === 0){
|
||||||
|
this.getUserPermissionProjectIds();
|
||||||
|
}
|
||||||
|
|
||||||
let arr = [];
|
let arr = [];
|
||||||
this.projectIds.forEach(id => {
|
this.projectIds.forEach(id => {
|
||||||
const project = this.projectList.find(p => p.id === id);
|
const project = this.projectList.find(p => p.id === id);
|
||||||
|
@ -86,6 +113,11 @@ export default {
|
||||||
})
|
})
|
||||||
return arr;
|
return arr;
|
||||||
},
|
},
|
||||||
|
getUserPermissionProjectIds(){
|
||||||
|
this.$get('/project/getOwnerProjectIds/', res => {
|
||||||
|
this.permissionProjectIds = res.data;
|
||||||
|
})
|
||||||
|
},
|
||||||
open() {
|
open() {
|
||||||
this.data = [];
|
this.data = [];
|
||||||
if (this.projectIds.size > 0) {
|
if (this.projectIds.size > 0) {
|
||||||
|
|
Loading…
Reference in New Issue