balibabu
commited on
Commit
·
1d4ba3c
1
Parent(s):
5112394
Fix: Hide the download button if it is an empty file #3762 (#3853)
Browse files### What problem does this PR solve?
Fix: Hide the download button if it is an empty file #3762
### Type of change
- [x] Bug Fix (non-breaking change which fixes an issue)
web/src/constants/knowledge.ts
CHANGED
@@ -57,3 +57,8 @@ export enum KnowledgeSearchParams {
|
|
57 |
DocumentId = 'doc_id',
|
58 |
KnowledgeId = 'id',
|
59 |
}
|
|
|
|
|
|
|
|
|
|
|
|
57 |
DocumentId = 'doc_id',
|
58 |
KnowledgeId = 'id',
|
59 |
}
|
60 |
+
|
61 |
+
export enum DocumentType {
|
62 |
+
Virtual = 'virtual',
|
63 |
+
Visual = 'visual',
|
64 |
+
}
|
web/src/pages/add-knowledge/components/knowledge-file/parsing-action-cell/index.tsx
CHANGED
@@ -11,6 +11,7 @@ import {
|
|
11 |
import { Button, Dropdown, MenuProps, Space, Tooltip } from 'antd';
|
12 |
import { isParserRunning } from '../utils';
|
13 |
|
|
|
14 |
import styles from './index.less';
|
15 |
|
16 |
interface IProps {
|
@@ -31,6 +32,7 @@ const ParsingActionCell = ({
|
|
31 |
const { t } = useTranslate('knowledgeDetails');
|
32 |
const { removeDocument } = useRemoveNextDocument();
|
33 |
const showDeleteConfirm = useShowDeleteConfirm();
|
|
|
34 |
|
35 |
const onRmDocument = () => {
|
36 |
if (!isRunning) {
|
@@ -73,15 +75,17 @@ const ParsingActionCell = ({
|
|
73 |
|
74 |
return (
|
75 |
<Space size={0}>
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
<
|
83 |
-
|
84 |
-
|
|
|
|
|
85 |
<Tooltip title={t('rename', { keyPrefix: 'common' })}>
|
86 |
<Button
|
87 |
type="text"
|
@@ -102,16 +106,18 @@ const ParsingActionCell = ({
|
|
102 |
<DeleteOutlined size={20} />
|
103 |
</Button>
|
104 |
</Tooltip>
|
105 |
-
|
106 |
-
<
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
|
|
|
|
115 |
</Space>
|
116 |
);
|
117 |
};
|
|
|
11 |
import { Button, Dropdown, MenuProps, Space, Tooltip } from 'antd';
|
12 |
import { isParserRunning } from '../utils';
|
13 |
|
14 |
+
import { DocumentType } from '../constant';
|
15 |
import styles from './index.less';
|
16 |
|
17 |
interface IProps {
|
|
|
32 |
const { t } = useTranslate('knowledgeDetails');
|
33 |
const { removeDocument } = useRemoveNextDocument();
|
34 |
const showDeleteConfirm = useShowDeleteConfirm();
|
35 |
+
const isVirtualDocument = record.type === DocumentType.Virtual;
|
36 |
|
37 |
const onRmDocument = () => {
|
38 |
if (!isRunning) {
|
|
|
75 |
|
76 |
return (
|
77 |
<Space size={0}>
|
78 |
+
{isVirtualDocument || (
|
79 |
+
<Dropdown
|
80 |
+
menu={{ items: chunkItems }}
|
81 |
+
trigger={['click']}
|
82 |
+
disabled={isRunning}
|
83 |
+
>
|
84 |
+
<Button type="text" className={styles.iconButton}>
|
85 |
+
<ToolOutlined size={20} />
|
86 |
+
</Button>
|
87 |
+
</Dropdown>
|
88 |
+
)}
|
89 |
<Tooltip title={t('rename', { keyPrefix: 'common' })}>
|
90 |
<Button
|
91 |
type="text"
|
|
|
106 |
<DeleteOutlined size={20} />
|
107 |
</Button>
|
108 |
</Tooltip>
|
109 |
+
{isVirtualDocument || (
|
110 |
+
<Tooltip title={t('download', { keyPrefix: 'common' })}>
|
111 |
+
<Button
|
112 |
+
type="text"
|
113 |
+
disabled={isRunning}
|
114 |
+
onClick={onDownloadDocument}
|
115 |
+
className={styles.iconButton}
|
116 |
+
>
|
117 |
+
<DownloadOutlined size={20} />
|
118 |
+
</Button>
|
119 |
+
</Tooltip>
|
120 |
+
)}
|
121 |
</Space>
|
122 |
);
|
123 |
};
|
web/src/pages/add-knowledge/components/knowledge-file/parsing-status-cell/index.tsx
CHANGED
@@ -7,7 +7,7 @@ import { Badge, DescriptionsProps, Flex, Popover, Space, Tag } from 'antd';
|
|
7 |
import classNames from 'classnames';
|
8 |
import { useTranslation } from 'react-i18next';
|
9 |
import reactStringReplace from 'react-string-replace';
|
10 |
-
import { RunningStatus, RunningStatusMap } from '../constant';
|
11 |
import { useHandleRunDocumentByIds } from '../hooks';
|
12 |
import { isParserRunning } from '../utils';
|
13 |
import styles from './index.less';
|
@@ -96,7 +96,7 @@ export const ParsingStatusCell = ({ record }: IProps) => {
|
|
96 |
handleRunDocumentByIds(record.id, isRunning);
|
97 |
};
|
98 |
|
99 |
-
return (
|
100 |
<Flex justify={'space-between'} align="center">
|
101 |
<Popover content={<PopoverContent record={record}></PopoverContent>}>
|
102 |
<Tag color={runningStatus.color}>
|
|
|
7 |
import classNames from 'classnames';
|
8 |
import { useTranslation } from 'react-i18next';
|
9 |
import reactStringReplace from 'react-string-replace';
|
10 |
+
import { DocumentType, RunningStatus, RunningStatusMap } from '../constant';
|
11 |
import { useHandleRunDocumentByIds } from '../hooks';
|
12 |
import { isParserRunning } from '../utils';
|
13 |
import styles from './index.less';
|
|
|
96 |
handleRunDocumentByIds(record.id, isRunning);
|
97 |
};
|
98 |
|
99 |
+
return record.type === DocumentType.Virtual ? null : (
|
100 |
<Flex justify={'space-between'} align="center">
|
101 |
<Popover content={<PopoverContent record={record}></PopoverContent>}>
|
102 |
<Tag color={runningStatus.color}>
|