Files
ragflow/web/src/pages/add-knowledge/components/knowledge-testing/testing-result/select-files.tsx
balibabu 58e95f76c1 feat: change all file names to lowercase #1574 (#1575)
### What problem does this PR solve?

feat: change all file names to lowercase #1574

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
2024-07-17 19:07:34 +08:00

76 lines
1.9 KiB
TypeScript

import { ReactComponent as NavigationPointerIcon } from '@/assets/svg/navigation-pointer.svg';
import NewDocumentLink from '@/components/new-document-link';
import { useGetDocumentUrl } from '@/hooks/document-hooks';
import { ITestingDocument } from '@/interfaces/database/knowledge';
import { isPdf } from '@/utils/documentUtils';
import { Table, TableProps } from 'antd';
import { useDispatch, useSelector } from 'umi';
interface IProps {
handleTesting: () => Promise<any>;
}
const SelectFiles = ({ handleTesting }: IProps) => {
const documents: ITestingDocument[] = useSelector(
(state: any) => state.testingModel.documents,
);
const dispatch = useDispatch();
const getDocumentUrl = useGetDocumentUrl();
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
link={getDocumentUrl(doc_id)}
preventDefault={!isPdf(doc_name)}
>
<NavigationPointerIcon />
</NewDocumentLink>
),
},
];
const rowSelection = {
onChange: (selectedRowKeys: React.Key[]) => {
dispatch({
type: 'testingModel/setSelectedDocumentIds',
payload: selectedRowKeys,
});
handleTesting();
},
getCheckboxProps: (record: ITestingDocument) => ({
disabled: record.doc_name === 'Disabled User', // Column configuration not to be checked
name: record.doc_name,
}),
};
return (
<Table
columns={columns}
dataSource={documents}
showHeader={false}
rowSelection={rowSelection}
rowKey={'doc_id'}
/>
);
};
export default SelectFiles;