balibabu
commited on
Commit
·
8872ee4
1
Parent(s):
561b959
feat: Disable clicking the Next button while uploading files in RunDrawer #3355 (#3477)
Browse files### 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)
web/src/components/file-icon/index.tsx
CHANGED
@@ -18,7 +18,9 @@ const FileIcon = ({ name, id }: IProps) => {
|
|
18 |
const fileThumbnail = fileThumbnails[id];
|
19 |
|
20 |
useEffect(() => {
|
21 |
-
|
|
|
|
|
22 |
}, [id, setDocumentIds]);
|
23 |
|
24 |
return fileThumbnail ? (
|
|
|
18 |
const fileThumbnail = fileThumbnails[id];
|
19 |
|
20 |
useEffect(() => {
|
21 |
+
if (id) {
|
22 |
+
setDocumentIds([id]);
|
23 |
+
}
|
24 |
}, [id, setDocumentIds]);
|
25 |
|
26 |
return fileThumbnail ? (
|
web/src/interfaces/database/knowledge.ts
CHANGED
@@ -94,6 +94,7 @@ export interface ITestingChunk {
|
|
94 |
doc_id: string;
|
95 |
doc_name: string;
|
96 |
img_id: string;
|
|
|
97 |
important_kwd: any[];
|
98 |
kb_id: string;
|
99 |
similarity: number;
|
|
|
94 |
doc_id: string;
|
95 |
doc_name: string;
|
96 |
img_id: string;
|
97 |
+
image_id: string;
|
98 |
important_kwd: any[];
|
99 |
kb_id: string;
|
100 |
similarity: number;
|
web/src/pages/flow/hooks.tsx
CHANGED
@@ -462,13 +462,13 @@ export const useSaveGraphBeforeOpeningDebugDrawer = (show: () => void) => {
|
|
462 |
const resetRet = await resetFlow();
|
463 |
// After resetting, all previous messages will be cleared.
|
464 |
if (resetRet?.code === 0) {
|
|
|
465 |
// fetch prologue
|
466 |
const sendRet = await send({ id });
|
467 |
if (receiveMessageError(sendRet)) {
|
468 |
message.error(sendRet?.data?.message);
|
469 |
} else {
|
470 |
refetch();
|
471 |
-
show();
|
472 |
}
|
473 |
}
|
474 |
}
|
@@ -641,13 +641,13 @@ export const useBuildComponentIdSelectOptions = (nodeId?: string) => {
|
|
641 |
|
642 |
const groupedOptions = [
|
643 |
{
|
644 |
-
label: <span>Component
|
645 |
-
title: 'Component
|
646 |
options: componentIdOptions,
|
647 |
},
|
648 |
{
|
649 |
-
label: <span>Begin
|
650 |
-
title: 'Begin
|
651 |
options: query.map((x) => ({
|
652 |
label: x.name,
|
653 |
value: `begin@${x.key}`,
|
|
|
462 |
const resetRet = await resetFlow();
|
463 |
// After resetting, all previous messages will be cleared.
|
464 |
if (resetRet?.code === 0) {
|
465 |
+
show();
|
466 |
// fetch prologue
|
467 |
const sendRet = await send({ id });
|
468 |
if (receiveMessageError(sendRet)) {
|
469 |
message.error(sendRet?.data?.message);
|
470 |
} else {
|
471 |
refetch();
|
|
|
472 |
}
|
473 |
}
|
474 |
}
|
|
|
641 |
|
642 |
const groupedOptions = [
|
643 |
{
|
644 |
+
label: <span>Component Output</span>,
|
645 |
+
title: 'Component Output',
|
646 |
options: componentIdOptions,
|
647 |
},
|
648 |
{
|
649 |
+
label: <span>Begin Input</span>,
|
650 |
+
title: 'Begin Input',
|
651 |
options: query.map((x) => ({
|
652 |
label: x.name,
|
653 |
value: `begin@${x.key}`,
|
web/src/pages/flow/run-drawer/index.tsx
CHANGED
@@ -20,7 +20,7 @@ import {
|
|
20 |
} from 'antd';
|
21 |
import { pick } from 'lodash';
|
22 |
import { Link2, Trash2 } from 'lucide-react';
|
23 |
-
import { useCallback } from 'react';
|
24 |
import { useTranslation } from 'react-i18next';
|
25 |
import { BeginQueryType } from '../constant';
|
26 |
import {
|
@@ -32,6 +32,7 @@ import useGraphStore from '../store';
|
|
32 |
import { getDrawerWidth } from '../utils';
|
33 |
import { PopoverForm } from './popover-form';
|
34 |
|
|
|
35 |
import styles from './index.less';
|
36 |
|
37 |
const RunDrawer = ({
|
@@ -49,6 +50,7 @@ const RunDrawer = ({
|
|
49 |
} = useSetModalState();
|
50 |
const { setRecord, currentRecord } = useSetSelectedRecord<number>();
|
51 |
const { submittable } = useHandleSubmittable(form);
|
|
|
52 |
|
53 |
const handleShowPopover = useCallback(
|
54 |
(idx: number) => () => {
|
@@ -80,6 +82,16 @@ const RunDrawer = ({
|
|
80 |
return e?.fileList;
|
81 |
};
|
82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
const renderWidget = useCallback(
|
84 |
(q: BeginQuery, idx: number) => {
|
85 |
const props: FormItemProps & { key: number } = {
|
@@ -124,6 +136,7 @@ const RunDrawer = ({
|
|
124 |
action={api.parse}
|
125 |
multiple
|
126 |
headers={{ [Authorization]: getAuthorization() }}
|
|
|
127 |
>
|
128 |
<p className="ant-upload-drag-icon">
|
129 |
<InboxOutlined />
|
@@ -146,7 +159,7 @@ const RunDrawer = ({
|
|
146 |
</Form.Item>
|
147 |
),
|
148 |
[BeginQueryType.Url]: (
|
149 |
-
|
150 |
<Form.Item
|
151 |
{...pick(props, ['key', 'label', 'rules'])}
|
152 |
required={!q.optional}
|
@@ -190,13 +203,21 @@ const RunDrawer = ({
|
|
190 |
) : null;
|
191 |
}}
|
192 |
</Form.Item>
|
193 |
-
|
194 |
),
|
195 |
};
|
196 |
|
197 |
return BeginQueryTypeMap[q.type as BeginQueryType];
|
198 |
},
|
199 |
-
[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
200 |
);
|
201 |
|
202 |
const { handleRun } = useSaveGraphBeforeOpeningDebugDrawer(showChatModal!);
|
@@ -221,9 +242,9 @@ const RunDrawer = ({
|
|
221 |
value.forEach((x, idx) => {
|
222 |
if (x?.originFileObj instanceof File) {
|
223 |
if (idx === 0) {
|
224 |
-
nextValue += `${x.name}\n\n${x.response
|
225 |
} else {
|
226 |
-
nextValue += `${x.response
|
227 |
}
|
228 |
} else {
|
229 |
if (idx === 0) {
|
@@ -274,7 +295,12 @@ const RunDrawer = ({
|
|
274 |
</Form>
|
275 |
</Form.Provider>
|
276 |
</section>
|
277 |
-
<Button
|
|
|
|
|
|
|
|
|
|
|
278 |
{t('common.next')}
|
279 |
</Button>
|
280 |
</Drawer>
|
|
|
20 |
} from 'antd';
|
21 |
import { pick } from 'lodash';
|
22 |
import { Link2, Trash2 } from 'lucide-react';
|
23 |
+
import React, { useCallback, useState } from 'react';
|
24 |
import { useTranslation } from 'react-i18next';
|
25 |
import { BeginQueryType } from '../constant';
|
26 |
import {
|
|
|
32 |
import { getDrawerWidth } from '../utils';
|
33 |
import { PopoverForm } from './popover-form';
|
34 |
|
35 |
+
import { UploadChangeParam, UploadFile } from 'antd/es/upload';
|
36 |
import styles from './index.less';
|
37 |
|
38 |
const RunDrawer = ({
|
|
|
50 |
} = useSetModalState();
|
51 |
const { setRecord, currentRecord } = useSetSelectedRecord<number>();
|
52 |
const { submittable } = useHandleSubmittable(form);
|
53 |
+
const [isUploading, setIsUploading] = useState(false);
|
54 |
|
55 |
const handleShowPopover = useCallback(
|
56 |
(idx: number) => () => {
|
|
|
82 |
return e?.fileList;
|
83 |
};
|
84 |
|
85 |
+
const onChange = useCallback(
|
86 |
+
(optional: boolean) =>
|
87 |
+
({ fileList }: UploadChangeParam<UploadFile>) => {
|
88 |
+
if (!optional) {
|
89 |
+
setIsUploading(fileList.some((x) => x.status === 'uploading'));
|
90 |
+
}
|
91 |
+
},
|
92 |
+
[],
|
93 |
+
);
|
94 |
+
|
95 |
const renderWidget = useCallback(
|
96 |
(q: BeginQuery, idx: number) => {
|
97 |
const props: FormItemProps & { key: number } = {
|
|
|
136 |
action={api.parse}
|
137 |
multiple
|
138 |
headers={{ [Authorization]: getAuthorization() }}
|
139 |
+
onChange={onChange(q.optional)}
|
140 |
>
|
141 |
<p className="ant-upload-drag-icon">
|
142 |
<InboxOutlined />
|
|
|
159 |
</Form.Item>
|
160 |
),
|
161 |
[BeginQueryType.Url]: (
|
162 |
+
<React.Fragment key={idx}>
|
163 |
<Form.Item
|
164 |
{...pick(props, ['key', 'label', 'rules'])}
|
165 |
required={!q.optional}
|
|
|
203 |
) : null;
|
204 |
}}
|
205 |
</Form.Item>
|
206 |
+
</React.Fragment>
|
207 |
),
|
208 |
};
|
209 |
|
210 |
return BeginQueryTypeMap[q.type as BeginQueryType];
|
211 |
},
|
212 |
+
[
|
213 |
+
form,
|
214 |
+
handleRemoveUrl,
|
215 |
+
handleShowPopover,
|
216 |
+
onChange,
|
217 |
+
switchVisible,
|
218 |
+
t,
|
219 |
+
visible,
|
220 |
+
],
|
221 |
);
|
222 |
|
223 |
const { handleRun } = useSaveGraphBeforeOpeningDebugDrawer(showChatModal!);
|
|
|
242 |
value.forEach((x, idx) => {
|
243 |
if (x?.originFileObj instanceof File) {
|
244 |
if (idx === 0) {
|
245 |
+
nextValue += `${x.name}\n\n${x.response?.data}\n\n`;
|
246 |
} else {
|
247 |
+
nextValue += `${x.response?.data}\n\n`;
|
248 |
}
|
249 |
} else {
|
250 |
if (idx === 0) {
|
|
|
295 |
</Form>
|
296 |
</Form.Provider>
|
297 |
</section>
|
298 |
+
<Button
|
299 |
+
type={'primary'}
|
300 |
+
block
|
301 |
+
onClick={onOk}
|
302 |
+
disabled={!submittable || isUploading}
|
303 |
+
>
|
304 |
{t('common.next')}
|
305 |
</Button>
|
306 |
</Drawer>
|
web/src/pages/search/index.tsx
CHANGED
@@ -186,7 +186,7 @@ const SearchPage = () => {
|
|
186 |
}
|
187 |
>
|
188 |
<FileIcon
|
189 |
-
id={item.
|
190 |
name={item.docnm_kwd}
|
191 |
></FileIcon>
|
192 |
{item.docnm_kwd}
|
|
|
186 |
}
|
187 |
>
|
188 |
<FileIcon
|
189 |
+
id={item.image_id}
|
190 |
name={item.docnm_kwd}
|
191 |
></FileIcon>
|
192 |
{item.docnm_kwd}
|