feat(workflow): add group node support and translations

- Introduced GroupDefault node with metadata and default values for group nodes.
- Enhanced useNodeMetaData hook to handle group node author and description using translations.
- Added translations for group node functionality in English, Japanese, Simplified Chinese, and Traditional Chinese.
This commit is contained in:
zhsama 2026-01-05 16:29:00 +08:00
parent 60250355cb
commit 50bed78d7a
6 changed files with 40 additions and 1 deletions

View File

@ -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 {

View File

@ -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<GroupNodeData> = {
metaData,
defaultValue: {
members: [],
handlers: [],
headNodeIds: [],
leafNodeIds: [],
},
checkValid() {
return {
isValid: true,
}
},
}
export default nodeDefault

View File

@ -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: {

View File

@ -351,6 +351,7 @@ const translation = {
'trigger-schedule': 'スケジュールに基づいてワークフローを開始する時間ベースのトリガー',
'trigger-webhook': 'Webhook トリガーは第三者システムからの HTTP プッシュを受信してワークフローを自動的に開始します。',
'trigger-plugin': 'サードパーティ統合トリガー、外部プラットフォームのイベントによってワークフローを開始します',
'group': '複数のノードをグループ化して整理・管理しやすくします',
},
difyTeam: 'Dify チーム',
operator: {

View File

@ -351,6 +351,7 @@ const translation = {
'trigger-webhook': 'Webhook 触发器接收来自第三方系统的 HTTP 推送以自动触发工作流。',
'trigger-schedule': '基于时间的工作流触发器,按计划启动工作流',
'trigger-plugin': '从外部平台事件启动工作流的第三方集成触发器',
'group': '将多个节点组合在一起,以便更好地组织和管理',
},
difyTeam: 'Dify 团队',
operator: {

View File

@ -337,6 +337,7 @@ const translation = {
'trigger-schedule': '基於時間的工作流程觸發器,可按計劃啟動工作流程',
'trigger-webhook': 'Webhook 觸發器接收來自第三方系統的 HTTP 推送,以自動觸發工作流程。',
'trigger-plugin': '第三方整合觸發器,從外部平台事件啟動工作流程',
'group': '將多個節點組合在一起,以便更好地組織和管理',
},
operator: {
zoomIn: '放大',