import { memo, useCallback, } from 'react' import { useTranslation } from 'react-i18next' import { useNodes } from 'reactflow' import FormItem from '../nodes/_base/components/before-run-form/form-item' import { BlockEnum } from '../types' import { useStore, useWorkflowStore, } from '../store' import { useWorkflowRun } from '../hooks' import type { StartNodeType } from '../nodes/start/types' import Button from '@/app/components/base/button' const InputsPanel = () => { const { t } = useTranslation() const workflowStore = useWorkflowStore() const nodes = useNodes() const inputs = useStore(s => s.inputs) const { handleRun, handleRunSetting, } = useWorkflowRun() const startNode = nodes.find(node => node.data.type === BlockEnum.Start) const variables = startNode?.data.variables || [] const handleValueChange = (variable: string, v: string) => { workflowStore.getState().setInputs({ ...inputs, [variable]: v, }) } const handleCancel = useCallback(() => { workflowStore.setState({ showInputsPanel: false }) }, [workflowStore]) const doRun = () => { handleCancel() handleRunSetting() handleRun({ inputs }) } return (
{t('workflow.singleRun.testRun')}
{ variables.map(variable => (
handleValueChange(variable.variable, v)} />
)) }
) } export default memo(InputsPanel)