refactor(测试跟踪): 测试计划功能用例跨项目跳转优化

--bug=1018699 --user=陈建星 【测试跟踪】测试计划中,无项目权限账号点击测试用例发生跳转,提示异常后再系统管理页面显示,建议优化 https://www.tapd.cn/55049933/s/1285584
This commit is contained in:
chenjianxing 2022-11-01 18:27:55 +08:00 committed by jianxing
parent 94c465186f
commit df4db6b736
3 changed files with 24 additions and 5 deletions

View File

@ -242,6 +242,11 @@ public class TestCaseController {
return testCaseService.testCaseImport(file, request, httpRequest); return testCaseService.testCaseImport(file, request, httpRequest);
} }
@GetMapping("/check/permission/{projectId}")
public boolean checkProjectPermission(@PathVariable String projectId) {
return baseCheckPermissionService.getUserRelatedProjectIds().contains(projectId);
}
@GetMapping("/export/template/{projectId}/{importType}") @GetMapping("/export/template/{projectId}/{importType}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ_EXPORT) @RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ_EXPORT)
public void testCaseTemplateExport(@PathVariable String projectId, @PathVariable String importType, HttpServletResponse response) { public void testCaseTemplateExport(@PathVariable String projectId, @PathVariable String importType, HttpServletResponse response) {

View File

@ -1,6 +1,4 @@
import {post, get} from "metersphere-frontend/src/plugins/request"; import {post, get} from "metersphere-frontend/src/plugins/request";
import {$success} from "metersphere-frontend/src/plugins/message";
import i18n from "@/i18n";
import {getCurrentProjectID, getCurrentWorkspaceId} from "metersphere-frontend/src/utils/token"; import {getCurrentProjectID, getCurrentWorkspaceId} from "metersphere-frontend/src/utils/token";
import {buildPagePath} from "@/api/base-network"; import {buildPagePath} from "@/api/base-network";
@ -246,3 +244,7 @@ export function saveCaseRelevanceScenario(caseId, param) {
export function saveCaseRelevanceLoad(caseId, param) { export function saveCaseRelevanceLoad(caseId, param) {
return post(BASE_URL + "relate/test/performance/" + caseId, param); return post(BASE_URL + "relate/test/performance/" + caseId, param);
} }
export function checkProjectPermission(projectId) {
return get(BASE_URL + "check/permission/" + projectId);
}

View File

@ -43,7 +43,11 @@
<el-row class="head-bar"> <el-row class="head-bar">
<el-col> <el-col>
<el-divider content-position="left" class="title-divider"> <el-divider content-position="left" class="title-divider">
<el-button class="test-case-name" type="text" @click="openTestTestCase(testCase)"> <el-button
class="test-case-name"
type="text"
:disabled="!hasProjectPermission"
@click="openTestTestCase(testCase)">
<span <span
class="title-link" class="title-link"
:title="testCase.name" :title="testCase.name"
@ -113,7 +117,8 @@
<el-form-item :label="$t('test_track.case.other_info')" :label-width="formLabelWidth"> <el-form-item :label="$t('test_track.case.other_info')" :label-width="formLabelWidth">
<test-case-edit-other-info :plan-id="testCase.planId" v-if="otherInfoActive" @openTest="openTest" <test-case-edit-other-info :plan-id="testCase.planId" v-if="otherInfoActive" @openTest="openTest"
:is-test-plan-edit="true" @syncRelationGraphOpen="syncRelationGraphOpen" :is-test-plan-edit="true"
@syncRelationGraphOpen="syncRelationGraphOpen"
:read-only="true" :is-test-plan="true" :project-id="testCase.projectId" :read-only="true" :is-test-plan="true" :project-id="testCase.projectId"
:form="testCase" :case-id="testCase.caseId" ref="otherInfo"/> :form="testCase" :case-id="testCase.caseId" ref="otherInfo"/>
</el-form-item> </el-form-item>
@ -166,6 +171,8 @@ import StatusTableItem from "@/business/common/tableItems/planview/StatusTableIt
import {testPlanTestCaseEdit, testPlanTestCaseGet} from "@/api/remote/plan/test-plan-test-case"; import {testPlanTestCaseEdit, testPlanTestCaseGet} from "@/api/remote/plan/test-plan-test-case";
import {testPlanEditStatus} from "@/api/remote/plan/test-plan"; import {testPlanEditStatus} from "@/api/remote/plan/test-plan";
import {getTestTemplate} from "@/api/custom-field-template"; import {getTestTemplate} from "@/api/custom-field-template";
import {getCurrentProjectID} from "@/business/utils/sdk-utils";
import {checkProjectPermission} from "@/api/testCase";
export default { export default {
name: "FunctionalTestCaseEdit", name: "FunctionalTestCaseEdit",
@ -190,6 +197,7 @@ export default {
return { return {
loading: false, loading: false,
showDialog: false, showDialog: false,
hasProjectPermission: true,
testCase: {}, testCase: {},
index: 0, index: 0,
editor: ClassicEditor, editor: ClassicEditor,
@ -235,7 +243,7 @@ export default {
}, },
pageTotal() { pageTotal() {
return Math.ceil(this.total / this.pageSize); return Math.ceil(this.total / this.pageSize);
} },
}, },
methods: { methods: {
handleClose() { handleClose() {
@ -431,6 +439,10 @@ export default {
}); });
}, },
openTestCaseEdit(testCase, tableData) { openTestCaseEdit(testCase, tableData) {
checkProjectPermission(testCase.projectId)
.then(r => {
this.hasProjectPermission = r.data;
});
this.showDialog = true; this.showDialog = true;
this.activeTab = 'detail'; this.activeTab = 'detail';
this.hasTapdId = false; this.hasTapdId = false;