balibabu
commited on
Commit
·
825281b
1
Parent(s):
944c0a6
feat: add chunkText to messageText to distinguish table rows and when parsing, the delete and other buttons are set to disabled. (#130)
Browse files* feat: when parsing, the delete and other buttons are set to disabled.
* feat: add chunkText to messageText to distinguish table rows
- web/src/pages/add-knowledge/components/knowledge-file/parsing-action-cell/index.less +3 -0
- web/src/pages/add-knowledge/components/knowledge-file/parsing-action-cell/index.tsx +43 -11
- web/src/pages/add-knowledge/components/knowledge-file/parsing-status-cell/index.tsx +2 -1
- web/src/pages/add-knowledge/components/knowledge-file/utils.ts +6 -0
- web/src/pages/chat/chat-container/index.less +1 -0
- web/src/pages/chat/chat-container/index.tsx +2 -2
web/src/pages/add-knowledge/components/knowledge-file/parsing-action-cell/index.less
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
.iconButton {
|
2 |
+
padding: 4px 8px;
|
3 |
+
}
|
web/src/pages/add-knowledge/components/knowledge-file/parsing-action-cell/index.tsx
CHANGED
@@ -3,6 +3,9 @@ import { IKnowledgeFile } from '@/interfaces/database/knowledge';
|
|
3 |
import { DeleteOutlined, EditOutlined, ToolOutlined } from '@ant-design/icons';
|
4 |
import { Button, Dropdown, MenuProps, Space, Tooltip } from 'antd';
|
5 |
import { useDispatch } from 'umi';
|
|
|
|
|
|
|
6 |
|
7 |
interface IProps {
|
8 |
knowledgeBaseId: string;
|
@@ -17,6 +20,7 @@ const ParsingActionCell = ({
|
|
17 |
}: IProps) => {
|
18 |
const dispatch = useDispatch();
|
19 |
const documentId = record.id;
|
|
|
20 |
|
21 |
const removeDocument = () => {
|
22 |
dispatch({
|
@@ -29,7 +33,9 @@ const ParsingActionCell = ({
|
|
29 |
};
|
30 |
|
31 |
const onRmDocument = () => {
|
32 |
-
|
|
|
|
|
33 |
};
|
34 |
|
35 |
const setCurrentRecord = () => {
|
@@ -49,11 +55,13 @@ const ParsingActionCell = ({
|
|
49 |
};
|
50 |
|
51 |
const showRenameModal = () => {
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
|
|
|
|
57 |
};
|
58 |
|
59 |
const chunkItems: MenuProps['items'] = [
|
@@ -70,14 +78,38 @@ const ParsingActionCell = ({
|
|
70 |
];
|
71 |
|
72 |
return (
|
73 |
-
<Space size={
|
74 |
-
<Dropdown
|
75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
</Dropdown>
|
77 |
<Tooltip title="Rename">
|
78 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
</Tooltip>
|
80 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
</Space>
|
82 |
);
|
83 |
};
|
|
|
3 |
import { DeleteOutlined, EditOutlined, ToolOutlined } from '@ant-design/icons';
|
4 |
import { Button, Dropdown, MenuProps, Space, Tooltip } from 'antd';
|
5 |
import { useDispatch } from 'umi';
|
6 |
+
import { isParserRunning } from '../utils';
|
7 |
+
|
8 |
+
import styles from './index.less';
|
9 |
|
10 |
interface IProps {
|
11 |
knowledgeBaseId: string;
|
|
|
20 |
}: IProps) => {
|
21 |
const dispatch = useDispatch();
|
22 |
const documentId = record.id;
|
23 |
+
const isRunning = isParserRunning(record.run);
|
24 |
|
25 |
const removeDocument = () => {
|
26 |
dispatch({
|
|
|
33 |
};
|
34 |
|
35 |
const onRmDocument = () => {
|
36 |
+
if (!isRunning) {
|
37 |
+
showDeleteConfirm({ onOk: removeDocument });
|
38 |
+
}
|
39 |
};
|
40 |
|
41 |
const setCurrentRecord = () => {
|
|
|
55 |
};
|
56 |
|
57 |
const showRenameModal = () => {
|
58 |
+
if (!isRunning) {
|
59 |
+
setCurrentRecord();
|
60 |
+
dispatch({
|
61 |
+
type: 'kFModel/setIsShowRenameModal',
|
62 |
+
payload: true,
|
63 |
+
});
|
64 |
+
}
|
65 |
};
|
66 |
|
67 |
const chunkItems: MenuProps['items'] = [
|
|
|
78 |
];
|
79 |
|
80 |
return (
|
81 |
+
<Space size={0}>
|
82 |
+
<Dropdown
|
83 |
+
menu={{ items: chunkItems }}
|
84 |
+
trigger={['click']}
|
85 |
+
disabled={isRunning}
|
86 |
+
>
|
87 |
+
<Button
|
88 |
+
type="text"
|
89 |
+
onClick={setDocumentAndParserId}
|
90 |
+
className={styles.iconButton}
|
91 |
+
>
|
92 |
+
<ToolOutlined size={20} />
|
93 |
+
</Button>
|
94 |
</Dropdown>
|
95 |
<Tooltip title="Rename">
|
96 |
+
<Button
|
97 |
+
type="text"
|
98 |
+
disabled={isRunning}
|
99 |
+
onClick={showRenameModal}
|
100 |
+
className={styles.iconButton}
|
101 |
+
>
|
102 |
+
<EditOutlined size={20} />
|
103 |
+
</Button>
|
104 |
</Tooltip>
|
105 |
+
<Button
|
106 |
+
type="text"
|
107 |
+
disabled={isRunning}
|
108 |
+
onClick={onRmDocument}
|
109 |
+
className={styles.iconButton}
|
110 |
+
>
|
111 |
+
<DeleteOutlined size={20} />
|
112 |
+
</Button>
|
113 |
</Space>
|
114 |
);
|
115 |
};
|
web/src/pages/add-knowledge/components/knowledge-file/parsing-status-cell/index.tsx
CHANGED
@@ -6,6 +6,7 @@ import { Badge, DescriptionsProps, Flex, Popover, Space, Tag } from 'antd';
|
|
6 |
import reactStringReplace from 'react-string-replace';
|
7 |
import { useDispatch } from 'umi';
|
8 |
import { RunningStatus, RunningStatusMap } from '../constant';
|
|
|
9 |
import styles from './index.less';
|
10 |
|
11 |
const iconMap = {
|
@@ -77,7 +78,7 @@ export const ParsingStatusCell = ({ record }: IProps) => {
|
|
77 |
const text = record.run;
|
78 |
const runningStatus = RunningStatusMap[text];
|
79 |
|
80 |
-
const isRunning = text
|
81 |
|
82 |
const OperationIcon = iconMap[text];
|
83 |
|
|
|
6 |
import reactStringReplace from 'react-string-replace';
|
7 |
import { useDispatch } from 'umi';
|
8 |
import { RunningStatus, RunningStatusMap } from '../constant';
|
9 |
+
import { isParserRunning } from '../utils';
|
10 |
import styles from './index.less';
|
11 |
|
12 |
const iconMap = {
|
|
|
78 |
const text = record.run;
|
79 |
const runningStatus = RunningStatusMap[text];
|
80 |
|
81 |
+
const isRunning = isParserRunning(text);
|
82 |
|
83 |
const OperationIcon = iconMap[text];
|
84 |
|
web/src/pages/add-knowledge/components/knowledge-file/utils.ts
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { RunningStatus } from './constant';
|
2 |
+
|
3 |
+
export const isParserRunning = (text: RunningStatus) => {
|
4 |
+
const isRunning = text === RunningStatus.RUNNING;
|
5 |
+
return isRunning;
|
6 |
+
};
|
web/src/pages/chat/chat-container/index.less
CHANGED
@@ -25,6 +25,7 @@
|
|
25 |
flex-direction: row-reverse;
|
26 |
}
|
27 |
.messageText {
|
|
|
28 |
padding: 0 14px;
|
29 |
background-color: rgba(249, 250, 251, 1);
|
30 |
word-break: break-all;
|
|
|
25 |
flex-direction: row-reverse;
|
26 |
}
|
27 |
.messageText {
|
28 |
+
.chunkText();
|
29 |
padding: 0 14px;
|
30 |
background-color: rgba(249, 250, 251, 1);
|
31 |
word-break: break-all;
|
web/src/pages/chat/chat-container/index.tsx
CHANGED
@@ -262,12 +262,12 @@ const ChatContainer = () => {
|
|
262 |
if (!loading) {
|
263 |
setValue('');
|
264 |
addNewestConversation(value);
|
265 |
-
sendMessage(value);
|
266 |
}
|
267 |
};
|
268 |
|
269 |
const handleInputChange: ChangeEventHandler<HTMLInputElement> = (e) => {
|
270 |
-
const value = e.target.value
|
271 |
const nextValue = value.replaceAll('\\n', '\n').replaceAll('\\t', '\t');
|
272 |
setValue(nextValue);
|
273 |
};
|
|
|
262 |
if (!loading) {
|
263 |
setValue('');
|
264 |
addNewestConversation(value);
|
265 |
+
sendMessage(value.trim());
|
266 |
}
|
267 |
};
|
268 |
|
269 |
const handleInputChange: ChangeEventHandler<HTMLInputElement> = (e) => {
|
270 |
+
const value = e.target.value;
|
271 |
const nextValue = value.replaceAll('\\n', '\n').replaceAll('\\t', '\t');
|
272 |
setValue(nextValue);
|
273 |
};
|