feat: add read permission checks for system management and sharing components
--bug=1062363 --user=刘瑞斌 【应用】简单应用进入编辑页面会弹工具无权限的提示 https://www.tapd.cn/62980211/s/1781286v3.2
parent
124d0ae288
commit
1dcca7fcc7
|
|
@ -3,6 +3,14 @@ import {ComplexPermission} from '@/utils/permission/type'
|
||||||
import {EditionConst, PermissionConst, RoleConst} from '@/utils/permission/data'
|
import {EditionConst, PermissionConst, RoleConst} from '@/utils/permission/data'
|
||||||
|
|
||||||
const systemManage = {
|
const systemManage = {
|
||||||
|
read: () =>
|
||||||
|
hasPermission(
|
||||||
|
[
|
||||||
|
RoleConst.ADMIN,
|
||||||
|
PermissionConst.RESOURCE_TOOL_READ,
|
||||||
|
],
|
||||||
|
'OR',
|
||||||
|
),
|
||||||
is_share: () =>
|
is_share: () =>
|
||||||
hasPermission(
|
hasPermission(
|
||||||
new ComplexPermission(
|
new ComplexPermission(
|
||||||
|
|
@ -57,7 +65,7 @@ const systemManage = {
|
||||||
'OR',
|
'OR',
|
||||||
),
|
),
|
||||||
|
|
||||||
auth: () =>
|
auth: () =>
|
||||||
hasPermission(
|
hasPermission(
|
||||||
[
|
[
|
||||||
RoleConst.ADMIN,
|
RoleConst.ADMIN,
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,14 @@ import { hasPermission } from '@/utils/permission/index'
|
||||||
import { ComplexPermission } from '@/utils/permission/type'
|
import { ComplexPermission } from '@/utils/permission/type'
|
||||||
import { EditionConst, PermissionConst, RoleConst } from '@/utils/permission/data'
|
import { EditionConst, PermissionConst, RoleConst } from '@/utils/permission/data'
|
||||||
const share = {
|
const share = {
|
||||||
|
read: () =>
|
||||||
|
hasPermission(
|
||||||
|
[
|
||||||
|
RoleConst.ADMIN,
|
||||||
|
PermissionConst.SHARED_TOOL_READ,
|
||||||
|
],
|
||||||
|
'OR',
|
||||||
|
),
|
||||||
is_share: () => false,
|
is_share: () => false,
|
||||||
create: () =>
|
create: () =>
|
||||||
hasPermission(
|
hasPermission(
|
||||||
|
|
@ -67,8 +75,8 @@ const share = {
|
||||||
],
|
],
|
||||||
'OR',
|
'OR',
|
||||||
),
|
),
|
||||||
|
|
||||||
auth: () => false,
|
auth: () => false,
|
||||||
folderCreate: () => false,
|
folderCreate: () => false,
|
||||||
folderEdit: () => false,
|
folderEdit: () => false,
|
||||||
folderDelete: () => false,
|
folderDelete: () => false,
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,11 @@ import { hasPermission } from '@/utils/permission/index'
|
||||||
import { ComplexPermission } from '@/utils/permission/type'
|
import { ComplexPermission } from '@/utils/permission/type'
|
||||||
import { EditionConst, PermissionConst, RoleConst } from '@/utils/permission/data'
|
import { EditionConst, PermissionConst, RoleConst } from '@/utils/permission/data'
|
||||||
const workspace = {
|
const workspace = {
|
||||||
|
read: () =>
|
||||||
|
hasPermission(
|
||||||
|
[PermissionConst.TOOL_READ.getWorkspacePermission, PermissionConst.TOOL_READ.getWorkspacePermissionWorkspaceManageRole],
|
||||||
|
'OR'
|
||||||
|
),
|
||||||
is_share: () =>
|
is_share: () =>
|
||||||
hasPermission(
|
hasPermission(
|
||||||
new ComplexPermission(
|
new ComplexPermission(
|
||||||
|
|
@ -29,7 +34,7 @@ const workspace = {
|
||||||
PermissionConst.TOOL_IMPORT.getWorkspacePermissionWorkspaceManageRole
|
PermissionConst.TOOL_IMPORT.getWorkspacePermissionWorkspaceManageRole
|
||||||
],
|
],
|
||||||
'OR'
|
'OR'
|
||||||
),
|
),
|
||||||
folderCreate: () =>
|
folderCreate: () =>
|
||||||
hasPermission(
|
hasPermission(
|
||||||
[
|
[
|
||||||
|
|
@ -109,7 +114,7 @@ const workspace = {
|
||||||
PermissionConst.TOOL_EXPORT.getWorkspacePermissionWorkspaceManageRole
|
PermissionConst.TOOL_EXPORT.getWorkspacePermissionWorkspaceManageRole
|
||||||
],
|
],
|
||||||
'OR'
|
'OR'
|
||||||
),
|
),
|
||||||
auth: (source_id:string) =>
|
auth: (source_id:string) =>
|
||||||
hasPermission(
|
hasPermission(
|
||||||
[
|
[
|
||||||
|
|
@ -119,18 +124,18 @@ const workspace = {
|
||||||
PermissionConst.TOOL_RESOURCE_AUTHORIZATION.getWorkspacePermissionWorkspaceManageRole
|
PermissionConst.TOOL_RESOURCE_AUTHORIZATION.getWorkspacePermissionWorkspaceManageRole
|
||||||
],
|
],
|
||||||
'OR'
|
'OR'
|
||||||
),
|
),
|
||||||
debug: () =>
|
debug: () =>
|
||||||
hasPermission(
|
hasPermission(
|
||||||
[
|
[
|
||||||
RoleConst.USER.getWorkspaceRole,
|
RoleConst.USER.getWorkspaceRole,
|
||||||
RoleConst.WORKSPACE_MANAGE.getWorkspaceRole,
|
RoleConst.WORKSPACE_MANAGE.getWorkspaceRole,
|
||||||
PermissionConst.TOOL_EDIT.getWorkspacePermission,
|
PermissionConst.TOOL_EDIT.getWorkspacePermission,
|
||||||
PermissionConst.TOOL_EDIT.getWorkspacePermissionWorkspaceManageRole
|
PermissionConst.TOOL_EDIT.getWorkspacePermissionWorkspaceManageRole
|
||||||
],
|
],
|
||||||
'OR'
|
'OR'
|
||||||
),
|
),
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default workspace
|
export default workspace
|
||||||
|
|
|
||||||
|
|
@ -304,7 +304,7 @@
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<!-- MCP-->
|
<!-- MCP-->
|
||||||
<el-form-item @click.prevent>
|
<el-form-item @click.prevent v-if="toolPermissionPrecise.read()">
|
||||||
<template #label>
|
<template #label>
|
||||||
<div class="flex-between">
|
<div class="flex-between">
|
||||||
<span>MCP</span>
|
<span>MCP</span>
|
||||||
|
|
@ -326,8 +326,10 @@
|
||||||
<div
|
<div
|
||||||
class="w-full mb-16"
|
class="w-full mb-16"
|
||||||
v-if="
|
v-if="
|
||||||
|
(
|
||||||
(applicationForm.mcp_tool_ids && applicationForm.mcp_tool_ids.length > 0) ||
|
(applicationForm.mcp_tool_ids && applicationForm.mcp_tool_ids.length > 0) ||
|
||||||
(applicationForm.mcp_servers && applicationForm.mcp_servers.length > 0)
|
(applicationForm.mcp_servers && applicationForm.mcp_servers.length > 0)
|
||||||
|
) && toolPermissionPrecise.read()
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
<template v-for="(item, index) in applicationForm.mcp_tool_ids" :key="index">
|
<template v-for="(item, index) in applicationForm.mcp_tool_ids" :key="index">
|
||||||
|
|
@ -368,7 +370,7 @@
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
<!-- 工具 -->
|
<!-- 工具 -->
|
||||||
<el-form-item @click.prevent>
|
<el-form-item @click.prevent v-if="toolPermissionPrecise.read()">
|
||||||
<template #label>
|
<template #label>
|
||||||
<div class="flex-between">
|
<div class="flex-between">
|
||||||
<span class="mr-4">
|
<span class="mr-4">
|
||||||
|
|
@ -395,7 +397,7 @@
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<div
|
<div
|
||||||
class="w-full mb-16"
|
class="w-full mb-16"
|
||||||
v-if="applicationForm.tool_ids && applicationForm.tool_ids.length > 0"
|
v-if="applicationForm.tool_ids && applicationForm.tool_ids.length > 0 && toolPermissionPrecise.read()"
|
||||||
>
|
>
|
||||||
<template v-for="(item, index) in applicationForm.tool_ids" :key="index">
|
<template v-for="(item, index) in applicationForm.tool_ids" :key="index">
|
||||||
<div
|
<div
|
||||||
|
|
@ -673,6 +675,10 @@ const permissionPrecise = computed(() => {
|
||||||
return permissionMap['application'][apiType.value]
|
return permissionMap['application'][apiType.value]
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const toolPermissionPrecise = computed(() => {
|
||||||
|
return permissionMap['tool'][apiType.value]
|
||||||
|
})
|
||||||
|
|
||||||
const defaultPrompt = t('views.application.form.prompt.defaultPrompt', {
|
const defaultPrompt = t('views.application.form.prompt.defaultPrompt', {
|
||||||
data: '{data}',
|
data: '{data}',
|
||||||
question: '{question}',
|
question: '{question}',
|
||||||
|
|
@ -1109,8 +1115,10 @@ onMounted(() => {
|
||||||
getDetail()
|
getDetail()
|
||||||
getSTTModel()
|
getSTTModel()
|
||||||
getTTSModel()
|
getTTSModel()
|
||||||
getToolSelectOptions()
|
if (toolPermissionPrecise.value.read()) {
|
||||||
getMcpToolSelectOptions()
|
getToolSelectOptions();
|
||||||
|
getMcpToolSelectOptions()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue