From f13f104c74064f1d19a694270266e6225d547b07 Mon Sep 17 00:00:00 2001 From: zhangzhanwei Date: Tue, 26 May 2026 17:40:41 +0800 Subject: [PATCH] feat: Copy permission --- apps/common/constants/permission_constants.py | 12 ++ apps/locales/en_US/LC_MESSAGES/django.po | 5 +- apps/locales/zh_CN/LC_MESSAGES/django.po | 5 +- apps/locales/zh_Hant/LC_MESSAGES/django.po | 5 +- .../permission/application/system-manage.ts | 1 + ui/src/permission/application/workspace.ts | 15 +++ ui/src/utils/permission/data.ts | 2 + ui/src/views/application/index.vue | 127 +++++++++--------- 8 files changed, 107 insertions(+), 65 deletions(-) diff --git a/apps/common/constants/permission_constants.py b/apps/common/constants/permission_constants.py index 262d212b6d8..b1d40debdbc 100644 --- a/apps/common/constants/permission_constants.py +++ b/apps/common/constants/permission_constants.py @@ -185,6 +185,7 @@ class Operate(Enum): TO_CHAT = "READ+TO_CHAT" # 去对话 SETTING = "READ+SETTING" # 管理 DOWNLOAD = "READ+DOWNLOAD" # 下载 + COPY = "READ+COPY" AUTH = "READ+AUTH" # 资源授权 TAG = "READ+TAG" # 标签设置 REPLACE = "READ+REPLACE" # 标签设置 @@ -341,6 +342,7 @@ def get_workspace_role(self): WorkspaceGroup.OTHER.value: _("Other"), Operate.READ.value: _("Read"), Operate.EDIT.value: _("Edit"), + Operate.COPY.value: _('Copy'), Operate.PUBLISH.value: _("Publish"), Operate.CREATE.value: _("Create"), Operate.DELETE.value: _("Delete"), @@ -1074,6 +1076,11 @@ class PermissionConstants(Enum): parent_group=[WorkspaceGroup.APPLICATION, UserGroup.APPLICATION], resource_permission_group_list=[ResourcePermissionConst.APPLICATION_MANGE], ) + APPLICATION_COPY = Permission(group=Group.APPLICATION, operate=Operate.COPY, + role_list=[RoleConstants.ADMIN, RoleConstants.USER], + parent_group=[WorkspaceGroup.APPLICATION, UserGroup.APPLICATION], + resource_permission_group_list=[ResourcePermissionConst.APPLICATION_MANGE], + ) APPLICATION_EDIT = Permission(group=Group.APPLICATION, operate=Operate.EDIT, role_list=[RoleConstants.ADMIN, RoleConstants.USER], parent_group=[WorkspaceGroup.APPLICATION, UserGroup.APPLICATION], @@ -1650,6 +1657,11 @@ class PermissionConstants(Enum): group=Group.SYSTEM_RES_APPLICATION, operate=Operate.EXPORT, role_list=[RoleConstants.ADMIN], parent_group=[SystemGroup.RESOURCE_APPLICATION], is_ee=settings.edition == "EE" ) + RESOURCE_APPLICATION_COPY = Permission( + group=Group.SYSTEM_RES_APPLICATION, operate=Operate.COPY, + role_list=[RoleConstants.ADMIN], + parent_group=[SystemGroup.RESOURCE_APPLICATION], is_ee=settings.edition == "EE" + ) RESOURCE_APPLICATION_AUTH = Permission( group=Group.SYSTEM_RES_APPLICATION, operate=Operate.AUTH, role_list=[RoleConstants.ADMIN], parent_group=[SystemGroup.RESOURCE_APPLICATION], is_ee=settings.edition == "EE" diff --git a/apps/locales/en_US/LC_MESSAGES/django.po b/apps/locales/en_US/LC_MESSAGES/django.po index 53ab3cd9cb9..710e822f685 100644 --- a/apps/locales/en_US/LC_MESSAGES/django.po +++ b/apps/locales/en_US/LC_MESSAGES/django.po @@ -9351,4 +9351,7 @@ msgid "Asker user information" msgstr "" msgid "Termbase" -msgstr "" \ No newline at end of file +msgstr "" + +msgid "Copy" +msgstr "Copy" \ No newline at end of file diff --git a/apps/locales/zh_CN/LC_MESSAGES/django.po b/apps/locales/zh_CN/LC_MESSAGES/django.po index de5e02e0bf8..74ee4c4f03f 100644 --- a/apps/locales/zh_CN/LC_MESSAGES/django.po +++ b/apps/locales/zh_CN/LC_MESSAGES/django.po @@ -9474,4 +9474,7 @@ msgid "Asker user information" msgstr "提问用户信息" msgid "Termbase" -msgstr "词库" \ No newline at end of file +msgstr "词库" + +msgid "Copy" +msgstr "复制" \ No newline at end of file diff --git a/apps/locales/zh_Hant/LC_MESSAGES/django.po b/apps/locales/zh_Hant/LC_MESSAGES/django.po index 748b9eee658..580bf3e1548 100644 --- a/apps/locales/zh_Hant/LC_MESSAGES/django.po +++ b/apps/locales/zh_Hant/LC_MESSAGES/django.po @@ -9471,4 +9471,7 @@ msgid "Asker user information" msgstr "提問使用者資訊" msgid "Termbase" -msgstr "詞庫" \ No newline at end of file +msgstr "詞庫" + +msgid "Copy" +msgstr "複製" \ No newline at end of file diff --git a/ui/src/permission/application/system-manage.ts b/ui/src/permission/application/system-manage.ts index 94ac6c44b03..607c996bed3 100644 --- a/ui/src/permission/application/system-manage.ts +++ b/ui/src/permission/application/system-manage.ts @@ -3,6 +3,7 @@ import { PermissionConst, RoleConst } from '@/utils/permission/data' const systemManage = { create: () => false, + copy: () => hasPermission([RoleConst.ADMIN, PermissionConst.RESOURCE_APPLICATION_COPY], 'OR'), batchDelete: () => false, batchMove: () => false, folderCreate: () => false, diff --git a/ui/src/permission/application/workspace.ts b/ui/src/permission/application/workspace.ts index 9f46d34020d..a528345d1be 100644 --- a/ui/src/permission/application/workspace.ts +++ b/ui/src/permission/application/workspace.ts @@ -33,6 +33,21 @@ const workspace = { ], 'OR', ), + copy: (source_id: string) => + hasPermission( + [ + new ComplexPermission( + [RoleConst.USER], + [PermissionConst.APPLICATION.getApplicationWorkspaceResourcePermission(source_id)], + [], + 'AND', + ), + RoleConst.WORKSPACE_MANAGE.getWorkspaceRole, + PermissionConst.APPLICATION_COPY.getApplicationWorkspaceResourcePermission(source_id), + PermissionConst.APPLICATION_COPY.getWorkspacePermissionWorkspaceManageRole, + ], + 'OR', + ), relate_map: (source_id: string) => hasPermission( [ diff --git a/ui/src/utils/permission/data.ts b/ui/src/utils/permission/data.ts index 2870da4a196..21a91cf7a2c 100644 --- a/ui/src/utils/permission/data.ts +++ b/ui/src/utils/permission/data.ts @@ -181,6 +181,7 @@ const PermissionConst = { APPLICATION_DELETE: new Permission('APPLICATION:READ+DELETE'), APPLICATION_EDIT: new Permission('APPLICATION:READ+EDIT'), APPLICATION_CREATE: new Permission('APPLICATION:READ+CREATE'), + APPLICATION_COPY: new Permission('APPLICATION:READ+COPY'), APPLICATION_IMPORT: new Permission('APPLICATION:READ+IMPORT'), APPLICATION_SETTING: new Permission('APPLICATION:READ+SETTING'), APPLICATION_TO_CHAT: new Permission('APPLICATION:READ+TO_CHAT'), @@ -383,6 +384,7 @@ const PermissionConst = { RESOURCE_KNOWLEDGE_HIT_TEST: new Permission('SYSTEM_RESOURCE_KNOWLEDGE_HIT_TEST:READ'), RESOURCE_APPLICATION_READ: new Permission('SYSTEM_RESOURCE_APPLICATION:READ'), + RESOURCE_APPLICATION_COPY: new Permission('SYSTEM_RESOURCE_APPLICATION:READ+COPY'), RESOURCE_APPLICATION_EDIT: new Permission('SYSTEM_RESOURCE_APPLICATION:READ+EDIT'), RESOURCE_APPLICATION_IMPORT: new Permission('SYSTEM_RESOURCE_APPLICATION:READ+IMPORT'), RESOURCE_APPLICATION_EXPORT: new Permission('SYSTEM_RESOURCE_APPLICATION:READ+EXPORT'), diff --git a/ui/src/views/application/index.vue b/ui/src/views/application/index.vue index fe934476153..f26e23ed7ab 100644 --- a/ui/src/views/application/index.vue +++ b/ui/src/views/application/index.vue @@ -14,7 +14,7 @@