From 4daf93ef4f351cda4cf805bd601297114bd00ac9 Mon Sep 17 00:00:00 2001 From: Joel Date: Mon, 18 Mar 2024 10:52:45 +0800 Subject: [PATCH] feat: form input var type --- web/app/components/workflow/custom-edge.tsx | 4 ++-- web/app/components/workflow/nodes/tool/use-config.ts | 8 ++------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/web/app/components/workflow/custom-edge.tsx b/web/app/components/workflow/custom-edge.tsx index 919c69d5da..162e77fdad 100644 --- a/web/app/components/workflow/custom-edge.tsx +++ b/web/app/components/workflow/custom-edge.tsx @@ -49,8 +49,8 @@ const CustomEdge = ({ const [open, setOpen] = useState(false) const { handleNodeAdd } = useNodesInteractions() const nodesExtraData = useNodesExtraData() - const availablePrevNodes = nodesExtraData[(data as Edge['data'])!.targetType].availablePrevNodes - const availableNextNodes = nodesExtraData[(data as Edge['data'])!.sourceType].availableNextNodes + const availablePrevNodes = nodesExtraData[(data as Edge['data'])?.targetType]?.availablePrevNodes || [] + const availableNextNodes = nodesExtraData[(data as Edge['data'])?.sourceType]?.availableNextNodes || [] const handleOpenChange = useCallback((v: boolean) => { setOpen(v) }, []) diff --git a/web/app/components/workflow/nodes/tool/use-config.ts b/web/app/components/workflow/nodes/tool/use-config.ts index bf2816b31c..b0a1e84a1a 100644 --- a/web/app/components/workflow/nodes/tool/use-config.ts +++ b/web/app/components/workflow/nodes/tool/use-config.ts @@ -12,7 +12,7 @@ import { fetchBuiltInToolList, fetchCollectionList, fetchCustomToolList, updateB import { addDefaultValue, toolParametersToFormSchemas } from '@/app/components/tools/utils/to-form-schema' import Toast from '@/app/components/base/toast' import type { Props as FormProps } from '@/app/components/workflow/nodes/_base/components/before-run-form/form' -import { InputVarType, VarType as VarVarType } from '@/app/components/workflow/types' +import { VarType as VarVarType } from '@/app/components/workflow/types' import type { InputVar, Var } from '@/app/components/workflow/types' import useOneStepRun from '@/app/components/workflow/nodes/_base/hooks/use-one-step-run' const useConfig = (id: string, payload: ToolNodeType) => { @@ -156,16 +156,12 @@ const useConfig = (id: string, payload: ToolNodeType) => { const singleRunForms = (() => { const formInputs: InputVar[] = [] toolInputVarSchema.forEach((item: any) => { - // const targetItem = toolInputs.find(input => input.variable === item.variable) - // TODO: support selector - // if (targetItem?.variable_type === VarType.selector) { formInputs.push({ label: item.label[language] || item.label.en_US, variable: item.variable, - type: InputVarType.textInput, // TODO: to form input + type: item.type, required: item.required, }) - // } }) const forms: FormProps[] = [{ inputs: formInputs,