Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions apps/common/constants/permission_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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" # 标签设置
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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],
Expand Down Expand Up @@ -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"
Expand Down
5 changes: 4 additions & 1 deletion apps/locales/en_US/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -9351,4 +9351,7 @@ msgid "Asker user information"
msgstr ""

msgid "Termbase"
msgstr ""
msgstr ""

msgid "Copy"
msgstr "Copy"
5 changes: 4 additions & 1 deletion apps/locales/zh_CN/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -9474,4 +9474,7 @@ msgid "Asker user information"
msgstr "提问用户信息"

msgid "Termbase"
msgstr "词库"
msgstr "词库"

msgid "Copy"
msgstr "复制"
5 changes: 4 additions & 1 deletion apps/locales/zh_Hant/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -9471,4 +9471,7 @@ msgid "Asker user information"
msgstr "提問使用者資訊"

msgid "Termbase"
msgstr "詞庫"
msgstr "詞庫"

msgid "Copy"
msgstr "複製"
1 change: 1 addition & 0 deletions ui/src/permission/application/system-manage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
15 changes: 15 additions & 0 deletions ui/src/permission/application/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
[
Expand Down
2 changes: 2 additions & 0 deletions ui/src/utils/permission/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down Expand Up @@ -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'),
Expand Down
Loading
Loading