Add password reset callout (#1332)

* Add password reset callout

* Add create password text

* Add password reset callout
This commit is contained in:
sunghyunkang1111 2022-10-04 10:50:47 -05:00 committed by GitHub
parent a34d3bb000
commit 7c77ffda6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 73 additions and 19 deletions

View File

@ -35,6 +35,7 @@ export enum MessageTypes {
RefreshDatabaseAccount, RefreshDatabaseAccount,
CloseTab, CloseTab,
OpenQuickstartBlade, OpenQuickstartBlade,
OpenPostgreSQLPasswordReset,
} }
export { Versions, ActionContracts, Diagnostics }; export { Versions, ActionContracts, Diagnostics };

View File

@ -11,6 +11,8 @@ import {
TeachingBubbleContent, TeachingBubbleContent,
Text, Text,
} from "@fluentui/react"; } from "@fluentui/react";
import { sendMessage } from "Common/MessageHandler";
import { MessageTypes } from "Contracts/ExplorerContracts";
import { TerminalKind } from "Contracts/ViewModels"; import { TerminalKind } from "Contracts/ViewModels";
import { useCarousel } from "hooks/useCarousel"; import { useCarousel } from "hooks/useCarousel";
import { usePostgres } from "hooks/usePostgres"; import { usePostgres } from "hooks/usePostgres";
@ -91,6 +93,12 @@ export class SplashScreen extends React.Component<SplashScreenProps> {
() => this.setState({}), () => this.setState({}),
(state) => state.showPostgreTeachingBubble (state) => state.showPostgreTeachingBubble
), ),
},
{
dispose: usePostgres.subscribe(
() => this.setState({}),
(state) => state.showResetPasswordBubble
),
} }
); );
} }
@ -118,26 +126,36 @@ export class SplashScreen extends React.Component<SplashScreenProps> {
: "Globally distributed, multi-model database service for any scale"} : "Globally distributed, multi-model database service for any scale"}
</div> </div>
<div className="mainButtonsContainer"> <div className="mainButtonsContainer">
{userContext.apiType === "Postgres" && usePostgres.getState().showPostgreTeachingBubble && ( {userContext.apiType === "Postgres" &&
<TeachingBubble usePostgres.getState().showPostgreTeachingBubble &&
headline="New to Cosmos DB PGSQL?" !usePostgres.getState().showResetPasswordBubble && (
target={"#quickstartDescription"} <TeachingBubble
hasCloseButton headline="New to Cosmos DB PGSQL?"
onDismiss={() => usePostgres.getState().setShowPostgreTeachingBubble(false)} target={"#mainButton-quickstartDescription"}
primaryButtonProps={{ hasCloseButton
text: "Get started", onDismiss={() => usePostgres.getState().setShowPostgreTeachingBubble(false)}
onClick: () => { calloutProps={{
useTabs.getState().openAndActivateReactTab(ReactTabKind.Quickstart); directionalHint: DirectionalHint.rightCenter,
usePostgres.getState().setShowPostgreTeachingBubble(false); directionalHintFixed: true,
}, preventDismissOnLostFocus: true,
}} preventDismissOnResize: true,
> preventDismissOnScroll: true,
Welcome! If you are new to Cosmos DB PGSQL and need help with getting started, here is where you can }}
find sample data, query. primaryButtonProps={{
</TeachingBubble> text: "Get started",
)} onClick: () => {
useTabs.getState().openAndActivateReactTab(ReactTabKind.Quickstart);
usePostgres.getState().setShowPostgreTeachingBubble(false);
},
}}
>
Welcome! If you are new to Cosmos DB PGSQL and need help with getting started, here is where you
can find sample data, query.
</TeachingBubble>
)}
{mainItems.map((item) => ( {mainItems.map((item) => (
<Stack <Stack
id={`mainButton-${item.id}`}
horizontal horizontal
className="mainButton focusable" className="mainButton focusable"
key={`${item.title}`} key={`${item.title}`}
@ -161,6 +179,32 @@ export class SplashScreen extends React.Component<SplashScreenProps> {
</div> </div>
</Stack> </Stack>
))} ))}
{userContext.apiType === "Postgres" && usePostgres.getState().showResetPasswordBubble && (
<TeachingBubble
headline="Create your password"
target={"#mainButton-quickstartDescription"}
hasCloseButton
onDismiss={() => usePostgres.getState().setShowResetPasswordBubble(false)}
calloutProps={{
directionalHint: DirectionalHint.bottomRightEdge,
directionalHintFixed: true,
preventDismissOnLostFocus: true,
preventDismissOnResize: true,
preventDismissOnScroll: true,
}}
primaryButtonProps={{
text: "Create",
onClick: () => {
sendMessage({
type: MessageTypes.OpenQuickstartBlade,
});
usePostgres.getState().setShowResetPasswordBubble(false);
},
}}
>
This password will be used to connect to the database.
</TeachingBubble>
)}
</div> </div>
{useCarousel.getState().showCoachMark && ( {useCarousel.getState().showCoachMark && (
<Coachmark <Coachmark

View File

@ -97,8 +97,10 @@ function updateUserContext(newContext: Partial<UserContext>): void {
if (newContext.apiType === "Postgres") { if (newContext.apiType === "Postgres") {
usePostgres.getState().setShowPostgreTeachingBubble(true); usePostgres.getState().setShowPostgreTeachingBubble(true);
localStorage.setItem(newContext.databaseAccount.id, "true"); localStorage.setItem(newContext.databaseAccount.id, "true");
} else if (userContext.isTryCosmosDBSubscription || isNewAccount) { }
if (userContext.isTryCosmosDBSubscription || isNewAccount) {
useCarousel.getState().setShouldOpen(true); useCarousel.getState().setShouldOpen(true);
usePostgres.getState().setShowResetPasswordBubble(true);
localStorage.setItem(newContext.databaseAccount.id, "true"); localStorage.setItem(newContext.databaseAccount.id, "true");
traceOpen(Action.OpenCarousel); traceOpen(Action.OpenCarousel);
} }
@ -130,6 +132,9 @@ function apiType(account: DatabaseAccount | undefined): ApiType {
if (account.kind === "MongoDB" || account.kind === "Parse") { if (account.kind === "MongoDB" || account.kind === "Parse") {
return "Mongo"; return "Mongo";
} }
if (account.kind === "Postgres") {
return "Postgres";
}
return "SQL"; return "SQL";
} }

View File

@ -2,10 +2,14 @@ import create, { UseStore } from "zustand";
interface TeachingBubbleState { interface TeachingBubbleState {
showPostgreTeachingBubble: boolean; showPostgreTeachingBubble: boolean;
showResetPasswordBubble: boolean;
setShowPostgreTeachingBubble: (showPostgreTeachingBubble: boolean) => void; setShowPostgreTeachingBubble: (showPostgreTeachingBubble: boolean) => void;
setShowResetPasswordBubble: (showResetPasswordBubble: boolean) => void;
} }
export const usePostgres: UseStore<TeachingBubbleState> = create((set) => ({ export const usePostgres: UseStore<TeachingBubbleState> = create((set) => ({
showPostgreTeachingBubble: false, showPostgreTeachingBubble: false,
showResetPasswordBubble: false,
setShowPostgreTeachingBubble: (showPostgreTeachingBubble: boolean) => set({ showPostgreTeachingBubble }), setShowPostgreTeachingBubble: (showPostgreTeachingBubble: boolean) => set({ showPostgreTeachingBubble }),
setShowResetPasswordBubble: (showResetPasswordBubble: boolean) => set({ showResetPasswordBubble }),
})); }));