Skip to content

Commit c0b2aa3

Browse files
feat: System resource authorization function (#3861)
Co-authored-by: wangdan-fit2cloud <[email protected]>
1 parent f78e241 commit c0b2aa3

File tree

12 files changed

+463
-397
lines changed

12 files changed

+463
-397
lines changed

ui/src/api/system/resource-authorization.ts

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import { Permission } from '@/utils/permission/type'
21
import { Result } from '@/request/Result'
32
import { get, put, post, del } from '@/request/index'
4-
import type { pageRequest } from '@/api/type/common'
53
import type { Ref } from 'vue'
4+
import type { pageRequest } from '@/api/type/common'
65
const prefix = '/workspace'
76

87
/**
@@ -13,11 +12,13 @@ const getResourceAuthorization: (
1312
workspace_id: string,
1413
user_id: string,
1514
resource: string,
15+
page: pageRequest,
16+
params?: any,
1617
loading?: Ref<boolean>,
17-
) => Promise<Result<any>> = (workspace_id, user_id, resource, loading) => {
18+
) => Promise<Result<any>> = (workspace_id, user_id, resource, page, params, loading) => {
1819
return get(
19-
`${prefix}/${workspace_id}/user_resource_permission/user/${user_id}/resource/${resource}`,
20-
undefined,
20+
`${prefix}/${workspace_id}/user_resource_permission/user/${user_id}/resource/${resource}/${page.current_page}/${page.page_size}`,
21+
params,
2122
loading,
2223
)
2324
}
@@ -26,18 +27,12 @@ const getResourceAuthorization: (
2627
* 修改成员权限
2728
* @param 参数 member_id
2829
* @param 参数 {
29-
"team_resource_permission_list": [
30-
{
31-
"auth_target_type": "KNOWLEDGE",
32-
"target_id": "string",
33-
"auth_type": "ROLE",
34-
"permission": {
35-
"VIEW": true,
36-
"MANAGE": true,
37-
"ROLE": true
38-
}
39-
}
40-
]
30+
[
31+
{
32+
"target_id": "string",
33+
"permission": "NOT_AUTH"
34+
}
35+
]
4136
}
4237
*/
4338
const putResourceAuthorization: (

ui/src/components/ai-chat/index.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
:type="type" :send-message="sendMessage" :chat-management="ChatManagement"
2323
:executionIsRightPanel="props.executionIsRightPanel"
2424
@open-execution-detail="emit('openExecutionDetail', chatList[index])"
25-
@openParagraph="emit('openParagraph', chatList[index])" @openParagraphDocument="
25+
@openParagraph="emit('openParagraph', chatList[index])"
26+
@openParagraphDocument="
2627
(val: any) => emit('openParagraphDocument', chatList[index], val)
2728
"></AnswerContent>
2829
</template>

ui/src/enums/system.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export enum AuthorizationEnum {
22
MANAGE = 'MANAGE',
33
VIEW = 'VIEW',
44
ROLE = 'ROLE',
5+
NOT_AUTH = 'NOT_AUTH',
56
KNOWLEDGE = 'KNOWLEDGE',
67
APPLICATION = 'APPLICATION',
78
MODEL = 'MODEL',

ui/src/locales/lang/en-US/views/system.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,18 +109,20 @@ export default {
109109
enableSSL: 'Enable SSL (if the SMTP port is 465, you usually need to enable SSL)',
110110
enableTLS: 'Enable TLS (if the SMTP port is 587, you usually need to enable TLS)',
111111
},
112+
112113
resourceAuthorization: {
113114
title: 'Resource Authorization',
114115
member: 'Member',
115116
permissionSetting: 'Permission Setting',
116117
setting: {
117118
management: 'management',
119+
managementDesc: 'Can delete or modify this resource',
118120
check: 'check',
119-
authorization: 'authorization',
120-
},
121-
priority: {
122-
label: 'Resource permission priority',
123-
role: 'Role',
121+
checkDesc: 'Can only view the resource',
122+
role: 'User Role',
123+
roleDesc: 'Authorize users based on their roles to access this resource',
124+
notAuthorized: 'Not Authorized',
125+
configure: 'Configure Permission',
124126
},
125127
},
126128
resource_management: {

ui/src/locales/lang/zh-CN/views/system.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import role from './role'
2+
13
export default {
24
title: '系统管理',
35
subTitle: '系统设置',
@@ -115,12 +117,13 @@ export default {
115117
permissionSetting: '资源权限配置',
116118
setting: {
117119
management: '管理',
120+
managementDesc: '可对该资源进行删改操作',
118121
check: '查看',
119-
authorization: '授权',
120-
},
121-
priority: {
122-
label: '资源权限优先级',
123-
role: '按角色',
122+
checkDesc: '仅能查看使用该资源',
123+
role: '按用户角色',
124+
roleDesc: '根据用户角色中的权限授权用户对该资源的操作权限',
125+
notAuthorized: '不授权',
126+
configure: '配置权限',
124127
},
125128
},
126129
resource_management: {

ui/src/locales/lang/zh-Hant/views/system.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,18 +109,20 @@ export default {
109109
enableSSL: '啟用 SSL(如果 SMTP 端口是 465,通常需要啟用 SSL)',
110110
enableTLS: '啟用 TLS(如果 SMTP 端口是 587,通常需要啟用 TLS)',
111111
},
112+
112113
resourceAuthorization: {
113-
title: '資源授权',
114+
title: '資源授權',
114115
member: '成員',
115-
permissionSetting: '資源权限配置',
116+
permissionSetting: '資源權限配置',
116117
setting: {
117118
management: '管理',
119+
managementDesc: '可對該資源進行刪改操作',
118120
check: '查看',
119-
authorization: '授权',
120-
},
121-
priority: {
122-
label: '資源权限优先级',
123-
role: '按角色',
121+
checkDesc: '僅能查看使用該資源',
122+
role: '按用戶角色',
123+
roleDesc: '根據用戶角色中的權限授權用戶對該資源的操作權限',
124+
notAuthorized: '不授權',
125+
configure: '配置權限',
124126
},
125127
},
126128
resource_management: {

ui/src/views/chat-log/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,12 +359,12 @@ const nextChatRecord = () => {
359359
}
360360
}
361361
const pre_disable = computed(() => {
362-
let index = tableIndexMap.value[currentChatId.value] - 1
362+
const index = tableIndexMap.value[currentChatId.value] - 1
363363
return index < 0 && paginationConfig.current_page <= 1
364364
})
365365
366366
const next_disable = computed(() => {
367-
let index = tableIndexMap.value[currentChatId.value] + 1
367+
const index = tableIndexMap.value[currentChatId.value] + 1
368368
return (
369369
index >= tableData.value.length &&
370370
index + (paginationConfig.current_page - 1) * paginationConfig.page_size >=

ui/src/views/document/index.vue

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,11 @@
5151
>{{ $t('views.document.generateQuestion.title') }}
5252
</el-button>
5353
<el-button
54-
@click="openknowledgeDialog()"
54+
@click="openBatchEditDocument"
5555
:disabled="multipleSelection.length === 0"
56-
v-if="permissionPrecise.doc_migrate(id)"
57-
>{{ $t('views.document.setting.migration') }}
56+
v-if="permissionPrecise.doc_edit(id)"
57+
>
58+
{{ $t('common.setting') }}
5859
</el-button>
5960
<el-dropdown v-if="MoreFilledPermission0(id)">
6061
<el-button class="ml-12 mr-12">
@@ -63,11 +64,11 @@
6364
<template #dropdown>
6465
<el-dropdown-menu>
6566
<el-dropdown-item
66-
@click="openBatchEditDocument"
67+
@click="openknowledgeDialog()"
6768
:disabled="multipleSelection.length === 0"
68-
v-if="permissionPrecise.doc_edit(id)"
69+
v-if="permissionPrecise.doc_migrate(id)"
6970
>
70-
{{ $t('common.setting') }}
71+
{{ $t('views.document.setting.migration') }}
7172
</el-dropdown-item>
7273
<el-dropdown-item
7374
divided
@@ -434,16 +435,12 @@
434435
"
435436
@click="cancelTask(row, TaskType.GENERATE_PROBLEM)"
436437
>
437-
<AppIcon
438-
iconName="app-generate-question"
439-
class="color-secondary"
440-
></AppIcon>
438+
<el-icon class="color-secondary"><Close /></el-icon>
441439
{{ $t('views.document.setting.cancelGenerateQuestion') }}
442440
</el-dropdown-item>
443441
<el-dropdown-item
444-
v-else
445442
@click="openGenerateDialog(row)"
446-
v-if="permissionPrecise.doc_generate(id)"
443+
v-else-if="permissionPrecise.doc_generate(id)"
447444
>
448445
<AppIcon
449446
iconName="app-generate-question"
@@ -494,18 +491,6 @@
494491
</span>
495492
</template>
496493
<template v-if="knowledgeDetail?.type === 1 || knowledgeDetail?.type === 2">
497-
<el-tooltip
498-
effect="dark"
499-
:content="$t('views.knowledge.setting.sync')"
500-
placement="top"
501-
v-if="permissionPrecise.sync(id)"
502-
>
503-
<span class="mr-4">
504-
<el-button type="primary" text @click.stop="syncDocument(row)">
505-
<AppIcon iconName="app-sync"></AppIcon>
506-
</el-button>
507-
</span>
508-
</el-tooltip>
509494
<el-tooltip
510495
effect="dark"
511496
:content="$t('views.document.setting.cancelVectorization')"
@@ -538,6 +523,18 @@
538523
</el-button>
539524
</span>
540525
</el-tooltip>
526+
<el-tooltip
527+
effect="dark"
528+
:content="$t('common.setting')"
529+
placement="top"
530+
v-if="permissionPrecise.doc_edit(id)"
531+
>
532+
<span class="mr-4">
533+
<el-button type="primary" text @click.stop="settingDoc(row)">
534+
<AppIcon iconName="app-setting"></AppIcon>
535+
</el-button>
536+
</span>
537+
</el-tooltip>
541538
<span @click.stop>
542539
<el-dropdown trigger="click" v-if="MoreFilledPermission2(id)">
543540
<el-button text type="primary">
@@ -546,11 +543,11 @@
546543
<template #dropdown>
547544
<el-dropdown-menu>
548545
<el-dropdown-item
549-
@click="settingDoc(row)"
550-
v-if="permissionPrecise.doc_edit(id)"
546+
@click="syncDocument(row)"
547+
v-if="permissionPrecise.sync(id)"
551548
>
552-
<AppIcon iconName="app-setting"></AppIcon>
553-
{{ $t('common.setting') }}</el-dropdown-item
549+
<AppIcon iconName="app-sync" class="color-secondary"></AppIcon>
550+
{{ $t('views.knowledge.setting.sync') }}</el-dropdown-item
554551
>
555552
<el-dropdown-item
556553
v-if="
@@ -561,43 +558,45 @@
561558
"
562559
@click="cancelTask(row, TaskType.GENERATE_PROBLEM)"
563560
>
564-
<AppIcon iconName="app-generate-question"></AppIcon>
561+
<el-icon class="color-secondary"><Close /></el-icon>
565562
{{ $t('views.document.setting.cancelGenerateQuestion') }}
566563
</el-dropdown-item>
567564
<el-dropdown-item
568-
v-else
569565
@click="openGenerateDialog(row)"
570-
v-if="permissionPrecise.doc_generate(id)"
566+
v-else-if="permissionPrecise.doc_generate(id)"
571567
>
572-
<AppIcon iconName="app-generate-question"></AppIcon>
568+
<AppIcon
569+
iconName="app-generate-question"
570+
class="color-secondary"
571+
></AppIcon>
573572
{{ $t('views.document.generateQuestion.title') }}
574573
</el-dropdown-item>
575574
<el-dropdown-item
576575
@click="openknowledgeDialog(row)"
577576
v-if="permissionPrecise.doc_migrate(id)"
578577
>
579-
<AppIcon iconName="app-migrate"></AppIcon>
578+
<AppIcon iconName="app-migrate" class="color-secondary"></AppIcon>
580579
{{ $t('views.document.setting.migration') }}
581580
</el-dropdown-item>
582581
<el-dropdown-item
583582
@click="exportDocument(row)"
584583
v-if="permissionPrecise.doc_export(id)"
585584
>
586-
<AppIcon iconName="app-export"></AppIcon>
585+
<AppIcon iconName="app-export" class="color-secondary"></AppIcon>
587586
{{ $t('views.document.setting.export') }} Excel
588587
</el-dropdown-item>
589588
<el-dropdown-item
590589
@click="exportDocumentZip(row)"
591590
v-if="permissionPrecise.doc_export(id)"
592591
>
593-
<AppIcon iconName="app-export"></AppIcon>
592+
<AppIcon iconName="app-export" class="color-secondary"></AppIcon>
594593
{{ $t('views.document.setting.export') }} Zip
595594
</el-dropdown-item>
596595
<el-dropdown-item
597596
@click.stop="deleteDocument(row)"
598597
v-if="permissionPrecise.doc_delete(id)"
599598
>
600-
<AppIcon iconName="app-delete"></AppIcon>
599+
<AppIcon iconName="app-delete" class="color-secondary"></AppIcon>
601600
{{ $t('common.delete') }}
602601
</el-dropdown-item>
603602
</el-dropdown-menu>
@@ -712,7 +711,7 @@ const permissionPrecise = computed(() => {
712711
713712
const MoreFilledPermission0 = (id: string) => {
714713
return (
715-
permissionPrecise.value.doc_edit(id) ||
714+
permissionPrecise.value.doc_migrate(id) ||
716715
(knowledgeDetail?.value.type === 1 && permissionPrecise.value.doc_sync(id)) ||
717716
(knowledgeDetail?.value.type === 2 && permissionPrecise.value.doc_sync(id)) ||
718717
permissionPrecise.value.doc_delete(id)
@@ -731,7 +730,7 @@ const MoreFilledPermission1 = (id: string) => {
731730
732731
const MoreFilledPermission2 = (id: string) => {
733732
return (
734-
permissionPrecise.value.doc_edit(id) ||
733+
permissionPrecise.value.sync(id) ||
735734
permissionPrecise.value.doc_generate(id) ||
736735
permissionPrecise.value.doc_migrate(id) ||
737736
permissionPrecise.value.doc_export(id) ||

ui/src/views/knowledge/component/BaseForm.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,10 @@ import { groupBy } from 'lodash'
4747
import type { knowledgeData } from '@/api/type/knowledge'
4848
import { t } from '@/locales'
4949
import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
50-
import modelResourceApi from '@/api/system-resource-management/model'
5150
const props = defineProps<{
5251
data?: {
53-
type: Object
54-
default: () => {}
52+
type: object
53+
default: () => null
5554
}
5655
apiType: 'systemShare' | 'workspace' | 'systemManage'
5756
}>()

0 commit comments

Comments
 (0)