Kaynağa Gözat

feat(input-field): add isEditMode prop to InputFieldForm and update handling of variable changes

tags/2.0.0-beta.1
twwu 2 ay önce
ebeveyn
işleme
32a009654f

+ 6
- 3
web/app/components/rag-pipeline/components/panel/input-field/editor/form/index.tsx Dosyayı Görüntüle

@@ -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)
},
})

+ 1
- 0
web/app/components/rag-pipeline/components/panel/input-field/editor/form/types.ts Dosyayı Görüntüle

@@ -25,6 +25,7 @@ export type InputFieldFormProps = {
supportFile?: boolean
onCancel: () => void
onSubmit: (value: FormData, moreInfo?: MoreInfo) => void
isEditMode?: boolean
}

export type SchemaOptions = {

+ 1
- 0
web/app/components/rag-pipeline/components/panel/input-field/editor/index.tsx Dosyayı Görüntüle

@@ -59,6 +59,7 @@ const InputFieldEditorPanel = ({
supportFile
onCancel={onClose}
onSubmit={handleSubmit}
isEditMode={!!initialData}
/>
</div>
)

+ 1
- 1
web/app/components/workflow/nodes/_base/components/variable/utils.ts Dosyayı Görüntüle

@@ -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),
}

Loading…
İptal
Kaydet