fix(接口测试): 接口定义页面按钮增加权限校验

--bug=1037399 --user=宋天阳  https://www.tapd.cn/55049933/s/1483087
This commit is contained in:
Jianguo-Genius 2024-03-28 18:19:06 +08:00 committed by Craftsman
parent 4cef3121d9
commit 7fe24a0d27
4 changed files with 35 additions and 15 deletions

View File

@ -47,14 +47,14 @@
@select="handleNodeMoreSelect($event, _props)"
@close="moreActionsClose"
>
<MsButton
type="text"
:size="props.nodeMoreActionSize || 'mini'"
class="ms-tree-node-extra__more"
@click="focusNodeKey = _props[props.fieldNames.key]"
>
<MsIcon type="icon-icon_more_outlined" size="14" class="text-[var(--color-text-4)]" />
</MsButton>
<!-- <MsButton-->
<!-- type="text"-->
<!-- :size="props.nodeMoreActionSize || 'mini'"-->
<!-- class="ms-tree-node-extra__more"-->
<!-- @click="focusNodeKey = _props[props.fieldNames.key]"-->
<!-- >-->
<!-- <MsIcon type="icon-icon_more_outlined" size="14" class="text-[var(&#45;&#45;color-text-4)]" />-->
<!-- </MsButton>-->
</MsTableMoreAction>
</div>
<div class="ms-tree-node-extra-end">

View File

@ -11,6 +11,7 @@
</template>
<template #titleRight>
<a-button
v-permission="['PROJECT_API_DEFINITION:READ+UPDATE']"
type="outline"
:loading="followLoading"
size="mini"

View File

@ -5,7 +5,7 @@
v-model:active-tab="activeApiTab"
v-model:tabs="apiTabs"
class="flex-1 overflow-hidden"
:show-add="currentTab === 'api'"
:show-add="currentTab === 'api' && hasAnyPermission(['PROJECT_API_DEFINITION:READ+ADD'])"
@add="newTab"
>
<template #label="{ tab }">
@ -68,6 +68,7 @@
import { getProtocolList } from '@/api/modules/api-test/common';
import { useI18n } from '@/hooks/useI18n';
import useAppStore from '@/store/modules/app';
import { hasAnyPermission } from '@/utils/permission';
import { ProtocolItem } from '@/models/apiTest/common';
import { ModuleTreeNode } from '@/models/common';

View File

@ -10,11 +10,24 @@
/>
<div class="mb-[8px] flex items-center gap-[8px]">
<a-input v-model:model-value="moduleKeyword" :placeholder="t('apiTestManagement.searchTip')" allow-clear />
<a-dropdown v-if="!props.readOnly && !props.trash" @select="handleSelect">
<a-dropdown
v-if="
!props.readOnly &&
!props.trash &&
hasAnyPermission(['PROJECT_API_DEFINITION:READ+ADD', 'PROJECT_API_DEFINITION:READ+IMPORT'])
"
@select="handleSelect"
>
<a-button type="primary">{{ t('apiTestManagement.newApi') }}</a-button>
<template #content>
<a-doption value="newApi">{{ t('apiTestManagement.newApi') }}</a-doption>
<a-doption v-if="moduleProtocol === 'HTTP'" value="import">
<a-doption v-permission="['PROJECT_API_DEFINITION:READ+ADD']" value="newApi">{{
t('apiTestManagement.newApi')
}}</a-doption>
<a-doption
v-if="moduleProtocol === 'HTTP'"
v-permission="['PROJECT_API_DEFINITION:READ+IMPORT']"
value="import"
>
{{ t('apiTestManagement.importApi') }}
</a-doption>
</template>
@ -43,7 +56,7 @@
</a-tooltip>
<template v-if="!props.readOnly && !props.trash">
<a-dropdown @select="handleSelect">
<MsButton type="icon" class="!mr-0 p-[2px]">
<MsButton v-permission="['PROJECT_API_DEFINITION:READ+ADD']" type="icon" class="!mr-0 p-[2px]">
<MsIcon
type="icon-icon_create_planarity"
size="18"
@ -51,8 +64,12 @@
/>
</MsButton>
<template #content>
<a-doption value="newApi">{{ t('apiTestManagement.newApi') }}</a-doption>
<a-doption value="addModule">{{ t('apiTestManagement.addSubModule') }}</a-doption>
<a-doption v-permission="['PROJECT_API_DEFINITION:READ+ADD']" value="newApi">{{
t('apiTestManagement.newApi')
}}</a-doption>
<a-doption v-permission="['PROJECT_API_DEFINITION:READ+ADD']" value="addModule">{{
t('apiTestManagement.addSubModule')
}}</a-doption>
</template>
</a-dropdown>
<popConfirm
@ -184,6 +201,7 @@
import useModal from '@/hooks/useModal';
import useAppStore from '@/store/modules/app';
import { mapTree } from '@/utils';
import { hasAnyPermission } from '@/utils/permission';
import { ModuleTreeNode } from '@/models/common';