diff --git a/src/Explorer/QueryCopilot/Popup/DeletePopup.test.tsx b/src/Explorer/QueryCopilot/Popup/DeletePopup.test.tsx index 4d3918865..b14ca69ce 100644 --- a/src/Explorer/QueryCopilot/Popup/DeletePopup.test.tsx +++ b/src/Explorer/QueryCopilot/Popup/DeletePopup.test.tsx @@ -5,7 +5,15 @@ import { DeletePopup } from "./DeletePopup"; describe("Delete Popup snapshot test", () => { it("should render when showDeletePopup is true", () => { - const wrapper = shallow( any} setQuery={() => any} />); + const wrapper = shallow( + any} + setQuery={() => any} + clearFeedback={() => any} + showFeedbackBar={() => any} + /> + ); expect(wrapper).toMatchSnapshot(); }); }); diff --git a/src/Explorer/QueryCopilot/Popup/DeletePopup.tsx b/src/Explorer/QueryCopilot/Popup/DeletePopup.tsx index bd2a168d8..2a4e29641 100644 --- a/src/Explorer/QueryCopilot/Popup/DeletePopup.tsx +++ b/src/Explorer/QueryCopilot/Popup/DeletePopup.tsx @@ -5,14 +5,20 @@ export const DeletePopup = ({ showDeletePopup, setShowDeletePopup, setQuery, + clearFeedback, + showFeedbackBar, }: { showDeletePopup: boolean; setShowDeletePopup: Dispatch>; setQuery: Dispatch>; + clearFeedback: Dispatch>; + showFeedbackBar: Dispatch>; }): JSX.Element => { const deleteCode = () => { setQuery(""); setShowDeletePopup(false); + clearFeedback(); + showFeedbackBar(false); }; return ( diff --git a/src/Explorer/QueryCopilot/QueryCopilotTab.tsx b/src/Explorer/QueryCopilot/QueryCopilotTab.tsx index ef6ed0be2..43f8ae6e8 100644 --- a/src/Explorer/QueryCopilot/QueryCopilotTab.tsx +++ b/src/Explorer/QueryCopilot/QueryCopilotTab.tsx @@ -87,6 +87,7 @@ export const QueryCopilotTab: React.FC = ({ const [isGeneratingQuery, setIsGeneratingQuery] = useState(false); const [isExecuting, setIsExecuting] = useState(false); const [likeQuery, setLikeQuery] = useState(); + const [dislikeQuery, setDislikeQuery] = useState(); const [showCallout, setShowCallout] = useState(false); const [showSamplePrompts, setShowSamplePrompts] = useState(false); const [queryIterator, setQueryIterator] = useState(); @@ -263,6 +264,12 @@ export const QueryCopilotTab: React.FC = ({ return [executeQueryBtn, saveQueryBtn, samplePromptsBtn]; }; + const resetButtonState = () => { + setDislikeQuery(false); + setLikeQuery(false); + setShowCallout(false); + }; + React.useEffect(() => { useCommandBar.getState().setContextButtons(getCommandbarButtons()); }, [query, selectedQuery]); @@ -291,6 +298,7 @@ export const QueryCopilotTab: React.FC = ({ onClick={() => { updateHistories(); generateSQLQuery(); + resetButtonState(); }} /> {isGeneratingQuery && } @@ -434,17 +442,23 @@ export const QueryCopilotTab: React.FC = ({ style={{ marginLeft: 20 }} iconProps={{ iconName: likeQuery === true ? "LikeSolid" : "Like" }} onClick={() => { - setLikeQuery(true); - setShowCallout(true); + setShowCallout(!likeQuery); + setLikeQuery(!likeQuery); + if (dislikeQuery) { + setDislikeQuery(!dislikeQuery); + } }} /> { - setLikeQuery(false); + if (!dislikeQuery) { + useQueryCopilot.getState().openFeedbackModal(generatedQuery, false, userPrompt); + setLikeQuery(false); + } + setDislikeQuery(!dislikeQuery); setShowCallout(false); - useQueryCopilot.getState().openFeedbackModal(generatedQuery, false, userPrompt); }} /> @@ -456,7 +470,9 @@ export const QueryCopilotTab: React.FC = ({ Copy code setShowDeletePopup(true)} + onClick={() => { + setShowDeletePopup(true); + }} iconProps={{ iconName: "Delete" }} style={{ margin: "0 10px", backgroundColor: "#FFF8F0", transition: "background-color 0.3s ease" }} > @@ -491,7 +507,13 @@ export const QueryCopilotTab: React.FC = ({ {isSamplePromptsOpen ? : <>} {query !== "" && query.trim().length !== 0 ? ( - + ) : ( <> )}