diff --git a/ui/src/permission/modules/tool/index.ts b/ui/src/permission/modules/tool/index.ts index aa778ea123a..481edda1c9f 100644 --- a/ui/src/permission/modules/tool/index.ts +++ b/ui/src/permission/modules/tool/index.ts @@ -3,12 +3,20 @@ import workspace from './workspace' import system from './system' import share from './share' +import workspaceShared from './workspace-shared' -export default { workspace, +export default { + /**工作空间「工具」权限 + * */ + workspace, /** * 系统「工具」权限 * */ system, /**系统「共享工具」权限 * */ - share } + share, + /**工作空间「共享工具」权限 + * */ + workspaceShared +} diff --git a/ui/src/permission/modules/tool/workspace-shared.ts b/ui/src/permission/modules/tool/workspace-shared.ts new file mode 100644 index 00000000000..bd7d415a614 --- /dev/null +++ b/ui/src/permission/modules/tool/workspace-shared.ts @@ -0,0 +1,42 @@ +/** 工作空间「共享工具」按钮权限。 */ + +import { can } from '../../policy' +import { PermissionConstants as P } from '../../core' + +const workspace = { + // —— 系统页不提供 —— + isShare: () => false, + create: () => false, + batchDelete: () => false, + batchMove: () => false, + import: () => false, + debug: () => false, + authToWorkspace: () => false, + edit: () => false, + switch: () => false, + copy: () => false, + delete: () => false, + publish: () => false, + export: () => false, + auth: () => false, + relateMap: () => false, + record: () => false, + triggerRead: () => false, + triggerCreate: () => false, + triggerEdit: () => false, + triggerDelete: () => false, + folderCreate: () => false, + folderRead: () => false, + folderEdit: () => false, + folderDelete: () => false, + folderAuth: () => false, + folderManage: () => false, + + // —— 工作空间级 —— + /** + * 工作空间「共享工具」只读权限 + */ + read: () => can(P.TOOL_READ), +} + +export default workspace diff --git a/ui/src/views/workflow/tool/index.vue b/ui/src/views/workflow/tool/index.vue index 2801c2bc2c1..480773a4fc9 100644 --- a/ui/src/views/workflow/tool/index.vue +++ b/ui/src/views/workflow/tool/index.vue @@ -22,7 +22,7 @@ import type { WorkflowVersionPayload, WorkflowStoreTemplate, } from '@/api/types' -import { getResourceScope, isSystemResource, isSystemSharedResource } from '@/utils/resource-context' +import { getResourceScope, isSystemResource, isSystemSharedResource, isWorkspaceSharedResource} from '@/utils/resource-context' import { MsgConfirm, MsgSuccess, MsgError } from '@/utils/message' import WorkflowCanvas from '@/workflow-canvas/index.vue' import { defaultToolNodes } from '@/workflow-canvas/config/node-mapping' @@ -36,6 +36,7 @@ import ButtonPublishHistory from './ButtonPublishHistory.vue' import DebugDrawer from './debug/DebugDrawer.vue' import ButtonTemplateStore from './ButtonTemplateStore.vue' import { goBack } from './navigation' +import perm from '@/permission/index.ts' defineOptions({ name: 'ToolWorkflowView' }) @@ -64,6 +65,14 @@ const loading = ref(false) const savedWorkflow = ref() const saveTime = ref() +function toolWorkflowPermission(method: 'read' | 'edit' | 'publish' | 'export' | 'record' ):boolean { + if (isSystemResource()) return Boolean(perm.tool.system[method]()) + if (isSystemSharedResource()) return Boolean(perm.tool.share[method]()) + if (isWorkspaceSharedResource()) return Boolean(perm.tool.workspaceShared[method]()) + if (method === 'read') return Boolean(perm.tool.workspace.read()) + return perm.tool.workspace[method](toolId) +} + function getGraphData() { return workflowRef.value?.getGraphData() } @@ -360,7 +369,7 @@ onBeforeUnmount(() => stopAutoSave())