Skip to content

Commit

Permalink
feat: Add FeedbackModal infiniflow#2088 (infiniflow#2089)
Browse files Browse the repository at this point in the history
### What problem does this PR solve?

feat: Add FeedbackModal infiniflow#2088

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
  • Loading branch information
cike8899 authored Aug 26, 2024
1 parent c18c8bb commit f972719
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 2 deletions.
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

0 comments on commit f972719

Please sign in to comment.