Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Hide the download button if it is an empty file #3762 #3853

Merged
merged 1 commit into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions web/src/constants/knowledge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,8 @@ export enum KnowledgeSearchParams {
DocumentId = 'doc_id',
KnowledgeId = 'id',
}

export enum DocumentType {
Virtual = 'virtual',
Visual = 'visual',
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
import { Button, Dropdown, MenuProps, Space, Tooltip } from 'antd';
import { isParserRunning } from '../utils';

import { DocumentType } from '../constant';
import styles from './index.less';

interface IProps {
Expand All @@ -31,6 +32,7 @@ const ParsingActionCell = ({
const { t } = useTranslate('knowledgeDetails');
const { removeDocument } = useRemoveNextDocument();
const showDeleteConfirm = useShowDeleteConfirm();
const isVirtualDocument = record.type === DocumentType.Virtual;

const onRmDocument = () => {
if (!isRunning) {
Expand Down Expand Up @@ -73,15 +75,17 @@ const ParsingActionCell = ({

return (
<Space size={0}>
<Dropdown
menu={{ items: chunkItems }}
trigger={['click']}
disabled={isRunning}
>
<Button type="text" className={styles.iconButton}>
<ToolOutlined size={20} />
</Button>
</Dropdown>
{isVirtualDocument || (
<Dropdown
menu={{ items: chunkItems }}
trigger={['click']}
disabled={isRunning}
>
<Button type="text" className={styles.iconButton}>
<ToolOutlined size={20} />
</Button>
</Dropdown>
)}
<Tooltip title={t('rename', { keyPrefix: 'common' })}>
<Button
type="text"
Expand All @@ -102,16 +106,18 @@ const ParsingActionCell = ({
<DeleteOutlined size={20} />
</Button>
</Tooltip>
<Tooltip title={t('download', { keyPrefix: 'common' })}>
<Button
type="text"
disabled={isRunning}
onClick={onDownloadDocument}
className={styles.iconButton}
>
<DownloadOutlined size={20} />
</Button>
</Tooltip>
{isVirtualDocument || (
<Tooltip title={t('download', { keyPrefix: 'common' })}>
<Button
type="text"
disabled={isRunning}
onClick={onDownloadDocument}
className={styles.iconButton}
>
<DownloadOutlined size={20} />
</Button>
</Tooltip>
)}
</Space>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Badge, DescriptionsProps, Flex, Popover, Space, Tag } from 'antd';
import classNames from 'classnames';
import { useTranslation } from 'react-i18next';
import reactStringReplace from 'react-string-replace';
import { RunningStatus, RunningStatusMap } from '../constant';
import { DocumentType, RunningStatus, RunningStatusMap } from '../constant';
import { useHandleRunDocumentByIds } from '../hooks';
import { isParserRunning } from '../utils';
import styles from './index.less';
Expand Down Expand Up @@ -96,7 +96,7 @@ export const ParsingStatusCell = ({ record }: IProps) => {
handleRunDocumentByIds(record.id, isRunning);
};

return (
return record.type === DocumentType.Virtual ? null : (
<Flex justify={'space-between'} align="center">
<Popover content={<PopoverContent record={record}></PopoverContent>}>
<Tag color={runningStatus.color}>
Expand Down