Feat: Create the first version of the eraser tool
This commit is contained in:
parent
11c874cd96
commit
70f4fd0770
2 changed files with 70 additions and 13 deletions
|
|
@ -18,6 +18,12 @@ import { chatViewProps } from "../../../../types/components";
|
||||||
import { classNames } from "../../../../utils/utils";
|
import { classNames } from "../../../../utils/utils";
|
||||||
import ChatInput from "./chatInput";
|
import ChatInput from "./chatInput";
|
||||||
import ChatMessage from "./chatMessage";
|
import ChatMessage from "./chatMessage";
|
||||||
|
import {
|
||||||
|
Select,
|
||||||
|
SelectContent,
|
||||||
|
SelectItem,
|
||||||
|
SelectTrigger,
|
||||||
|
} from "../../../../components/ui/select";
|
||||||
|
|
||||||
export default function ChatView({
|
export default function ChatView({
|
||||||
sendMessage,
|
sendMessage,
|
||||||
|
|
@ -118,10 +124,21 @@ export default function ChatView({
|
||||||
if (lockChat) setLockChat(false);
|
if (lockChat) setLockChat(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleSelectChange(event: string): void {
|
||||||
|
switch (event) {
|
||||||
|
case "builds":
|
||||||
|
clearChat();
|
||||||
|
break;
|
||||||
|
case "buildsNSession":
|
||||||
|
console.log("delete build and session");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function updateChat(
|
function updateChat(
|
||||||
chat: ChatMessageType,
|
chat: ChatMessageType,
|
||||||
message: string,
|
message: string,
|
||||||
stream_url?: string
|
stream_url?: string,
|
||||||
) {
|
) {
|
||||||
// if (message === "") return;
|
// if (message === "") return;
|
||||||
chat.message = message;
|
chat.message = message;
|
||||||
|
|
@ -149,18 +166,44 @@ export default function ChatView({
|
||||||
<div className="eraser-column-arrangement">
|
<div className="eraser-column-arrangement">
|
||||||
<div className="eraser-size">
|
<div className="eraser-size">
|
||||||
<div className="eraser-position">
|
<div className="eraser-position">
|
||||||
<button disabled={lockChat} onClick={() => clearChat()}>
|
<Select
|
||||||
<IconComponent
|
onValueChange={handleSelectChange}
|
||||||
name="Eraser"
|
value=""
|
||||||
className={classNames(
|
disabled={lockChat}
|
||||||
"h-5 w-5",
|
>
|
||||||
lockChat
|
<SelectTrigger className="">
|
||||||
? "animate-pulse text-primary"
|
<button className="flex gap-1">
|
||||||
: "text-primary hover:text-gray-600"
|
<IconComponent
|
||||||
)}
|
name="Eraser"
|
||||||
aria-hidden="true"
|
className={classNames(
|
||||||
/>
|
"h-5 w-5 transition-all duration-100",
|
||||||
</button>
|
lockChat ? "animate-pulse text-primary" : "text-primary",
|
||||||
|
)}
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
</button>
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent className="right-[9.5em]">
|
||||||
|
<SelectItem value="builds" className="cursor-pointer">
|
||||||
|
<div className="flex">
|
||||||
|
<IconComponent
|
||||||
|
name={"Trash2"}
|
||||||
|
className={`relative top-0.5 mr-2 h-4 w-4`}
|
||||||
|
/>
|
||||||
|
<span className="">Clear Builds</span>
|
||||||
|
</div>
|
||||||
|
</SelectItem>
|
||||||
|
<SelectItem value="buildsNSession" className="cursor-pointer">
|
||||||
|
<div className="flex">
|
||||||
|
<IconComponent
|
||||||
|
name={"Trash2"}
|
||||||
|
className={`relative top-0.5 mr-2 h-4 w-4`}
|
||||||
|
/>
|
||||||
|
<span className="">Clear Builds & Session</span>
|
||||||
|
</div>
|
||||||
|
</SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
<div ref={messagesRef} className="chat-message-div">
|
<div ref={messagesRef} className="chat-message-div">
|
||||||
{chatHistory?.length > 0 ? (
|
{chatHistory?.length > 0 ? (
|
||||||
|
|
|
||||||
|
|
@ -752,3 +752,17 @@ export type toolbarSelectItemProps = {
|
||||||
dataTestId: string;
|
dataTestId: string;
|
||||||
ping?: boolean;
|
ping?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type clearChatPropsType = {
|
||||||
|
lockChat: boolean;
|
||||||
|
setLockChat: (lock: boolean) => void;
|
||||||
|
setChatHistory: (chatHistory: ChatMessageType) => void;
|
||||||
|
method: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type handleSelectPropsType = {
|
||||||
|
event: string;
|
||||||
|
lockChat: boolean;
|
||||||
|
setLockChat: (lock: boolean) => void;
|
||||||
|
setChatHistory: (chatHistory: ChatMessageType) => void;
|
||||||
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue