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

View File

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

View File

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

View File

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