mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-08-13 04:08:59 +08:00
### What problem does this PR solve? Feat: Add FormSheet. #3221 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
parent
5c6a7cb4b8
commit
5859a3df72
@ -92,7 +92,6 @@ function RerankFormField() {
|
|||||||
<FormControl>
|
<FormControl>
|
||||||
<Select onValueChange={field.onChange} {...field}>
|
<Select onValueChange={field.onChange} {...field}>
|
||||||
<SelectTrigger
|
<SelectTrigger
|
||||||
className="w-[280px]"
|
|
||||||
value={field.value}
|
value={field.value}
|
||||||
onReset={() => {
|
onReset={() => {
|
||||||
form.resetField(RerankId);
|
form.resetField(RerankId);
|
||||||
|
@ -40,7 +40,7 @@ const sheetVariants = cva(
|
|||||||
'inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom',
|
'inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom',
|
||||||
left: 'inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm',
|
left: 'inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm',
|
||||||
right:
|
right:
|
||||||
'inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm',
|
'inset-y-0 right-0 h-full border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right w-1/3 max-w-[600px]',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
defaultVariants: {
|
defaultVariants: {
|
||||||
@ -51,12 +51,18 @@ const sheetVariants = cva(
|
|||||||
|
|
||||||
interface SheetContentProps
|
interface SheetContentProps
|
||||||
extends React.ComponentPropsWithoutRef<typeof SheetPrimitive.Content>,
|
extends React.ComponentPropsWithoutRef<typeof SheetPrimitive.Content>,
|
||||||
VariantProps<typeof sheetVariants> {}
|
VariantProps<typeof sheetVariants> {
|
||||||
|
closeIcon?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
const SheetContent = React.forwardRef<
|
const SheetContent = React.forwardRef<
|
||||||
React.ElementRef<typeof SheetPrimitive.Content>,
|
React.ElementRef<typeof SheetPrimitive.Content>,
|
||||||
SheetContentProps
|
SheetContentProps
|
||||||
>(({ side = 'right', className, children, ...props }, ref) => (
|
>(
|
||||||
|
(
|
||||||
|
{ side = 'right', className, children, closeIcon = true, ...props },
|
||||||
|
ref,
|
||||||
|
) => (
|
||||||
<SheetPortal>
|
<SheetPortal>
|
||||||
<SheetOverlay />
|
<SheetOverlay />
|
||||||
<SheetPrimitive.Content
|
<SheetPrimitive.Content
|
||||||
@ -65,13 +71,16 @@ const SheetContent = React.forwardRef<
|
|||||||
{...props}
|
{...props}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
|
{closeIcon ? (
|
||||||
<SheetPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary ">
|
<SheetPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary ">
|
||||||
<X className="h-4 w-4 " />
|
<X className="h-4 w-4 " />
|
||||||
<span className="sr-only">Close</span>
|
<span className="sr-only">Close</span>
|
||||||
</SheetPrimitive.Close>
|
</SheetPrimitive.Close>
|
||||||
|
) : null}
|
||||||
</SheetPrimitive.Content>
|
</SheetPrimitive.Content>
|
||||||
</SheetPortal>
|
</SheetPortal>
|
||||||
));
|
),
|
||||||
|
);
|
||||||
SheetContent.displayName = SheetPrimitive.Content.displayName;
|
SheetContent.displayName = SheetPrimitive.Content.displayName;
|
||||||
|
|
||||||
const SheetHeader = ({
|
const SheetHeader = ({
|
||||||
|
@ -6,7 +6,7 @@ import {
|
|||||||
} from '@xyflow/react';
|
} from '@xyflow/react';
|
||||||
import '@xyflow/react/dist/style.css';
|
import '@xyflow/react/dist/style.css';
|
||||||
// import ChatDrawer from '../chat/drawer';
|
// import ChatDrawer from '../chat/drawer';
|
||||||
import FormDrawer from '../form-drawer/next';
|
import FormSheet from '../form-sheet/next';
|
||||||
import {
|
import {
|
||||||
useHandleDrop,
|
useHandleDrop,
|
||||||
useSelectCanvasData,
|
useSelectCanvasData,
|
||||||
@ -154,14 +154,14 @@ function FlowCanvas({ drawerVisible, hideDrawer }: IProps) {
|
|||||||
<Background />
|
<Background />
|
||||||
</ReactFlow>
|
</ReactFlow>
|
||||||
{formDrawerVisible && (
|
{formDrawerVisible && (
|
||||||
<FormDrawer
|
<FormSheet
|
||||||
node={clickedNode}
|
node={clickedNode}
|
||||||
visible={formDrawerVisible}
|
visible={formDrawerVisible}
|
||||||
hideModal={hideFormDrawer}
|
hideModal={hideFormDrawer}
|
||||||
singleDebugDrawerVisible={singleDebugDrawerVisible}
|
singleDebugDrawerVisible={singleDebugDrawerVisible}
|
||||||
hideSingleDebugDrawer={hideSingleDebugDrawer}
|
hideSingleDebugDrawer={hideSingleDebugDrawer}
|
||||||
showSingleDebugDrawer={showSingleDebugDrawer}
|
showSingleDebugDrawer={showSingleDebugDrawer}
|
||||||
></FormDrawer>
|
></FormSheet>
|
||||||
)}
|
)}
|
||||||
{/* {chatVisible && (
|
{/* {chatVisible && (
|
||||||
<ChatDrawer
|
<ChatDrawer
|
||||||
|
@ -1,11 +1,16 @@
|
|||||||
|
import { Input } from '@/components/ui/input';
|
||||||
|
import { Sheet, SheetContent, SheetHeader } from '@/components/ui/sheet';
|
||||||
import { useTranslate } from '@/hooks/common-hooks';
|
import { useTranslate } from '@/hooks/common-hooks';
|
||||||
import { IModalProps } from '@/interfaces/common';
|
import { IModalProps } from '@/interfaces/common';
|
||||||
import { CloseOutlined } from '@ant-design/icons';
|
import { RAGFlowNodeType } from '@/interfaces/database/flow';
|
||||||
import { Flex, Input } from 'antd';
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
import { get, isPlainObject, lowerFirst } from 'lodash';
|
import { get, isPlainObject, lowerFirst } from 'lodash';
|
||||||
import { Play } from 'lucide-react';
|
import { Play, X } from 'lucide-react';
|
||||||
import { useEffect, useRef } from 'react';
|
import { useEffect, useRef } from 'react';
|
||||||
|
import { useForm } from 'react-hook-form';
|
||||||
import { BeginId, Operator, operatorMap } from '../constant';
|
import { BeginId, Operator, operatorMap } from '../constant';
|
||||||
|
import { FlowFormContext } from '../context';
|
||||||
|
import { RunTooltip } from '../flow-tooltip';
|
||||||
import { useHandleFormValuesChange, useHandleNodeNameChange } from '../hooks';
|
import { useHandleFormValuesChange, useHandleNodeNameChange } from '../hooks';
|
||||||
import OperatorIcon from '../operator-icon';
|
import OperatorIcon from '../operator-icon';
|
||||||
import {
|
import {
|
||||||
@ -13,14 +18,6 @@ import {
|
|||||||
needsSingleStepDebugging,
|
needsSingleStepDebugging,
|
||||||
} from '../utils';
|
} from '../utils';
|
||||||
import SingleDebugDrawer from './single-debug-drawer';
|
import SingleDebugDrawer from './single-debug-drawer';
|
||||||
|
|
||||||
import { Sheet, SheetContent, SheetHeader } from '@/components/ui/sheet';
|
|
||||||
import { RAGFlowNodeType } from '@/interfaces/database/flow';
|
|
||||||
import { FlowFormContext } from '../context';
|
|
||||||
import { RunTooltip } from '../flow-tooltip';
|
|
||||||
|
|
||||||
import { zodResolver } from '@hookform/resolvers/zod';
|
|
||||||
import { useForm } from 'react-hook-form';
|
|
||||||
import { useFormConfigMap } from './use-form-config-map';
|
import { useFormConfigMap } from './use-form-config-map';
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
@ -32,7 +29,7 @@ interface IProps {
|
|||||||
|
|
||||||
const EmptyContent = () => <div></div>;
|
const EmptyContent = () => <div></div>;
|
||||||
|
|
||||||
const FormDrawer = ({
|
const FormSheet = ({
|
||||||
visible,
|
visible,
|
||||||
hideModal,
|
hideModal,
|
||||||
node,
|
node,
|
||||||
@ -90,16 +87,16 @@ const FormDrawer = ({
|
|||||||
}, [visible, form, node?.data?.form, node?.id, node, operatorName]);
|
}, [visible, form, node?.data?.form, node?.id, node, operatorName]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Sheet onOpenChange={hideModal} open={visible}>
|
<Sheet onOpenChange={hideModal} open={visible} modal={false}>
|
||||||
<SheetContent className="bg-white">
|
<SheetContent className="bg-white top-20" closeIcon={false}>
|
||||||
<SheetHeader>
|
<SheetHeader>
|
||||||
<Flex vertical>
|
<section className="flex-col border-b pb-2">
|
||||||
<Flex gap={'middle'} align="center">
|
<div className="flex items-center gap-2 pb-3">
|
||||||
<OperatorIcon
|
<OperatorIcon
|
||||||
name={operatorName}
|
name={operatorName}
|
||||||
color={operatorMap[operatorName]?.color}
|
color={operatorMap[operatorName]?.color}
|
||||||
></OperatorIcon>
|
></OperatorIcon>
|
||||||
<Flex align="center" gap={'small'} flex={1}>
|
<div className="flex items-center gap-1 flex-1">
|
||||||
<label htmlFor="">{t('title')}</label>
|
<label htmlFor="">{t('title')}</label>
|
||||||
{node?.id === BeginId ? (
|
{node?.id === BeginId ? (
|
||||||
<span>{t(BeginId)}</span>
|
<span>{t(BeginId)}</span>
|
||||||
@ -110,7 +107,7 @@ const FormDrawer = ({
|
|||||||
onChange={handleNameChange}
|
onChange={handleNameChange}
|
||||||
></Input>
|
></Input>
|
||||||
)}
|
)}
|
||||||
</Flex>
|
</div>
|
||||||
|
|
||||||
{needsSingleStepDebugging(operatorName) && (
|
{needsSingleStepDebugging(operatorName) && (
|
||||||
<RunTooltip>
|
<RunTooltip>
|
||||||
@ -120,10 +117,10 @@ const FormDrawer = ({
|
|||||||
/>
|
/>
|
||||||
</RunTooltip>
|
</RunTooltip>
|
||||||
)}
|
)}
|
||||||
<CloseOutlined onClick={hideModal} />
|
<X onClick={hideModal} />
|
||||||
</Flex>
|
</div>
|
||||||
<span>{t(`${lowerFirst(operatorName)}Description`)}</span>
|
<span>{t(`${lowerFirst(operatorName)}Description`)}</span>
|
||||||
</Flex>
|
</section>
|
||||||
</SheetHeader>
|
</SheetHeader>
|
||||||
<section>
|
<section>
|
||||||
{visible && (
|
{visible && (
|
||||||
@ -148,4 +145,4 @@ const FormDrawer = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default FormDrawer;
|
export default FormSheet;
|
@ -58,7 +58,6 @@ export function DynamicVariableForm({ node }: IProps) {
|
|||||||
name={typeField}
|
name={typeField}
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem className="w-2/5">
|
<FormItem className="w-2/5">
|
||||||
{/* <FormLabel>City</FormLabel> */}
|
|
||||||
<FormDescription />
|
<FormDescription />
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<RAGFlowSelect
|
<RAGFlowSelect
|
||||||
@ -75,8 +74,7 @@ export function DynamicVariableForm({ node }: IProps) {
|
|||||||
control={form.control}
|
control={form.control}
|
||||||
name={`query.${index}.${getVariableName(typeValue)}`}
|
name={`query.${index}.${getVariableName(typeValue)}`}
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem className="flex-1">
|
||||||
{/* <FormLabel>State</FormLabel> */}
|
|
||||||
<FormDescription />
|
<FormDescription />
|
||||||
<FormControl>
|
<FormControl>
|
||||||
{typeValue === VariableType.Reference ? (
|
{typeValue === VariableType.Reference ? (
|
||||||
|
@ -11,14 +11,20 @@ import {
|
|||||||
FormMessage,
|
FormMessage,
|
||||||
} from '@/components/ui/form';
|
} from '@/components/ui/form';
|
||||||
import { Textarea } from '@/components/ui/textarea';
|
import { Textarea } from '@/components/ui/textarea';
|
||||||
import { useTranslate } from '@/hooks/common-hooks';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { INextOperatorForm } from '../../interface';
|
import { INextOperatorForm } from '../../interface';
|
||||||
import { DynamicVariableForm } from '../components/next-dynamic-input-variable';
|
import { DynamicVariableForm } from '../components/next-dynamic-input-variable';
|
||||||
|
|
||||||
const RetrievalForm = ({ form, node }: INextOperatorForm) => {
|
const RetrievalForm = ({ form, node }: INextOperatorForm) => {
|
||||||
const { t } = useTranslate('flow');
|
const { t } = useTranslation();
|
||||||
return (
|
return (
|
||||||
<Form {...form}>
|
<Form {...form}>
|
||||||
|
<form
|
||||||
|
className="space-y-6"
|
||||||
|
onSubmit={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
}}
|
||||||
|
>
|
||||||
<DynamicVariableForm></DynamicVariableForm>
|
<DynamicVariableForm></DynamicVariableForm>
|
||||||
<SimilaritySliderFormField name="keywords_similarity_weight"></SimilaritySliderFormField>
|
<SimilaritySliderFormField name="keywords_similarity_weight"></SimilaritySliderFormField>
|
||||||
<TopNFormField></TopNFormField>
|
<TopNFormField></TopNFormField>
|
||||||
@ -42,6 +48,7 @@ const RetrievalForm = ({ form, node }: INextOperatorForm) => {
|
|||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
</form>
|
||||||
</Form>
|
</Form>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user