Skip to content
Snippets Groups Projects
Unverified Commit 6cf08891 authored by balibabu's avatar balibabu Committed by GitHub
Browse files

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.
parent d5587a7c
No related branches found
No related tags found
No related merge requests found
...@@ -46,6 +46,7 @@ const getParserList = ( ...@@ -46,6 +46,7 @@ const getParserList = (
}; };
export const useFetchParserListOnMount = ( export const useFetchParserListOnMount = (
documentId: string,
parserId: string, parserId: string,
documentExtension: string, documentExtension: string,
) => { ) => {
...@@ -71,7 +72,7 @@ export const useFetchParserListOnMount = ( ...@@ -71,7 +72,7 @@ export const useFetchParserListOnMount = (
useEffect(() => { useEffect(() => {
setSelectedTag(parserId); setSelectedTag(parserId);
}, [parserId]); }, [parserId, documentId]);
const handleChange = (tag: string, checked: boolean) => { const handleChange = (tag: string, checked: boolean) => {
const nextSelectedTag = checked ? tag : selectedTag; const nextSelectedTag = checked ? tag : selectedTag;
......
...@@ -36,11 +36,13 @@ interface IProps extends Omit<IModalManagerChildrenProps, 'showModal'> { ...@@ -36,11 +36,13 @@ interface IProps extends Omit<IModalManagerChildrenProps, 'showModal'> {
parserId: string; parserId: string;
parserConfig: IKnowledgeFileParserConfig; parserConfig: IKnowledgeFileParserConfig;
documentExtension: string; documentExtension: string;
documentId: string;
} }
const hidePagesChunkMethods = ['qa', 'table', 'picture', 'resume', 'one']; const hidePagesChunkMethods = ['qa', 'table', 'picture', 'resume', 'one'];
const ChunkMethodModal: React.FC<IProps> = ({ const ChunkMethodModal: React.FC<IProps> = ({
documentId,
parserId, parserId,
onOk, onOk,
hideModal, hideModal,
...@@ -49,6 +51,7 @@ const ChunkMethodModal: React.FC<IProps> = ({ ...@@ -49,6 +51,7 @@ const ChunkMethodModal: React.FC<IProps> = ({
parserConfig, parserConfig,
}) => { }) => {
const { parserList, handleChange, selectedTag } = useFetchParserListOnMount( const { parserList, handleChange, selectedTag } = useFetchParserListOnMount(
documentId,
parserId, parserId,
documentExtension, documentExtension,
); );
......
...@@ -296,6 +296,7 @@ const KnowledgeUploadFile = () => { ...@@ -296,6 +296,7 @@ const KnowledgeUploadFile = () => {
</section> </section>
</div> </div>
<ChunkMethodModal <ChunkMethodModal
documentId={currentRecord.id}
parserId={currentRecord.parser_id} parserId={currentRecord.parser_id}
parserConfig={currentRecord.parser_config} parserConfig={currentRecord.parser_config}
documentExtension={getExtension(currentRecord.name)} documentExtension={getExtension(currentRecord.name)}
......
...@@ -9,10 +9,9 @@ import { useGetKnowledgeSearchParams } from '@/hooks/routeHook'; ...@@ -9,10 +9,9 @@ import { useGetKnowledgeSearchParams } from '@/hooks/routeHook';
import { useOneNamespaceEffectsLoading } from '@/hooks/storeHooks'; import { useOneNamespaceEffectsLoading } from '@/hooks/storeHooks';
import { useFetchTenantInfo } from '@/hooks/userSettingHook'; import { useFetchTenantInfo } from '@/hooks/userSettingHook';
import { Pagination } from '@/interfaces/common'; import { Pagination } from '@/interfaces/common';
import { IKnowledgeFile } from '@/interfaces/database/knowledge';
import { IChangeParserConfigRequestBody } from '@/interfaces/request/document'; import { IChangeParserConfigRequestBody } from '@/interfaces/request/document';
import { PaginationProps } from 'antd'; import { PaginationProps } from 'antd';
import { useCallback, useEffect, useMemo, useState } from 'react'; import { useCallback, useEffect, useMemo } from 'react';
import { useDispatch, useNavigate, useSelector } from 'umi'; import { useDispatch, useNavigate, useSelector } from 'umi';
import { KnowledgeRouteKey } from './constant'; import { KnowledgeRouteKey } from './constant';
...@@ -140,18 +139,6 @@ export const useHandleSearchChange = (setPagination: () => void) => { ...@@ -140,18 +139,6 @@ export const useHandleSearchChange = (setPagination: () => void) => {
return { handleInputChange }; 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) => { export const useRenameDocument = (documentId: string) => {
const saveName = useSaveDocumentName(); const saveName = useSaveDocumentName();
......
...@@ -36,12 +36,12 @@ import { ...@@ -36,12 +36,12 @@ import {
useHandleSearchChange, useHandleSearchChange,
useNavigateToOtherPage, useNavigateToOtherPage,
useRenameDocument, useRenameDocument,
useSetSelectedRecord,
} from './hooks'; } from './hooks';
import ParsingActionCell from './parsing-action-cell'; import ParsingActionCell from './parsing-action-cell';
import ParsingStatusCell from './parsing-status-cell'; import ParsingStatusCell from './parsing-status-cell';
import RenameModal from './rename-modal'; import RenameModal from './rename-modal';
import { useSetSelectedRecord } from '@/hooks/logicHooks';
import styles from './index.less'; import styles from './index.less';
const KnowledgeFile = () => { const KnowledgeFile = () => {
...@@ -178,11 +178,8 @@ const KnowledgeFile = () => { ...@@ -178,11 +178,8 @@ const KnowledgeFile = () => {
key: 'action', key: 'action',
render: (_, record) => ( render: (_, record) => (
<ParsingActionCell <ParsingActionCell
setDocumentAndParserId={setRecord(record)} setCurrentRecord={setRecord}
showRenameModal={() => { showRenameModal={showRenameModal}
setRecord(record)();
showRenameModal();
}}
showChangeParserModal={showChangeParserModal} showChangeParserModal={showChangeParserModal}
record={record} record={record}
></ParsingActionCell> ></ParsingActionCell>
...@@ -237,6 +234,7 @@ const KnowledgeFile = () => { ...@@ -237,6 +234,7 @@ const KnowledgeFile = () => {
onOk={onCreateOk} onOk={onCreateOk}
/> />
<ChunkMethodModal <ChunkMethodModal
documentId={currentRecord.id}
parserId={currentRecord.parser_id} parserId={currentRecord.parser_id}
parserConfig={currentRecord.parser_config} parserConfig={currentRecord.parser_config}
documentExtension={getExtension(currentRecord.name)} documentExtension={getExtension(currentRecord.name)}
......
...@@ -234,7 +234,7 @@ const model: DvaModel<KFModelState> = { ...@@ -234,7 +234,7 @@ const model: DvaModel<KFModelState> = {
location.pathname === '/knowledge/dataset/upload' location.pathname === '/knowledge/dataset/upload'
) { ) {
dispatch({ dispatch({
type: 'kFModel/setPagination', type: 'setPagination',
payload: { current: 1, pageSize: 10 }, payload: { current: 1, pageSize: 10 },
}); });
} }
......
...@@ -16,14 +16,14 @@ import styles from './index.less'; ...@@ -16,14 +16,14 @@ import styles from './index.less';
interface IProps { interface IProps {
record: IKnowledgeFile; record: IKnowledgeFile;
setDocumentAndParserId: () => void; setCurrentRecord: (record: IKnowledgeFile) => void;
showRenameModal: () => void; showRenameModal: () => void;
showChangeParserModal: () => void; showChangeParserModal: () => void;
} }
const ParsingActionCell = ({ const ParsingActionCell = ({
record, record,
setDocumentAndParserId, setCurrentRecord,
showRenameModal, showRenameModal,
showChangeParserModal, showChangeParserModal,
}: IProps) => { }: IProps) => {
...@@ -45,12 +45,25 @@ const ParsingActionCell = ({ ...@@ -45,12 +45,25 @@ const ParsingActionCell = ({
}); });
}; };
const setRecord = () => {
setCurrentRecord(record);
};
const onShowRenameModal = () => {
setRecord();
showRenameModal();
};
const onShowChangeParserModal = () => {
setRecord();
showChangeParserModal();
};
const chunkItems: MenuProps['items'] = [ const chunkItems: MenuProps['items'] = [
{ {
key: '1', key: '1',
label: ( label: (
<div> <div>
<Button type="link" onClick={showChangeParserModal}> <Button type="link" onClick={onShowChangeParserModal}>
Chunk Method Chunk Method
</Button> </Button>
</div> </div>
...@@ -65,11 +78,7 @@ const ParsingActionCell = ({ ...@@ -65,11 +78,7 @@ const ParsingActionCell = ({
trigger={['click']} trigger={['click']}
disabled={isRunning} disabled={isRunning}
> >
<Button <Button type="text" className={styles.iconButton}>
type="text"
onClick={setDocumentAndParserId}
className={styles.iconButton}
>
<ToolOutlined size={20} /> <ToolOutlined size={20} />
</Button> </Button>
</Dropdown> </Dropdown>
...@@ -77,7 +86,7 @@ const ParsingActionCell = ({ ...@@ -77,7 +86,7 @@ const ParsingActionCell = ({
<Button <Button
type="text" type="text"
disabled={isRunning} disabled={isRunning}
onClick={showRenameModal} onClick={onShowRenameModal}
className={styles.iconButton} className={styles.iconButton}
> >
<EditOutlined size={20} /> <EditOutlined size={20} />
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment