balibabu
commited on
Commit
·
4f62080
1
Parent(s):
16d9d00
fix: fixed the issue where ChunkMethodModal cannot correctly display … (#189)
Browse filesfix: fixed the issue where ChunkMethodModal cannot correctly display the
current chunk method when switching chunk methods between two document
rows.
- web/src/components/chunk-method-modal/hooks.ts +2 -1
- web/src/components/chunk-method-modal/index.tsx +3 -0
- web/src/pages/add-knowledge/components/knowledge-dataset/knowledge-upload-file/index.tsx +1 -0
- web/src/pages/add-knowledge/components/knowledge-file/hooks.ts +1 -14
- web/src/pages/add-knowledge/components/knowledge-file/index.tsx +4 -6
- web/src/pages/add-knowledge/components/knowledge-file/model.ts +1 -1
- web/src/pages/add-knowledge/components/knowledge-file/parsing-action-cell/index.tsx +18 -9
web/src/components/chunk-method-modal/hooks.ts
CHANGED
@@ -46,6 +46,7 @@ const getParserList = (
|
|
46 |
};
|
47 |
|
48 |
export const useFetchParserListOnMount = (
|
|
|
49 |
parserId: string,
|
50 |
documentExtension: string,
|
51 |
) => {
|
@@ -71,7 +72,7 @@ export const useFetchParserListOnMount = (
|
|
71 |
|
72 |
useEffect(() => {
|
73 |
setSelectedTag(parserId);
|
74 |
-
}, [parserId]);
|
75 |
|
76 |
const handleChange = (tag: string, checked: boolean) => {
|
77 |
const nextSelectedTag = checked ? tag : selectedTag;
|
|
|
46 |
};
|
47 |
|
48 |
export const useFetchParserListOnMount = (
|
49 |
+
documentId: string,
|
50 |
parserId: string,
|
51 |
documentExtension: string,
|
52 |
) => {
|
|
|
72 |
|
73 |
useEffect(() => {
|
74 |
setSelectedTag(parserId);
|
75 |
+
}, [parserId, documentId]);
|
76 |
|
77 |
const handleChange = (tag: string, checked: boolean) => {
|
78 |
const nextSelectedTag = checked ? tag : selectedTag;
|
web/src/components/chunk-method-modal/index.tsx
CHANGED
@@ -36,11 +36,13 @@ interface IProps extends Omit<IModalManagerChildrenProps, 'showModal'> {
|
|
36 |
parserId: string;
|
37 |
parserConfig: IKnowledgeFileParserConfig;
|
38 |
documentExtension: string;
|
|
|
39 |
}
|
40 |
|
41 |
const hidePagesChunkMethods = ['qa', 'table', 'picture', 'resume', 'one'];
|
42 |
|
43 |
const ChunkMethodModal: React.FC<IProps> = ({
|
|
|
44 |
parserId,
|
45 |
onOk,
|
46 |
hideModal,
|
@@ -49,6 +51,7 @@ const ChunkMethodModal: React.FC<IProps> = ({
|
|
49 |
parserConfig,
|
50 |
}) => {
|
51 |
const { parserList, handleChange, selectedTag } = useFetchParserListOnMount(
|
|
|
52 |
parserId,
|
53 |
documentExtension,
|
54 |
);
|
|
|
36 |
parserId: string;
|
37 |
parserConfig: IKnowledgeFileParserConfig;
|
38 |
documentExtension: string;
|
39 |
+
documentId: string;
|
40 |
}
|
41 |
|
42 |
const hidePagesChunkMethods = ['qa', 'table', 'picture', 'resume', 'one'];
|
43 |
|
44 |
const ChunkMethodModal: React.FC<IProps> = ({
|
45 |
+
documentId,
|
46 |
parserId,
|
47 |
onOk,
|
48 |
hideModal,
|
|
|
51 |
parserConfig,
|
52 |
}) => {
|
53 |
const { parserList, handleChange, selectedTag } = useFetchParserListOnMount(
|
54 |
+
documentId,
|
55 |
parserId,
|
56 |
documentExtension,
|
57 |
);
|
web/src/pages/add-knowledge/components/knowledge-dataset/knowledge-upload-file/index.tsx
CHANGED
@@ -296,6 +296,7 @@ const KnowledgeUploadFile = () => {
|
|
296 |
</section>
|
297 |
</div>
|
298 |
<ChunkMethodModal
|
|
|
299 |
parserId={currentRecord.parser_id}
|
300 |
parserConfig={currentRecord.parser_config}
|
301 |
documentExtension={getExtension(currentRecord.name)}
|
|
|
296 |
</section>
|
297 |
</div>
|
298 |
<ChunkMethodModal
|
299 |
+
documentId={currentRecord.id}
|
300 |
parserId={currentRecord.parser_id}
|
301 |
parserConfig={currentRecord.parser_config}
|
302 |
documentExtension={getExtension(currentRecord.name)}
|
web/src/pages/add-knowledge/components/knowledge-file/hooks.ts
CHANGED
@@ -9,10 +9,9 @@ import { useGetKnowledgeSearchParams } from '@/hooks/routeHook';
|
|
9 |
import { useOneNamespaceEffectsLoading } from '@/hooks/storeHooks';
|
10 |
import { useFetchTenantInfo } from '@/hooks/userSettingHook';
|
11 |
import { Pagination } from '@/interfaces/common';
|
12 |
-
import { IKnowledgeFile } from '@/interfaces/database/knowledge';
|
13 |
import { IChangeParserConfigRequestBody } from '@/interfaces/request/document';
|
14 |
import { PaginationProps } from 'antd';
|
15 |
-
import { useCallback, useEffect, useMemo
|
16 |
import { useDispatch, useNavigate, useSelector } from 'umi';
|
17 |
import { KnowledgeRouteKey } from './constant';
|
18 |
|
@@ -140,18 +139,6 @@ export const useHandleSearchChange = (setPagination: () => void) => {
|
|
140 |
return { handleInputChange };
|
141 |
};
|
142 |
|
143 |
-
export const useSetSelectedRecord = () => {
|
144 |
-
const [currentRecord, setCurrentRecord] = useState<IKnowledgeFile>(
|
145 |
-
{} as IKnowledgeFile,
|
146 |
-
);
|
147 |
-
|
148 |
-
const setRecord = (record: IKnowledgeFile) => () => {
|
149 |
-
setCurrentRecord(record);
|
150 |
-
};
|
151 |
-
|
152 |
-
return { currentRecord, setRecord };
|
153 |
-
};
|
154 |
-
|
155 |
export const useRenameDocument = (documentId: string) => {
|
156 |
const saveName = useSaveDocumentName();
|
157 |
|
|
|
9 |
import { useOneNamespaceEffectsLoading } from '@/hooks/storeHooks';
|
10 |
import { useFetchTenantInfo } from '@/hooks/userSettingHook';
|
11 |
import { Pagination } from '@/interfaces/common';
|
|
|
12 |
import { IChangeParserConfigRequestBody } from '@/interfaces/request/document';
|
13 |
import { PaginationProps } from 'antd';
|
14 |
+
import { useCallback, useEffect, useMemo } from 'react';
|
15 |
import { useDispatch, useNavigate, useSelector } from 'umi';
|
16 |
import { KnowledgeRouteKey } from './constant';
|
17 |
|
|
|
139 |
return { handleInputChange };
|
140 |
};
|
141 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
export const useRenameDocument = (documentId: string) => {
|
143 |
const saveName = useSaveDocumentName();
|
144 |
|
web/src/pages/add-knowledge/components/knowledge-file/index.tsx
CHANGED
@@ -36,12 +36,12 @@ import {
|
|
36 |
useHandleSearchChange,
|
37 |
useNavigateToOtherPage,
|
38 |
useRenameDocument,
|
39 |
-
useSetSelectedRecord,
|
40 |
} from './hooks';
|
41 |
import ParsingActionCell from './parsing-action-cell';
|
42 |
import ParsingStatusCell from './parsing-status-cell';
|
43 |
import RenameModal from './rename-modal';
|
44 |
|
|
|
45 |
import styles from './index.less';
|
46 |
|
47 |
const KnowledgeFile = () => {
|
@@ -178,11 +178,8 @@ const KnowledgeFile = () => {
|
|
178 |
key: 'action',
|
179 |
render: (_, record) => (
|
180 |
<ParsingActionCell
|
181 |
-
|
182 |
-
showRenameModal={
|
183 |
-
setRecord(record)();
|
184 |
-
showRenameModal();
|
185 |
-
}}
|
186 |
showChangeParserModal={showChangeParserModal}
|
187 |
record={record}
|
188 |
></ParsingActionCell>
|
@@ -237,6 +234,7 @@ const KnowledgeFile = () => {
|
|
237 |
onOk={onCreateOk}
|
238 |
/>
|
239 |
<ChunkMethodModal
|
|
|
240 |
parserId={currentRecord.parser_id}
|
241 |
parserConfig={currentRecord.parser_config}
|
242 |
documentExtension={getExtension(currentRecord.name)}
|
|
|
36 |
useHandleSearchChange,
|
37 |
useNavigateToOtherPage,
|
38 |
useRenameDocument,
|
|
|
39 |
} from './hooks';
|
40 |
import ParsingActionCell from './parsing-action-cell';
|
41 |
import ParsingStatusCell from './parsing-status-cell';
|
42 |
import RenameModal from './rename-modal';
|
43 |
|
44 |
+
import { useSetSelectedRecord } from '@/hooks/logicHooks';
|
45 |
import styles from './index.less';
|
46 |
|
47 |
const KnowledgeFile = () => {
|
|
|
178 |
key: 'action',
|
179 |
render: (_, record) => (
|
180 |
<ParsingActionCell
|
181 |
+
setCurrentRecord={setRecord}
|
182 |
+
showRenameModal={showRenameModal}
|
|
|
|
|
|
|
183 |
showChangeParserModal={showChangeParserModal}
|
184 |
record={record}
|
185 |
></ParsingActionCell>
|
|
|
234 |
onOk={onCreateOk}
|
235 |
/>
|
236 |
<ChunkMethodModal
|
237 |
+
documentId={currentRecord.id}
|
238 |
parserId={currentRecord.parser_id}
|
239 |
parserConfig={currentRecord.parser_config}
|
240 |
documentExtension={getExtension(currentRecord.name)}
|
web/src/pages/add-knowledge/components/knowledge-file/model.ts
CHANGED
@@ -234,7 +234,7 @@ const model: DvaModel<KFModelState> = {
|
|
234 |
location.pathname === '/knowledge/dataset/upload'
|
235 |
) {
|
236 |
dispatch({
|
237 |
-
type: '
|
238 |
payload: { current: 1, pageSize: 10 },
|
239 |
});
|
240 |
}
|
|
|
234 |
location.pathname === '/knowledge/dataset/upload'
|
235 |
) {
|
236 |
dispatch({
|
237 |
+
type: 'setPagination',
|
238 |
payload: { current: 1, pageSize: 10 },
|
239 |
});
|
240 |
}
|
web/src/pages/add-knowledge/components/knowledge-file/parsing-action-cell/index.tsx
CHANGED
@@ -16,14 +16,14 @@ import styles from './index.less';
|
|
16 |
|
17 |
interface IProps {
|
18 |
record: IKnowledgeFile;
|
19 |
-
|
20 |
showRenameModal: () => void;
|
21 |
showChangeParserModal: () => void;
|
22 |
}
|
23 |
|
24 |
const ParsingActionCell = ({
|
25 |
record,
|
26 |
-
|
27 |
showRenameModal,
|
28 |
showChangeParserModal,
|
29 |
}: IProps) => {
|
@@ -45,12 +45,25 @@ const ParsingActionCell = ({
|
|
45 |
});
|
46 |
};
|
47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
const chunkItems: MenuProps['items'] = [
|
49 |
{
|
50 |
key: '1',
|
51 |
label: (
|
52 |
<div>
|
53 |
-
<Button type="link" onClick={
|
54 |
Chunk Method
|
55 |
</Button>
|
56 |
</div>
|
@@ -65,11 +78,7 @@ const ParsingActionCell = ({
|
|
65 |
trigger={['click']}
|
66 |
disabled={isRunning}
|
67 |
>
|
68 |
-
<Button
|
69 |
-
type="text"
|
70 |
-
onClick={setDocumentAndParserId}
|
71 |
-
className={styles.iconButton}
|
72 |
-
>
|
73 |
<ToolOutlined size={20} />
|
74 |
</Button>
|
75 |
</Dropdown>
|
@@ -77,7 +86,7 @@ const ParsingActionCell = ({
|
|
77 |
<Button
|
78 |
type="text"
|
79 |
disabled={isRunning}
|
80 |
-
onClick={
|
81 |
className={styles.iconButton}
|
82 |
>
|
83 |
<EditOutlined size={20} />
|
|
|
16 |
|
17 |
interface IProps {
|
18 |
record: IKnowledgeFile;
|
19 |
+
setCurrentRecord: (record: IKnowledgeFile) => void;
|
20 |
showRenameModal: () => void;
|
21 |
showChangeParserModal: () => void;
|
22 |
}
|
23 |
|
24 |
const ParsingActionCell = ({
|
25 |
record,
|
26 |
+
setCurrentRecord,
|
27 |
showRenameModal,
|
28 |
showChangeParserModal,
|
29 |
}: IProps) => {
|
|
|
45 |
});
|
46 |
};
|
47 |
|
48 |
+
const setRecord = () => {
|
49 |
+
setCurrentRecord(record);
|
50 |
+
};
|
51 |
+
|
52 |
+
const onShowRenameModal = () => {
|
53 |
+
setRecord();
|
54 |
+
showRenameModal();
|
55 |
+
};
|
56 |
+
const onShowChangeParserModal = () => {
|
57 |
+
setRecord();
|
58 |
+
showChangeParserModal();
|
59 |
+
};
|
60 |
+
|
61 |
const chunkItems: MenuProps['items'] = [
|
62 |
{
|
63 |
key: '1',
|
64 |
label: (
|
65 |
<div>
|
66 |
+
<Button type="link" onClick={onShowChangeParserModal}>
|
67 |
Chunk Method
|
68 |
</Button>
|
69 |
</div>
|
|
|
78 |
trigger={['click']}
|
79 |
disabled={isRunning}
|
80 |
>
|
81 |
+
<Button type="text" className={styles.iconButton}>
|
|
|
|
|
|
|
|
|
82 |
<ToolOutlined size={20} />
|
83 |
</Button>
|
84 |
</Dropdown>
|
|
|
86 |
<Button
|
87 |
type="text"
|
88 |
disabled={isRunning}
|
89 |
+
onClick={onShowRenameModal}
|
90 |
className={styles.iconButton}
|
91 |
>
|
92 |
<EditOutlined size={20} />
|