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

feat: Add FeedbackModal #2088 #2089

Merged
merged 3 commits into from
Aug 26, 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
37 changes: 37 additions & 0 deletions web/src/components/message-item/feedback-modal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { Form, Input, Modal } from 'antd';

import { IModalProps } from '@/interfaces/common';

type FieldType = {
username?: string;
};

const FeedbackModal = ({ visible, hideModal }: IModalProps<any>) => {
const [form] = Form.useForm();

const handleOk = async () => {
const ret = await form.validateFields();
};

return (
<Modal title="Feedback" open={visible} onOk={handleOk} onCancel={hideModal}>
<Form
name="basic"
labelCol={{ span: 0 }}
wrapperCol={{ span: 24 }}
style={{ maxWidth: 600 }}
autoComplete="off"
form={form}
>
<Form.Item<FieldType>
name="username"
rules={[{ required: true, message: 'Please input your username!' }]}
>
<Input.TextArea rows={8} placeholder="Please input your username!" />
</Form.Item>
</Form>
</Modal>
);
};

export default FeedbackModal;
53 changes: 53 additions & 0 deletions web/src/components/message-item/group-button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import CopyToClipboard from '@/components/copy-to-clipboard';
import { useSetModalState } from '@/hooks/common-hooks';
import {
DeleteOutlined,
DislikeOutlined,
LikeOutlined,
SoundOutlined,
SyncOutlined,
} from '@ant-design/icons';
import { Radio } from 'antd';
import FeedbackModal from './feedback-modal';

export const AssistantGroupButton = () => {
const { visible, hideModal, showModal } = useSetModalState();

return (
<>
<Radio.Group size="small">
<Radio.Button value="a">
<CopyToClipboard text="xxx"></CopyToClipboard>
</Radio.Button>
<Radio.Button value="b">
<SoundOutlined />
</Radio.Button>
<Radio.Button value="c">
<LikeOutlined />
</Radio.Button>
<Radio.Button value="d" onClick={showModal}>
<DislikeOutlined />
</Radio.Button>
</Radio.Group>
{visible && (
<FeedbackModal visible={visible} hideModal={hideModal}></FeedbackModal>
)}
</>
);
};

export const UserGroupButton = () => {
return (
<Radio.Group size="small">
<Radio.Button value="a">
<CopyToClipboard text="xxx"></CopyToClipboard>
</Radio.Button>
<Radio.Button value="b">
<SyncOutlined />
</Radio.Button>
<Radio.Button value="c">
<DeleteOutlined />
</Radio.Button>
</Radio.Group>
);
};
13 changes: 11 additions & 2 deletions web/src/components/message-item/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ import {
} from '@/hooks/document-hooks';
import MarkdownContent from '@/pages/chat/markdown-content';
import { getExtension, isImage } from '@/utils/document-util';
import { Avatar, Button, Flex, List, Typography } from 'antd';
import { Avatar, Button, Flex, List, Space, Typography } from 'antd';
import FileIcon from '../file-icon';
import IndentedTreeModal from '../indented-tree/modal';
import NewDocumentLink from '../new-document-link';
import { AssistantGroupButton, UserGroupButton } from './group-button';
import styles from './index.less';

const { Text } = Typography;
Expand Down Expand Up @@ -109,7 +110,15 @@ const MessageItem = ({
<AssistantIcon></AssistantIcon>
)}
<Flex vertical gap={8} flex={1}>
<b>{isAssistant ? '' : nickname}</b>
<Space>
{isAssistant ? (
<AssistantGroupButton></AssistantGroupButton>
) : (
<UserGroupButton></UserGroupButton>
)}

{/* <b>{isAssistant ? '' : nickname}</b> */}
</Space>
<div
className={
isAssistant ? styles.messageText : styles.messageUserText
Expand Down