import { Input } from '@/components/ui/input'; import { Sheet, SheetContent, SheetHeader, SheetTitle, } from '@/components/ui/sheet'; import { useTranslate } from '@/hooks/common-hooks'; import { IModalProps } from '@/interfaces/common'; import { RAGFlowNodeType } from '@/interfaces/database/flow'; import { cn } from '@/lib/utils'; import { lowerFirst } from 'lodash'; import { Play, X } from 'lucide-react'; import { BeginId, Operator } from '../constant'; import { AgentFormContext } from '../context'; import { RunTooltip } from '../flow-tooltip'; import { useHandleNodeNameChange } from '../hooks'; import OperatorIcon from '../operator-icon'; import { needsSingleStepDebugging } from '../utils'; import SingleDebugDrawer from './single-debug-drawer'; import { useFormConfigMap } from './use-form-config-map'; interface IProps { node?: RAGFlowNodeType; singleDebugDrawerVisible: IModalProps['visible']; hideSingleDebugDrawer: IModalProps['hideModal']; showSingleDebugDrawer: IModalProps['showModal']; } const EmptyContent = () =>
; const FormSheet = ({ visible, hideModal, node, singleDebugDrawerVisible, hideSingleDebugDrawer, showSingleDebugDrawer, }: IModalProps & IProps) => { const operatorName: Operator = node?.data.label as Operator; const FormConfigMap = useFormConfigMap(); const currentFormMap = FormConfigMap[operatorName]; const OperatorForm = currentFormMap?.component ?? EmptyContent; const { name, handleNameBlur, handleNameChange } = useHandleNodeNameChange({ id: node?.id, data: node?.data, }); const { t } = useTranslate('flow'); return (
{node?.id === BeginId ? ( {t(BeginId)} ) : ( )}
{needsSingleStepDebugging(operatorName) && ( )}
{t(`${lowerFirst(operatorName)}Description`)}
{visible && ( )}
{singleDebugDrawerVisible && ( )}
); }; export default FormSheet;