balibabu
commited on
Commit
·
d13f144
1
Parent(s):
da67205
fix: omit long file names (#608)
Browse files### 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)
- web/src/components/chunk-method-modal/hooks.ts +3 -3
- web/src/components/chunk-method-modal/index.less +4 -0
- web/src/components/chunk-method-modal/index.tsx +9 -18
- web/src/locales/en.ts +1 -0
- web/src/locales/zh-traditional.ts +1 -0
- web/src/locales/zh.ts +1 -0
- web/src/pages/add-knowledge/components/knowledge-file/index.less +5 -1
- web/src/pages/add-knowledge/components/knowledge-file/index.tsx +7 -3
- web/src/pages/add-knowledge/components/knowledge-file/model.ts +7 -1
- web/src/pages/add-knowledge/components/knowledge-file/parsing-action-cell/index.tsx +20 -16
- web/src/pages/chat/chat-overview-modal/index.tsx +1 -0
- web/src/pages/chat/index.tsx +4 -3
web/src/components/chunk-method-modal/hooks.ts
CHANGED
@@ -74,9 +74,9 @@ export const useFetchParserListOnMount = (
|
|
74 |
setSelectedTag(parserId);
|
75 |
}, [parserId, documentId]);
|
76 |
|
77 |
-
const handleChange = (tag: string
|
78 |
-
const nextSelectedTag = checked ? tag : selectedTag;
|
79 |
-
setSelectedTag(
|
80 |
};
|
81 |
|
82 |
return { parserList: nextParserList, handleChange, selectedTag };
|
|
|
74 |
setSelectedTag(parserId);
|
75 |
}, [parserId, documentId]);
|
76 |
|
77 |
+
const handleChange = (tag: string) => {
|
78 |
+
// const nextSelectedTag = checked ? tag : selectedTag;
|
79 |
+
setSelectedTag(tag);
|
80 |
};
|
81 |
|
82 |
return { parserList: nextParserList, handleChange, selectedTag };
|
web/src/components/chunk-method-modal/index.less
CHANGED
@@ -8,3 +8,7 @@
|
|
8 |
cursor: help;
|
9 |
writing-mode: horizontal-tb;
|
10 |
}
|
|
|
|
|
|
|
|
|
|
8 |
cursor: help;
|
9 |
writing-mode: horizontal-tb;
|
10 |
}
|
11 |
+
|
12 |
+
.chunkMethod {
|
13 |
+
margin-bottom: 0;
|
14 |
+
}
|
web/src/components/chunk-method-modal/index.tsx
CHANGED
@@ -13,9 +13,9 @@ import {
|
|
13 |
Form,
|
14 |
InputNumber,
|
15 |
Modal,
|
|
|
16 |
Space,
|
17 |
Switch,
|
18 |
-
Tag,
|
19 |
Tooltip,
|
20 |
} from 'antd';
|
21 |
import omit from 'lodash/omit';
|
@@ -25,8 +25,6 @@ import { useFetchParserListOnMount } from './hooks';
|
|
25 |
import { useTranslate } from '@/hooks/commonHooks';
|
26 |
import styles from './index.less';
|
27 |
|
28 |
-
const { CheckableTag } = Tag;
|
29 |
-
|
30 |
interface IProps extends Omit<IModalManagerChildrenProps, 'showModal'> {
|
31 |
loading: boolean;
|
32 |
onOk: (
|
@@ -113,21 +111,14 @@ const ChunkMethodModal: React.FC<IProps> = ({
|
|
113 |
afterClose={afterClose}
|
114 |
>
|
115 |
<Space size={[0, 8]} wrap>
|
116 |
-
<
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
}}
|
125 |
-
>
|
126 |
-
{x.label}
|
127 |
-
</CheckableTag>
|
128 |
-
);
|
129 |
-
})}
|
130 |
-
</div>
|
131 |
</Space>
|
132 |
{hideDivider || <Divider></Divider>}
|
133 |
<Form name="dynamic_form_nest_item" autoComplete="off" form={form}>
|
|
|
13 |
Form,
|
14 |
InputNumber,
|
15 |
Modal,
|
16 |
+
Select,
|
17 |
Space,
|
18 |
Switch,
|
|
|
19 |
Tooltip,
|
20 |
} from 'antd';
|
21 |
import omit from 'lodash/omit';
|
|
|
25 |
import { useTranslate } from '@/hooks/commonHooks';
|
26 |
import styles from './index.less';
|
27 |
|
|
|
|
|
28 |
interface IProps extends Omit<IModalManagerChildrenProps, 'showModal'> {
|
29 |
loading: boolean;
|
30 |
onOk: (
|
|
|
111 |
afterClose={afterClose}
|
112 |
>
|
113 |
<Space size={[0, 8]} wrap>
|
114 |
+
<Form.Item label={t('chunkMethod')} className={styles.chunkMethod}>
|
115 |
+
<Select
|
116 |
+
style={{ width: 120 }}
|
117 |
+
onChange={handleChange}
|
118 |
+
value={selectedTag}
|
119 |
+
options={parserList}
|
120 |
+
/>
|
121 |
+
</Form.Item>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
</Space>
|
123 |
{hideDivider || <Divider></Divider>}
|
124 |
<Form name="dynamic_form_nest_item" autoComplete="off" form={form}>
|
web/src/locales/en.ts
CHANGED
@@ -24,6 +24,7 @@ export default {
|
|
24 |
copied: 'Copied',
|
25 |
comingSoon: 'Coming Soon',
|
26 |
download: 'Download',
|
|
|
27 |
},
|
28 |
login: {
|
29 |
login: 'Sign in',
|
|
|
24 |
copied: 'Copied',
|
25 |
comingSoon: 'Coming Soon',
|
26 |
download: 'Download',
|
27 |
+
close: 'Close',
|
28 |
},
|
29 |
login: {
|
30 |
login: 'Sign in',
|
web/src/locales/zh-traditional.ts
CHANGED
@@ -24,6 +24,7 @@ export default {
|
|
24 |
copied: '複製成功',
|
25 |
comingSoon: '即將推出',
|
26 |
download: '下載',
|
|
|
27 |
},
|
28 |
login: {
|
29 |
login: '登入',
|
|
|
24 |
copied: '複製成功',
|
25 |
comingSoon: '即將推出',
|
26 |
download: '下載',
|
27 |
+
close: '关闭',
|
28 |
},
|
29 |
login: {
|
30 |
login: '登入',
|
web/src/locales/zh.ts
CHANGED
@@ -24,6 +24,7 @@ export default {
|
|
24 |
copied: '复制成功',
|
25 |
comingSoon: '即将推出',
|
26 |
download: '下载',
|
|
|
27 |
},
|
28 |
login: {
|
29 |
login: '登录',
|
|
|
24 |
copied: '复制成功',
|
25 |
comingSoon: '即将推出',
|
26 |
download: '下载',
|
27 |
+
close: '关闭',
|
28 |
},
|
29 |
login: {
|
30 |
login: '登录',
|
web/src/pages/add-knowledge/components/knowledge-file/index.less
CHANGED
@@ -28,7 +28,7 @@
|
|
28 |
min-width: 200px;
|
29 |
}
|
30 |
|
31 |
-
.
|
32 |
cursor: pointer;
|
33 |
}
|
34 |
|
@@ -42,3 +42,7 @@
|
|
42 |
cursor: help;
|
43 |
writing-mode: horizontal-tb;
|
44 |
}
|
|
|
|
|
|
|
|
|
|
28 |
min-width: 200px;
|
29 |
}
|
30 |
|
31 |
+
.toChunks {
|
32 |
cursor: pointer;
|
33 |
}
|
34 |
|
|
|
42 |
cursor: help;
|
43 |
writing-mode: horizontal-tb;
|
44 |
}
|
45 |
+
|
46 |
+
.nameText {
|
47 |
+
color: #1677ff;
|
48 |
+
}
|
web/src/pages/add-knowledge/components/knowledge-file/index.tsx
CHANGED
@@ -8,7 +8,7 @@ import { useSetSelectedRecord } from '@/hooks/logicHooks';
|
|
8 |
import { useSelectParserList } from '@/hooks/userSettingHook';
|
9 |
import { IKnowledgeFile } from '@/interfaces/database/knowledge';
|
10 |
import { getExtension } from '@/utils/documentUtils';
|
11 |
-
import { Divider, Flex, Switch, Table } from 'antd';
|
12 |
import type { ColumnsType } from 'antd/es/table';
|
13 |
import { useTranslation } from 'react-i18next';
|
14 |
import CreateFileModal from './create-file-modal';
|
@@ -31,6 +31,8 @@ import FileUploadModal from '@/components/file-upload-modal';
|
|
31 |
import { formatDate } from '@/utils/date';
|
32 |
import styles from './index.less';
|
33 |
|
|
|
|
|
34 |
const KnowledgeFile = () => {
|
35 |
const data = useSelectDocumentList();
|
36 |
const { fetchDocumentList } = useFetchDocumentListOnMount();
|
@@ -80,7 +82,7 @@ const KnowledgeFile = () => {
|
|
80 |
key: 'name',
|
81 |
fixed: 'left',
|
82 |
render: (text: any, { id, thumbnail, name }) => (
|
83 |
-
<div className={styles.
|
84 |
<Flex gap={10} align="center">
|
85 |
{thumbnail ? (
|
86 |
<img className={styles.img} src={thumbnail} alt="" />
|
@@ -90,7 +92,9 @@ const KnowledgeFile = () => {
|
|
90 |
width={24}
|
91 |
></SvgIcon>
|
92 |
)}
|
93 |
-
{text}
|
|
|
|
|
94 |
</Flex>
|
95 |
</div>
|
96 |
),
|
|
|
8 |
import { useSelectParserList } from '@/hooks/userSettingHook';
|
9 |
import { IKnowledgeFile } from '@/interfaces/database/knowledge';
|
10 |
import { getExtension } from '@/utils/documentUtils';
|
11 |
+
import { Divider, Flex, Switch, Table, Typography } from 'antd';
|
12 |
import type { ColumnsType } from 'antd/es/table';
|
13 |
import { useTranslation } from 'react-i18next';
|
14 |
import CreateFileModal from './create-file-modal';
|
|
|
31 |
import { formatDate } from '@/utils/date';
|
32 |
import styles from './index.less';
|
33 |
|
34 |
+
const { Text } = Typography;
|
35 |
+
|
36 |
const KnowledgeFile = () => {
|
37 |
const data = useSelectDocumentList();
|
38 |
const { fetchDocumentList } = useFetchDocumentListOnMount();
|
|
|
82 |
key: 'name',
|
83 |
fixed: 'left',
|
84 |
render: (text: any, { id, thumbnail, name }) => (
|
85 |
+
<div className={styles.toChunks} onClick={() => toChunk(id)}>
|
86 |
<Flex gap={10} align="center">
|
87 |
{thumbnail ? (
|
88 |
<img className={styles.img} src={thumbnail} alt="" />
|
|
|
92 |
width={24}
|
93 |
></SvgIcon>
|
94 |
)}
|
95 |
+
<Text ellipsis={{ tooltip: text }} className={styles.nameText}>
|
96 |
+
{text}
|
97 |
+
</Text>
|
98 |
</Flex>
|
99 |
</div>
|
100 |
),
|
web/src/pages/add-knowledge/components/knowledge-file/model.ts
CHANGED
@@ -218,7 +218,13 @@ const model: DvaModel<KFModelState> = {
|
|
218 |
});
|
219 |
|
220 |
const { data } = yield call(kbService.document_upload, formData);
|
221 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
222 |
yield put({
|
223 |
type: 'getKfList',
|
224 |
payload: { kb_id: payload.kb_id },
|
|
|
218 |
});
|
219 |
|
220 |
const { data } = yield call(kbService.document_upload, formData);
|
221 |
+
|
222 |
+
const succeed = data.retcode === 0;
|
223 |
+
|
224 |
+
if (succeed) {
|
225 |
+
message.success(i18n.t('message.uploaded'));
|
226 |
+
}
|
227 |
+
if (succeed || data.retcode === 500) {
|
228 |
yield put({
|
229 |
type: 'getKfList',
|
230 |
payload: { kb_id: payload.kb_id },
|
web/src/pages/add-knowledge/components/knowledge-file/parsing-action-cell/index.tsx
CHANGED
@@ -93,22 +93,26 @@ const ParsingActionCell = ({
|
|
93 |
<EditOutlined size={20} />
|
94 |
</Button>
|
95 |
</Tooltip>
|
96 |
-
<
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
|
|
|
|
|
|
|
|
112 |
</Space>
|
113 |
);
|
114 |
};
|
|
|
93 |
<EditOutlined size={20} />
|
94 |
</Button>
|
95 |
</Tooltip>
|
96 |
+
<Tooltip title={t('delete', { keyPrefix: 'common' })}>
|
97 |
+
<Button
|
98 |
+
type="text"
|
99 |
+
disabled={isRunning}
|
100 |
+
onClick={onRmDocument}
|
101 |
+
className={styles.iconButton}
|
102 |
+
>
|
103 |
+
<DeleteOutlined size={20} />
|
104 |
+
</Button>
|
105 |
+
</Tooltip>
|
106 |
+
<Tooltip title={t('download', { keyPrefix: 'common' })}>
|
107 |
+
<Button
|
108 |
+
type="text"
|
109 |
+
disabled={isRunning}
|
110 |
+
onClick={onDownloadDocument}
|
111 |
+
className={styles.iconButton}
|
112 |
+
>
|
113 |
+
<DownloadOutlined size={20} />
|
114 |
+
</Button>
|
115 |
+
</Tooltip>
|
116 |
</Space>
|
117 |
);
|
118 |
};
|
web/src/pages/chat/chat-overview-modal/index.tsx
CHANGED
@@ -73,6 +73,7 @@ const ChatOverviewModal = ({
|
|
73 |
cancelButtonProps={{ style: { display: 'none' } }}
|
74 |
onOk={hideModal}
|
75 |
width={'100vw'}
|
|
|
76 |
>
|
77 |
<Flex vertical gap={'middle'}>
|
78 |
<Card title={t('backendServiceApi')}>
|
|
|
73 |
cancelButtonProps={{ style: { display: 'none' } }}
|
74 |
onOk={hideModal}
|
75 |
width={'100vw'}
|
76 |
+
okText={t('close', { keyPrefix: 'common' })}
|
77 |
>
|
78 |
<Flex vertical gap={'middle'}>
|
79 |
<Card title={t('backendServiceApi')}>
|
web/src/pages/chat/index.tsx
CHANGED
@@ -4,7 +4,7 @@ import {
|
|
4 |
CloudOutlined,
|
5 |
DeleteOutlined,
|
6 |
EditOutlined,
|
7 |
-
|
8 |
} from '@ant-design/icons';
|
9 |
import {
|
10 |
Avatar,
|
@@ -157,7 +157,7 @@ const Chat = () => {
|
|
157 |
onClick: handleCreateTemporaryConversation,
|
158 |
label: (
|
159 |
<Space>
|
160 |
-
<
|
161 |
{t('newChat')}
|
162 |
</Space>
|
163 |
),
|
@@ -293,7 +293,8 @@ const Chat = () => {
|
|
293 |
<Tag>{conversationList.length}</Tag>
|
294 |
</Space>
|
295 |
<Dropdown menu={{ items }}>
|
296 |
-
<FormOutlined />
|
|
|
297 |
</Dropdown>
|
298 |
</Flex>
|
299 |
<Divider></Divider>
|
|
|
4 |
CloudOutlined,
|
5 |
DeleteOutlined,
|
6 |
EditOutlined,
|
7 |
+
PlusOutlined,
|
8 |
} from '@ant-design/icons';
|
9 |
import {
|
10 |
Avatar,
|
|
|
157 |
onClick: handleCreateTemporaryConversation,
|
158 |
label: (
|
159 |
<Space>
|
160 |
+
<PlusOutlined />
|
161 |
{t('newChat')}
|
162 |
</Space>
|
163 |
),
|
|
|
293 |
<Tag>{conversationList.length}</Tag>
|
294 |
</Space>
|
295 |
<Dropdown menu={{ items }}>
|
296 |
+
{/* <FormOutlined /> */}
|
297 |
+
<PlusOutlined />
|
298 |
</Dropdown>
|
299 |
</Flex>
|
300 |
<Divider></Divider>
|