Skip to content

Commit fd11a18

Browse files
committed
feat: Resource tool permission
1 parent f13dcbc commit fd11a18

File tree

2 files changed

+115
-1
lines changed

2 files changed

+115
-1
lines changed
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
import {hasPermission} from '@/utils/permission/index'
2+
import {ComplexPermission} from '@/utils/permission/type'
3+
import {EditionConst, PermissionConst, RoleConst} from '@/utils/permission/data'
4+
5+
const systemManage = {
6+
create: () => false,
7+
folderCreate: () => false,
8+
edit: () =>
9+
hasPermission(
10+
[
11+
RoleConst.ADMIN,
12+
PermissionConst.RESOURCE_APPLICATION_EDIT
13+
],
14+
'OR'
15+
),
16+
folderEdit: () => false,
17+
export: () =>
18+
hasPermission(
19+
[
20+
RoleConst.ADMIN,
21+
PermissionConst.RESOURCE_APPLICATION_EXPORT
22+
],
23+
'OR'
24+
),
25+
delete: () =>
26+
hasPermission(
27+
[
28+
RoleConst.ADMIN,
29+
PermissionConst.RESOURCE_APPLICATION_DELETE
30+
],
31+
'OR'
32+
),
33+
folderDelete: () => false,
34+
overview_embed: () =>
35+
hasPermission(
36+
[
37+
RoleConst.ADMIN,
38+
PermissionConst.RESOURCE_APPLICATION_OVERVIEW_EMBED
39+
],
40+
'OR'
41+
),
42+
overview_access: () =>
43+
hasPermission(
44+
[
45+
RoleConst.ADMIN,
46+
PermissionConst.RESOURCE_APPLICATION_OVERVIEW_ACCESS
47+
],
48+
'OR'
49+
),
50+
overview_display: () =>
51+
hasPermission(
52+
[
53+
RoleConst.ADMIN,
54+
PermissionConst.RESOURCE_APPLICATION_OVERVIEW_DISPLAY
55+
],
56+
'OR'
57+
),
58+
overview_api_key: () =>
59+
hasPermission(
60+
[
61+
RoleConst.ADMIN,
62+
PermissionConst.RESOURCE_APPLICATION_OVERVIEW_API_KEY
63+
],
64+
'OR'
65+
),
66+
access_edit: () =>
67+
hasPermission(
68+
[
69+
RoleConst.ADMIN,
70+
PermissionConst.RESOURCE_APPLICATION_ACCESS_EDIT
71+
],
72+
'OR'
73+
),
74+
application_chat_user_edit: () =>
75+
hasPermission(
76+
[
77+
RoleConst.ADMIN,
78+
PermissionConst.RESOURCE_APPLICATION_CHAT_USER_EDIT
79+
],
80+
'OR'
81+
),
82+
chat_log_clear: () =>
83+
hasPermission(
84+
[
85+
RoleConst.ADMIN,
86+
PermissionConst.RESOURCE_APPLICATION_CHAT_LOG_CLEAR_POLICY
87+
],
88+
'OR'
89+
),
90+
chat_log_export: () =>
91+
hasPermission(
92+
[
93+
RoleConst.ADMIN,
94+
PermissionConst.RESOURCE_APPLICATION_CHAT_LOG_EXPORT
95+
],
96+
'OR'
97+
),
98+
chat_log_add_knowledge: () =>
99+
hasPermission(
100+
[
101+
RoleConst.ADMIN,
102+
PermissionConst.RESOURCE_APPLICATION_CHAT_LOG_ADD_KNOWLEDGE
103+
],
104+
'OR'
105+
),
106+
}

ui/src/views/system-resource-management/ToolResourceIndex.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,9 @@
227227
</el-button>
228228
</span>
229229
</el-tooltip>
230-
<el-dropdown trigger="click">
230+
<el-dropdown trigger="click"
231+
v-if="MoreFilledPermission(row)"
232+
>
231233
<el-button text @click.stop>
232234
<el-icon>
233235
<MoreFilled />
@@ -314,6 +316,12 @@ const permissionPrecise = computed(() => {
314316
return permissionMap['tool']['systemManage']
315317
})
316318
319+
const MoreFilledPermission = (row: any) => {
320+
return permissionPrecise.value.export() ||
321+
permissionPrecise.value.delete() ||
322+
(row.init_field_list?.length > 0 && permissionPrecise.value.edit())
323+
}
324+
317325
function exportTool(row: any) {
318326
ToolResourceApi.exportTool(row.id, row.name, loading).catch((e: any) => {
319327
if (e.response.status !== 403) {

0 commit comments

Comments
 (0)