From 3f8bc94378126921d542a4e003bb2ad75f5188ff Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Thu, 10 Jun 2021 16:06:17 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=B7=A8=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E5=BC=95=E7=94=A8=E5=9C=BA=E6=99=AF=E6=97=B6=E4=B8=8D?= =?UTF-8?q?=E5=90=8C=E7=94=A8=E6=88=B7=E6=9D=83=E9=99=90=E5=BC=95=E8=B5=B7?= =?UTF-8?q?=E7=9A=84=E7=BC=BA=E9=99=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 场景中存在引用无权限的项目,展开运行环境直接报错。现在改为没有权限的用户环境展开时只能进行选择,不能进行配置 --- .../controller/ProjectController.java | 6 ++++ .../service/CheckPermissionService.java | 2 +- .../api/automation/report/ApiReportDetail.vue | 4 +-- .../automation/scenario/EditApiScenario.vue | 2 ++ .../api/automation/scenario/EnvPopover.vue | 7 ++++ .../api/automation/scenario/EnvSelect.vue | 36 +++++++++++++++++-- 6 files changed, 52 insertions(+), 5 deletions(-) diff --git a/backend/src/main/java/io/metersphere/controller/ProjectController.java b/backend/src/main/java/io/metersphere/controller/ProjectController.java index 6079093b9f..fa25f25be4 100644 --- a/backend/src/main/java/io/metersphere/controller/ProjectController.java +++ b/backend/src/main/java/io/metersphere/controller/ProjectController.java @@ -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 getOwnerProjectIds() { + return checkPermissionService.getUserRelatedProjectIds(); + } } diff --git a/backend/src/main/java/io/metersphere/service/CheckPermissionService.java b/backend/src/main/java/io/metersphere/service/CheckPermissionService.java index 599be37c4f..68d7b0cb31 100644 --- a/backend/src/main/java/io/metersphere/service/CheckPermissionService.java +++ b/backend/src/main/java/io/metersphere/service/CheckPermissionService.java @@ -39,7 +39,7 @@ public class CheckPermissionService { } } - private Set getUserRelatedProjectIds() { + public Set getUserRelatedProjectIds() { List groupIds = Objects.requireNonNull(SessionUtils.getUser()).getGroups() .stream() .filter(g -> StringUtils.equals(g.getType(), UserGroupType.PROJECT)) diff --git a/frontend/src/business/components/api/automation/report/ApiReportDetail.vue b/frontend/src/business/components/api/automation/report/ApiReportDetail.vue index ec80eb4a03..43d6152799 100644 --- a/frontend/src/business/components/api/automation/report/ApiReportDetail.vue +++ b/frontend/src/business/components/api/automation/report/ApiReportDetail.vue @@ -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("_"); diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue index 05f5d1d526..49d5cfee18 100644 --- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue @@ -136,6 +136,7 @@ @@ -317,6 +318,7 @@ export default { data() { return { enableContinues: false, + showConfigButtonWithOutPermission:false, props: { label: "label", children: "hashTree" diff --git a/frontend/src/business/components/api/automation/scenario/EnvPopover.vue b/frontend/src/business/components/api/automation/scenario/EnvPopover.vue index ad77d9f763..704bca75b7 100644 --- a/frontend/src/business/components/api/automation/scenario/EnvPopover.vue +++ b/frontend/src/business/components/api/automation/scenario/EnvPopover.vue @@ -7,6 +7,7 @@ @show="showPopover" trigger="click"> {{ $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() { diff --git a/frontend/src/business/components/api/automation/scenario/EnvSelect.vue b/frontend/src/business/components/api/automation/scenario/EnvSelect.vue index 3216af147d..b3ea7098a4 100644 --- a/frontend/src/business/components/api/automation/scenario/EnvSelect.vue +++ b/frontend/src/business/components/api/automation/scenario/EnvSelect.vue @@ -5,12 +5,12 @@ - {{ $t('api_test.environment.environment_config') }}