From 6e30857c779ee11ca5824583d9ec76fd0bf62d69 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Thu, 23 Dec 2021 11:35:58 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E5=85=AC=E5=85=B1=E7=94=A8=E4=BE=8B=E5=BA=93=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=A8=E4=BE=8B=E8=B4=A3=E4=BB=BB=E4=BA=BA?= =?UTF-8?q?=E5=90=8E=EF=BC=8C=E6=96=B0=E7=9A=84=E8=B4=A3=E4=BB=BB=E4=BA=BA?= =?UTF-8?q?=E4=BB=8D=E4=B8=8D=E5=8F=AF=E7=BC=96=E8=BE=91=E5=92=8C=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E8=AF=A5=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1008907 --user=王孝刚 【公共用例库】-选择修改用例责任人后,新的责任人仍不可编辑和删除该用例 https://www.tapd.cn/55049933/s/1086358 --- .../track/controller/TestCaseController.java | 7 +- .../track/service/TestCaseService.java | 1 + .../common/json-schema/JsonSchemaEditor.vue | 4 +- .../components/track/case/TestCase.vue | 12 +++- .../track/case/components/TestCaseEdit.vue | 71 +++++++++++++------ .../case/components/TestCaseEditShow.vue | 43 +++++++---- .../track/case/components/TestCaseList.vue | 20 +++--- 7 files changed, 107 insertions(+), 51 deletions(-) diff --git a/backend/src/main/java/io/metersphere/track/controller/TestCaseController.java b/backend/src/main/java/io/metersphere/track/controller/TestCaseController.java index 0390403577..dbfb0de901 100644 --- a/backend/src/main/java/io/metersphere/track/controller/TestCaseController.java +++ b/backend/src/main/java/io/metersphere/track/controller/TestCaseController.java @@ -107,6 +107,12 @@ public class TestCaseController { return testCaseService.listTestCaseIds(request); } + @PostMapping("/list/ids/public") + public List getTestPlanCaseIdsPublic(@RequestBody QueryTestCaseRequest request) { + return testCaseService.publicListTestCase(request); + } + + @GetMapping("/relationship/case/{id}/{relationshipType}") public List getRelationshipCase(@PathVariable("id") String id, @PathVariable("relationshipType") String relationshipType) { return testCaseService.getRelationshipCase(id, relationshipType); @@ -184,7 +190,6 @@ public class TestCaseController { @GetMapping("/get/{testCaseId}") public TestCaseWithBLOBs getTestCase(@PathVariable String testCaseId) { - checkPermissionService.checkTestCaseOwner(testCaseId); return testCaseService.getTestCase(testCaseId); } diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java index 1dbe290177..9755e55623 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java @@ -1337,6 +1337,7 @@ public class TestCaseService { BeanUtils.copyBean(batchCopy, item); checkTestCaseExist(batchCopy); batchCopy.setId(UUID.randomUUID().toString()); + batchCopy.setName("copy_" + item.getName()); batchCopy.setCreateTime(System.currentTimeMillis()); batchCopy.setUpdateTime(System.currentTimeMillis()); batchCopy.setNum(getNextNum(SessionUtils.getCurrentProjectId())); diff --git a/frontend/src/business/components/common/json-schema/JsonSchemaEditor.vue b/frontend/src/business/components/common/json-schema/JsonSchemaEditor.vue index 94c5298e9a..b775da3731 100644 --- a/frontend/src/business/components/common/json-schema/JsonSchemaEditor.vue +++ b/frontend/src/business/components/common/json-schema/JsonSchemaEditor.vue @@ -2,7 +2,9 @@
- 导入 + + {{ this.$t('commons.import') }} +
diff --git a/frontend/src/business/components/track/case/TestCase.vue b/frontend/src/business/components/track/case/TestCase.vue index e391264dcb..600a8a23f9 100644 --- a/frontend/src/business/components/track/case/TestCase.vue +++ b/frontend/src/business/components/track/case/TestCase.vue @@ -75,6 +75,7 @@ :isRedirectEdit="isRedirectEdit" :tree-nodes="treeNodes" :trash-enable="false" + :public-enable="false" @refreshTable="refresh" @testCaseEdit="editTestCase" @testCaseCopy="copyTestCase" @@ -112,6 +113,7 @@ :tree-nodes="treeNodes" :select-node="selectNode" :select-condition="condition" + :public-enable="currentActiveName === 'default' ? false : true" :type="type" @addTab="addTab" ref="testCaseEdit"> @@ -128,7 +130,7 @@ :select-node="selectNode" :select-condition="condition" :type="type" - :is-public="publicEnable" + :public-enable="currentActiveName === 'default' ? false : true" @addTab="addTabShow" ref="testCaseEditShow"> @@ -202,6 +204,7 @@ export default { showPublic: false, condition: {}, activeName: 'default', + currentActiveName: '', tabs: [], renderComponent: true, loading: false, @@ -344,12 +347,18 @@ export default { let label = this.$t('test_track.case.create'); let name = getUUID().substring(0, 8); this.activeName = name; + this.currentActiveName = 'default' this.type = 'add'; this.tabs.push({label: label, name: name, testCaseInfo: {testCaseModuleId: "", id: getUUID()}}); } if (tab.name === 'edit') { let label = this.$t('test_track.case.create'); let name = getUUID().substring(0, 8); + if (this.activeName === 'public') { + this.currentActiveName = 'public' + } else { + this.currentActiveName = 'default' + } this.activeName = name; label = tab.testCaseInfo.name; this.tabs.push({label: label, name: name, testCaseInfo: tab.testCaseInfo}); @@ -367,6 +376,7 @@ export default { let label = this.$t('test_track.case.create'); let name = getUUID().substring(0, 8); this.activeName = name; + this.currentActiveName = 'public' label = tab.testCaseInfo.name; this.tabs.push({label: label, name: name, testCaseInfo: tab.testCaseInfo}); } diff --git a/frontend/src/business/components/track/case/components/TestCaseEdit.vue b/frontend/src/business/components/track/case/components/TestCaseEdit.vue index ba2f6a95d0..c37baadeb0 100644 --- a/frontend/src/business/components/track/case/components/TestCaseEdit.vue +++ b/frontend/src/business/components/track/case/components/TestCaseEdit.vue @@ -18,23 +18,15 @@ {{ $t('operating_log.change_history') }} - - {{ $t('commons.save') }} - {{ + {{ $t('test_track.case.save_create_continue') }} - {{ + {{ $t('test_track.case.save_add_public') }} @@ -55,12 +47,22 @@ - + + + + + + + + + { + this.projectList = response.data; //获取当前工作空间所拥有的项目, + }) + } this.projectId = this.projectIds; let initAddFuc = this.initAddFuc; getTestTemplate() @@ -401,7 +414,7 @@ export default { this.result = this.$get('/project/get/' + this.projectId, res => { let data = res.data; if (data.casePublic) { - this.publicEnable = true; + this.isPublic = true; } }) if (hasLicense()) { @@ -583,16 +596,28 @@ export default { this.getTestCase(this.index); }, initTestCases(testCase) { - this.selectCondition.workspaceId = null; - this.result = this.$post('/test/case/list/ids', this.selectCondition, response => { - this.testCases = response.data; - for (let i = 0; i < this.testCases.length; i++) { - if (this.testCases[i].id === testCase.id) { - this.index = i; - this.getTestCase(i); + if (this.publicEnable) { + this.result = this.$post('/test/case/list/ids/public', this.selectCondition, response => { + this.testCases = response.data; + for (let i = 0; i < this.testCases.length; i++) { + if (this.testCases[i].id === testCase.id) { + this.index = i; + this.getTestCase(i); + } } - } - }); + }); + } else { + this.selectCondition.workspaceId = null; + this.result = this.$post('/test/case/list/ids', this.selectCondition, response => { + this.testCases = response.data; + for (let i = 0; i < this.testCases.length; i++) { + if (this.testCases[i].id === testCase.id) { + this.index = i; + this.getTestCase(i); + } + } + }); + } }, getTestCase(index) { let id = ""; diff --git a/frontend/src/business/components/track/case/components/TestCaseEditShow.vue b/frontend/src/business/components/track/case/components/TestCaseEditShow.vue index c07d47e20b..21a539b757 100644 --- a/frontend/src/business/components/track/case/components/TestCaseEditShow.vue +++ b/frontend/src/business/components/track/case/components/TestCaseEditShow.vue @@ -59,7 +59,7 @@ + :issue-template="testCaseTemplate" :is-public="publicEnable"/> @@ -121,7 +121,7 @@
- @@ -191,7 +191,7 @@ export default { path: "/test/case/add", selectIds: [], projectList: [], - publicEnable: false, + isPublic: false, isXpack: false, testCaseTemplate: {}, options: REVIEW_STATUS, @@ -287,8 +287,9 @@ export default { type: Object }, type: String, - isPublic: { - type: Boolean + publicEnable: { + type: Boolean, + default: false } }, computed: { @@ -381,7 +382,7 @@ export default { this.result = this.$get('/project/get/' + this.projectId, res => { let data = res.data; if (data.casePublic) { - this.publicEnable = true; + this.isPublic = true; } }) if (hasLicense()) { @@ -562,16 +563,28 @@ export default { this.getTestCase(this.index); }, initTestCases(testCase) { - this.selectCondition.workspaceId = null; - this.result = this.$post('/test/case/list/ids', this.selectCondition, response => { - this.testCases = response.data; - for (let i = 0; i < this.testCases.length; i++) { - if (this.testCases[i].id === testCase.id) { - this.index = i; - this.getTestCase(i); + if (this.publicEnable) { + this.result = this.$post('/test/case/list/ids/public', this.selectCondition, response => { + this.testCases = response.data; + for (let i = 0; i < this.testCases.length; i++) { + if (this.testCases[i].id === testCase.id) { + this.index = i; + this.getTestCase(i); + } } - } - }); + }); + } else { + this.selectCondition.workspaceId = null; + this.result = this.$post('/test/case/list/ids', this.selectCondition, response => { + this.testCases = response.data; + for (let i = 0; i < this.testCases.length; i++) { + if (this.testCases[i].id === testCase.id) { + this.index = i; + this.getTestCase(i); + } + } + }); + } }, getTestCase(index) { let id = ""; diff --git a/frontend/src/business/components/track/case/components/TestCaseList.vue b/frontend/src/business/components/track/case/components/TestCaseList.vue index 776ac6be7e..3a3deeee6a 100644 --- a/frontend/src/business/components/track/case/components/TestCaseList.vue +++ b/frontend/src/business/components/track/case/components/TestCaseList.vue @@ -757,10 +757,14 @@ export default { }, handleEdit(testCase, column) { if (column.label !== this.$t('test_track.case.case_desc')) { - this.$get('test/case/get/' + testCase.id, response => { - let testCase = response.data; - this.$emit('testCaseEdit', testCase); - }); + if (this.publicEnable) { + return; + } else { + this.$get('test/case/get/' + testCase.id, response => { + let testCase = response.data; + this.$emit('testCaseEdit', testCase); + }); + } } }, @@ -774,14 +778,10 @@ export default { }, isPublic(testCase) { - if (testCase.maintainer && testCase.maintainer !== getCurrentUserId()) { - return true; - } - if (testCase.createUser && testCase.createUser !== getCurrentUserId()) { - return true; - } else { + if ((testCase.maintainer && testCase.maintainer === getCurrentUserId()) || (testCase.createUser && testCase.createUser === getCurrentUserId())) { return false; } + return true; }, getCase(id) { this.$refs.testCasePreview.open();