From d90a065e631469b50216a3a9973391b58180cb12 Mon Sep 17 00:00:00 2001 From: Steve Faulkner Date: Tue, 13 Apr 2021 15:43:05 -0500 Subject: [PATCH] Fix feature flags in Portal (#659) --- src/Contracts/ViewModels.ts | 3 +++ src/hooks/useKnockoutExplorer.ts | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Contracts/ViewModels.ts b/src/Contracts/ViewModels.ts index 240031f52..d839b3223 100644 --- a/src/Contracts/ViewModels.ts +++ b/src/Contracts/ViewModels.ts @@ -390,6 +390,9 @@ export interface DataExplorerInputsFrame { dataExplorerVersion?: string; defaultCollectionThroughput?: CollectionCreationDefaults; flights?: readonly string[]; + features?: { + [key: string]: string; + }; } export interface SelfServeFrameInputs { diff --git a/src/hooks/useKnockoutExplorer.ts b/src/hooks/useKnockoutExplorer.ts index 6d4c94575..2905474a9 100644 --- a/src/hooks/useKnockoutExplorer.ts +++ b/src/hooks/useKnockoutExplorer.ts @@ -18,6 +18,7 @@ import { ResourceToken, } from "../HostedExplorerChildFrame"; import { emulatorAccount } from "../Platform/Emulator/emulatorAccount"; +import { extractFeatures } from "../Platform/Hosted/extractFeatures"; import { parseResourceTokenConnectionString } from "../Platform/Hosted/Helpers/ResourceTokenUtils"; import { getDatabaseAccountKindFromExperience, @@ -25,7 +26,7 @@ import { } from "../Platform/Hosted/HostedUtils"; import { CollectionCreation } from "../Shared/Constants"; import { DefaultExperienceUtility } from "../Shared/DefaultExperienceUtility"; -import { PortalEnv, updateUserContext } from "../UserContext"; +import { PortalEnv, updateUserContext, userContext } from "../UserContext"; import { listKeys } from "../Utils/arm/generatedClients/2020-04-01/databaseAccounts"; import { isInvalidParentFrameOrigin } from "../Utils/MessageValidation"; @@ -308,6 +309,9 @@ function updateContextsFromPortalMessage(inputs: DataExplorerInputsFrame) { hasWriteAccess: inputs.hasWriteAccess ?? true, addCollectionFlight: inputs.addCollectionDefaultFlight || CollectionCreation.DefaultAddCollectionDefaultFlight, }); + if (inputs.features) { + Object.assign(userContext.features, extractFeatures(new URLSearchParams(inputs.features))); + } } interface PortalMessage {