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);
}
@GetMapping("/check/permission/{projectId}")
public boolean checkProjectPermission(@PathVariable String projectId) {
return baseCheckPermissionService.getUserRelatedProjectIds().contains(projectId);
}
@GetMapping("/export/template/{projectId}/{importType}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ_EXPORT)
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 {$success} from "metersphere-frontend/src/plugins/message";
import i18n from "@/i18n";
import {getCurrentProjectID, getCurrentWorkspaceId} from "metersphere-frontend/src/utils/token";
import {buildPagePath} from "@/api/base-network";
@ -246,3 +244,7 @@ export function saveCaseRelevanceScenario(caseId, param) {
export function saveCaseRelevanceLoad(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-col>
<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
class="title-link"
:title="testCase.name"
@ -113,7 +117,8 @@
<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"
: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"
:form="testCase" :case-id="testCase.caseId" ref="otherInfo"/>
</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 {testPlanEditStatus} from "@/api/remote/plan/test-plan";
import {getTestTemplate} from "@/api/custom-field-template";
import {getCurrentProjectID} from "@/business/utils/sdk-utils";
import {checkProjectPermission} from "@/api/testCase";
export default {
name: "FunctionalTestCaseEdit",
@ -190,6 +197,7 @@ export default {
return {
loading: false,
showDialog: false,
hasProjectPermission: true,
testCase: {},
index: 0,
editor: ClassicEditor,
@ -235,7 +243,7 @@ export default {
},
pageTotal() {
return Math.ceil(this.total / this.pageSize);
}
},
},
methods: {
handleClose() {
@ -431,6 +439,10 @@ export default {
});
},
openTestCaseEdit(testCase, tableData) {
checkProjectPermission(testCase.projectId)
.then(r => {
this.hasProjectPermission = r.data;
});
this.showDialog = true;
this.activeTab = 'detail';
this.hasTapdId = false;