mirror of
https://github.com/langgenius/dify.git
synced 2026-01-14 06:07:33 +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.
36 lines
1005 B
TypeScript
36 lines
1005 B
TypeScript
import type { NodeDefault } from '../../types'
|
|
import type { CommandNodeType } from './types'
|
|
import { BlockClassificationEnum } from '@/app/components/workflow/block-selector/types'
|
|
import { BlockEnum } from '@/app/components/workflow/types'
|
|
import { genNodeMetaData } from '@/app/components/workflow/utils'
|
|
|
|
const i18nPrefix = 'errorMsg'
|
|
|
|
const metaData = genNodeMetaData({
|
|
classification: BlockClassificationEnum.Utilities,
|
|
sort: 2,
|
|
type: BlockEnum.Command,
|
|
})
|
|
|
|
const nodeDefault: NodeDefault<CommandNodeType> = {
|
|
metaData,
|
|
defaultValue: {
|
|
working_directory: '',
|
|
command: '',
|
|
},
|
|
checkValid(payload: CommandNodeType, t: any) {
|
|
let errorMessages = ''
|
|
const { command } = payload
|
|
|
|
if (!errorMessages && !command)
|
|
errorMessages = t(`${i18nPrefix}.fieldRequired`, { ns: 'workflow', field: t(`${i18nPrefix}.fields.command`, { ns: 'workflow' }) })
|
|
|
|
return {
|
|
isValid: !errorMessages,
|
|
errorMessage: errorMessages,
|
|
}
|
|
},
|
|
}
|
|
|
|
export default nodeDefault
|