mirror of
https://github.com/langgenius/dify.git
synced 2026-01-25 21:22:16 +08:00
- 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.
34 lines
1010 B
TypeScript
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
|