Skip to content

Commit 85ebd22

Browse files
committed
feat: Share tool permission
1 parent a85cf51 commit 85ebd22

File tree

5 files changed

+68
-25
lines changed

5 files changed

+68
-25
lines changed

ui/src/permission/tool/system-share.ts

Lines changed: 56 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,61 @@ import { ComplexPermission } from '@/utils/permission/type'
33
import { EditionConst, PermissionConst, RoleConst } from '@/utils/permission/data'
44
const share = {
55
is_share: () => false,
6-
delete: () => false,
7-
create: () => false,
8-
switch: () => false,
9-
edit: () => false,
10-
copy: () => false,
11-
export: () => false,
12-
debug: () => false,
6+
create: () =>
7+
hasPermission(
8+
[
9+
RoleConst.ADMIN,
10+
PermissionConst.SHARED_TOOL_CREATE,
11+
],
12+
'OR',
13+
),
14+
delete: () =>
15+
hasPermission(
16+
[
17+
RoleConst.ADMIN,
18+
PermissionConst.SHARED_TOOL_DELETE,
19+
],
20+
'OR',
21+
),
22+
switch: () =>
23+
hasPermission(
24+
[
25+
RoleConst.ADMIN,
26+
PermissionConst.SHARED_TOOL_EDIT,
27+
],
28+
'OR',
29+
),
30+
edit: () =>
31+
hasPermission(
32+
[
33+
RoleConst.ADMIN,
34+
PermissionConst.SHARED_TOOL_EDIT,
35+
],
36+
'OR',
37+
),
38+
copy: () =>
39+
hasPermission(
40+
[
41+
RoleConst.ADMIN,
42+
PermissionConst.SHARED_TOOL_CREATE,
43+
],
44+
'OR',
45+
),
46+
export: () =>
47+
hasPermission(
48+
[
49+
RoleConst.ADMIN,
50+
PermissionConst.SHARED_TOOL_EXPORT,
51+
],
52+
'OR',
53+
),
54+
debug: () =>
55+
hasPermission(
56+
[
57+
RoleConst.ADMIN,
58+
PermissionConst.SHARED_TOOL_DEBUG,
59+
],
60+
'OR',
61+
),
1362
}
1463
export default share

ui/src/permission/tool/workspace.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,7 @@ import { EditionConst, PermissionConst, RoleConst } from '@/utils/permission/dat
44
const workspace = {
55
is_share: () =>
66
hasPermission(
7-
new ComplexPermission(
8-
[RoleConst.ADMIN],
9-
[PermissionConst.SHARED_TOOL_READ],
10-
[EditionConst.IS_EE],
11-
'OR',
12-
),
7+
[EditionConst.IS_EE],
138
'OR',
149
),
1510
delete: () =>

ui/src/router/modules/system.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,14 @@ const systemRouter = {
145145
activeMenu: '/system',
146146
parentPath: '/system',
147147
parentName: 'system',
148+
permission: [
149+
new ComplexPermission(
150+
[RoleConst.ADMIN],
151+
[PermissionConst.SHARED_TOOL_READ],
152+
[EditionConst.IS_EE],
153+
'OR'
154+
)
155+
]
148156
},
149157
component: () => import('@/views/system-shared/ToolSharedIndex.vue'),
150158
},

ui/src/views/knowledge/index.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@
189189
@click="
190190
router.push({ path: `/knowledge/${item.id}/${currentFolder.id}/document` })
191191
"
192-
v-if="permissionPrecise.single(item.id)"
193192
>
194193
<template #icon>
195194
<KnowledgeIcon :type="item.type" />

ui/src/views/tool/component/ToolListContainer.vue

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
<el-option v-for="u in user_options" :key="u.id" :value="u.id" :label="u.username" />
3535
</el-select>
3636
</div>
37-
<el-dropdown trigger="click" v-if="!isShared">
38-
<el-button type="primary" class="ml-8" v-if="permissionPrecise.create()">
37+
<el-dropdown trigger="click" v-if="!isShared && permissionPrecise.create()">
38+
<el-button type="primary" class="ml-8">
3939
{{ $t('common.create') }}
4040
<el-icon class="el-icon--right">
4141
<arrow-down />
@@ -151,15 +151,7 @@
151151
class="cursor"
152152
@click.stop="openCreateDialog(item)"
153153
:disabled="
154-
hasPermission(
155-
[
156-
RoleConst.WORKSPACE_MANAGE.getWorkspaceRole,
157-
RoleConst.USER.getWorkspaceRole,
158-
PermissionConst.TOOL_EDIT.getWorkspacePermissionWorkspaceManageRole,
159-
PermissionConst.TOOL_EDIT.getWorkspacePermission,
160-
],
161-
'OR',
162-
)
154+
permissionPrecise.edit()
163155
"
164156
>
165157
<template #icon>

0 commit comments

Comments
 (0)