From f35c5ed11959977ac05978bafb98839dec0462f2 Mon Sep 17 00:00:00 2001 From: balibabu Date: Fri, 10 Oct 2025 16:30:13 +0800 Subject: [PATCH] Fix: Fixed an issue where parser configurations could be added infinitely #9869 (#10464) ### What problem does this PR solve? Fix: Fixed an issue where parser configurations could be added infinitely #9869 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- web/src/components/home-card.tsx | 6 +-- web/src/layouts/next-header.tsx | 2 +- web/src/locales/en.ts | 4 +- web/src/locales/zh.ts | 2 + .../form/parser-form/common-form-fields.tsx | 17 ++++++-- .../data-flow/form/parser-form/index.tsx | 43 ++++++++++++------- .../data-flow/form/tokenizer-form/index.tsx | 1 + web/src/pages/data-flow/index.tsx | 4 +- .../data-flow/log-sheet/dataflow-timeline.tsx | 2 +- web/src/pages/data-flow/log-sheet/index.tsx | 42 +++++++++--------- web/src/pages/home/banner.tsx | 2 +- web/src/pages/home/index.tsx | 14 +++--- 12 files changed, 83 insertions(+), 56 deletions(-) diff --git a/web/src/components/home-card.tsx b/web/src/components/home-card.tsx index 76b16a400..91eecf178 100644 --- a/web/src/components/home-card.tsx +++ b/web/src/components/home-card.tsx @@ -39,9 +39,9 @@ export function HomeCard({ />
-
-
-
+
+
+
{data.name}
{icon} diff --git a/web/src/layouts/next-header.tsx b/web/src/layouts/next-header.tsx index 26cce2ba0..367449540 100644 --- a/web/src/layouts/next-header.tsx +++ b/web/src/layouts/next-header.tsx @@ -106,7 +106,7 @@ export function Header() { }, [navigate]); return ( -
+
>((pre, [key, value]) => { pre[key] = Object.values(value).map((v) => ({ - label: v === PdfOutputFormat.Json ? 'JSON' : upperFirst(v), + label: UppercaseFields.some((x) => x === v) + ? upperCase(v) + : upperFirst(v), value: v, })); return pre; diff --git a/web/src/pages/data-flow/form/parser-form/index.tsx b/web/src/pages/data-flow/form/parser-form/index.tsx index 836f5414e..cfb06e06d 100644 --- a/web/src/pages/data-flow/form/parser-form/index.tsx +++ b/web/src/pages/data-flow/form/parser-form/index.tsx @@ -1,4 +1,7 @@ -import { SelectWithSearch } from '@/components/originui/select-with-search'; +import { + SelectWithSearch, + SelectWithSearchFlagOptionType, +} from '@/components/originui/select-with-search'; import { RAGFlowFormItem } from '@/components/ragflow-form'; import { BlockButton, Button } from '@/components/ui/button'; import { Form } from '@/components/ui/form'; @@ -49,6 +52,7 @@ type ParserItemProps = { index: number; fieldLength: number; remove: UseFieldArrayRemove; + fileFormatOptions: SelectWithSearchFlagOptionType[]; }; export const FormSchema = z.object({ @@ -67,7 +71,13 @@ export const FormSchema = z.object({ export type ParserFormSchemaType = z.infer; -function ParserItem({ name, index, fieldLength, remove }: ParserItemProps) { +function ParserItem({ + name, + index, + fieldLength, + remove, + fileFormatOptions, +}: ParserItemProps) { const { t } = useTranslation(); const form = useFormContext(); const ref = useRef(null); @@ -79,23 +89,15 @@ function ParserItem({ name, index, fieldLength, remove }: ParserItemProps) { const values = form.getValues(); const parserList = values.setups.slice(); // Adding, deleting, or modifying the parser array will not change the reference. - const FileFormatOptions = buildOptions( - FileType, - t, - 'dataflow.fileFormatOptions', - ).filter( - (x) => x.value !== FileType.Video, // Temporarily hide the video option - ); - const filteredFileFormatOptions = useMemo(() => { const otherFileFormatList = parserList .filter((_, idx) => idx !== index) .map((x) => x.fileFormat); - return FileFormatOptions.filter((x) => { + return fileFormatOptions.filter((x) => { return !otherFileFormatList.includes(x.value); }); - }, [FileFormatOptions, index, parserList]); + }, [fileFormatOptions, index, parserList]); const Widget = typeof fileFormat === 'string' && fileFormat in FileFormatWidgetMap @@ -158,6 +160,14 @@ const ParserForm = ({ node }: INextOperatorForm) => { const { t } = useTranslation(); const defaultValues = useFormValues(initialParserValues, node); + const FileFormatOptions = buildOptions( + FileType, + t, + 'dataflow.fileFormatOptions', + ).filter( + (x) => x.value !== FileType.Video, // Temporarily hide the video option + ); + const form = useForm>({ defaultValues, resolver: zodResolver(FormSchema), @@ -194,12 +204,15 @@ const ParserForm = ({ node }: INextOperatorForm) => { index={index} fieldLength={fields.length} remove={remove} + fileFormatOptions={FileFormatOptions} > ); })} - - {t('dataflow.addParser')} - + {fields.length < FileFormatOptions.length && ( + + {t('dataflow.addParser')} + + )}
diff --git a/web/src/pages/data-flow/form/tokenizer-form/index.tsx b/web/src/pages/data-flow/form/tokenizer-form/index.tsx index 1b4975db9..cc949d5cd 100644 --- a/web/src/pages/data-flow/form/tokenizer-form/index.tsx +++ b/web/src/pages/data-flow/form/tokenizer-form/index.tsx @@ -58,6 +58,7 @@ const TokenizerForm = ({ node }: INextOperatorForm) => { {(field) => ( - + {isParsing || running ? t('dataflow.running') : t('flow.run')} diff --git a/web/src/pages/data-flow/log-sheet/dataflow-timeline.tsx b/web/src/pages/data-flow/log-sheet/dataflow-timeline.tsx index 25787a2e4..e15465baf 100644 --- a/web/src/pages/data-flow/log-sheet/dataflow-timeline.tsx +++ b/web/src/pages/data-flow/log-sheet/dataflow-timeline.tsx @@ -78,7 +78,7 @@ export function DataflowTimeline({ traceList }: DataflowTimelineProps) {
- {progress}% + {progress.toFixed(2)}%
diff --git a/web/src/pages/data-flow/log-sheet/index.tsx b/web/src/pages/data-flow/log-sheet/index.tsx index a5bcb2787..546d28328 100644 --- a/web/src/pages/data-flow/log-sheet/index.tsx +++ b/web/src/pages/data-flow/log-sheet/index.tsx @@ -55,10 +55,10 @@ export function LogSheet({ return ( e.preventDefault()} > - + {t('flow.log')} {isCompleted && ( @@ -82,30 +82,32 @@ export function LogSheet({ )} -
+
{isLogEmpty ? ( ) : ( )}
- {isParsing ? ( - - ) : ( - - )} +
+ {isParsing ? ( + + ) : ( + + )} +
); diff --git a/web/src/pages/home/banner.tsx b/web/src/pages/home/banner.tsx index 3173a40ba..973e417aa 100644 --- a/web/src/pages/home/banner.tsx +++ b/web/src/pages/home/banner.tsx @@ -42,7 +42,7 @@ export function Banner() { export function NextBanner() { const { t } = useTranslation(); return ( -
+
{t('header.welcome')} RAGFlow diff --git a/web/src/pages/home/index.tsx b/web/src/pages/home/index.tsx index 54b2f83d5..137f50ec5 100644 --- a/web/src/pages/home/index.tsx +++ b/web/src/pages/home/index.tsx @@ -4,15 +4,13 @@ import { Datasets } from './datasets'; const Home = () => { return ( -
-
- -
- - -
+
+ +
+ +
-
+
); };