From cb7760b3f63dfda2be3f442dd0f84c25c49e7220 Mon Sep 17 00:00:00 2001 From: Steve Faulkner Date: Tue, 6 Apr 2021 13:33:12 -0500 Subject: [PATCH] Remove Explorer.flight and Explorer.hasWriteAccess (#618) * Remove Explorer.flight * Update snapshots * Remove Explorere.hasWriteAccess * Update snapshot --- .../__snapshots__/SettingsComponent.test.tsx.snap | 8 -------- src/Explorer/Explorer.tsx | 10 ---------- src/Explorer/Panes/AddCollectionPane.ts | 11 ++++------- src/Explorer/Panes/AddDatabasePane.ts | 11 ++++------- src/Explorer/Panes/CassandraAddCollectionPane.ts | 12 ++++-------- .../SettingsPane/__snapshots__/index.test.tsx.snap | 4 ---- .../__snapshots__/index.test.tsx.snap | 2 -- .../DeleteDatabaseConfirmationPanel.test.tsx.snap | 2 -- src/UserContext.ts | 5 +++++ src/hooks/useKnockoutExplorer.ts | 4 ++++ 10 files changed, 21 insertions(+), 48 deletions(-) diff --git a/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap b/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap index e2b4bd1a9..28544f2bd 100644 --- a/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap +++ b/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap @@ -666,7 +666,6 @@ exports[`SettingsComponent renders 1`] = ` "title": [Function], "visible": [Function], }, - "flight": [Function], "graphStylingPane": GraphStylingPane { "container": [Circular], "firstFieldHasFocus": [Function], @@ -688,7 +687,6 @@ exports[`SettingsComponent renders 1`] = ` "visible": [Function], }, "hasStorageAnalyticsAfecFeature": [Function], - "hasWriteAccess": [Function], "isAccountReady": [Function], "isAutoscaleDefaultEnabled": [Function], "isCopyNotebookPaneEnabled": [Function], @@ -1506,7 +1504,6 @@ exports[`SettingsComponent renders 1`] = ` "title": [Function], "visible": [Function], }, - "flight": [Function], "graphStylingPane": GraphStylingPane { "container": [Circular], "firstFieldHasFocus": [Function], @@ -1528,7 +1525,6 @@ exports[`SettingsComponent renders 1`] = ` "visible": [Function], }, "hasStorageAnalyticsAfecFeature": [Function], - "hasWriteAccess": [Function], "isAccountReady": [Function], "isAutoscaleDefaultEnabled": [Function], "isCopyNotebookPaneEnabled": [Function], @@ -2359,7 +2355,6 @@ exports[`SettingsComponent renders 1`] = ` "title": [Function], "visible": [Function], }, - "flight": [Function], "graphStylingPane": GraphStylingPane { "container": [Circular], "firstFieldHasFocus": [Function], @@ -2381,7 +2376,6 @@ exports[`SettingsComponent renders 1`] = ` "visible": [Function], }, "hasStorageAnalyticsAfecFeature": [Function], - "hasWriteAccess": [Function], "isAccountReady": [Function], "isAutoscaleDefaultEnabled": [Function], "isCopyNotebookPaneEnabled": [Function], @@ -3199,7 +3193,6 @@ exports[`SettingsComponent renders 1`] = ` "title": [Function], "visible": [Function], }, - "flight": [Function], "graphStylingPane": GraphStylingPane { "container": [Circular], "firstFieldHasFocus": [Function], @@ -3221,7 +3214,6 @@ exports[`SettingsComponent renders 1`] = ` "visible": [Function], }, "hasStorageAnalyticsAfecFeature": [Function], - "hasWriteAccess": [Function], "isAccountReady": [Function], "isAutoscaleDefaultEnabled": [Function], "isCopyNotebookPaneEnabled": [Function], diff --git a/src/Explorer/Explorer.tsx b/src/Explorer/Explorer.tsx index 50861453b..d59f797f0 100644 --- a/src/Explorer/Explorer.tsx +++ b/src/Explorer/Explorer.tsx @@ -97,10 +97,6 @@ export interface ExplorerParams { } export default class Explorer { - public flight: ko.Observable = ko.observable( - SharedConstants.CollectionCreation.DefaultAddCollectionDefaultFlight - ); - public addCollectionText: ko.Observable; public addDatabaseText: ko.Observable; public collectionTitle: ko.Observable; @@ -108,7 +104,6 @@ export default class Explorer { public deleteDatabaseText: ko.Observable; public collectionTreeNodeAltText: ko.Observable; public refreshTreeTitle: ko.Observable; - public hasWriteAccess: ko.Observable; public collapsedResourceTreeWidth: number = ExplorerMetrics.CollapsedResourceTreeWidth; /** @@ -271,7 +266,6 @@ export default class Explorer { }); this.addCollectionText = ko.observable("New Collection"); this.addDatabaseText = ko.observable("New Database"); - this.hasWriteAccess = ko.observable(true); this.collectionTitle = ko.observable("Collections"); this.collectionTreeNodeAltText = ko.observable("Collection"); this.deleteCollectionText = ko.observable("Delete Collection"); @@ -1283,10 +1277,6 @@ export default class Explorer { } this.databaseAccount(databaseAccount); this.subscriptionType(inputs.subscriptionType ?? SharedConstants.CollectionCreation.DefaultSubscriptionType); - this.hasWriteAccess(inputs.hasWriteAccess ?? true); - if (inputs.addCollectionDefaultFlight) { - this.flight(inputs.addCollectionDefaultFlight); - } this.setFeatureFlagsFromFlights(inputs.flights); TelemetryProcessor.traceSuccess( Action.LoadDatabaseAccount, diff --git a/src/Explorer/Panes/AddCollectionPane.ts b/src/Explorer/Panes/AddCollectionPane.ts index 74d1071ca..d74b7b96a 100644 --- a/src/Explorer/Panes/AddCollectionPane.ts +++ b/src/Explorer/Panes/AddCollectionPane.ts @@ -478,9 +478,6 @@ export default class AddCollectionPane extends ContextualPaneBase { }); this.resetData(); - this.container.flight.subscribe(() => { - this.resetData(); - }); this.freeTierExceedThroughputTooltip = ko.pureComputed(() => this.isFreeTierAccount() && !this.container.isFirstResourceCreated() @@ -706,7 +703,7 @@ export default class AddCollectionPane extends ContextualPaneBase { defaultsCheck: { storage: this.storage() === Constants.BackendDefaults.singlePartitionStorageInGb ? "f" : "u", throughput: this._getThroughput(), - flight: this.container.flight(), + flight: userContext.addCollectionFlight, }, dataExplorerArea: Constants.Areas.ContextualPane, }; @@ -810,7 +807,7 @@ export default class AddCollectionPane extends ContextualPaneBase { defaultsCheck: { storage: this.storage() === Constants.BackendDefaults.singlePartitionStorageInGb ? "f" : "u", throughput: offerThroughput, - flight: this.container.flight(), + flight: userContext.addCollectionFlight, }, dataExplorerArea: Constants.Areas.ContextualPane, useIndexingForSharedThroughput: this.useIndexingForSharedThroughput(), @@ -882,7 +879,7 @@ export default class AddCollectionPane extends ContextualPaneBase { defaultsCheck: { storage: this.storage() === Constants.BackendDefaults.singlePartitionStorageInGb ? "f" : "u", throughput: offerThroughput, - flight: this.container.flight(), + flight: userContext.addCollectionFlight, }, dataExplorerArea: Constants.Areas.ContextualPane, }; @@ -914,7 +911,7 @@ export default class AddCollectionPane extends ContextualPaneBase { defaultsCheck: { storage: this.storage() === Constants.BackendDefaults.singlePartitionStorageInGb ? "f" : "u", throughput: offerThroughput, - flight: this.container.flight(), + flight: userContext.addCollectionFlight, }, dataExplorerArea: Constants.Areas.ContextualPane, error: errorMessage, diff --git a/src/Explorer/Panes/AddDatabasePane.ts b/src/Explorer/Panes/AddDatabasePane.ts index b8336b941..094ecc646 100644 --- a/src/Explorer/Panes/AddDatabasePane.ts +++ b/src/Explorer/Panes/AddDatabasePane.ts @@ -231,9 +231,6 @@ export default class AddDatabasePane extends ContextualPaneBase { }); this.resetData(); - this.container.flight.subscribe(() => { - this.resetData(); - }); this.freeTierExceedThroughputTooltip = ko.pureComputed(() => this.isFreeTierAccount() && !this.container.isFirstResourceCreated() @@ -280,7 +277,7 @@ export default class AddDatabasePane extends ContextualPaneBase { subscriptionQuotaId: userContext.quotaId, defaultsCheck: { throughput: this.throughput(), - flight: this.container.flight(), + flight: userContext.addCollectionFlight, }, dataExplorerArea: Constants.Areas.ContextualPane, }; @@ -305,7 +302,7 @@ export default class AddDatabasePane extends ContextualPaneBase { subscriptionType: SubscriptionType[this.container.subscriptionType()], subscriptionQuotaId: userContext.quotaId, defaultsCheck: { - flight: this.container.flight(), + flight: userContext.addCollectionFlight, }, dataExplorerArea: Constants.Areas.ContextualPane, }; @@ -367,7 +364,7 @@ export default class AddDatabasePane extends ContextualPaneBase { subscriptionType: SubscriptionType[this.container.subscriptionType()], subscriptionQuotaId: userContext.quotaId, defaultsCheck: { - flight: this.container.flight(), + flight: userContext.addCollectionFlight, }, dataExplorerArea: Constants.Areas.ContextualPane, }; @@ -389,7 +386,7 @@ export default class AddDatabasePane extends ContextualPaneBase { subscriptionType: SubscriptionType[this.container.subscriptionType()], subscriptionQuotaId: userContext.quotaId, defaultsCheck: { - flight: this.container.flight(), + flight: userContext.addCollectionFlight, }, dataExplorerArea: Constants.Areas.ContextualPane, error: errorMessage, diff --git a/src/Explorer/Panes/CassandraAddCollectionPane.ts b/src/Explorer/Panes/CassandraAddCollectionPane.ts index 44cf83a7f..385d9b291 100644 --- a/src/Explorer/Panes/CassandraAddCollectionPane.ts +++ b/src/Explorer/Panes/CassandraAddCollectionPane.ts @@ -117,10 +117,6 @@ export default class CassandraAddCollectionPane extends ContextualPaneBase { this.resetData(); - this.container.flight.subscribe(() => { - this.resetData(); - }); - this.requestUnitsUsageCostDedicated = ko.computed(() => { const account = this.container.databaseAccount(); if (!account) { @@ -311,7 +307,7 @@ export default class CassandraAddCollectionPane extends ContextualPaneBase { defaultsCheck: { storage: "u", throughput: this.throughput(), - flight: this.container.flight(), + flight: userContext.addCollectionFlight, }, dataExplorerArea: Constants.Areas.ContextualPane, }; @@ -363,7 +359,7 @@ export default class CassandraAddCollectionPane extends ContextualPaneBase { defaultsCheck: { storage: "u", throughput: this.throughput(), - flight: this.container.flight(), + flight: userContext.addCollectionFlight, }, dataExplorerArea: Constants.Areas.ContextualPane, toCreateKeyspace: toCreateKeyspace, @@ -407,7 +403,7 @@ export default class CassandraAddCollectionPane extends ContextualPaneBase { defaultsCheck: { storage: "u", throughput: this.throughput(), - flight: this.container.flight(), + flight: userContext.addCollectionFlight, }, dataExplorerArea: Constants.Areas.ContextualPane, toCreateKeyspace: toCreateKeyspace, @@ -435,7 +431,7 @@ export default class CassandraAddCollectionPane extends ContextualPaneBase { defaultsCheck: { storage: "u", throughput: this.throughput(), - flight: this.container.flight(), + flight: userContext.addCollectionFlight, }, dataExplorerArea: Constants.Areas.ContextualPane, toCreateKeyspace: toCreateKeyspace, diff --git a/src/Explorer/Panes/SettingsPane/__snapshots__/index.test.tsx.snap b/src/Explorer/Panes/SettingsPane/__snapshots__/index.test.tsx.snap index 39940921f..22dbd0432 100644 --- a/src/Explorer/Panes/SettingsPane/__snapshots__/index.test.tsx.snap +++ b/src/Explorer/Panes/SettingsPane/__snapshots__/index.test.tsx.snap @@ -642,7 +642,6 @@ exports[`Settings Pane should render Default properly 1`] = ` "title": [Function], "visible": [Function], }, - "flight": [Function], "graphStylingPane": GraphStylingPane { "container": [Circular], "firstFieldHasFocus": [Function], @@ -664,7 +663,6 @@ exports[`Settings Pane should render Default properly 1`] = ` "visible": [Function], }, "hasStorageAnalyticsAfecFeature": [Function], - "hasWriteAccess": [Function], "isAccountReady": [Function], "isAutoscaleDefaultEnabled": [Function], "isCopyNotebookPaneEnabled": [Function], @@ -1570,7 +1568,6 @@ exports[`Settings Pane should render Gremlin properly 1`] = ` "title": [Function], "visible": [Function], }, - "flight": [Function], "graphStylingPane": GraphStylingPane { "container": [Circular], "firstFieldHasFocus": [Function], @@ -1592,7 +1589,6 @@ exports[`Settings Pane should render Gremlin properly 1`] = ` "visible": [Function], }, "hasStorageAnalyticsAfecFeature": [Function], - "hasWriteAccess": [Function], "isAccountReady": [Function], "isAutoscaleDefaultEnabled": [Function], "isCopyNotebookPaneEnabled": [Function], diff --git a/src/Explorer/Panes/UploadItemsPane/__snapshots__/index.test.tsx.snap b/src/Explorer/Panes/UploadItemsPane/__snapshots__/index.test.tsx.snap index f5b51c529..51cb54bbb 100644 --- a/src/Explorer/Panes/UploadItemsPane/__snapshots__/index.test.tsx.snap +++ b/src/Explorer/Panes/UploadItemsPane/__snapshots__/index.test.tsx.snap @@ -642,7 +642,6 @@ exports[`Upload Items Pane should render Default properly 1`] = ` "title": [Function], "visible": [Function], }, - "flight": [Function], "graphStylingPane": GraphStylingPane { "container": [Circular], "firstFieldHasFocus": [Function], @@ -664,7 +663,6 @@ exports[`Upload Items Pane should render Default properly 1`] = ` "visible": [Function], }, "hasStorageAnalyticsAfecFeature": [Function], - "hasWriteAccess": [Function], "isAccountReady": [Function], "isAutoscaleDefaultEnabled": [Function], "isCopyNotebookPaneEnabled": [Function], diff --git a/src/Explorer/Panes/__snapshots__/DeleteDatabaseConfirmationPanel.test.tsx.snap b/src/Explorer/Panes/__snapshots__/DeleteDatabaseConfirmationPanel.test.tsx.snap index a515e5a65..88067eaf6 100644 --- a/src/Explorer/Panes/__snapshots__/DeleteDatabaseConfirmationPanel.test.tsx.snap +++ b/src/Explorer/Panes/__snapshots__/DeleteDatabaseConfirmationPanel.test.tsx.snap @@ -643,7 +643,6 @@ exports[`Delete Database Confirmation Pane submit() Should call delete database "title": [Function], "visible": [Function], }, - "flight": [Function], "graphStylingPane": GraphStylingPane { "container": [Circular], "firstFieldHasFocus": [Function], @@ -665,7 +664,6 @@ exports[`Delete Database Confirmation Pane submit() Should call delete database "visible": [Function], }, "hasStorageAnalyticsAfecFeature": [Function], - "hasWriteAccess": [Function], "isAccountReady": [Function], "isAutoscaleDefaultEnabled": [Function], "isCopyNotebookPaneEnabled": [Function], diff --git a/src/UserContext.ts b/src/UserContext.ts index f8d2970e9..421b5df79 100644 --- a/src/UserContext.ts +++ b/src/UserContext.ts @@ -3,6 +3,7 @@ import { DatabaseAccount } from "./Contracts/DataModels"; import { SubscriptionType } from "./Contracts/SubscriptionType"; import { DefaultAccountExperienceType } from "./DefaultAccountExperienceType"; import { extractFeatures, Features } from "./Platform/Hosted/extractFeatures"; +import { CollectionCreation } from "./Shared/Constants"; interface UserContext { readonly authType?: AuthType; @@ -24,6 +25,8 @@ interface UserContext { readonly isTryCosmosDBSubscription?: boolean; readonly portalEnv?: PortalEnv; readonly features: Features; + readonly addCollectionFlight: string; + readonly hasWriteAccess: boolean; } type ApiType = "SQL" | "Mongo" | "Gremlin" | "Tables" | "Cassandra"; @@ -33,10 +36,12 @@ const features = extractFeatures(); const { enableSDKoperations: useSDKOperations } = features; const userContext: UserContext = { + hasWriteAccess: true, isTryCosmosDBSubscription: false, portalEnv: "prod", features, useSDKOperations, + addCollectionFlight: CollectionCreation.DefaultAddCollectionDefaultFlight, }; function updateUserContext(newContext: Partial): void { diff --git a/src/hooks/useKnockoutExplorer.ts b/src/hooks/useKnockoutExplorer.ts index 80dd38a68..f1fce5827 100644 --- a/src/hooks/useKnockoutExplorer.ts +++ b/src/hooks/useKnockoutExplorer.ts @@ -23,6 +23,7 @@ import { getDatabaseAccountKindFromExperience, getDatabaseAccountPropertiesFromMetadata, } from "../Platform/Hosted/HostedUtils"; +import { CollectionCreation } from "../Shared/Constants"; import { DefaultExperienceUtility } from "../Shared/DefaultExperienceUtility"; import { PortalEnv, updateUserContext } from "../UserContext"; import { listKeys } from "../Utils/arm/generatedClients/2020-04-01/databaseAccounts"; @@ -254,6 +255,9 @@ async function configurePortal(explorerParams: ExplorerParams): Promise