import { useShowDeleteConfirm, useTranslate } from '@/hooks/common-hooks'; import { useRemoveNextDocument } from '@/hooks/document-hooks'; import { IDocumentInfo } from '@/interfaces/database/document'; import { api_host } from '@/utils/api'; import { downloadFile } from '@/utils/file-util'; import { DeleteOutlined, DownloadOutlined, EditOutlined, ToolOutlined, } from '@ant-design/icons'; import { Button, Dropdown, MenuProps, Space, Tooltip } from 'antd'; import { isParserRunning } from '../utils'; import styles from './index.less'; interface IProps { record: IDocumentInfo; setCurrentRecord: (record: IDocumentInfo) => void; showRenameModal: () => void; showChangeParserModal: () => void; } const ParsingActionCell = ({ record, setCurrentRecord, showRenameModal, showChangeParserModal, }: IProps) => { const documentId = record.id; const isRunning = isParserRunning(record.run); const { t } = useTranslate('knowledgeDetails'); const { removeDocument } = useRemoveNextDocument(); const showDeleteConfirm = useShowDeleteConfirm(); const onRmDocument = () => { if (!isRunning) { showDeleteConfirm({ onOk: () => removeDocument([documentId]) }); } }; const onDownloadDocument = () => { downloadFile({ url: `${api_host}/document/get/${documentId}`, filename: record.name, }); }; const setRecord = () => { setCurrentRecord(record); }; const onShowRenameModal = () => { setRecord(); showRenameModal(); }; const onShowChangeParserModal = () => { setRecord(); showChangeParserModal(); }; const chunkItems: MenuProps['items'] = [ { key: '1', label: (
), }, ]; return ( ); }; export default ParsingActionCell;