dify/web/app/components/workflow/nodes/command/use-config.ts
Harry 1c7c475c43 feat: add Command node support
- Introduced Command node type in workflow with associated UI components and translations.
- Enhanced SandboxLayer to manage sandbox attachment for Command nodes during execution.
- Updated various components and constants to integrate Command node functionality across the workflow.
2026-01-06 19:30:38 +08:00

34 lines
1010 B
TypeScript

import type { CommandNodeType } from './types'
import { produce } from 'immer'
import { useCallback } from 'react'
import { useNodesReadOnly } from '@/app/components/workflow/hooks'
import useNodeCrud from '@/app/components/workflow/nodes/_base/hooks/use-node-crud'
const useConfig = (id: string, payload: CommandNodeType) => {
const { nodesReadOnly: readOnly } = useNodesReadOnly()
const { inputs, setInputs } = useNodeCrud<CommandNodeType>(id, payload)
const handleWorkingDirectoryChange = useCallback((value: string) => {
const newInputs = produce(inputs, (draft) => {
draft.working_directory = value
})
setInputs(newInputs)
}, [inputs, setInputs])
const handleCommandChange = useCallback((value: string) => {
const newInputs = produce(inputs, (draft) => {
draft.command = value
})
setInputs(newInputs)
}, [inputs, setInputs])
return {
readOnly,
inputs,
handleWorkingDirectoryChange,
handleCommandChange,
}
}
export default useConfig