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: show chat description #36805

Merged
merged 2 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Button, Text, TextArea } from "@appsmith/wds";
import { Button, Flex, Text, TextArea } from "@appsmith/wds";
import type { FormEvent, ForwardedRef, KeyboardEvent } from "react";
import React, { forwardRef, useCallback } from "react";
import { ChatDescriptionModal } from "./ChatDescriptionModal";
import { ChatTitle } from "./ChatTitle";
import styles from "./styles.module.css";
import { ThreadMessage } from "./ThreadMessage";
Expand All @@ -12,6 +13,7 @@ const MIN_PROMPT_LENGTH = 3;
const _AIChat = (props: AIChatProps, ref: ForwardedRef<HTMLDivElement>) => {
const {
// assistantName,
chatDescription,
chatTitle,
isWaitingForResponse = false,
onApplyAssistantSuggestion,
Expand All @@ -23,6 +25,8 @@ const _AIChat = (props: AIChatProps, ref: ForwardedRef<HTMLDivElement>) => {
username,
...rest
} = props;
const [isChatDescriptionModalOpen, setIsChatDescriptionModalOpen] =
React.useState(false);

const handleFormSubmit = useCallback(
(event: FormEvent<HTMLFormElement>) => {
Expand All @@ -44,15 +48,31 @@ const _AIChat = (props: AIChatProps, ref: ForwardedRef<HTMLDivElement>) => {

return (
<div className={styles.root} ref={ref} {...rest}>
<ChatDescriptionModal
isOpen={isChatDescriptionModalOpen}
setOpen={() =>
setIsChatDescriptionModalOpen(!isChatDescriptionModalOpen)
}
>
{chatDescription}
</ChatDescriptionModal>

<div className={styles.header}>
<ChatTitle title={chatTitle} />
<Flex alignItems="center" gap="8px">
<ChatTitle title={chatTitle} />
<Button
icon="info-square-rounded"
onPress={() => setIsChatDescriptionModalOpen(true)}
variant="ghost"
/>
</Flex>

<div className={styles.username}>
<Flex alignItems="center" gap="8px">
<UserAvatar username={username} />
znamenskii-ilia marked this conversation as resolved.
Show resolved Hide resolved
<Text data-testid="t--aichat-username" size="body">
{username}
</Text>
</div>
</Flex>
</div>

<ul className={styles.thread} data-testid="t--aichat-thread">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Modal, ModalBody, ModalContent, ModalHeader } from "@appsmith/wds";
import React from "react";
import type { ChatDescriptionModalProps } from "./types";

export const ChatDescriptionModal = ({
children,
...rest
}: ChatDescriptionModalProps) => {
return (
<Modal {...rest}>
<ModalContent>
<ModalHeader title="Information about the bot" />
<ModalBody>{children}</ModalBody>
</ModalContent>
</Modal>
znamenskii-ilia marked this conversation as resolved.
Show resolved Hide resolved
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./ChatDescriptionModal";
export * from "./types";
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import type { ModalProps } from "@appsmith/wds";

export interface ChatDescriptionModalProps extends ModalProps {}
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@
}
}

.username {
display: flex;
align-items: center;
gap: 8px;
}

.thread {
display: flex;
flex-direction: column;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export * from "./ModalHeader";
export * from "./ModalFooter";
export * from "./ModalBody";
export * from "./ModalContent";
export * from "./types";
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ class WDSAIChatWidget extends BaseWidget<WDSAIChatWidgetProps, State> {
return (
<AIChat
assistantName={this.props.assistantName}
chatDescription={this.props.chatDescription}
chatTitle={this.props.chatTitle}
isWaitingForResponse={this.state.isWaitingForResponse}
onApplyAssistantSuggestion={this.handleApplyAssistantSuggestion}
Expand Down
Loading