diff --git a/src/Explorer/Controls/Settings/SettingsSubComponents/ScaleComponent.tsx b/src/Explorer/Controls/Settings/SettingsSubComponents/ScaleComponent.tsx index 8b2cf2d43..e23f1da0a 100644 --- a/src/Explorer/Controls/Settings/SettingsSubComponents/ScaleComponent.tsx +++ b/src/Explorer/Controls/Settings/SettingsSubComponents/ScaleComponent.tsx @@ -5,6 +5,7 @@ import { configContext, Platform } from "../../../../ConfigContext"; import * as DataModels from "../../../../Contracts/DataModels"; import * as ViewModels from "../../../../Contracts/ViewModels"; import * as SharedConstants from "../../../../Shared/Constants"; +import { userContext } from "../../../../UserContext"; import * as AutoPilotUtils from "../../../../Utils/AutoPilotUtils"; import Explorer from "../../../Explorer"; import { @@ -79,7 +80,7 @@ export class ScaleComponent extends React.Component { }; public getMaxRUs = (): number => { - if (this.props.container?.isTryCosmosDBSubscription()) { + if (userContext.isTryCosmosDBSubscription) { return Constants.TryCosmosExperience.maxRU; } @@ -91,7 +92,7 @@ export class ScaleComponent extends React.Component { }; public getMinRUs = (): number => { - if (this.props.container?.isTryCosmosDBSubscription()) { + if (userContext.isTryCosmosDBSubscription) { return SharedConstants.CollectionCreation.DefaultCollectionRUs400; } diff --git a/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap b/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap index defce3016..f57ef59f0 100644 --- a/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap +++ b/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap @@ -945,7 +945,6 @@ exports[`SettingsComponent renders 1`] = ` "isSparkEnabledForAccount": [Function], "isSynapseLinkUpdating": [Function], "isTabsContentExpanded": [Function], - "isTryCosmosDBSubscription": [Function], "loadQueryPane": LoadQueryPane { "container": [Circular], "files": [Function], @@ -2144,7 +2143,6 @@ exports[`SettingsComponent renders 1`] = ` "isSparkEnabledForAccount": [Function], "isSynapseLinkUpdating": [Function], "isTabsContentExpanded": [Function], - "isTryCosmosDBSubscription": [Function], "loadQueryPane": LoadQueryPane { "container": [Circular], "files": [Function], @@ -3356,7 +3354,6 @@ exports[`SettingsComponent renders 1`] = ` "isSparkEnabledForAccount": [Function], "isSynapseLinkUpdating": [Function], "isTabsContentExpanded": [Function], - "isTryCosmosDBSubscription": [Function], "loadQueryPane": LoadQueryPane { "container": [Circular], "files": [Function], @@ -4555,7 +4552,6 @@ exports[`SettingsComponent renders 1`] = ` "isSparkEnabledForAccount": [Function], "isSynapseLinkUpdating": [Function], "isTabsContentExpanded": [Function], - "isTryCosmosDBSubscription": [Function], "loadQueryPane": LoadQueryPane { "container": [Circular], "files": [Function], diff --git a/src/Explorer/Explorer.tsx b/src/Explorer/Explorer.tsx index 970068fec..cfef5ab9c 100644 --- a/src/Explorer/Explorer.tsx +++ b/src/Explorer/Explorer.tsx @@ -163,7 +163,6 @@ export default class Explorer { public isAccountReady: ko.Observable; public canSaveQueries: ko.Computed; public features: ko.Observable; - public isTryCosmosDBSubscription: ko.Observable; public queriesClient: QueriesClient; public tableDataClient: TableDataClient; public splitter: Splitter; @@ -398,7 +397,6 @@ export default class Explorer { this.features = ko.observable(); this.queriesClient = new QueriesClient(this); - this.isTryCosmosDBSubscription = ko.observable(false); this.resourceTokenDatabaseId = ko.observable(); this.resourceTokenCollectionId = ko.observable(); @@ -1447,7 +1445,6 @@ export default class Explorer { if (inputs.addCollectionDefaultFlight) { this.flight(inputs.addCollectionDefaultFlight); } - this.isTryCosmosDBSubscription(inputs.isTryCosmosDBSubscription ?? false); this.setFeatureFlagsFromFlights(inputs.flights); TelemetryProcessor.traceSuccess( Action.LoadDatabaseAccount, diff --git a/src/Explorer/Panes/AddCollectionPane.ts b/src/Explorer/Panes/AddCollectionPane.ts index 51ca127b0..67b9ed6ff 100644 --- a/src/Explorer/Panes/AddCollectionPane.ts +++ b/src/Explorer/Panes/AddCollectionPane.ts @@ -49,7 +49,7 @@ export default class AddCollectionPane extends ContextualPaneBase { public throughputDatabase: ViewModels.Editable; public isPreferredApiTable: ko.Computed; public partitionKeyPlaceholder: ko.Computed; - public isTryCosmosDBSubscription: ko.Computed; + public isTryCosmosDBSubscription: ko.Observable; public maxThroughputRU: ko.Observable; public minThroughputRU: ko.Observable; public throughputRangeText: ko.Computed; @@ -288,9 +288,7 @@ export default class AddCollectionPane extends ContextualPaneBase { return estimatedSpend; }); - this.isTryCosmosDBSubscription = ko.pureComputed(() => { - return (this.container && this.container.isTryCosmosDBSubscription()) || false; - }); + this.isTryCosmosDBSubscription = ko.observable(userContext.isTryCosmosDBSubscription || false); this.isTryCosmosDBSubscription.subscribe((isTryCosmosDB: boolean) => { if (!!isTryCosmosDB) { @@ -301,7 +299,7 @@ export default class AddCollectionPane extends ContextualPaneBase { this.canRequestSupport = ko.pureComputed(() => { if ( configContext.platform !== Platform.Emulator && - !this.container.isTryCosmosDBSubscription() && + !userContext.isTryCosmosDBSubscription && configContext.platform !== Platform.Portal ) { const offerThroughput: number = this._getThroughput(); diff --git a/src/Explorer/Panes/AddDatabasePane.ts b/src/Explorer/Panes/AddDatabasePane.ts index 937de124d..b8336b941 100644 --- a/src/Explorer/Panes/AddDatabasePane.ts +++ b/src/Explorer/Panes/AddDatabasePane.ts @@ -169,7 +169,7 @@ export default class AddDatabasePane extends ContextualPaneBase { this.canRequestSupport = ko.pureComputed(() => { if ( configContext.platform !== Platform.Emulator && - !this.container.isTryCosmosDBSubscription() && + !userContext.isTryCosmosDBSubscription && configContext.platform !== Platform.Portal ) { const offerThroughput: number = this.throughput(); diff --git a/src/Explorer/Panes/CassandraAddCollectionPane.ts b/src/Explorer/Panes/CassandraAddCollectionPane.ts index 7de0b353f..92bfa87bc 100644 --- a/src/Explorer/Panes/CassandraAddCollectionPane.ts +++ b/src/Explorer/Panes/CassandraAddCollectionPane.ts @@ -223,7 +223,7 @@ export default class CassandraAddCollectionPane extends ContextualPaneBase { }); this.canRequestSupport = ko.pureComputed(() => { - if (configContext.platform !== Platform.Emulator && !this.container.isTryCosmosDBSubscription()) { + if (configContext.platform !== Platform.Emulator && !userContext.isTryCosmosDBSubscription) { const offerThroughput: number = this.throughput(); return offerThroughput <= 100000; } diff --git a/src/UserContext.ts b/src/UserContext.ts index 8e36076c7..0130392cd 100644 --- a/src/UserContext.ts +++ b/src/UserContext.ts @@ -20,15 +20,14 @@ interface UserContext { // API Type is not yet provided by ARM. You need to manually inspect all the capabilities+kind so we abstract that logic in userContext // This is coming in a future Cosmos ARM API version as a prperty on databaseAccount apiType?: ApiType; + isTryCosmosDBSubscription?: boolean; portalEnv?: PortalEnv; } type ApiType = "SQL" | "Mongo" | "Gremlin" | "Tables" | "Cassandra"; export type PortalEnv = "localhost" | "blackforest" | "fairfax" | "mooncake" | "prod" | "dev"; -const userContext: UserContext = { - portalEnv: "prod", -}; +const userContext: UserContext = { isTryCosmosDBSubscription: false, portalEnv: "prod" }; function updateUserContext(newContext: UserContext): void { Object.assign(userContext, newContext); diff --git a/test/mongo/mongoIndexPolicy.spec.ts b/test/mongo/mongoIndexPolicy.spec.ts index 219715744..ce96a16ad 100644 --- a/test/mongo/mongoIndexPolicy.spec.ts +++ b/test/mongo/mongoIndexPolicy.spec.ts @@ -33,7 +33,7 @@ describe("MongoDB Index policy tests", () => { await frame.click(`div[data-test="${collectionId}"]`); await frame.waitFor(`div[data-test="Scale & Settings"]`), { visible: true }; - await frame.waitFor(LOADING_STATE_DELAY); + await frame.waitFor(10000); await frame.click(`div[data-test="Scale & Settings"]`); await frame.waitFor(`button[data-content="Indexing Policy"]`), { visible: true };