mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
### What problem does this PR solve? Feat: Reparse a file shall reuse existing chunks if possible #3793 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -213,6 +213,7 @@ export const useHandleRunDocumentByIds = (id: string) => {
|
||||
const handleRunDocumentByIds = async (
|
||||
documentId: string,
|
||||
isRunning: boolean,
|
||||
shouldDelete: boolean = false,
|
||||
) => {
|
||||
if (isLoading) {
|
||||
return;
|
||||
@ -222,6 +223,7 @@ export const useHandleRunDocumentByIds = (id: string) => {
|
||||
await runDocumentByIds({
|
||||
documentIds: [documentId],
|
||||
run: isRunning ? 2 : 1,
|
||||
shouldDelete,
|
||||
});
|
||||
setCurrentId('');
|
||||
} catch (error) {
|
||||
|
||||
@ -3,7 +3,15 @@ import { ReactComponent as RefreshIcon } from '@/assets/svg/refresh.svg';
|
||||
import { ReactComponent as RunIcon } from '@/assets/svg/run.svg';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { IDocumentInfo } from '@/interfaces/database/document';
|
||||
import { Badge, DescriptionsProps, Flex, Popover, Space, Tag } from 'antd';
|
||||
import {
|
||||
Badge,
|
||||
DescriptionsProps,
|
||||
Flex,
|
||||
Popconfirm,
|
||||
Popover,
|
||||
Space,
|
||||
Tag,
|
||||
} from 'antd';
|
||||
import classNames from 'classnames';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import reactStringReplace from 'react-string-replace';
|
||||
@ -92,9 +100,11 @@ export const ParsingStatusCell = ({ record }: IProps) => {
|
||||
|
||||
const label = t(`knowledgeDetails.runningStatus${text}`);
|
||||
|
||||
const handleOperationIconClick = () => {
|
||||
handleRunDocumentByIds(record.id, isRunning);
|
||||
};
|
||||
const handleOperationIconClick =
|
||||
(shouldDelete: boolean = false) =>
|
||||
() => {
|
||||
handleRunDocumentByIds(record.id, isRunning, shouldDelete);
|
||||
};
|
||||
|
||||
return record.type === DocumentType.Virtual ? null : (
|
||||
<Flex justify={'space-between'} align="center">
|
||||
@ -111,14 +121,25 @@ export const ParsingStatusCell = ({ record }: IProps) => {
|
||||
)}
|
||||
</Tag>
|
||||
</Popover>
|
||||
<div
|
||||
onClick={handleOperationIconClick}
|
||||
className={classNames(styles.operationIcon, {
|
||||
[styles.operationIconSpin]: loading,
|
||||
})}
|
||||
<Popconfirm
|
||||
title={t(`knowledgeDetails.redo`, { chunkNum: record.chunk_num })}
|
||||
onConfirm={handleOperationIconClick(true)}
|
||||
onCancel={handleOperationIconClick(false)}
|
||||
disabled={record.chunk_num === 0}
|
||||
okText={t('common.ok')}
|
||||
cancelText={t('common.cancel')}
|
||||
>
|
||||
<OperationIcon />
|
||||
</div>
|
||||
<div
|
||||
className={classNames(styles.operationIcon, {
|
||||
[styles.operationIconSpin]: loading,
|
||||
})}
|
||||
onClick={
|
||||
record.chunk_num === 0 ? handleOperationIconClick(false) : () => {}
|
||||
}
|
||||
>
|
||||
<OperationIcon />
|
||||
</div>
|
||||
</Popconfirm>
|
||||
</Flex>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user