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.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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -126,7 +126,7 @@ export default {
|
|||
//运行场景中如果连续将1个场景引入多次,会出现运行结果合并的情况。
|
||||
//为了解决这种问题,在转hashTree的时候给场景放了个新ID,前台加载解析的时候也要做处理
|
||||
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("_");
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue