fix: omit long file names (#608)

### What problem does this PR solve?

#607
fix: omit long file names
fix: change the parsing method from tag to select
fix: replace icon for new chat
fix: change the OK button text of the Chat Bot API modal to close


### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
balibabu 2024-04-29 18:22:17 +08:00 committed by GitHub
parent 2af74cc494
commit 4c1476032d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 63 additions and 45 deletions

View File

@ -74,9 +74,9 @@ export const useFetchParserListOnMount = (
setSelectedTag(parserId); setSelectedTag(parserId);
}, [parserId, documentId]); }, [parserId, documentId]);
const handleChange = (tag: string, checked: boolean) => { const handleChange = (tag: string) => {
const nextSelectedTag = checked ? tag : selectedTag; // const nextSelectedTag = checked ? tag : selectedTag;
setSelectedTag(nextSelectedTag); setSelectedTag(tag);
}; };
return { parserList: nextParserList, handleChange, selectedTag }; return { parserList: nextParserList, handleChange, selectedTag };

View File

@ -8,3 +8,7 @@
cursor: help; cursor: help;
writing-mode: horizontal-tb; writing-mode: horizontal-tb;
} }
.chunkMethod {
margin-bottom: 0;
}

View File

@ -13,9 +13,9 @@ import {
Form, Form,
InputNumber, InputNumber,
Modal, Modal,
Select,
Space, Space,
Switch, Switch,
Tag,
Tooltip, Tooltip,
} from 'antd'; } from 'antd';
import omit from 'lodash/omit'; import omit from 'lodash/omit';
@ -25,8 +25,6 @@ import { useFetchParserListOnMount } from './hooks';
import { useTranslate } from '@/hooks/commonHooks'; import { useTranslate } from '@/hooks/commonHooks';
import styles from './index.less'; import styles from './index.less';
const { CheckableTag } = Tag;
interface IProps extends Omit<IModalManagerChildrenProps, 'showModal'> { interface IProps extends Omit<IModalManagerChildrenProps, 'showModal'> {
loading: boolean; loading: boolean;
onOk: ( onOk: (
@ -113,21 +111,14 @@ const ChunkMethodModal: React.FC<IProps> = ({
afterClose={afterClose} afterClose={afterClose}
> >
<Space size={[0, 8]} wrap> <Space size={[0, 8]} wrap>
<div className={styles.tags}> <Form.Item label={t('chunkMethod')} className={styles.chunkMethod}>
{parserList.map((x) => { <Select
return ( style={{ width: 120 }}
<CheckableTag onChange={handleChange}
key={x.value} value={selectedTag}
checked={selectedTag === x.value} options={parserList}
onChange={(checked) => { />
handleChange(x.value, checked); </Form.Item>
}}
>
{x.label}
</CheckableTag>
);
})}
</div>
</Space> </Space>
{hideDivider || <Divider></Divider>} {hideDivider || <Divider></Divider>}
<Form name="dynamic_form_nest_item" autoComplete="off" form={form}> <Form name="dynamic_form_nest_item" autoComplete="off" form={form}>

View File

@ -24,6 +24,7 @@ export default {
copied: 'Copied', copied: 'Copied',
comingSoon: 'Coming Soon', comingSoon: 'Coming Soon',
download: 'Download', download: 'Download',
close: 'Close',
}, },
login: { login: {
login: 'Sign in', login: 'Sign in',

View File

@ -24,6 +24,7 @@ export default {
copied: '複製成功', copied: '複製成功',
comingSoon: '即將推出', comingSoon: '即將推出',
download: '下載', download: '下載',
close: '关闭',
}, },
login: { login: {
login: '登入', login: '登入',

View File

@ -24,6 +24,7 @@ export default {
copied: '复制成功', copied: '复制成功',
comingSoon: '即将推出', comingSoon: '即将推出',
download: '下载', download: '下载',
close: '关闭',
}, },
login: { login: {
login: '登录', login: '登录',

View File

@ -28,7 +28,7 @@
min-width: 200px; min-width: 200px;
} }
.tochunks { .toChunks {
cursor: pointer; cursor: pointer;
} }
@ -42,3 +42,7 @@
cursor: help; cursor: help;
writing-mode: horizontal-tb; writing-mode: horizontal-tb;
} }
.nameText {
color: #1677ff;
}

View File

@ -8,7 +8,7 @@ import { useSetSelectedRecord } from '@/hooks/logicHooks';
import { useSelectParserList } from '@/hooks/userSettingHook'; import { useSelectParserList } from '@/hooks/userSettingHook';
import { IKnowledgeFile } from '@/interfaces/database/knowledge'; import { IKnowledgeFile } from '@/interfaces/database/knowledge';
import { getExtension } from '@/utils/documentUtils'; import { getExtension } from '@/utils/documentUtils';
import { Divider, Flex, Switch, Table } from 'antd'; import { Divider, Flex, Switch, Table, Typography } from 'antd';
import type { ColumnsType } from 'antd/es/table'; import type { ColumnsType } from 'antd/es/table';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import CreateFileModal from './create-file-modal'; import CreateFileModal from './create-file-modal';
@ -31,6 +31,8 @@ import FileUploadModal from '@/components/file-upload-modal';
import { formatDate } from '@/utils/date'; import { formatDate } from '@/utils/date';
import styles from './index.less'; import styles from './index.less';
const { Text } = Typography;
const KnowledgeFile = () => { const KnowledgeFile = () => {
const data = useSelectDocumentList(); const data = useSelectDocumentList();
const { fetchDocumentList } = useFetchDocumentListOnMount(); const { fetchDocumentList } = useFetchDocumentListOnMount();
@ -80,7 +82,7 @@ const KnowledgeFile = () => {
key: 'name', key: 'name',
fixed: 'left', fixed: 'left',
render: (text: any, { id, thumbnail, name }) => ( render: (text: any, { id, thumbnail, name }) => (
<div className={styles.tochunks} onClick={() => toChunk(id)}> <div className={styles.toChunks} onClick={() => toChunk(id)}>
<Flex gap={10} align="center"> <Flex gap={10} align="center">
{thumbnail ? ( {thumbnail ? (
<img className={styles.img} src={thumbnail} alt="" /> <img className={styles.img} src={thumbnail} alt="" />
@ -90,7 +92,9 @@ const KnowledgeFile = () => {
width={24} width={24}
></SvgIcon> ></SvgIcon>
)} )}
{text} <Text ellipsis={{ tooltip: text }} className={styles.nameText}>
{text}
</Text>
</Flex> </Flex>
</div> </div>
), ),

View File

@ -218,7 +218,13 @@ const model: DvaModel<KFModelState> = {
}); });
const { data } = yield call(kbService.document_upload, formData); const { data } = yield call(kbService.document_upload, formData);
if (data.retcode === 0 || data.retcode === 500) {
const succeed = data.retcode === 0;
if (succeed) {
message.success(i18n.t('message.uploaded'));
}
if (succeed || data.retcode === 500) {
yield put({ yield put({
type: 'getKfList', type: 'getKfList',
payload: { kb_id: payload.kb_id }, payload: { kb_id: payload.kb_id },

View File

@ -93,22 +93,26 @@ const ParsingActionCell = ({
<EditOutlined size={20} /> <EditOutlined size={20} />
</Button> </Button>
</Tooltip> </Tooltip>
<Button <Tooltip title={t('delete', { keyPrefix: 'common' })}>
type="text" <Button
disabled={isRunning} type="text"
onClick={onRmDocument} disabled={isRunning}
className={styles.iconButton} onClick={onRmDocument}
> className={styles.iconButton}
<DeleteOutlined size={20} /> >
</Button> <DeleteOutlined size={20} />
<Button </Button>
type="text" </Tooltip>
disabled={isRunning} <Tooltip title={t('download', { keyPrefix: 'common' })}>
onClick={onDownloadDocument} <Button
className={styles.iconButton} type="text"
> disabled={isRunning}
<DownloadOutlined size={20} /> onClick={onDownloadDocument}
</Button> className={styles.iconButton}
>
<DownloadOutlined size={20} />
</Button>
</Tooltip>
</Space> </Space>
); );
}; };

View File

@ -73,6 +73,7 @@ const ChatOverviewModal = ({
cancelButtonProps={{ style: { display: 'none' } }} cancelButtonProps={{ style: { display: 'none' } }}
onOk={hideModal} onOk={hideModal}
width={'100vw'} width={'100vw'}
okText={t('close', { keyPrefix: 'common' })}
> >
<Flex vertical gap={'middle'}> <Flex vertical gap={'middle'}>
<Card title={t('backendServiceApi')}> <Card title={t('backendServiceApi')}>

View File

@ -4,7 +4,7 @@ import {
CloudOutlined, CloudOutlined,
DeleteOutlined, DeleteOutlined,
EditOutlined, EditOutlined,
FormOutlined, PlusOutlined,
} from '@ant-design/icons'; } from '@ant-design/icons';
import { import {
Avatar, Avatar,
@ -157,7 +157,7 @@ const Chat = () => {
onClick: handleCreateTemporaryConversation, onClick: handleCreateTemporaryConversation,
label: ( label: (
<Space> <Space>
<EditOutlined /> <PlusOutlined />
{t('newChat')} {t('newChat')}
</Space> </Space>
), ),
@ -293,7 +293,8 @@ const Chat = () => {
<Tag>{conversationList.length}</Tag> <Tag>{conversationList.length}</Tag>
</Space> </Space>
<Dropdown menu={{ items }}> <Dropdown menu={{ items }}>
<FormOutlined /> {/* <FormOutlined /> */}
<PlusOutlined />
</Dropdown> </Dropdown>
</Flex> </Flex>
<Divider></Divider> <Divider></Divider>