From 8ce7aaa72828b144da24752d725236947c8dc72a Mon Sep 17 00:00:00 2001 From: Predrag Klepic Date: Wed, 6 Sep 2023 11:03:04 +0200 Subject: [PATCH] Delete chat history button --- .../QueryCopilot/V2/Header/Header.tsx | 100 +++++++++++++----- 1 file changed, 71 insertions(+), 29 deletions(-) diff --git a/src/Explorer/QueryCopilot/V2/Header/Header.tsx b/src/Explorer/QueryCopilot/V2/Header/Header.tsx index d464995ba..0286aab83 100644 --- a/src/Explorer/QueryCopilot/V2/Header/Header.tsx +++ b/src/Explorer/QueryCopilot/V2/Header/Header.tsx @@ -1,39 +1,81 @@ -import { IconButton, Image, Stack, Text } from "@fluentui/react"; +import { DefaultButton, IconButton, Image, Modal, PrimaryButton, Stack, Text } from "@fluentui/react"; import { useQueryCopilot } from "hooks/useQueryCopilot"; import React from "react"; import CopilotIcon from "../../../../../images/CopilotSidebarLogo.svg"; export const Header: React.FC = (): JSX.Element => { - const { setShowCopilotSidebar } = useQueryCopilot(); + const { setShowCopilotSidebar, chatMessages, setChatMessages, setShowExplanationBubble } = useQueryCopilot(); + const [showDeleteHistoryModal, setShowDeleteHistoryModal] = React.useState(false); + + const getDeleteHistoryModal = () => { + return ( + + + + Delete chat history? + + + This action will clear all chat history. Are you sure you want to continue? + + + { + setChatMessages([]); + setShowExplanationBubble(false); + setShowDeleteHistoryModal(false); + }} + > + Continue + + setShowDeleteHistoryModal(false)}> + Close + + + + + ); + }; return ( - - - - Copilot - - Preview - + <> + + + + Copilot + + Preview + + + setShowDeleteHistoryModal(true)} + iconProps={{ iconName: "History" }} + title="Delete history" + ariaLabel="Delete history" + style={{ color: "#424242", verticalAlign: "middle" }} + disabled={chatMessages.length === 0} + /> + setShowCopilotSidebar(false)} + iconProps={{ iconName: "Cancel" }} + title="Exit" + ariaLabel="Exit" + style={{ color: "#424242", verticalAlign: "middle" }} + /> - setShowCopilotSidebar(false)} - iconProps={{ iconName: "Cancel" }} - title="Exit" - ariaLabel="Exit" - style={{ color: "#424242", verticalAlign: "middle" }} - /> - + {getDeleteHistoryModal()} + ); };