From f78e24105fb69fe012dcee8f4ecd6b7a3a828b5b Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Fri, 15 Aug 2025 15:43:25 +0800 Subject: [PATCH 01/18] feat: enhance WeCom Bot configuration with updated URL info and additional guidance --- ui/src/locales/lang/en-US/views/application.ts | 2 +- ui/src/locales/lang/zh-CN/views/application.ts | 4 ++-- ui/src/locales/lang/zh-Hant/views/application.ts | 6 +++--- .../application/component/AccessSettingDrawer.vue | 10 ++++++++++ 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/ui/src/locales/lang/en-US/views/application.ts b/ui/src/locales/lang/en-US/views/application.ts index cd185ddee..c5c9bcab9 100644 --- a/ui/src/locales/lang/en-US/views/application.ts +++ b/ui/src/locales/lang/en-US/views/application.ts @@ -212,7 +212,7 @@ export default { }, wecomBotSetting: { title: 'WeCom Bot Configuration', - urlInfo: '-Security and Management-Management Tools-Intelligent Bots-API Mode', + urlInfo: '-Management Tools-Smart Bot-Create Bot-API Mode Create "URL"', }, larkSetting: { title: 'Lark Configuration', diff --git a/ui/src/locales/lang/zh-CN/views/application.ts b/ui/src/locales/lang/zh-CN/views/application.ts index 9c2b4afb8..11226f971 100644 --- a/ui/src/locales/lang/zh-CN/views/application.ts +++ b/ui/src/locales/lang/zh-CN/views/application.ts @@ -179,8 +179,8 @@ export default { urlInfo: '-应用管理-自建-创建的应用-接收消息-设置 API 接收的 "URL" 中', }, wecomBotSetting: { - title: '企业微信应用配置', - urlInfo: '-安全与管理-管理工具-智能机器人- API 模式创建的 "URL" 中', + title: '企业微信智能机器人配置', + urlInfo: '-管理工具-智能机器人-创建机器人-API模式创建的 "URL" 中', }, dingtalkSetting: { title: '钉钉应用配置', diff --git a/ui/src/locales/lang/zh-Hant/views/application.ts b/ui/src/locales/lang/zh-Hant/views/application.ts index 82b23beda..d7a7684c4 100644 --- a/ui/src/locales/lang/zh-Hant/views/application.ts +++ b/ui/src/locales/lang/zh-Hant/views/application.ts @@ -204,9 +204,9 @@ export default { verificationTokenPlaceholder: '請輸入Verification Token', urlInfo: '-事件與回呼-事件配置-配置訂閱方式的 "請求位址" 中', }, - wecomBotSetting: { - title: '企業微信機器人配置', - urlInfo: '-安全與管理-管理工具-智能機器人- API 模式建立的 "URL" 中', + wecomBotSetting: { + title: '企業微信智能機器人配置', + urlInfo: '-管理工具-智能机器人-创建机器人-API模式创建的 "URL" 中', }, slackSetting: { title: 'Slack 應用配置', diff --git a/ui/src/views/application/component/AccessSettingDrawer.vue b/ui/src/views/application/component/AccessSettingDrawer.vue index f530fc4f2..73fb3247d 100644 --- a/ui/src/views/application/component/AccessSettingDrawer.vue +++ b/ui/src/views/application/component/AccessSettingDrawer.vue @@ -84,6 +84,16 @@ }}{{ $t('views.application.applicationAccess.larkSetting.urlInfo') }} + + {{ $t('views.application.applicationAccess.copyUrl') }} + {{ $t('views.application.applicationAccess.wecomPlatform') }}{{ $t('views.application.applicationAccess.wecomBotSetting.urlInfo') }} + + From c0b2aa3688ae514ea44fe9de7ce51d4c37600865 Mon Sep 17 00:00:00 2001 From: shaohuzhang1 <80892890+shaohuzhang1@users.noreply.github.com> Date: Fri, 15 Aug 2025 16:03:03 +0800 Subject: [PATCH 02/18] feat: System resource authorization function (#3861) Co-authored-by: wangdan-fit2cloud --- ui/src/api/system/resource-authorization.ts | 29 +- ui/src/components/ai-chat/index.vue | 3 +- ui/src/enums/system.ts | 1 + ui/src/locales/lang/en-US/views/system.ts | 12 +- ui/src/locales/lang/zh-CN/views/system.ts | 13 +- ui/src/locales/lang/zh-Hant/views/system.ts | 16 +- ui/src/views/chat-log/index.vue | 4 +- ui/src/views/document/index.vue | 75 ++-- ui/src/views/knowledge/component/BaseForm.vue | 5 +- .../component/PermissionTable.vue | 308 +++++++++++++++ .../system/resource-authorization/constant.ts | 25 ++ .../system/resource-authorization/index.vue | 369 +++--------------- 12 files changed, 463 insertions(+), 397 deletions(-) create mode 100644 ui/src/views/system/resource-authorization/component/PermissionTable.vue create mode 100644 ui/src/views/system/resource-authorization/constant.ts diff --git a/ui/src/api/system/resource-authorization.ts b/ui/src/api/system/resource-authorization.ts index b12e72358..a53a9d10a 100644 --- a/ui/src/api/system/resource-authorization.ts +++ b/ui/src/api/system/resource-authorization.ts @@ -1,8 +1,7 @@ -import { Permission } from '@/utils/permission/type' import { Result } from '@/request/Result' import { get, put, post, del } from '@/request/index' -import type { pageRequest } from '@/api/type/common' import type { Ref } from 'vue' +import type { pageRequest } from '@/api/type/common' const prefix = '/workspace' /** @@ -13,11 +12,13 @@ const getResourceAuthorization: ( workspace_id: string, user_id: string, resource: string, + page: pageRequest, + params?: any, loading?: Ref, -) => Promise> = (workspace_id, user_id, resource, loading) => { +) => Promise> = (workspace_id, user_id, resource, page, params, loading) => { return get( - `${prefix}/${workspace_id}/user_resource_permission/user/${user_id}/resource/${resource}`, - undefined, + `${prefix}/${workspace_id}/user_resource_permission/user/${user_id}/resource/${resource}/${page.current_page}/${page.page_size}`, + params, loading, ) } @@ -26,18 +27,12 @@ const getResourceAuthorization: ( * 修改成员权限 * @param 参数 member_id * @param 参数 { - "team_resource_permission_list": [ - { - "auth_target_type": "KNOWLEDGE", - "target_id": "string", - "auth_type": "ROLE", - "permission": { - "VIEW": true, - "MANAGE": true, - "ROLE": true - } - } - ] + [ + { + "target_id": "string", + "permission": "NOT_AUTH" + } + ] } */ const putResourceAuthorization: ( diff --git a/ui/src/components/ai-chat/index.vue b/ui/src/components/ai-chat/index.vue index 0c1b8c08b..3af8b9c1b 100644 --- a/ui/src/components/ai-chat/index.vue +++ b/ui/src/components/ai-chat/index.vue @@ -22,7 +22,8 @@ :type="type" :send-message="sendMessage" :chat-management="ChatManagement" :executionIsRightPanel="props.executionIsRightPanel" @open-execution-detail="emit('openExecutionDetail', chatList[index])" - @openParagraph="emit('openParagraph', chatList[index])" @openParagraphDocument=" + @openParagraph="emit('openParagraph', chatList[index])" + @openParagraphDocument=" (val: any) => emit('openParagraphDocument', chatList[index], val) "> diff --git a/ui/src/enums/system.ts b/ui/src/enums/system.ts index 3fcbf7217..5a4fd920d 100644 --- a/ui/src/enums/system.ts +++ b/ui/src/enums/system.ts @@ -2,6 +2,7 @@ export enum AuthorizationEnum { MANAGE = 'MANAGE', VIEW = 'VIEW', ROLE = 'ROLE', + NOT_AUTH = 'NOT_AUTH', KNOWLEDGE = 'KNOWLEDGE', APPLICATION = 'APPLICATION', MODEL = 'MODEL', diff --git a/ui/src/locales/lang/en-US/views/system.ts b/ui/src/locales/lang/en-US/views/system.ts index 8b2efe24f..045d7a59d 100644 --- a/ui/src/locales/lang/en-US/views/system.ts +++ b/ui/src/locales/lang/en-US/views/system.ts @@ -109,18 +109,20 @@ export default { enableSSL: 'Enable SSL (if the SMTP port is 465, you usually need to enable SSL)', enableTLS: 'Enable TLS (if the SMTP port is 587, you usually need to enable TLS)', }, + resourceAuthorization: { title: 'Resource Authorization', member: 'Member', permissionSetting: 'Permission Setting', setting: { management: 'management', + managementDesc: 'Can delete or modify this resource', check: 'check', - authorization: 'authorization', - }, - priority: { - label: 'Resource permission priority', - role: 'Role', + checkDesc: 'Can only view the resource', + role: 'User Role', + roleDesc: 'Authorize users based on their roles to access this resource', + notAuthorized: 'Not Authorized', + configure: 'Configure Permission', }, }, resource_management: { diff --git a/ui/src/locales/lang/zh-CN/views/system.ts b/ui/src/locales/lang/zh-CN/views/system.ts index 666d0874f..4bf583d1e 100644 --- a/ui/src/locales/lang/zh-CN/views/system.ts +++ b/ui/src/locales/lang/zh-CN/views/system.ts @@ -1,3 +1,5 @@ +import role from './role' + export default { title: '系统管理', subTitle: '系统设置', @@ -115,12 +117,13 @@ export default { permissionSetting: '资源权限配置', setting: { management: '管理', + managementDesc: '可对该资源进行删改操作', check: '查看', - authorization: '授权', - }, - priority: { - label: '资源权限优先级', - role: '按角色', + checkDesc: '仅能查看使用该资源', + role: '按用户角色', + roleDesc: '根据用户角色中的权限授权用户对该资源的操作权限', + notAuthorized: '不授权', + configure: '配置权限', }, }, resource_management: { diff --git a/ui/src/locales/lang/zh-Hant/views/system.ts b/ui/src/locales/lang/zh-Hant/views/system.ts index 1527b507e..4fb0c9323 100644 --- a/ui/src/locales/lang/zh-Hant/views/system.ts +++ b/ui/src/locales/lang/zh-Hant/views/system.ts @@ -109,18 +109,20 @@ export default { enableSSL: '啟用 SSL(如果 SMTP 端口是 465,通常需要啟用 SSL)', enableTLS: '啟用 TLS(如果 SMTP 端口是 587,通常需要啟用 TLS)', }, + resourceAuthorization: { - title: '資源授权', + title: '資源授權', member: '成員', - permissionSetting: '資源权限配置', + permissionSetting: '資源權限配置', setting: { management: '管理', + managementDesc: '可對該資源進行刪改操作', check: '查看', - authorization: '授权', - }, - priority: { - label: '資源权限优先级', - role: '按角色', + checkDesc: '僅能查看使用該資源', + role: '按用戶角色', + roleDesc: '根據用戶角色中的權限授權用戶對該資源的操作權限', + notAuthorized: '不授權', + configure: '配置權限', }, }, resource_management: { diff --git a/ui/src/views/chat-log/index.vue b/ui/src/views/chat-log/index.vue index 55575ff5a..03d37f601 100644 --- a/ui/src/views/chat-log/index.vue +++ b/ui/src/views/chat-log/index.vue @@ -359,12 +359,12 @@ const nextChatRecord = () => { } } const pre_disable = computed(() => { - let index = tableIndexMap.value[currentChatId.value] - 1 + const index = tableIndexMap.value[currentChatId.value] - 1 return index < 0 && paginationConfig.current_page <= 1 }) const next_disable = computed(() => { - let index = tableIndexMap.value[currentChatId.value] + 1 + const index = tableIndexMap.value[currentChatId.value] + 1 return ( index >= tableData.value.length && index + (paginationConfig.current_page - 1) * paginationConfig.page_size >= diff --git a/ui/src/views/document/index.vue b/ui/src/views/document/index.vue index 8d87f0ad9..b30a64384 100644 --- a/ui/src/views/document/index.vue +++ b/ui/src/views/document/index.vue @@ -51,10 +51,11 @@ >{{ $t('views.document.generateQuestion.title') }} {{ $t('views.document.setting.migration') }} + v-if="permissionPrecise.doc_edit(id)" + > + {{ $t('common.setting') }} @@ -63,11 +64,11 @@ From a85c36f289873919be7ad9270a411a8088882328 Mon Sep 17 00:00:00 2001 From: shaohuzhang1 <80892890+shaohuzhang1@users.noreply.github.com> Date: Fri, 15 Aug 2025 18:08:18 +0800 Subject: [PATCH 08/18] feat: Workflow form nodes support reference assignment (#3866) #2439 --- .../form_node/impl/base_form_node.py | 37 ++++++++++++ .../items/MultiSelectConstructor.vue | 57 +++++++++++++++++- .../items/RadioCardConstructor.vue | 59 ++++++++++++++++++- .../items/SingleSelectConstructor.vue | 57 +++++++++++++++++- .../dynamics-form/items/radio/RadioCard.vue | 4 +- ui/src/locales/lang/en-US/dynamics-form.ts | 53 ++++++++++------- ui/src/locales/lang/zh-CN/dynamics-form.ts | 53 ++++++++++------- ui/src/locales/lang/zh-Hant/dynamics-form.ts | 53 ++++++++++------- ui/src/workflow/nodes/form-node/index.vue | 3 +- 9 files changed, 301 insertions(+), 75 deletions(-) diff --git a/apps/application/flow/step_node/form_node/impl/base_form_node.py b/apps/application/flow/step_node/form_node/impl/base_form_node.py index dcf35dd3c..9a0e4ba8b 100644 --- a/apps/application/flow/step_node/form_node/impl/base_form_node.py +++ b/apps/application/flow/step_node/form_node/impl/base_form_node.py @@ -17,6 +17,19 @@ from application.flow.i_step_node import NodeResult from application.flow.step_node.form_node.i_form_node import IFormNode +def get_default_option(option_list, _type, value_field): + if option_list is not None and len(option_list) > 0: + default_value_list = [o.get(value_field) for o in option_list if o.get('default')] + if len(default_value_list) == 0: + return option_list[0].get(value_field) + else: + if _type == 'MultiSelect': + return default_value_list + else: + return default_value_list[0] + return [] + + def write_context(step_variable: Dict, global_variable: Dict, node, workflow): if step_variable is not None: for key in step_variable: @@ -44,6 +57,28 @@ class BaseFormNode(IFormNode): for key in form_data: self.context[key] = form_data[key] + def reset_field(self, field): + if ['SingleSelect', 'MultiSelect', 'RadioCard'].__contains__(field.get('input_type')): + if field.get('assignment_method') == 'ref_variables': + option_list = self.workflow_manage.get_reference_field(field.get('option_list')[0], + field.get('option_list')[1:]) + field['option_list'] = option_list + field['default_value'] = get_default_option(option_list, field.get('input_type'), + field.get('value_field')) + + reset_field = ['field', 'label', 'default_value'] + for f in reset_field: + _value = field[f] + if isinstance(_value, str): + field[f] = self.workflow_manage.generate_prompt(_value) + else: + _label_value = _value.get('label') + _value['label'] = self.workflow_manage.generate_prompt(_label_value) + tooltip = _value.get('attrs').get('tooltip') + if tooltip is not None: + _value.get('attrs')['tooltip'] = self.workflow_manage.generate_prompt(tooltip) + return field + def execute(self, form_field_list, form_content_format, form_data, **kwargs) -> NodeResult: if form_data is not None: self.context['is_submit'] = True @@ -52,6 +87,7 @@ class BaseFormNode(IFormNode): self.context[key] = form_data.get(key) else: self.context['is_submit'] = False + form_field_list = [self.reset_field(field) for field in form_field_list] form_setting = {"form_field_list": form_field_list, "runtime_node_id": self.runtime_node_id, "chat_record_id": self.flow_params_serializer.data.get("chat_record_id"), "is_submit": self.context.get("is_submit", False)} @@ -60,6 +96,7 @@ class BaseFormNode(IFormNode): form_content_format = self.workflow_manage.reset_prompt(form_content_format) prompt_template = PromptTemplate.from_template(form_content_format, template_format='jinja2') value = prompt_template.format(form=form, context=context) + return NodeResult( {'result': value, 'form_field_list': form_field_list, 'form_content_format': form_content_format}, {}, _write_context=write_context) diff --git a/ui/src/components/dynamics-form/constructor/items/MultiSelectConstructor.vue b/ui/src/components/dynamics-form/constructor/items/MultiSelectConstructor.vue index 5ff808668..e5ef2b407 100644 --- a/ui/src/components/dynamics-form/constructor/items/MultiSelectConstructor.vue +++ b/ui/src/components/dynamics-form/constructor/items/MultiSelectConstructor.vue @@ -1,5 +1,28 @@