mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-08-12 12:49:03 +08:00
### What problem does this PR solve? Feat: merge the begin operator's url and file into one field #3355 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
parent
9b4c2868bd
commit
4d42bcd517
@ -45,7 +45,6 @@ import {
|
|||||||
import upperFirst from 'lodash/upperFirst';
|
import upperFirst from 'lodash/upperFirst';
|
||||||
import {
|
import {
|
||||||
CloudUpload,
|
CloudUpload,
|
||||||
Link2,
|
|
||||||
ListOrdered,
|
ListOrdered,
|
||||||
OptionIcon,
|
OptionIcon,
|
||||||
TextCursorInput,
|
TextCursorInput,
|
||||||
@ -2876,7 +2875,6 @@ export enum BeginQueryType {
|
|||||||
File = 'file',
|
File = 'file',
|
||||||
Integer = 'integer',
|
Integer = 'integer',
|
||||||
Boolean = 'boolean',
|
Boolean = 'boolean',
|
||||||
Url = 'url',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const BeginQueryTypeIconMap = {
|
export const BeginQueryTypeIconMap = {
|
||||||
@ -2886,5 +2884,4 @@ export const BeginQueryTypeIconMap = {
|
|||||||
[BeginQueryType.File]: CloudUpload,
|
[BeginQueryType.File]: CloudUpload,
|
||||||
[BeginQueryType.Integer]: ListOrdered,
|
[BeginQueryType.Integer]: ListOrdered,
|
||||||
[BeginQueryType.Boolean]: ToggleLeft,
|
[BeginQueryType.Boolean]: ToggleLeft,
|
||||||
[BeginQueryType.Url]: Link2,
|
|
||||||
};
|
};
|
||||||
|
@ -36,7 +36,6 @@ const DynamicParameters = ({ nodeId }: IProps) => {
|
|||||||
title: t('key'),
|
title: t('key'),
|
||||||
dataIndex: 'key',
|
dataIndex: 'key',
|
||||||
key: 'key',
|
key: 'key',
|
||||||
width: 50,
|
|
||||||
onCell: (record: IGenerateParameter) => ({
|
onCell: (record: IGenerateParameter) => ({
|
||||||
record,
|
record,
|
||||||
editable: true,
|
editable: true,
|
||||||
|
@ -5,11 +5,10 @@ import { useHandleSubmittable } from '@/hooks/login-hooks';
|
|||||||
import { IModalProps } from '@/interfaces/common';
|
import { IModalProps } from '@/interfaces/common';
|
||||||
import api from '@/utils/api';
|
import api from '@/utils/api';
|
||||||
import { getAuthorization } from '@/utils/authorization-util';
|
import { getAuthorization } from '@/utils/authorization-util';
|
||||||
import { InboxOutlined } from '@ant-design/icons';
|
import { UploadOutlined } from '@ant-design/icons';
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Drawer,
|
Drawer,
|
||||||
Flex,
|
|
||||||
Form,
|
Form,
|
||||||
FormItemProps,
|
FormItemProps,
|
||||||
Input,
|
Input,
|
||||||
@ -19,7 +18,6 @@ import {
|
|||||||
Upload,
|
Upload,
|
||||||
} from 'antd';
|
} from 'antd';
|
||||||
import { pick } from 'lodash';
|
import { pick } from 'lodash';
|
||||||
import { Link2, Trash2 } from 'lucide-react';
|
|
||||||
import React, { useCallback, useState } from 'react';
|
import React, { useCallback, useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { BeginQueryType } from '../constant';
|
import { BeginQueryType } from '../constant';
|
||||||
@ -33,6 +31,7 @@ import { getDrawerWidth } from '../utils';
|
|||||||
import { PopoverForm } from './popover-form';
|
import { PopoverForm } from './popover-form';
|
||||||
|
|
||||||
import { UploadChangeParam, UploadFile } from 'antd/es/upload';
|
import { UploadChangeParam, UploadFile } from 'antd/es/upload';
|
||||||
|
import { Link } from 'lucide-react';
|
||||||
import styles from './index.less';
|
import styles from './index.less';
|
||||||
|
|
||||||
const RunDrawer = ({
|
const RunDrawer = ({
|
||||||
@ -60,18 +59,6 @@ const RunDrawer = ({
|
|||||||
[setRecord, showPopover],
|
[setRecord, showPopover],
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleRemoveUrl = useCallback(
|
|
||||||
(key: number, index: number) => () => {
|
|
||||||
const list: any[] = form.getFieldValue(key);
|
|
||||||
|
|
||||||
form.setFieldValue(
|
|
||||||
key,
|
|
||||||
list.filter((_, idx) => idx !== index),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
[form],
|
|
||||||
);
|
|
||||||
|
|
||||||
const getBeginNodeDataQuery = useGetBeginNodeDataQuery();
|
const getBeginNodeDataQuery = useGetBeginNodeDataQuery();
|
||||||
const query: BeginQuery[] = getBeginNodeDataQuery();
|
const query: BeginQuery[] = getBeginNodeDataQuery();
|
||||||
|
|
||||||
@ -126,27 +113,47 @@ const RunDrawer = ({
|
|||||||
</Form.Item>
|
</Form.Item>
|
||||||
),
|
),
|
||||||
[BeginQueryType.File]: (
|
[BeginQueryType.File]: (
|
||||||
<Form.Item
|
<React.Fragment key={idx}>
|
||||||
{...props}
|
<Form.Item label={q.name} required={!q.optional}>
|
||||||
valuePropName="fileList"
|
<div className="relative">
|
||||||
getValueFromEvent={normFile}
|
<Form.Item
|
||||||
>
|
{...props}
|
||||||
<Upload.Dragger
|
valuePropName="fileList"
|
||||||
name="file"
|
getValueFromEvent={normFile}
|
||||||
action={api.parse}
|
noStyle
|
||||||
multiple
|
>
|
||||||
headers={{ [Authorization]: getAuthorization() }}
|
<Upload
|
||||||
onChange={onChange(q.optional)}
|
name="file"
|
||||||
>
|
action={api.parse}
|
||||||
<p className="ant-upload-drag-icon">
|
multiple
|
||||||
<InboxOutlined />
|
headers={{ [Authorization]: getAuthorization() }}
|
||||||
</p>
|
onChange={onChange(q.optional)}
|
||||||
<p className="ant-upload-text">{t('fileManager.uploadTitle')}</p>
|
>
|
||||||
<p className="ant-upload-hint">
|
<Button icon={<UploadOutlined />}>
|
||||||
{t('fileManager.uploadDescription')}
|
{t('common.upload')}
|
||||||
</p>
|
</Button>
|
||||||
</Upload.Dragger>
|
</Upload>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
<Form.Item
|
||||||
|
{...pick(props, ['key', 'label', 'rules'])}
|
||||||
|
required={!q.optional}
|
||||||
|
className={urlList.length > 0 ? 'mb-1' : ''}
|
||||||
|
noStyle
|
||||||
|
>
|
||||||
|
<PopoverForm visible={visible} switchVisible={switchVisible}>
|
||||||
|
<Button
|
||||||
|
onClick={handleShowPopover(idx)}
|
||||||
|
className="absolute left-1/2 top-0"
|
||||||
|
icon={<Link className="size-3" />}
|
||||||
|
>
|
||||||
|
{t('flow.pasteFileLink')}
|
||||||
|
</Button>
|
||||||
|
</PopoverForm>
|
||||||
|
</Form.Item>
|
||||||
|
</div>
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item name={idx} noStyle {...pick(props, ['rules'])} />
|
||||||
|
</React.Fragment>
|
||||||
),
|
),
|
||||||
[BeginQueryType.Integer]: (
|
[BeginQueryType.Integer]: (
|
||||||
<Form.Item {...props}>
|
<Form.Item {...props}>
|
||||||
@ -158,66 +165,11 @@ const RunDrawer = ({
|
|||||||
<Switch></Switch>
|
<Switch></Switch>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
),
|
),
|
||||||
[BeginQueryType.Url]: (
|
|
||||||
<React.Fragment key={idx}>
|
|
||||||
<Form.Item
|
|
||||||
{...pick(props, ['key', 'label', 'rules'])}
|
|
||||||
required={!q.optional}
|
|
||||||
className={urlList.length > 0 ? 'mb-1' : ''}
|
|
||||||
>
|
|
||||||
<PopoverForm visible={visible} switchVisible={switchVisible}>
|
|
||||||
<Button
|
|
||||||
onClick={handleShowPopover(idx)}
|
|
||||||
className="text-buttonBlueText"
|
|
||||||
>
|
|
||||||
{t('flow.pasteFileLink')}
|
|
||||||
</Button>
|
|
||||||
</PopoverForm>
|
|
||||||
</Form.Item>
|
|
||||||
<Form.Item name={idx} noStyle {...pick(props, ['rules'])} />
|
|
||||||
<Form.Item
|
|
||||||
noStyle
|
|
||||||
shouldUpdate={(prevValues, curValues) =>
|
|
||||||
prevValues[idx] !== curValues[idx]
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{({ getFieldValue }) => {
|
|
||||||
const urlInfo: { url: string; result: string }[] =
|
|
||||||
getFieldValue(idx) || [];
|
|
||||||
return urlInfo.length ? (
|
|
||||||
<Flex vertical gap={8} className="mb-3">
|
|
||||||
{urlInfo.map((u, index) => (
|
|
||||||
<div
|
|
||||||
key={index}
|
|
||||||
className="flex items-center justify-between gap-2 hover:bg-slate-100 group"
|
|
||||||
>
|
|
||||||
<Link2 className="size-5"></Link2>
|
|
||||||
<span className="flex-1 truncate"> {u.url}</span>
|
|
||||||
<Trash2
|
|
||||||
className="size-4 invisible group-hover:visible cursor-pointer"
|
|
||||||
onClick={handleRemoveUrl(idx, index)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</Flex>
|
|
||||||
) : null;
|
|
||||||
}}
|
|
||||||
</Form.Item>
|
|
||||||
</React.Fragment>
|
|
||||||
),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return BeginQueryTypeMap[q.type as BeginQueryType];
|
return BeginQueryTypeMap[q.type as BeginQueryType];
|
||||||
},
|
},
|
||||||
[
|
[form, handleShowPopover, onChange, switchVisible, t, visible],
|
||||||
form,
|
|
||||||
handleRemoveUrl,
|
|
||||||
handleShowPopover,
|
|
||||||
onChange,
|
|
||||||
switchVisible,
|
|
||||||
t,
|
|
||||||
visible,
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const { handleRun } = useSaveGraphBeforeOpeningDebugDrawer(showChatModal!);
|
const { handleRun } = useSaveGraphBeforeOpeningDebugDrawer(showChatModal!);
|
||||||
@ -239,20 +191,11 @@ const RunDrawer = ({
|
|||||||
if (Array.isArray(value)) {
|
if (Array.isArray(value)) {
|
||||||
nextValue = ``;
|
nextValue = ``;
|
||||||
|
|
||||||
value.forEach((x, idx) => {
|
value.forEach((x) => {
|
||||||
if (x?.originFileObj instanceof File) {
|
nextValue +=
|
||||||
if (idx === 0) {
|
x?.originFileObj instanceof File
|
||||||
nextValue += `${x.name}\n\n${x.response?.data}\n\n`;
|
? `${x.name}\n${x.response?.data}\n----\n`
|
||||||
} else {
|
: `${x.url}\n${x.result}\n----\n`;
|
||||||
nextValue += `${x.response?.data}\n\n`;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (idx === 0) {
|
|
||||||
nextValue += `${x.url}\n\n${x.result}\n\n`;
|
|
||||||
} else {
|
|
||||||
nextValue += `${x.result}\n\n`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return { ...item, value: nextValue };
|
return { ...item, value: nextValue };
|
||||||
@ -277,7 +220,7 @@ const RunDrawer = ({
|
|||||||
const { basicForm } = forms;
|
const { basicForm } = forms;
|
||||||
const urlInfo = basicForm.getFieldValue(currentRecord) || [];
|
const urlInfo = basicForm.getFieldValue(currentRecord) || [];
|
||||||
basicForm.setFieldsValue({
|
basicForm.setFieldsValue({
|
||||||
[currentRecord]: [...urlInfo, values],
|
[currentRecord]: [...urlInfo, { ...values, name: values.url }],
|
||||||
});
|
});
|
||||||
hidePopover();
|
hidePopover();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user