Fix P2 bgs

This commit is contained in:
sunghyunkang1111 2023-11-20 11:20:54 -06:00
parent 6af1925d15
commit 3283d4073b
6 changed files with 21 additions and 11 deletions

View File

@ -1397,6 +1397,7 @@ export default class Explorer {
]); ]);
useQueryCopilot.getState().setCopilotEnabled(copilotEnabled); useQueryCopilot.getState().setCopilotEnabled(copilotEnabled);
useQueryCopilot.getState().setCopilotUserDBEnabled(copilotUserDBEnabled); useQueryCopilot.getState().setCopilotUserDBEnabled(copilotUserDBEnabled);
useQueryCopilot.getState().setShowWelcomeModal(window.localStorage.getItem("hideWelcomeModal") !== "true");
} }
public async refreshSampleData(): Promise<void> { public async refreshSampleData(): Promise<void> {

View File

@ -336,7 +336,8 @@ exports[`AddCollectionPanel should render Default properly 1`] = `
directionalHint={4} directionalHint={4}
> >
<Icon <Icon
ariaLabel="Enable analytical store capability to perform near real-time analytics on your operational data, without impacting the performance of transactional workloads." ariaLabel="Enable analytical store capability to perform near real-time analytics on your operational data, without
impacting the performance of transactional workloads."
className="panelInfoIcon" className="panelInfoIcon"
iconName="Info" iconName="Info"
tabIndex={0} tabIndex={0}

View File

@ -1,5 +1,6 @@
import { IconButton, Image, Link, Modal, PrimaryButton, Stack, StackItem, Text } from "@fluentui/react"; import { IconButton, Image, Link, Modal, PrimaryButton, Stack, StackItem, Text } from "@fluentui/react";
import { useBoolean } from "@fluentui/react-hooks"; import { useBoolean } from "@fluentui/react-hooks";
import { useQueryCopilot } from "hooks/useQueryCopilot";
import React from "react"; import React from "react";
import Flash from "../../../../images/CopilotFlash.svg"; import Flash from "../../../../images/CopilotFlash.svg";
import Thumb from "../../../../images/CopilotThumb.svg"; import Thumb from "../../../../images/CopilotThumb.svg";
@ -13,7 +14,11 @@ export const WelcomeModal = ({ visible }: { visible: boolean }): JSX.Element =>
if (visible) { if (visible) {
window.localStorage.setItem("hideWelcomeModal", "true"); window.localStorage.setItem("hideWelcomeModal", "true");
} }
}); }, []);
React.useEffect(() => {
useQueryCopilot.getState().setShowWelcomeModal(isModalVisible);
}, [isModalVisible]);
return ( return (
<> <>

View File

@ -72,7 +72,6 @@ export const QueryCopilotPromptbar: React.FC<QueryCopilotPromptProps> = ({
containerId, containerId,
}: QueryCopilotPromptProps): JSX.Element => { }: QueryCopilotPromptProps): JSX.Element => {
const [copilotTeachingBubbleVisible, { toggle: toggleCopilotTeachingBubbleVisible }] = useBoolean(false); const [copilotTeachingBubbleVisible, { toggle: toggleCopilotTeachingBubbleVisible }] = useBoolean(false);
const inputEdited = useRef(false);
const { const {
openFeedbackModal, openFeedbackModal,
hideFeedbackModalForLikedQueries, hideFeedbackModalForLikedQueries,
@ -110,6 +109,8 @@ export const QueryCopilotPromptbar: React.FC<QueryCopilotPromptProps> = ({
errorMessage, errorMessage,
} = useCopilotStore(); } = useCopilotStore();
const inputEdited = useRef(!!userPrompt);
const sampleProps: SamplePromptsProps = { const sampleProps: SamplePromptsProps = {
isSamplePromptsOpen: isSamplePromptsOpen, isSamplePromptsOpen: isSamplePromptsOpen,
setIsSamplePromptsOpen: setIsSamplePromptsOpen, setIsSamplePromptsOpen: setIsSamplePromptsOpen,
@ -274,7 +275,7 @@ export const QueryCopilotPromptbar: React.FC<QueryCopilotPromptProps> = ({
const showTeachingBubble = (): void => { const showTeachingBubble = (): void => {
if (!inputEdited.current) { if (!inputEdited.current) {
setTimeout(() => { setTimeout(() => {
if (!inputEdited.current && !isWelcomModalVisible()) { if (!useQueryCopilot.getState().showWelcomeModal && !userPrompt && !inputEdited.current) {
toggleCopilotTeachingBubbleVisible(); toggleCopilotTeachingBubbleVisible();
inputEdited.current = true; inputEdited.current = true;
} }
@ -282,10 +283,6 @@ export const QueryCopilotPromptbar: React.FC<QueryCopilotPromptProps> = ({
} }
}; };
const isWelcomModalVisible = (): boolean => {
return localStorage.getItem("hideWelcomeModal") !== "true";
};
const clearFeedback = () => { const clearFeedback = () => {
resetButtonState(); resetButtonState();
resetQueryResults(); resetQueryResults();
@ -305,6 +302,7 @@ export const QueryCopilotPromptbar: React.FC<QueryCopilotPromptProps> = ({
React.useEffect(() => { React.useEffect(() => {
showTeachingBubble(); showTeachingBubble();
useQueryCopilot.subscribe((state) => state.showWelcomeModal, showTeachingBubble);
useTabs.getState().setIsQueryErrorThrown(false); useTabs.getState().setIsQueryErrorThrown(false);
}, []); }, []);
@ -591,7 +589,7 @@ export const QueryCopilotPromptbar: React.FC<QueryCopilotPromptProps> = ({
</CommandBarButton> </CommandBarButton>
</Stack> </Stack>
)} )}
<WelcomeModal visible={isWelcomModalVisible()} /> <WelcomeModal visible={useQueryCopilot.getState().showWelcomeModal} />
{isSamplePromptsOpen && <SamplePrompts sampleProps={sampleProps} />} {isSamplePromptsOpen && <SamplePrompts sampleProps={sampleProps} />}
{query !== "" && query.trim().length !== 0 && ( {query !== "" && query.trim().length !== 0 && (
<DeletePopup <DeletePopup

View File

@ -104,12 +104,13 @@ interface IQueryTabStates {
export const QueryTabFunctionComponent = (props: IQueryTabComponentProps): any => { export const QueryTabFunctionComponent = (props: IQueryTabComponentProps): any => {
const copilotStore = useCopilotStore(); const copilotStore = useCopilotStore();
const copilotGlobalStore = useQueryCopilot();
const isSampleCopilotActive = useSelectedNode.getState().isQueryCopilotCollectionSelected(); const isSampleCopilotActive = useSelectedNode.getState().isQueryCopilotCollectionSelected();
const queryTabProps = { const queryTabProps = {
...props, ...props,
copilotEnabled: copilotEnabled:
useQueryCopilot().copilotEnabled && copilotGlobalStore.copilotEnabled &&
(useQueryCopilot().copilotUserDBEnabled || (isSampleCopilotActive && !!userContext.sampleDataConnectionInfo)), (copilotGlobalStore.copilotUserDBEnabled || (isSampleCopilotActive && !!userContext.sampleDataConnectionInfo)),
isSampleCopilotActive: isSampleCopilotActive, isSampleCopilotActive: isSampleCopilotActive,
copilotStore: copilotStore, copilotStore: copilotStore,
}; };

View File

@ -36,6 +36,7 @@ export interface QueryCopilotState {
generatedQueryComments: string; generatedQueryComments: string;
wasCopilotUsed: boolean; wasCopilotUsed: boolean;
showWelcomeSidebar: boolean; showWelcomeSidebar: boolean;
showWelcomeModal: boolean;
showCopilotSidebar: boolean; showCopilotSidebar: boolean;
chatMessages: CopilotMessage[]; chatMessages: CopilotMessage[];
shouldIncludeInMessages: boolean; shouldIncludeInMessages: boolean;
@ -77,6 +78,7 @@ export interface QueryCopilotState {
setGeneratedQueryComments: (generatedQueryComments: string) => void; setGeneratedQueryComments: (generatedQueryComments: string) => void;
setWasCopilotUsed: (wasCopilotUsed: boolean) => void; setWasCopilotUsed: (wasCopilotUsed: boolean) => void;
setShowWelcomeSidebar: (showWelcomeSidebar: boolean) => void; setShowWelcomeSidebar: (showWelcomeSidebar: boolean) => void;
setShowWelcomeModal: (showWelcomeModal: boolean) => void;
setShowCopilotSidebar: (showCopilotSidebar: boolean) => void; setShowCopilotSidebar: (showCopilotSidebar: boolean) => void;
setChatMessages: (chatMessages: CopilotMessage[]) => void; setChatMessages: (chatMessages: CopilotMessage[]) => void;
setShouldIncludeInMessages: (shouldIncludeInMessages: boolean) => void; setShouldIncludeInMessages: (shouldIncludeInMessages: boolean) => void;
@ -122,6 +124,7 @@ export const useQueryCopilot: QueryCopilotStore = create((set) => ({
generatedQueryComments: "", generatedQueryComments: "",
wasCopilotUsed: false, wasCopilotUsed: false,
showWelcomeSidebar: true, showWelcomeSidebar: true,
showWelcomeModal: true,
showCopilotSidebar: false, showCopilotSidebar: false,
chatMessages: [], chatMessages: [],
shouldIncludeInMessages: true, shouldIncludeInMessages: true,
@ -174,6 +177,7 @@ export const useQueryCopilot: QueryCopilotStore = create((set) => ({
setGeneratedQueryComments: (generatedQueryComments: string) => set({ generatedQueryComments }), setGeneratedQueryComments: (generatedQueryComments: string) => set({ generatedQueryComments }),
setWasCopilotUsed: (wasCopilotUsed: boolean) => set({ wasCopilotUsed }), setWasCopilotUsed: (wasCopilotUsed: boolean) => set({ wasCopilotUsed }),
setShowWelcomeSidebar: (showWelcomeSidebar: boolean) => set({ showWelcomeSidebar }), setShowWelcomeSidebar: (showWelcomeSidebar: boolean) => set({ showWelcomeSidebar }),
setShowWelcomeModal: (showWelcomeModal: boolean) => set({ showWelcomeModal }),
setShowCopilotSidebar: (showCopilotSidebar: boolean) => set({ showCopilotSidebar }), setShowCopilotSidebar: (showCopilotSidebar: boolean) => set({ showCopilotSidebar }),
setChatMessages: (chatMessages: CopilotMessage[]) => set({ chatMessages }), setChatMessages: (chatMessages: CopilotMessage[]) => set({ chatMessages }),
setShouldIncludeInMessages: (shouldIncludeInMessages: boolean) => set({ shouldIncludeInMessages }), setShouldIncludeInMessages: (shouldIncludeInMessages: boolean) => set({ shouldIncludeInMessages }),