From beca0d660872dca4ac5b5120beccad99fe362a5d Mon Sep 17 00:00:00 2001 From: victor-meng <56978073+victor-meng@users.noreply.github.com> Date: Tue, 20 Sep 2022 10:42:09 -0700 Subject: [PATCH] Properly load a postgres account in data explorer (#1323) --- src/Contracts/ViewModels.ts | 1 + src/Explorer/Explorer.tsx | 2 +- .../Menus/CommandBar/CommandBarComponentAdapter.tsx | 2 +- src/Platform/Hosted/extractFeatures.ts | 2 -- src/UserContext.ts | 4 ---- src/hooks/useKnockoutExplorer.ts | 6 ++++++ 6 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Contracts/ViewModels.ts b/src/Contracts/ViewModels.ts index 9e89807e2..c9a158f0c 100644 --- a/src/Contracts/ViewModels.ts +++ b/src/Contracts/ViewModels.ts @@ -395,6 +395,7 @@ export interface DataExplorerInputsFrame { sharedThroughputDefault?: number; dataExplorerVersion?: string; defaultCollectionThroughput?: CollectionCreationDefaults; + isPostgresAccount?: boolean; flights?: readonly string[]; features?: { [key: string]: string; diff --git a/src/Explorer/Explorer.tsx b/src/Explorer/Explorer.tsx index f4fb4400c..bb157d703 100644 --- a/src/Explorer/Explorer.tsx +++ b/src/Explorer/Explorer.tsx @@ -185,7 +185,7 @@ export default class Explorer { useNotebook.getState().setNotebookBasePath(userContext.features.notebookBasePath); } - if (!userContext.features.enablePGQuickstart || userContext.apiType !== "Postgres") { + if (userContext.apiType !== "Postgres") { this.refreshExplorer(); } } diff --git a/src/Explorer/Menus/CommandBar/CommandBarComponentAdapter.tsx b/src/Explorer/Menus/CommandBar/CommandBarComponentAdapter.tsx index 755dc16e0..9b69e2a9b 100644 --- a/src/Explorer/Menus/CommandBar/CommandBarComponentAdapter.tsx +++ b/src/Explorer/Menus/CommandBar/CommandBarComponentAdapter.tsx @@ -34,7 +34,7 @@ export const CommandBar: React.FC = ({ container }: Props) => { const buttons = useCommandBar((state) => state.contextButtons); const backgroundColor = StyleConstants.BaseLight; - if (userContext.features.enablePGQuickstart && userContext.apiType === "Postgres") { + if (userContext.apiType === "Postgres") { const buttons = CommandBarComponentButtonFactory.createPostgreButtons(container); return (
diff --git a/src/Platform/Hosted/extractFeatures.ts b/src/Platform/Hosted/extractFeatures.ts index 0eb35ad44..368f09eb2 100644 --- a/src/Platform/Hosted/extractFeatures.ts +++ b/src/Platform/Hosted/extractFeatures.ts @@ -29,7 +29,6 @@ export type Features = { readonly mongoProxyEndpoint?: string; readonly mongoProxyAPIs?: string; readonly enableThroughputCap: boolean; - readonly enablePGQuickstart: boolean; // can be set via both flight and feature flag autoscaleDefault: boolean; @@ -91,7 +90,6 @@ export function extractFeatures(given = new URLSearchParams(window.location.sear partitionKeyDefault2: "true" === get("pkpartitionkeytest"), notebooksDownBanner: "true" === get("notebooksDownBanner"), enableThroughputCap: "true" === get("enablethroughputcap"), - enablePGQuickstart: "true" === get("enablepgquickstart"), }; } diff --git a/src/UserContext.ts b/src/UserContext.ts index f430802dd..ee5e7eb41 100644 --- a/src/UserContext.ts +++ b/src/UserContext.ts @@ -112,10 +112,6 @@ function apiType(account: DatabaseAccount | undefined): ApiType { return "SQL"; } - if (features.enablePGQuickstart) { - return "Postgres"; - } - const capabilities = account.properties?.capabilities; if (capabilities) { if (capabilities.find((c) => c.name === "EnableCassandra")) { diff --git a/src/hooks/useKnockoutExplorer.ts b/src/hooks/useKnockoutExplorer.ts index 09b1654ca..e93d28196 100644 --- a/src/hooks/useKnockoutExplorer.ts +++ b/src/hooks/useKnockoutExplorer.ts @@ -354,9 +354,15 @@ function updateContextsFromPortalMessage(inputs: DataExplorerInputsFrame) { collectionCreationDefaults: inputs.defaultCollectionThroughput, isTryCosmosDBSubscription: inputs.isTryCosmosDBSubscription, }); + + if (inputs.isPostgresAccount) { + updateUserContext({ apiType: "Postgres" }); + } + if (inputs.features) { Object.assign(userContext.features, extractFeatures(new URLSearchParams(inputs.features))); } + if (inputs.flights) { if (inputs.flights.indexOf(Flights.AutoscaleTest) !== -1) { userContext.features.autoscaleDefault;