Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Fix: Error related to the 'UserFillUpForm' type (#21062)

balibabu642d8a65d5c3
diff --git a/web/src/pages/agent/form/user-fill-up-form/index.tsx b/web/src/pages/agent/form/user-fill-up-form/index.tsx
index 59dde97c7f..384c268980 100644
--- a/web/src/pages/agent/form/user-fill-up-form/index.tsx
+++ b/web/src/pages/agent/form/user-fill-up-form/index.tsx
@@ -1,19 +1,13 @@
import { Collapse } from '@/components/collapse';
import { LayoutRecognizeFormField } from '@/components/layout-recognize-form-field';
+import { RAGFlowFormItem } from '@/components/ragflow-form';
+import { SwitchFormField } from '@/components/switch-form-field';
import { Button } from '@/components/ui/button';
-import {
- Form,
- FormControl,
- FormField,
- FormItem,
- FormLabel,
- FormMessage,
-} from '@/components/ui/form';
-import { Switch } from '@/components/ui/switch';
+import { Form, FormField } from '@/components/ui/form';
import { FormTooltip } from '@/components/ui/tooltip';
import { zodResolver } from '@hookform/resolvers/zod';
import { Plus } from 'lucide-react';
-import { memo, useMemo } from 'react';
+import { memo, useCallback, useMemo } from 'react';
import { useForm, useWatch } from 'react-hook-form';
import { useTranslation } from 'react-i18next';
import { z } from 'zod';
@@ -87,43 +81,26 @@ function UserFillUpForm({ node }: INextOperatorForm) {
node,
});
+ const handleAddQuery = useCallback(() => {
+ showModal();
+ }, [showModal]);
+
return (
<section className="px-5 space-y-5">
<Form {...form}>
- <FormField
- control={form.control}
- name={'enable_tips'}
- render={({ field }) => (
- <FormItem>
- <FormLabel tooltip={t('flow.openingSwitchTip')}>
- {t('flow.guidingQuestion')}
- </FormLabel>
- <FormControl>
- <Switch
- checked={field.value}
- onCheckedChange={field.onChange}
- />
- </FormControl>
- <FormMessage />
- </FormItem>
- )}
+ <SwitchFormField
+ name="enable_tips"
+ label={t('flow.guidingQuestion')}
+ tooltip={t('flow.openingSwitchTip')}
/>
- <FormField
- control={form.control}
- name={'tips'}
- render={({ field }) => (
- <FormItem>
- <FormLabel tooltip={t('chat.setAnOpenerTip')}>
- {t('flow.msg')}
- </FormLabel>
- <FormControl>
- <PromptEditor value={field.value} onChange={field.onChange} />
- </FormControl>
- <FormMessage />
- </FormItem>
- )}
- />
+ <RAGFlowFormItem
+ name="tips"
+ label={t('flow.msg')}
+ tooltip={t('chat.setAnOpenerTip')}
+ >
+ <PromptEditor></PromptEditor>
+ </RAGFlowFormItem>
{/* Create a hidden field to make Form instance record this */}
<FormField
@@ -139,13 +116,7 @@ function UserFillUpForm({ node }: INextOperatorForm) {
</div>
}
rightContent={
- <Button
- variant={'ghost'}
- onClick={(e) => {
- e.preventDefault();
- showModal();
- }}
- >
+ <Button variant={'ghost'} onClick={handleAddQuery}>
<Plus />
</Button>
}