Преглед на файлове

feat: Disable clicking the Next button while uploading files in RunDrawer #3355 (#3477)

### What problem does this PR solve?

feat: Disable clicking the Next button while uploading files in
RunDrawer #3355

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
tags/v0.14.0
balibabu преди 11 месеца
родител
ревизия
eef84a86bf
No account linked to committer's email address

+ 3
- 1
web/src/components/file-icon/index.tsx Целия файл

const fileThumbnail = fileThumbnails[id]; const fileThumbnail = fileThumbnails[id];


useEffect(() => { useEffect(() => {
setDocumentIds([id]);
if (id) {
setDocumentIds([id]);
}
}, [id, setDocumentIds]); }, [id, setDocumentIds]);


return fileThumbnail ? ( return fileThumbnail ? (

+ 1
- 0
web/src/interfaces/database/knowledge.ts Целия файл

doc_id: string; doc_id: string;
doc_name: string; doc_name: string;
img_id: string; img_id: string;
image_id: string;
important_kwd: any[]; important_kwd: any[];
kb_id: string; kb_id: string;
similarity: number; similarity: number;

+ 5
- 5
web/src/pages/flow/hooks.tsx Целия файл

const resetRet = await resetFlow(); const resetRet = await resetFlow();
// After resetting, all previous messages will be cleared. // After resetting, all previous messages will be cleared.
if (resetRet?.code === 0) { if (resetRet?.code === 0) {
show();
// fetch prologue // fetch prologue
const sendRet = await send({ id }); const sendRet = await send({ id });
if (receiveMessageError(sendRet)) { if (receiveMessageError(sendRet)) {
message.error(sendRet?.data?.message); message.error(sendRet?.data?.message);
} else { } else {
refetch(); refetch();
show();
} }
} }
} }


const groupedOptions = [ const groupedOptions = [
{ {
label: <span>Component id</span>,
title: 'Component Id',
label: <span>Component Output</span>,
title: 'Component Output',
options: componentIdOptions, options: componentIdOptions,
}, },
{ {
label: <span>Begin input</span>,
title: 'Begin input',
label: <span>Begin Input</span>,
title: 'Begin Input',
options: query.map((x) => ({ options: query.map((x) => ({
label: x.name, label: x.name,
value: `begin@${x.key}`, value: `begin@${x.key}`,

+ 33
- 7
web/src/pages/flow/run-drawer/index.tsx Целия файл

} from 'antd'; } from 'antd';
import { pick } from 'lodash'; import { pick } from 'lodash';
import { Link2, Trash2 } from 'lucide-react'; import { Link2, Trash2 } from 'lucide-react';
import { useCallback } 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';
import { import {
import { getDrawerWidth } from '../utils'; import { getDrawerWidth } from '../utils';
import { PopoverForm } from './popover-form'; import { PopoverForm } from './popover-form';


import { UploadChangeParam, UploadFile } from 'antd/es/upload';
import styles from './index.less'; import styles from './index.less';


const RunDrawer = ({ const RunDrawer = ({
} = useSetModalState(); } = useSetModalState();
const { setRecord, currentRecord } = useSetSelectedRecord<number>(); const { setRecord, currentRecord } = useSetSelectedRecord<number>();
const { submittable } = useHandleSubmittable(form); const { submittable } = useHandleSubmittable(form);
const [isUploading, setIsUploading] = useState(false);


const handleShowPopover = useCallback( const handleShowPopover = useCallback(
(idx: number) => () => { (idx: number) => () => {
return e?.fileList; return e?.fileList;
}; };


const onChange = useCallback(
(optional: boolean) =>
({ fileList }: UploadChangeParam<UploadFile>) => {
if (!optional) {
setIsUploading(fileList.some((x) => x.status === 'uploading'));
}
},
[],
);

const renderWidget = useCallback( const renderWidget = useCallback(
(q: BeginQuery, idx: number) => { (q: BeginQuery, idx: number) => {
const props: FormItemProps & { key: number } = { const props: FormItemProps & { key: number } = {
action={api.parse} action={api.parse}
multiple multiple
headers={{ [Authorization]: getAuthorization() }} headers={{ [Authorization]: getAuthorization() }}
onChange={onChange(q.optional)}
> >
<p className="ant-upload-drag-icon"> <p className="ant-upload-drag-icon">
<InboxOutlined /> <InboxOutlined />
</Form.Item> </Form.Item>
), ),
[BeginQueryType.Url]: ( [BeginQueryType.Url]: (
<>
<React.Fragment key={idx}>
<Form.Item <Form.Item
{...pick(props, ['key', 'label', 'rules'])} {...pick(props, ['key', 'label', 'rules'])}
required={!q.optional} required={!q.optional}
) : null; ) : null;
}} }}
</Form.Item> </Form.Item>
</>
</React.Fragment>
), ),
}; };


return BeginQueryTypeMap[q.type as BeginQueryType]; return BeginQueryTypeMap[q.type as BeginQueryType];
}, },
[form, handleRemoveUrl, handleShowPopover, switchVisible, t, visible],
[
form,
handleRemoveUrl,
handleShowPopover,
onChange,
switchVisible,
t,
visible,
],
); );


const { handleRun } = useSaveGraphBeforeOpeningDebugDrawer(showChatModal!); const { handleRun } = useSaveGraphBeforeOpeningDebugDrawer(showChatModal!);
value.forEach((x, idx) => { value.forEach((x, idx) => {
if (x?.originFileObj instanceof File) { if (x?.originFileObj instanceof File) {
if (idx === 0) { if (idx === 0) {
nextValue += `${x.name}\n\n${x.response.data}\n\n`;
nextValue += `${x.name}\n\n${x.response?.data}\n\n`;
} else { } else {
nextValue += `${x.response.data}\n\n`;
nextValue += `${x.response?.data}\n\n`;
} }
} else { } else {
if (idx === 0) { if (idx === 0) {
</Form> </Form>
</Form.Provider> </Form.Provider>
</section> </section>
<Button type={'primary'} block onClick={onOk} disabled={!submittable}>
<Button
type={'primary'}
block
onClick={onOk}
disabled={!submittable || isUploading}
>
{t('common.next')} {t('common.next')}
</Button> </Button>
</Drawer> </Drawer>

+ 1
- 1
web/src/pages/search/index.tsx Целия файл

} }
> >
<FileIcon <FileIcon
id={item.img_id}
id={item.image_id}
name={item.docnm_kwd} name={item.docnm_kwd}
></FileIcon> ></FileIcon>
{item.docnm_kwd} {item.docnm_kwd}

Loading…
Отказ
Запис