feat(测试计划): 脑图执行用例-操作权限

This commit is contained in:
teukkk 2024-07-30 11:22:00 +08:00 committed by 刘瑞斌
parent 308a2da1ee
commit c56ca2975d
3 changed files with 27 additions and 14 deletions

View File

@ -12,7 +12,7 @@
:can-show-more-menu="canShowMoreMenu" :can-show-more-menu="canShowMoreMenu"
:can-show-enter-node="canShowEnterNode" :can-show-enter-node="canShowEnterNode"
:can-show-more-menu-node-operation="false" :can-show-more-menu-node-operation="false"
:more-menu-other-operation-list="canShowFloatMenu ? moreMenuOtherOperationList : []" :more-menu-other-operation-list="canShowFloatMenu && hasOperationPermission ? moreMenuOtherOperationList : []"
disabled disabled
@node-select="handleNodeSelect" @node-select="handleNodeSelect"
@node-unselect="handleNodeUnselect" @node-unselect="handleNodeUnselect"
@ -21,7 +21,11 @@
<!-- 缺陷 --> <!-- 缺陷 -->
<a-dropdown position="bl"> <a-dropdown position="bl">
<a-tooltip <a-tooltip
v-if="showAssociateBugMenu && hasAnyPermission(['PROJECT_BUG:READ', 'PROJECT_BUG:READ+ADD'])" v-if="
props.canEdit &&
showAssociateBugMenu &&
hasAllPermission(['PROJECT_BUG:READ', 'PROJECT_TEST_PLAN:READ+EXECUTE'])
"
:content="t('common.add')" :content="t('common.add')"
> >
<MsButton type="icon" class="ms-minder-node-float-menu-icon-button"> <MsButton type="icon" class="ms-minder-node-float-menu-icon-button">
@ -38,7 +42,10 @@
</template> </template>
</a-dropdown> </a-dropdown>
<!-- 执行 --> <!-- 执行 -->
<a-tooltip :content="t('common.execute')"> <a-tooltip
v-if="props.canEdit && hasAnyPermission(['PROJECT_TEST_PLAN:READ+EXECUTE'])"
:content="t('common.execute')"
>
<MsButton type="icon" class="ms-minder-node-float-menu-icon-button"> <MsButton type="icon" class="ms-minder-node-float-menu-icon-button">
<MsIcon type="icon-icon_play-round_filled" class="text-[var(--color-text-4)]" /> <MsIcon type="icon-icon_play-round_filled" class="text-[var(--color-text-4)]" />
</MsButton> </MsButton>
@ -77,7 +84,7 @@
v-else-if="activeExtraKey === 'bug'" v-else-if="activeExtraKey === 'bug'"
:active-case="activeCaseInfo" :active-case="activeCaseInfo"
is-test-plan-case is-test-plan-case
show-disassociate-button :show-disassociate-button="props.canEdit && hasAnyPermission(['PROJECT_TEST_PLAN:READ+EXECUTE'])"
/> />
<ReviewCommentList <ReviewCommentList
v-else v-else
@ -115,7 +122,7 @@
import useMinderStore from '@/store/modules/components/minder-editor/index'; import useMinderStore from '@/store/modules/components/minder-editor/index';
import useTestPlanFeatureCaseStore from '@/store/modules/testPlan/testPlanFeatureCase'; import useTestPlanFeatureCaseStore from '@/store/modules/testPlan/testPlanFeatureCase';
import { findNodeByKey, mapTree, replaceNodeInTree } from '@/utils'; import { findNodeByKey, mapTree, replaceNodeInTree } from '@/utils';
import { hasAnyPermission } from '@/utils/permission'; import { hasAllPermission, hasAnyPermission } from '@/utils/permission';
import { ModuleTreeNode } from '@/models/common'; import { ModuleTreeNode } from '@/models/common';
import type { ExecuteHistoryItem } from '@/models/testPlan/testPlan'; import type { ExecuteHistoryItem } from '@/models/testPlan/testPlan';
@ -131,6 +138,7 @@
activeModule: string; activeModule: string;
moduleTree: ModuleTreeNode[]; moduleTree: ModuleTreeNode[];
planId: string; planId: string;
canEdit: boolean; //
}>(); }>();
const emit = defineEmits<{ const emit = defineEmits<{
@ -423,10 +431,9 @@
} }
} }
const hasOperationPermission = hasAnyPermission([ const hasOperationPermission = computed(
'PROJECT_TEST_PLAN:READ+UPDATE', () => hasAnyPermission(['PROJECT_TEST_PLAN:READ+UPDATE', 'PROJECT_TEST_PLAN:READ+ASSOCIATION']) && props.canEdit
'PROJECT_TEST_PLAN:READ+ASSOCIATION', );
]);
const canShowFloatMenu = ref(false); // const canShowFloatMenu = ref(false); //
const canShowMoreMenu = ref(false); // const canShowMoreMenu = ref(false); //
const canShowEnterNode = ref(false); const canShowEnterNode = ref(false);
@ -472,7 +479,7 @@
node.data?.resource?.includes(caseTag) || node.data?.resource?.includes(caseTag) ||
(node.data?.resource?.includes(moduleTag) && (node.data?.resource?.includes(moduleTag) &&
(node.children || []).length > 0 && (node.children || []).length > 0 &&
!(!hasOperationPermission && node.type === 'root')) !(!hasOperationPermission.value && node.type === 'root'))
) { ) {
canShowFloatMenu.value = true; canShowFloatMenu.value = true;
setMoreMenuOtherOperationList(node); setMoreMenuOtherOperationList(node);
@ -481,7 +488,7 @@
} }
// //
if (node.data?.resource?.includes(caseTag) && !hasOperationPermission) { if (node.data?.resource?.includes(caseTag) && !hasOperationPermission.value) {
canShowMoreMenu.value = false; canShowMoreMenu.value = false;
} else { } else {
canShowMoreMenu.value = true; canShowMoreMenu.value = true;

View File

@ -115,6 +115,7 @@
:active-module="props.activeModule" :active-module="props.activeModule"
:module-tree="moduleTree" :module-tree="moduleTree"
:plan-id="props.planId" :plan-id="props.planId"
:can-edit="props.canEdit"
/> />
</div> </div>
<!-- 批量执行 --> <!-- 批量执行 -->

View File

@ -130,7 +130,12 @@
<span class="ml-1 text-[rgb(var(--danger-6))]">{{ caseDetail.bugListCount }}</span> <span class="ml-1 text-[rgb(var(--danger-6))]">{{ caseDetail.bugListCount }}</span>
</MsTag> </MsTag>
<a-dropdown @select="handleSelect"> <a-dropdown @select="handleSelect">
<a-button v-if="hasAnyPermission(['PROJECT_BUG:READ'])" type="outline" size="small" class="ml-1"> <a-button
v-if="hasAllPermission(['PROJECT_BUG:READ', 'PROJECT_TEST_PLAN:READ+EXECUTE'])"
type="outline"
size="small"
class="ml-1"
>
<template #icon> <icon-plus class="text-[12px]" /> </template> <template #icon> <icon-plus class="text-[12px]" /> </template>
</a-button> </a-button>
<template #content> <template #content>
@ -186,7 +191,7 @@
ref="bugRef" ref="bugRef"
:case-id="activeCaseId" :case-id="activeCaseId"
:test-plan-case-id="activeId" :test-plan-case-id="activeId"
:can-edit="canEdit" :can-edit="canEdit && hasAnyPermission(['PROJECT_TEST_PLAN:READ+EXECUTE'])"
@link="linkDefect" @link="linkDefect"
@new="addBug" @new="addBug"
@update-count="loadCaseDetail()" @update-count="loadCaseDetail()"
@ -256,7 +261,7 @@
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
import useOpenNewPage from '@/hooks/useOpenNewPage'; import useOpenNewPage from '@/hooks/useOpenNewPage';
import useAppStore from '@/store/modules/app'; import useAppStore from '@/store/modules/app';
import { hasAnyPermission } from '@/utils/permission'; import { hasAllPermission, hasAnyPermission } from '@/utils/permission';
import type { TableQueryParams } from '@/models/common'; import type { TableQueryParams } from '@/models/common';
import type { ExecuteHistoryItem, PlanDetailFeatureCaseItem, TestPlanDetail } from '@/models/testPlan/testPlan'; import type { ExecuteHistoryItem, PlanDetailFeatureCaseItem, TestPlanDetail } from '@/models/testPlan/testPlan';