balibabu
commited on
Commit
·
08ede16
1
Parent(s):
a7642c6
feat: Add FeedbackModal #2088 (#2089)
Browse files### What problem does this PR solve?
feat: Add FeedbackModal #2088
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
web/src/components/message-item/feedback-modal.tsx
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { Form, Input, Modal } from 'antd';
|
2 |
+
|
3 |
+
import { IModalProps } from '@/interfaces/common';
|
4 |
+
|
5 |
+
type FieldType = {
|
6 |
+
username?: string;
|
7 |
+
};
|
8 |
+
|
9 |
+
const FeedbackModal = ({ visible, hideModal }: IModalProps<any>) => {
|
10 |
+
const [form] = Form.useForm();
|
11 |
+
|
12 |
+
const handleOk = async () => {
|
13 |
+
const ret = await form.validateFields();
|
14 |
+
};
|
15 |
+
|
16 |
+
return (
|
17 |
+
<Modal title="Feedback" open={visible} onOk={handleOk} onCancel={hideModal}>
|
18 |
+
<Form
|
19 |
+
name="basic"
|
20 |
+
labelCol={{ span: 0 }}
|
21 |
+
wrapperCol={{ span: 24 }}
|
22 |
+
style={{ maxWidth: 600 }}
|
23 |
+
autoComplete="off"
|
24 |
+
form={form}
|
25 |
+
>
|
26 |
+
<Form.Item<FieldType>
|
27 |
+
name="username"
|
28 |
+
rules={[{ required: true, message: 'Please input your username!' }]}
|
29 |
+
>
|
30 |
+
<Input.TextArea rows={8} placeholder="Please input your username!" />
|
31 |
+
</Form.Item>
|
32 |
+
</Form>
|
33 |
+
</Modal>
|
34 |
+
);
|
35 |
+
};
|
36 |
+
|
37 |
+
export default FeedbackModal;
|
web/src/components/message-item/group-button.tsx
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import CopyToClipboard from '@/components/copy-to-clipboard';
|
2 |
+
import { useSetModalState } from '@/hooks/common-hooks';
|
3 |
+
import {
|
4 |
+
DeleteOutlined,
|
5 |
+
DislikeOutlined,
|
6 |
+
LikeOutlined,
|
7 |
+
SoundOutlined,
|
8 |
+
SyncOutlined,
|
9 |
+
} from '@ant-design/icons';
|
10 |
+
import { Radio } from 'antd';
|
11 |
+
import FeedbackModal from './feedback-modal';
|
12 |
+
|
13 |
+
export const AssistantGroupButton = () => {
|
14 |
+
const { visible, hideModal, showModal } = useSetModalState();
|
15 |
+
|
16 |
+
return (
|
17 |
+
<>
|
18 |
+
<Radio.Group size="small">
|
19 |
+
<Radio.Button value="a">
|
20 |
+
<CopyToClipboard text="xxx"></CopyToClipboard>
|
21 |
+
</Radio.Button>
|
22 |
+
<Radio.Button value="b">
|
23 |
+
<SoundOutlined />
|
24 |
+
</Radio.Button>
|
25 |
+
<Radio.Button value="c">
|
26 |
+
<LikeOutlined />
|
27 |
+
</Radio.Button>
|
28 |
+
<Radio.Button value="d" onClick={showModal}>
|
29 |
+
<DislikeOutlined />
|
30 |
+
</Radio.Button>
|
31 |
+
</Radio.Group>
|
32 |
+
{visible && (
|
33 |
+
<FeedbackModal visible={visible} hideModal={hideModal}></FeedbackModal>
|
34 |
+
)}
|
35 |
+
</>
|
36 |
+
);
|
37 |
+
};
|
38 |
+
|
39 |
+
export const UserGroupButton = () => {
|
40 |
+
return (
|
41 |
+
<Radio.Group size="small">
|
42 |
+
<Radio.Button value="a">
|
43 |
+
<CopyToClipboard text="xxx"></CopyToClipboard>
|
44 |
+
</Radio.Button>
|
45 |
+
<Radio.Button value="b">
|
46 |
+
<SyncOutlined />
|
47 |
+
</Radio.Button>
|
48 |
+
<Radio.Button value="c">
|
49 |
+
<DeleteOutlined />
|
50 |
+
</Radio.Button>
|
51 |
+
</Radio.Group>
|
52 |
+
);
|
53 |
+
};
|
web/src/components/message-item/index.tsx
CHANGED
@@ -13,10 +13,11 @@ import {
|
|
13 |
} from '@/hooks/document-hooks';
|
14 |
import MarkdownContent from '@/pages/chat/markdown-content';
|
15 |
import { getExtension, isImage } from '@/utils/document-util';
|
16 |
-
import { Avatar, Button, Flex, List, Typography } from 'antd';
|
17 |
import FileIcon from '../file-icon';
|
18 |
import IndentedTreeModal from '../indented-tree/modal';
|
19 |
import NewDocumentLink from '../new-document-link';
|
|
|
20 |
import styles from './index.less';
|
21 |
|
22 |
const { Text } = Typography;
|
@@ -109,7 +110,15 @@ const MessageItem = ({
|
|
109 |
<AssistantIcon></AssistantIcon>
|
110 |
)}
|
111 |
<Flex vertical gap={8} flex={1}>
|
112 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
<div
|
114 |
className={
|
115 |
isAssistant ? styles.messageText : styles.messageUserText
|
|
|
13 |
} from '@/hooks/document-hooks';
|
14 |
import MarkdownContent from '@/pages/chat/markdown-content';
|
15 |
import { getExtension, isImage } from '@/utils/document-util';
|
16 |
+
import { Avatar, Button, Flex, List, Space, Typography } from 'antd';
|
17 |
import FileIcon from '../file-icon';
|
18 |
import IndentedTreeModal from '../indented-tree/modal';
|
19 |
import NewDocumentLink from '../new-document-link';
|
20 |
+
import { AssistantGroupButton, UserGroupButton } from './group-button';
|
21 |
import styles from './index.less';
|
22 |
|
23 |
const { Text } = Typography;
|
|
|
110 |
<AssistantIcon></AssistantIcon>
|
111 |
)}
|
112 |
<Flex vertical gap={8} flex={1}>
|
113 |
+
<Space>
|
114 |
+
{isAssistant ? (
|
115 |
+
<AssistantGroupButton></AssistantGroupButton>
|
116 |
+
) : (
|
117 |
+
<UserGroupButton></UserGroupButton>
|
118 |
+
)}
|
119 |
+
|
120 |
+
{/* <b>{isAssistant ? '' : nickname}</b> */}
|
121 |
+
</Space>
|
122 |
<div
|
123 |
className={
|
124 |
isAssistant ? styles.messageText : styles.messageUserText
|