Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

index.tsx 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. import { useShowDeleteConfirm, useTranslate } from '@/hooks/common-hooks';
  2. import { useRemoveDocument } from '@/hooks/document-hooks';
  3. import { IKnowledgeFile } from '@/interfaces/database/knowledge';
  4. import { api_host } from '@/utils/api';
  5. import { downloadFile } from '@/utils/file-util';
  6. import {
  7. DeleteOutlined,
  8. DownloadOutlined,
  9. EditOutlined,
  10. ToolOutlined,
  11. } from '@ant-design/icons';
  12. import { Button, Dropdown, MenuProps, Space, Tooltip } from 'antd';
  13. import { isParserRunning } from '../utils';
  14. import styles from './index.less';
  15. interface IProps {
  16. record: IKnowledgeFile;
  17. setCurrentRecord: (record: IKnowledgeFile) => void;
  18. showRenameModal: () => void;
  19. showChangeParserModal: () => void;
  20. }
  21. const ParsingActionCell = ({
  22. record,
  23. setCurrentRecord,
  24. showRenameModal,
  25. showChangeParserModal,
  26. }: IProps) => {
  27. const documentId = record.id;
  28. const isRunning = isParserRunning(record.run);
  29. const { t } = useTranslate('knowledgeDetails');
  30. const removeDocument = useRemoveDocument();
  31. const showDeleteConfirm = useShowDeleteConfirm();
  32. const onRmDocument = () => {
  33. if (!isRunning) {
  34. showDeleteConfirm({ onOk: () => removeDocument([documentId]) });
  35. }
  36. };
  37. const onDownloadDocument = () => {
  38. downloadFile({
  39. url: `${api_host}/document/get/${documentId}`,
  40. filename: record.name,
  41. });
  42. };
  43. const setRecord = () => {
  44. setCurrentRecord(record);
  45. };
  46. const onShowRenameModal = () => {
  47. setRecord();
  48. showRenameModal();
  49. };
  50. const onShowChangeParserModal = () => {
  51. setRecord();
  52. showChangeParserModal();
  53. };
  54. const chunkItems: MenuProps['items'] = [
  55. {
  56. key: '1',
  57. label: (
  58. <div>
  59. <Button type="link" onClick={onShowChangeParserModal}>
  60. {t('chunkMethod')}
  61. </Button>
  62. </div>
  63. ),
  64. },
  65. ];
  66. return (
  67. <Space size={0}>
  68. <Dropdown
  69. menu={{ items: chunkItems }}
  70. trigger={['click']}
  71. disabled={isRunning}
  72. >
  73. <Button type="text" className={styles.iconButton}>
  74. <ToolOutlined size={20} />
  75. </Button>
  76. </Dropdown>
  77. <Tooltip title={t('rename', { keyPrefix: 'common' })}>
  78. <Button
  79. type="text"
  80. disabled={isRunning}
  81. onClick={onShowRenameModal}
  82. className={styles.iconButton}
  83. >
  84. <EditOutlined size={20} />
  85. </Button>
  86. </Tooltip>
  87. <Tooltip title={t('delete', { keyPrefix: 'common' })}>
  88. <Button
  89. type="text"
  90. disabled={isRunning}
  91. onClick={onRmDocument}
  92. className={styles.iconButton}
  93. >
  94. <DeleteOutlined size={20} />
  95. </Button>
  96. </Tooltip>
  97. <Tooltip title={t('download', { keyPrefix: 'common' })}>
  98. <Button
  99. type="text"
  100. disabled={isRunning}
  101. onClick={onDownloadDocument}
  102. className={styles.iconButton}
  103. >
  104. <DownloadOutlined size={20} />
  105. </Button>
  106. </Tooltip>
  107. </Space>
  108. );
  109. };
  110. export default ParsingActionCell;