### What problem does this PR solve? https://github.com/infiniflow/ragflow/issues/7753 The internal is due to when the selected row keys change will trigger a testing, but I do not know why. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
79 lines
2.1 KiB
TypeScript
79 lines
2.1 KiB
TypeScript
import NewDocumentLink from '@/components/new-document-link';
|
|
import { useTranslate } from '@/hooks/common-hooks';
|
|
import {
|
|
useAllTestingResult,
|
|
useSelectTestingResult,
|
|
} from '@/hooks/knowledge-hooks';
|
|
import { ITestingDocument } from '@/interfaces/database/knowledge';
|
|
import { EyeOutlined } from '@ant-design/icons';
|
|
import { Button, Table, TableProps, Tooltip } from 'antd';
|
|
|
|
interface IProps {
|
|
handleTesting: (ids: string[]) => void;
|
|
setSelectedDocumentIds: (ids: string[]) => void;
|
|
}
|
|
|
|
const SelectFiles = ({ setSelectedDocumentIds, handleTesting }: IProps) => {
|
|
const { documents } = useSelectTestingResult();
|
|
const { documents: documentsAll } = useAllTestingResult();
|
|
const useDocuments =
|
|
documentsAll?.length > documents?.length ? documentsAll : documents;
|
|
const { t } = useTranslate('fileManager');
|
|
|
|
const columns: TableProps<ITestingDocument>['columns'] = [
|
|
{
|
|
title: 'Name',
|
|
dataIndex: 'doc_name',
|
|
key: 'doc_name',
|
|
render: (text) => <p>{text}</p>,
|
|
},
|
|
|
|
{
|
|
title: 'Hits',
|
|
dataIndex: 'count',
|
|
key: 'count',
|
|
width: 80,
|
|
},
|
|
{
|
|
title: 'View',
|
|
key: 'view',
|
|
width: 50,
|
|
render: (_, { doc_id, doc_name }) => (
|
|
<NewDocumentLink
|
|
documentName={doc_name}
|
|
documentId={doc_id}
|
|
prefix="document"
|
|
>
|
|
<Tooltip title={t('preview')}>
|
|
<Button type="text">
|
|
<EyeOutlined size={20} />
|
|
</Button>
|
|
</Tooltip>
|
|
</NewDocumentLink>
|
|
),
|
|
},
|
|
];
|
|
|
|
const rowSelection = {
|
|
onChange: (selectedRowKeys: React.Key[]) => {
|
|
handleTesting(selectedRowKeys as string[]);
|
|
setSelectedDocumentIds(selectedRowKeys as string[]);
|
|
},
|
|
getCheckboxProps: (record: ITestingDocument) => ({
|
|
disabled: record.doc_name === 'Disabled User', // Column configuration not to be checked
|
|
name: record.doc_name,
|
|
}),
|
|
};
|
|
|
|
return (
|
|
<Table
|
|
columns={columns}
|
|
dataSource={useDocuments}
|
|
showHeader={false}
|
|
rowSelection={rowSelection}
|
|
rowKey={'doc_id'}
|
|
/>
|
|
);
|
|
};
|
|
|
|
export default SelectFiles;
|