From 0f8c36bbf075df2f87001387e78b0e28f039107f Mon Sep 17 00:00:00 2001 From: Steve Faulkner Date: Tue, 15 Dec 2020 23:26:30 -0600 Subject: [PATCH] Move serverId --- src/ConfigContext.ts | 1 + .../SettingsSubComponents/ScaleComponent.tsx | 2 +- src/Explorer/Explorer.ts | 12 +++++------- src/Explorer/Panes/AddCollectionPane.ts | 8 ++++---- src/Explorer/Panes/AddDatabasePane.ts | 4 ++-- src/Explorer/Panes/CassandraAddCollectionPane.ts | 4 ++-- src/Explorer/Tabs/DatabaseSettingsTab.ts | 2 +- src/Explorer/Tabs/MongoShellTab.ts | 2 +- 8 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/ConfigContext.ts b/src/ConfigContext.ts index db244e3f2..3a9f4fa2c 100644 --- a/src/ConfigContext.ts +++ b/src/ConfigContext.ts @@ -26,6 +26,7 @@ interface ConfigContext { GITHUB_CLIENT_SECRET?: string; // No need to inject secret for prod. Juno already knows it. hostedExplorerURL: string; armAPIVersion?: string; + serverId?: string; } // Default configuration diff --git a/src/Explorer/Controls/Settings/SettingsSubComponents/ScaleComponent.tsx b/src/Explorer/Controls/Settings/SettingsSubComponents/ScaleComponent.tsx index 10aaa0cbf..988d231e5 100644 --- a/src/Explorer/Controls/Settings/SettingsSubComponents/ScaleComponent.tsx +++ b/src/Explorer/Controls/Settings/SettingsSubComponents/ScaleComponent.tsx @@ -165,7 +165,7 @@ export class ScaleComponent extends React.Component { private getThroughputInputComponent = (): JSX.Element => ( ; public canSaveQueries: ko.Computed; public features: ko.Observable; - public serverId: ko.Observable; public isTryCosmosDBSubscription: ko.Observable; public queriesClient: QueriesClient; public tableDataClient: TableDataClient; @@ -365,7 +364,6 @@ export default class Explorer { this.memoryUsageInfo = ko.observable(); this.features = ko.observable(); - this.serverId = ko.observable(); this.queriesClient = new QueriesClient(this); this.isTryCosmosDBSubscription = ko.observable(false); @@ -1854,7 +1852,6 @@ export default class Explorer { this.collectionCreationDefaults = inputs.defaultCollectionThroughput; } this.features(inputs.features); - this.serverId(inputs.serverId); this.databaseAccount(databaseAccount); this.subscriptionType(inputs.subscriptionType); this.hasWriteAccess(inputs.hasWriteAccess); @@ -1866,7 +1863,8 @@ export default class Explorer { updateConfigContext({ BACKEND_ENDPOINT: inputs.extensionEndpoint || "", - ARM_ENDPOINT: normalizeArmEndpoint(inputs.csmEndpoint || configContext.ARM_ENDPOINT) + ARM_ENDPOINT: normalizeArmEndpoint(inputs.csmEndpoint || configContext.ARM_ENDPOINT), + serverId: inputs.serverId }); updateUserContext({ @@ -1953,9 +1951,9 @@ export default class Explorer { public isRunningOnNationalCloud(): boolean { return ( - this.serverId() === Constants.ServerIds.blackforest || - this.serverId() === Constants.ServerIds.fairfax || - this.serverId() === Constants.ServerIds.mooncake + userContext === Constants.ServerIds.blackforest || + userContext === Constants.ServerIds.fairfax || + userContext === Constants.ServerIds.mooncake ); } diff --git a/src/Explorer/Panes/AddCollectionPane.ts b/src/Explorer/Panes/AddCollectionPane.ts index 08bd372f1..87d4c4268 100644 --- a/src/Explorer/Panes/AddCollectionPane.ts +++ b/src/Explorer/Panes/AddCollectionPane.ts @@ -186,7 +186,7 @@ export default class AddCollectionPane extends ContextualPaneBase { return ""; } - const serverId: string = this.container.serverId(); + const serverId = configContext.serverId; const regions = (account && account.properties && @@ -200,7 +200,7 @@ export default class AddCollectionPane extends ContextualPaneBase { if (!this.isSharedAutoPilotSelected()) { throughputSpendAckText = PricingUtils.getEstimatedSpendAcknowledgeString( offerThroughput, - serverId, + configContext.serverId, regions, multimaster, this.isSharedAutoPilotSelected() @@ -240,7 +240,7 @@ export default class AddCollectionPane extends ContextualPaneBase { return ""; } - const serverId: string = this.container.serverId(); + const serverId: string = configContext.serverId; const regions = (account && account.properties && @@ -482,7 +482,7 @@ export default class AddCollectionPane extends ContextualPaneBase { }); this.upsellMessage = ko.pureComputed(() => { - return PricingUtils.getUpsellMessage(this.container.serverId(), this.isFreeTierAccount()); + return PricingUtils.getUpsellMessage(configContext.serverId, this.isFreeTierAccount()); }); this.upsellMessageAriaLabel = ko.pureComputed(() => { diff --git a/src/Explorer/Panes/AddDatabasePane.ts b/src/Explorer/Panes/AddDatabasePane.ts index 16f800923..5f48914aa 100644 --- a/src/Explorer/Panes/AddDatabasePane.ts +++ b/src/Explorer/Panes/AddDatabasePane.ts @@ -122,7 +122,7 @@ export default class AddDatabasePane extends ContextualPaneBase { return ""; } - const serverId = this.container.serverId(); + const serverId = configContext.serverId; const regions = (account && account.properties && @@ -220,7 +220,7 @@ export default class AddDatabasePane extends ContextualPaneBase { }); this.upsellMessage = ko.pureComputed(() => { - return PricingUtils.getUpsellMessage(this.container.serverId(), this.isFreeTierAccount()); + return PricingUtils.getUpsellMessage(configContext.serverId, this.isFreeTierAccount()); }); this.upsellMessageAriaLabel = ko.pureComputed(() => { diff --git a/src/Explorer/Panes/CassandraAddCollectionPane.ts b/src/Explorer/Panes/CassandraAddCollectionPane.ts index 092f032a7..96c2bc695 100644 --- a/src/Explorer/Panes/CassandraAddCollectionPane.ts +++ b/src/Explorer/Panes/CassandraAddCollectionPane.ts @@ -127,7 +127,7 @@ export default class CassandraAddCollectionPane extends ContextualPaneBase { return ""; } - const serverId = this.container.serverId(); + const serverId = configContext.serverId; const regions = (account && account.properties && @@ -172,7 +172,7 @@ export default class CassandraAddCollectionPane extends ContextualPaneBase { return ""; } - const serverId = this.container.serverId(); + const serverId = configContext.serverId; const regions = (account && account.properties && diff --git a/src/Explorer/Tabs/DatabaseSettingsTab.ts b/src/Explorer/Tabs/DatabaseSettingsTab.ts index 75f441af4..0fb2110d7 100644 --- a/src/Explorer/Tabs/DatabaseSettingsTab.ts +++ b/src/Explorer/Tabs/DatabaseSettingsTab.ts @@ -139,7 +139,7 @@ export default class DatabaseSettingsTab extends TabsBase implements ViewModels. return ""; } - const serverId = this.container.serverId(); + const serverId = configContext.serverId; const regions = (account && account.properties && diff --git a/src/Explorer/Tabs/MongoShellTab.ts b/src/Explorer/Tabs/MongoShellTab.ts index 04b9528b7..2519d2b19 100644 --- a/src/Explorer/Tabs/MongoShellTab.ts +++ b/src/Explorer/Tabs/MongoShellTab.ts @@ -33,7 +33,7 @@ export default class MongoShellTab extends TabsBase { this._runtimeEndpoint = configContext.platform === Platform.Hosted ? configContext.BACKEND_ENDPOINT : ""; const extensionEndpoint: string = configContext.BACKEND_ENDPOINT || this._runtimeEndpoint || ""; let baseUrl = "/content/mongoshell/dist/"; - if (this._container.serverId() === "localhost") { + if (configContext.serverId === "localhost") { baseUrl = "/content/mongoshell/"; }