mirror of
https://github.com/langgenius/dify.git
synced 2026-04-29 12:37:20 +08:00
fix(workflow): Fix onboarding node creation after knowledge pipeline refactor (#26289)
This commit is contained in:
parent
764436ed8e
commit
1a9798c559
@ -20,7 +20,11 @@ import WorkflowHeader from './workflow-header'
|
|||||||
import WorkflowPanel from './workflow-panel'
|
import WorkflowPanel from './workflow-panel'
|
||||||
import dynamic from 'next/dynamic'
|
import dynamic from 'next/dynamic'
|
||||||
import { BlockEnum } from '@/app/components/workflow/types'
|
import { BlockEnum } from '@/app/components/workflow/types'
|
||||||
import type { ToolDefaultValue } from '@/app/components/workflow/block-selector/types'
|
import type {
|
||||||
|
PluginDefaultValue,
|
||||||
|
ToolDefaultValue,
|
||||||
|
TriggerDefaultValue,
|
||||||
|
} from '@/app/components/workflow/block-selector/types'
|
||||||
import { useAutoOnboarding } from '../hooks/use-auto-onboarding'
|
import { useAutoOnboarding } from '../hooks/use-auto-onboarding'
|
||||||
import { useAvailableNodesMetaData } from '../hooks'
|
import { useAvailableNodesMetaData } from '../hooks'
|
||||||
|
|
||||||
@ -37,6 +41,31 @@ const WorkflowOnboardingModal = dynamic(() => import('./workflow-onboarding-moda
|
|||||||
ssr: false,
|
ssr: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const getTriggerPluginNodeData = (
|
||||||
|
triggerConfig: TriggerDefaultValue,
|
||||||
|
fallbackTitle?: string,
|
||||||
|
fallbackDesc?: string,
|
||||||
|
) => {
|
||||||
|
return {
|
||||||
|
plugin_id: triggerConfig.provider_id,
|
||||||
|
provider_id: triggerConfig.provider_id,
|
||||||
|
provider_type: triggerConfig.provider_type,
|
||||||
|
provider_name: triggerConfig.provider_name,
|
||||||
|
trigger_name: triggerConfig.trigger_name,
|
||||||
|
trigger_label: triggerConfig.trigger_label,
|
||||||
|
trigger_description: triggerConfig.trigger_description,
|
||||||
|
title: triggerConfig.trigger_label || triggerConfig.title || fallbackTitle,
|
||||||
|
desc: triggerConfig.trigger_description || fallbackDesc,
|
||||||
|
output_schema: { ...(triggerConfig.output_schema || {}) },
|
||||||
|
parameters_schema: triggerConfig.paramSchemas ? [...triggerConfig.paramSchemas] : [],
|
||||||
|
config: { ...(triggerConfig.params || {}) },
|
||||||
|
subscription_id: triggerConfig.subscription_id,
|
||||||
|
plugin_unique_identifier: triggerConfig.plugin_unique_identifier,
|
||||||
|
is_team_authorization: triggerConfig.is_team_authorization,
|
||||||
|
meta: triggerConfig.meta ? { ...triggerConfig.meta } : undefined,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const WorkflowChildren = () => {
|
const WorkflowChildren = () => {
|
||||||
const { eventEmitter } = useEventEmitterContextContext()
|
const { eventEmitter } = useEventEmitterContextContext()
|
||||||
const [secretEnvList, setSecretEnvList] = useState<EnvironmentVariable[]>([])
|
const [secretEnvList, setSecretEnvList] = useState<EnvironmentVariable[]>([])
|
||||||
@ -67,14 +96,40 @@ const WorkflowChildren = () => {
|
|||||||
handleOnboardingClose()
|
handleOnboardingClose()
|
||||||
}, [handleOnboardingClose])
|
}, [handleOnboardingClose])
|
||||||
|
|
||||||
const handleSelectStartNode = useCallback((nodeType: BlockEnum, toolConfig?: ToolDefaultValue) => {
|
const handleSelectStartNode = useCallback((nodeType: BlockEnum, toolConfig?: ToolDefaultValue | TriggerDefaultValue | PluginDefaultValue) => {
|
||||||
const nodeData = nodeType === BlockEnum.Start
|
const nodeDefault = availableNodesMetaData.nodesMap?.[nodeType]
|
||||||
? availableNodesMetaData.nodesMap?.[BlockEnum.Start]
|
if (!nodeDefault?.defaultValue)
|
||||||
: { ...availableNodesMetaData.nodesMap?.[nodeType], ...toolConfig }
|
return
|
||||||
|
|
||||||
|
const baseNodeData = { ...nodeDefault.defaultValue }
|
||||||
|
|
||||||
|
const mergedNodeData = (() => {
|
||||||
|
if (nodeType !== BlockEnum.TriggerPlugin || !toolConfig) {
|
||||||
|
return {
|
||||||
|
...baseNodeData,
|
||||||
|
...toolConfig,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const triggerNodeData = getTriggerPluginNodeData(
|
||||||
|
toolConfig as TriggerDefaultValue,
|
||||||
|
baseNodeData.title,
|
||||||
|
baseNodeData.desc,
|
||||||
|
)
|
||||||
|
|
||||||
|
return {
|
||||||
|
...baseNodeData,
|
||||||
|
...triggerNodeData,
|
||||||
|
config: {
|
||||||
|
...(baseNodeData as { config?: Record<string, any> }).config || {},
|
||||||
|
...(triggerNodeData.config || {}),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
})()
|
||||||
|
|
||||||
const { newNode } = generateNewNode({
|
const { newNode } = generateNewNode({
|
||||||
data: {
|
data: {
|
||||||
...nodeData,
|
...mergedNodeData,
|
||||||
} as any,
|
} as any,
|
||||||
position: START_INITIAL_POSITION,
|
position: START_INITIAL_POSITION,
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user