diff --git a/web/app/components/workflow/hooks/use-nodes-meta-data.ts b/web/app/components/workflow/hooks/use-nodes-meta-data.ts index 2ea2fd9e9f..36c071f4d4 100644 --- a/web/app/components/workflow/hooks/use-nodes-meta-data.ts +++ b/web/app/components/workflow/hooks/use-nodes-meta-data.ts @@ -1,8 +1,10 @@ import type { AvailableNodesMetaData } from '@/app/components/workflow/hooks-store' import type { Node } from '@/app/components/workflow/types' import { useMemo } from 'react' +import { useTranslation } from 'react-i18next' import { CollectionType } from '@/app/components/tools/types' import { useHooksStore } from '@/app/components/workflow/hooks-store' +import GroupDefault from '@/app/components/workflow/nodes/group/default' import { useStore } from '@/app/components/workflow/store' import { BlockEnum } from '@/app/components/workflow/types' import { useGetLanguage } from '@/context/i18n' @@ -25,6 +27,7 @@ export const useNodesMetaData = () => { } export const useNodeMetaData = (node: Node) => { + const { t } = useTranslation() const language = useGetLanguage() const { data: buildInTools } = useAllBuiltInTools() const { data: customTools } = useAllCustomTools() @@ -34,6 +37,9 @@ export const useNodeMetaData = (node: Node) => { const { data } = node const nodeMetaData = availableNodesMetaData.nodesMap?.[data.type] const author = useMemo(() => { + if (data.type === BlockEnum.Group) + return GroupDefault.metaData.author + if (data.type === BlockEnum.DataSource) return dataSourceList?.find(dataSource => dataSource.plugin_id === data.plugin_id)?.author @@ -48,6 +54,9 @@ export const useNodeMetaData = (node: Node) => { }, [data, buildInTools, customTools, workflowTools, nodeMetaData, dataSourceList]) const description = useMemo(() => { + if (data.type === BlockEnum.Group) + return t('blocksAbout.group', { ns: 'workflow' }) + if (data.type === BlockEnum.DataSource) return dataSourceList?.find(dataSource => dataSource.plugin_id === data.plugin_id)?.description[language] if (data.type === BlockEnum.Tool) { @@ -58,7 +67,7 @@ export const useNodeMetaData = (node: Node) => { return customTools?.find(toolWithProvider => toolWithProvider.id === data.provider_id)?.description[language] } return nodeMetaData?.metaData.description - }, [data, buildInTools, customTools, workflowTools, nodeMetaData, dataSourceList, language]) + }, [data, buildInTools, customTools, workflowTools, nodeMetaData, dataSourceList, language, t]) return useMemo(() => { return { diff --git a/web/app/components/workflow/nodes/group/default.ts b/web/app/components/workflow/nodes/group/default.ts new file mode 100644 index 0000000000..b46d3544b6 --- /dev/null +++ b/web/app/components/workflow/nodes/group/default.ts @@ -0,0 +1,26 @@ +import type { NodeDefault } from '../../types' +import type { GroupNodeData } from './types' +import { BlockEnum } from '@/app/components/workflow/types' +import { genNodeMetaData } from '@/app/components/workflow/utils' + +const metaData = genNodeMetaData({ + sort: 100, + type: BlockEnum.Group, +}) + +const nodeDefault: NodeDefault = { + metaData, + defaultValue: { + members: [], + handlers: [], + headNodeIds: [], + leafNodeIds: [], + }, + checkValid() { + return { + isValid: true, + } + }, +} + +export default nodeDefault diff --git a/web/i18n/en-US/workflow.ts b/web/i18n/en-US/workflow.ts index c46ad45996..76050edabb 100644 --- a/web/i18n/en-US/workflow.ts +++ b/web/i18n/en-US/workflow.ts @@ -351,6 +351,7 @@ const translation = { 'trigger-schedule': 'Time-based workflow trigger that starts workflows on a schedule', 'trigger-webhook': 'Webhook Trigger receives HTTP pushes from third-party systems to automatically trigger workflows.', 'trigger-plugin': 'Third-party integration trigger that starts workflows from external platform events', + 'group': 'Group multiple nodes together for better organization and reusability.', }, difyTeam: 'Dify Team', operator: { diff --git a/web/i18n/ja-JP/workflow.ts b/web/i18n/ja-JP/workflow.ts index 850796fa48..1a5283f5b3 100644 --- a/web/i18n/ja-JP/workflow.ts +++ b/web/i18n/ja-JP/workflow.ts @@ -351,6 +351,7 @@ const translation = { 'trigger-schedule': 'スケジュールに基づいてワークフローを開始する時間ベースのトリガー', 'trigger-webhook': 'Webhook トリガーは第三者システムからの HTTP プッシュを受信してワークフローを自動的に開始します。', 'trigger-plugin': 'サードパーティ統合トリガー、外部プラットフォームのイベントによってワークフローを開始します', + 'group': '複数のノードをグループ化して整理・管理しやすくします', }, difyTeam: 'Dify チーム', operator: { diff --git a/web/i18n/zh-Hans/workflow.ts b/web/i18n/zh-Hans/workflow.ts index 78deb4bf84..6d00f279a3 100644 --- a/web/i18n/zh-Hans/workflow.ts +++ b/web/i18n/zh-Hans/workflow.ts @@ -351,6 +351,7 @@ const translation = { 'trigger-webhook': 'Webhook 触发器接收来自第三方系统的 HTTP 推送以自动触发工作流。', 'trigger-schedule': '基于时间的工作流触发器,按计划启动工作流', 'trigger-plugin': '从外部平台事件启动工作流的第三方集成触发器', + 'group': '将多个节点组合在一起,以便更好地组织和管理', }, difyTeam: 'Dify 团队', operator: { diff --git a/web/i18n/zh-Hant/workflow.ts b/web/i18n/zh-Hant/workflow.ts index da8b4996cd..bd4bc720f6 100644 --- a/web/i18n/zh-Hant/workflow.ts +++ b/web/i18n/zh-Hant/workflow.ts @@ -337,6 +337,7 @@ const translation = { 'trigger-schedule': '基於時間的工作流程觸發器,可按計劃啟動工作流程', 'trigger-webhook': 'Webhook 觸發器接收來自第三方系統的 HTTP 推送,以自動觸發工作流程。', 'trigger-plugin': '第三方整合觸發器,從外部平台事件啟動工作流程', + 'group': '將多個節點組合在一起,以便更好地組織和管理', }, operator: { zoomIn: '放大',