mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-09-25 16:16:01 +00:00
fix: fixed the issue where ChunkMethodModal cannot correctly display … (#189)
fix: fixed the issue where ChunkMethodModal cannot correctly display the current chunk method when switching chunk methods between two document rows.
This commit is contained in:
parent
d5587a7cc1
commit
6cf088911f
@ -46,6 +46,7 @@ const getParserList = (
|
||||
};
|
||||
|
||||
export const useFetchParserListOnMount = (
|
||||
documentId: string,
|
||||
parserId: string,
|
||||
documentExtension: string,
|
||||
) => {
|
||||
@ -71,7 +72,7 @@ export const useFetchParserListOnMount = (
|
||||
|
||||
useEffect(() => {
|
||||
setSelectedTag(parserId);
|
||||
}, [parserId]);
|
||||
}, [parserId, documentId]);
|
||||
|
||||
const handleChange = (tag: string, checked: boolean) => {
|
||||
const nextSelectedTag = checked ? tag : selectedTag;
|
||||
|
@ -36,11 +36,13 @@ interface IProps extends Omit<IModalManagerChildrenProps, 'showModal'> {
|
||||
parserId: string;
|
||||
parserConfig: IKnowledgeFileParserConfig;
|
||||
documentExtension: string;
|
||||
documentId: string;
|
||||
}
|
||||
|
||||
const hidePagesChunkMethods = ['qa', 'table', 'picture', 'resume', 'one'];
|
||||
|
||||
const ChunkMethodModal: React.FC<IProps> = ({
|
||||
documentId,
|
||||
parserId,
|
||||
onOk,
|
||||
hideModal,
|
||||
@ -49,6 +51,7 @@ const ChunkMethodModal: React.FC<IProps> = ({
|
||||
parserConfig,
|
||||
}) => {
|
||||
const { parserList, handleChange, selectedTag } = useFetchParserListOnMount(
|
||||
documentId,
|
||||
parserId,
|
||||
documentExtension,
|
||||
);
|
||||
|
@ -296,6 +296,7 @@ const KnowledgeUploadFile = () => {
|
||||
</section>
|
||||
</div>
|
||||
<ChunkMethodModal
|
||||
documentId={currentRecord.id}
|
||||
parserId={currentRecord.parser_id}
|
||||
parserConfig={currentRecord.parser_config}
|
||||
documentExtension={getExtension(currentRecord.name)}
|
||||
|
@ -9,10 +9,9 @@ import { useGetKnowledgeSearchParams } from '@/hooks/routeHook';
|
||||
import { useOneNamespaceEffectsLoading } from '@/hooks/storeHooks';
|
||||
import { useFetchTenantInfo } from '@/hooks/userSettingHook';
|
||||
import { Pagination } from '@/interfaces/common';
|
||||
import { IKnowledgeFile } from '@/interfaces/database/knowledge';
|
||||
import { IChangeParserConfigRequestBody } from '@/interfaces/request/document';
|
||||
import { PaginationProps } from 'antd';
|
||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { useCallback, useEffect, useMemo } from 'react';
|
||||
import { useDispatch, useNavigate, useSelector } from 'umi';
|
||||
import { KnowledgeRouteKey } from './constant';
|
||||
|
||||
@ -140,18 +139,6 @@ export const useHandleSearchChange = (setPagination: () => void) => {
|
||||
return { handleInputChange };
|
||||
};
|
||||
|
||||
export const useSetSelectedRecord = () => {
|
||||
const [currentRecord, setCurrentRecord] = useState<IKnowledgeFile>(
|
||||
{} as IKnowledgeFile,
|
||||
);
|
||||
|
||||
const setRecord = (record: IKnowledgeFile) => () => {
|
||||
setCurrentRecord(record);
|
||||
};
|
||||
|
||||
return { currentRecord, setRecord };
|
||||
};
|
||||
|
||||
export const useRenameDocument = (documentId: string) => {
|
||||
const saveName = useSaveDocumentName();
|
||||
|
||||
|
@ -36,12 +36,12 @@ import {
|
||||
useHandleSearchChange,
|
||||
useNavigateToOtherPage,
|
||||
useRenameDocument,
|
||||
useSetSelectedRecord,
|
||||
} from './hooks';
|
||||
import ParsingActionCell from './parsing-action-cell';
|
||||
import ParsingStatusCell from './parsing-status-cell';
|
||||
import RenameModal from './rename-modal';
|
||||
|
||||
import { useSetSelectedRecord } from '@/hooks/logicHooks';
|
||||
import styles from './index.less';
|
||||
|
||||
const KnowledgeFile = () => {
|
||||
@ -178,11 +178,8 @@ const KnowledgeFile = () => {
|
||||
key: 'action',
|
||||
render: (_, record) => (
|
||||
<ParsingActionCell
|
||||
setDocumentAndParserId={setRecord(record)}
|
||||
showRenameModal={() => {
|
||||
setRecord(record)();
|
||||
showRenameModal();
|
||||
}}
|
||||
setCurrentRecord={setRecord}
|
||||
showRenameModal={showRenameModal}
|
||||
showChangeParserModal={showChangeParserModal}
|
||||
record={record}
|
||||
></ParsingActionCell>
|
||||
@ -237,6 +234,7 @@ const KnowledgeFile = () => {
|
||||
onOk={onCreateOk}
|
||||
/>
|
||||
<ChunkMethodModal
|
||||
documentId={currentRecord.id}
|
||||
parserId={currentRecord.parser_id}
|
||||
parserConfig={currentRecord.parser_config}
|
||||
documentExtension={getExtension(currentRecord.name)}
|
||||
|
@ -234,7 +234,7 @@ const model: DvaModel<KFModelState> = {
|
||||
location.pathname === '/knowledge/dataset/upload'
|
||||
) {
|
||||
dispatch({
|
||||
type: 'kFModel/setPagination',
|
||||
type: 'setPagination',
|
||||
payload: { current: 1, pageSize: 10 },
|
||||
});
|
||||
}
|
||||
|
@ -16,14 +16,14 @@ import styles from './index.less';
|
||||
|
||||
interface IProps {
|
||||
record: IKnowledgeFile;
|
||||
setDocumentAndParserId: () => void;
|
||||
setCurrentRecord: (record: IKnowledgeFile) => void;
|
||||
showRenameModal: () => void;
|
||||
showChangeParserModal: () => void;
|
||||
}
|
||||
|
||||
const ParsingActionCell = ({
|
||||
record,
|
||||
setDocumentAndParserId,
|
||||
setCurrentRecord,
|
||||
showRenameModal,
|
||||
showChangeParserModal,
|
||||
}: IProps) => {
|
||||
@ -45,12 +45,25 @@ const ParsingActionCell = ({
|
||||
});
|
||||
};
|
||||
|
||||
const setRecord = () => {
|
||||
setCurrentRecord(record);
|
||||
};
|
||||
|
||||
const onShowRenameModal = () => {
|
||||
setRecord();
|
||||
showRenameModal();
|
||||
};
|
||||
const onShowChangeParserModal = () => {
|
||||
setRecord();
|
||||
showChangeParserModal();
|
||||
};
|
||||
|
||||
const chunkItems: MenuProps['items'] = [
|
||||
{
|
||||
key: '1',
|
||||
label: (
|
||||
<div>
|
||||
<Button type="link" onClick={showChangeParserModal}>
|
||||
<Button type="link" onClick={onShowChangeParserModal}>
|
||||
Chunk Method
|
||||
</Button>
|
||||
</div>
|
||||
@ -65,11 +78,7 @@ const ParsingActionCell = ({
|
||||
trigger={['click']}
|
||||
disabled={isRunning}
|
||||
>
|
||||
<Button
|
||||
type="text"
|
||||
onClick={setDocumentAndParserId}
|
||||
className={styles.iconButton}
|
||||
>
|
||||
<Button type="text" className={styles.iconButton}>
|
||||
<ToolOutlined size={20} />
|
||||
</Button>
|
||||
</Dropdown>
|
||||
@ -77,7 +86,7 @@ const ParsingActionCell = ({
|
||||
<Button
|
||||
type="text"
|
||||
disabled={isRunning}
|
||||
onClick={showRenameModal}
|
||||
onClick={onShowRenameModal}
|
||||
className={styles.iconButton}
|
||||
>
|
||||
<EditOutlined size={20} />
|
||||
|
Loading…
x
Reference in New Issue
Block a user