From 32a009654f10deb08a1de4328df2e5c50cfa8f2d Mon Sep 17 00:00:00 2001 From: twwu Date: Tue, 2 Sep 2025 18:19:40 +0800 Subject: [PATCH] feat(input-field): add isEditMode prop to InputFieldForm and update handling of variable changes --- .../components/panel/input-field/editor/form/index.tsx | 9 ++++++--- .../components/panel/input-field/editor/form/types.ts | 1 + .../components/panel/input-field/editor/index.tsx | 1 + .../workflow/nodes/_base/components/variable/utils.ts | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/web/app/components/rag-pipeline/components/panel/input-field/editor/form/index.tsx b/web/app/components/rag-pipeline/components/panel/input-field/editor/form/index.tsx index a26371a4e8..61254e35e4 100644 --- a/web/app/components/rag-pipeline/components/panel/input-field/editor/form/index.tsx +++ b/web/app/components/rag-pipeline/components/panel/input-field/editor/form/index.tsx @@ -1,5 +1,6 @@ import { useTranslation } from 'react-i18next' import { useCallback, useState } from 'react' +import type { MoreInfo } from '@/app/components/workflow/types' import { ChangeType } from '@/app/components/workflow/types' import { useFileUploadConfig } from '@/service/use-common' import type { FormData, InputFieldFormProps } from './types' @@ -18,6 +19,7 @@ const InputFieldForm = ({ supportFile = false, onCancel, onSubmit, + isEditMode = true, }: InputFieldFormProps) => { const { t } = useTranslation() @@ -47,12 +49,13 @@ const InputFieldForm = ({ }, }, onSubmit: ({ value }) => { - const moreInfo = value.variable === initialData?.variable - ? undefined - : { + let moreInfo: MoreInfo | undefined + if (isEditMode && value.variable !== initialData?.variable) { + moreInfo = { type: ChangeType.changeVarName, payload: { beforeKey: initialData?.variable || '', afterKey: value.variable }, } + } onSubmit(value as FormData, moreInfo) }, }) diff --git a/web/app/components/rag-pipeline/components/panel/input-field/editor/form/types.ts b/web/app/components/rag-pipeline/components/panel/input-field/editor/form/types.ts index 8692e56813..f0412078a4 100644 --- a/web/app/components/rag-pipeline/components/panel/input-field/editor/form/types.ts +++ b/web/app/components/rag-pipeline/components/panel/input-field/editor/form/types.ts @@ -25,6 +25,7 @@ export type InputFieldFormProps = { supportFile?: boolean onCancel: () => void onSubmit: (value: FormData, moreInfo?: MoreInfo) => void + isEditMode?: boolean } export type SchemaOptions = { diff --git a/web/app/components/rag-pipeline/components/panel/input-field/editor/index.tsx b/web/app/components/rag-pipeline/components/panel/input-field/editor/index.tsx index 67d589c3ff..615939e002 100644 --- a/web/app/components/rag-pipeline/components/panel/input-field/editor/index.tsx +++ b/web/app/components/rag-pipeline/components/panel/input-field/editor/index.tsx @@ -59,6 +59,7 @@ const InputFieldEditorPanel = ({ supportFile onCancel={onClose} onSubmit={handleSubmit} + isEditMode={!!initialData} /> ) diff --git a/web/app/components/workflow/nodes/_base/components/variable/utils.ts b/web/app/components/workflow/nodes/_base/components/variable/utils.ts index 1df833d95f..187adece6d 100644 --- a/web/app/components/workflow/nodes/_base/components/variable/utils.ts +++ b/web/app/components/workflow/nodes/_base/components/variable/utils.ts @@ -258,7 +258,7 @@ const formatItem = ( required: v.required, } try { - if(type === VarType.object && v.json_schema) { + if (type === VarType.object && v.json_schema) { varRes.children = { schema: JSON.parse(v.json_schema), }