From db4958be05cc6e7ed777926e891582ab70f9274e Mon Sep 17 00:00:00 2001 From: twwu Date: Fri, 23 May 2025 17:52:00 +0800 Subject: [PATCH] fix: fix modal handling in InputFieldEditor --- .../input-field/editor/dialog-wrapper.tsx | 54 +++++++++++++++++++ .../components/input-field/editor/index.tsx | 37 ++++++------- 2 files changed, 71 insertions(+), 20 deletions(-) create mode 100644 web/app/components/rag-pipeline/components/input-field/editor/dialog-wrapper.tsx diff --git a/web/app/components/rag-pipeline/components/input-field/editor/dialog-wrapper.tsx b/web/app/components/rag-pipeline/components/input-field/editor/dialog-wrapper.tsx new file mode 100644 index 0000000000..c3c877eaf4 --- /dev/null +++ b/web/app/components/rag-pipeline/components/input-field/editor/dialog-wrapper.tsx @@ -0,0 +1,54 @@ +import { Fragment, useCallback } from 'react' +import type { ReactNode } from 'react' +import { Dialog, DialogPanel, Transition, TransitionChild } from '@headlessui/react' +import cn from '@/utils/classnames' + +type DialogWrapperProps = { + className?: string + panelWrapperClassName?: string + children: ReactNode + show: boolean + onClose?: () => void +} + +const DialogWrapper = ({ + className, + panelWrapperClassName, + children, + show, + onClose, +}: DialogWrapperProps) => { + const close = useCallback(() => onClose?.(), [onClose]) + return ( + + + +
+ + +
+
+ + + {children} + + +
+
+
+
+ ) +} + +export default DialogWrapper diff --git a/web/app/components/rag-pipeline/components/input-field/editor/index.tsx b/web/app/components/rag-pipeline/components/input-field/editor/index.tsx index 5641400e3e..77882f0259 100644 --- a/web/app/components/rag-pipeline/components/input-field/editor/index.tsx +++ b/web/app/components/rag-pipeline/components/input-field/editor/index.tsx @@ -1,5 +1,5 @@ import { RiCloseLine } from '@remixicon/react' -import DialogWrapper from '../dialog-wrapper' +import DialogWrapper from './dialog-wrapper' import InputFieldForm from './form' import { convertToInputFieldFormData } from './utils' import { useCallback } from 'react' @@ -60,27 +60,24 @@ const InputFieldEditor = ({ -
-
- {initialData ? t('datasetPipeline.inputFieldPanel.editInputField') : t('datasetPipeline.inputFieldPanel.addInputField')} -
- - +
+ {initialData ? t('datasetPipeline.inputFieldPanel.editInputField') : t('datasetPipeline.inputFieldPanel.addInputField')}
+ + ) }