Remvoe Explorer.subscriptionType (#622)

This commit is contained in:
Steve Faulkner 2021-04-06 14:35:14 -05:00 committed by GitHub
parent cb7760b3f6
commit 0f88176a27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 32 additions and 46 deletions

View File

@ -839,7 +839,6 @@ exports[`SettingsComponent renders 1`] = `
"title": [Function], "title": [Function],
"visible": [Function], "visible": [Function],
}, },
"subscriptionType": [Function],
"tabsManager": TabsManager { "tabsManager": TabsManager {
"activeTab": [Function], "activeTab": [Function],
"openedTabs": [Function], "openedTabs": [Function],
@ -1677,7 +1676,6 @@ exports[`SettingsComponent renders 1`] = `
"title": [Function], "title": [Function],
"visible": [Function], "visible": [Function],
}, },
"subscriptionType": [Function],
"tabsManager": TabsManager { "tabsManager": TabsManager {
"activeTab": [Function], "activeTab": [Function],
"openedTabs": [Function], "openedTabs": [Function],
@ -2528,7 +2526,6 @@ exports[`SettingsComponent renders 1`] = `
"title": [Function], "title": [Function],
"visible": [Function], "visible": [Function],
}, },
"subscriptionType": [Function],
"tabsManager": TabsManager { "tabsManager": TabsManager {
"activeTab": [Function], "activeTab": [Function],
"openedTabs": [Function], "openedTabs": [Function],
@ -3366,7 +3363,6 @@ exports[`SettingsComponent renders 1`] = `
"title": [Function], "title": [Function],
"visible": [Function], "visible": [Function],
}, },
"subscriptionType": [Function],
"tabsManager": TabsManager { "tabsManager": TabsManager {
"activeTab": [Function], "activeTab": [Function],
"openedTabs": [Function], "openedTabs": [Function],

View File

@ -19,7 +19,6 @@ import { Splitter, SplitterBounds, SplitterDirection } from "../Common/Splitter"
import { configContext, Platform } from "../ConfigContext"; import { configContext, Platform } from "../ConfigContext";
import * as DataModels from "../Contracts/DataModels"; import * as DataModels from "../Contracts/DataModels";
import { MessageTypes } from "../Contracts/ExplorerContracts"; import { MessageTypes } from "../Contracts/ExplorerContracts";
import { SubscriptionType } from "../Contracts/SubscriptionType";
import * as ViewModels from "../Contracts/ViewModels"; import * as ViewModels from "../Contracts/ViewModels";
import { IGalleryItem } from "../Juno/JunoClient"; import { IGalleryItem } from "../Juno/JunoClient";
import { NotebookWorkspaceManager } from "../NotebookWorkspaceManager/NotebookWorkspaceManager"; import { NotebookWorkspaceManager } from "../NotebookWorkspaceManager/NotebookWorkspaceManager";
@ -112,11 +111,6 @@ export default class Explorer {
* */ * */
public databaseAccount: ko.Observable<DataModels.DatabaseAccount>; public databaseAccount: ko.Observable<DataModels.DatabaseAccount>;
public collectionCreationDefaults: ViewModels.CollectionCreationDefaults = SharedConstants.CollectionCreationDefaults; public collectionCreationDefaults: ViewModels.CollectionCreationDefaults = SharedConstants.CollectionCreationDefaults;
/**
* @deprecated
* Use userContext.subscriptionType instead
* */
public subscriptionType: ko.Observable<SubscriptionType>;
/** /**
* @deprecated * @deprecated
* Use userContext.apiType instead * Use userContext.apiType instead
@ -273,7 +267,6 @@ export default class Explorer {
this.refreshTreeTitle = ko.observable<string>("Refresh collections"); this.refreshTreeTitle = ko.observable<string>("Refresh collections");
this.databaseAccount = ko.observable<DataModels.DatabaseAccount>(); this.databaseAccount = ko.observable<DataModels.DatabaseAccount>();
this.subscriptionType = ko.observable<SubscriptionType>(SharedConstants.CollectionCreation.DefaultSubscriptionType);
this.isAccountReady = ko.observable<boolean>(false); this.isAccountReady = ko.observable<boolean>(false);
this._isInitializingNotebooks = false; this._isInitializingNotebooks = false;
this.arcadiaToken = ko.observable<string>(); this.arcadiaToken = ko.observable<string>();
@ -1276,7 +1269,6 @@ export default class Explorer {
this.collectionCreationDefaults = inputs.defaultCollectionThroughput; this.collectionCreationDefaults = inputs.defaultCollectionThroughput;
} }
this.databaseAccount(databaseAccount); this.databaseAccount(databaseAccount);
this.subscriptionType(inputs.subscriptionType ?? SharedConstants.CollectionCreation.DefaultSubscriptionType);
this.setFeatureFlagsFromFlights(inputs.flights); this.setFeatureFlagsFromFlights(inputs.flights);
TelemetryProcessor.traceSuccess( TelemetryProcessor.traceSuccess(
Action.LoadDatabaseAccount, Action.LoadDatabaseAccount,

View File

@ -105,10 +105,6 @@ export default class AddCollectionPane extends ContextualPaneBase {
this.databaseId = ko.observable<string>(); this.databaseId = ko.observable<string>();
this.databaseCreateNew = ko.observable<boolean>(true); this.databaseCreateNew = ko.observable<boolean>(true);
this.databaseCreateNewShared = ko.observable<boolean>(this.getSharedThroughputDefault()); this.databaseCreateNewShared = ko.observable<boolean>(this.getSharedThroughputDefault());
this.container.subscriptionType &&
this.container.subscriptionType.subscribe((subscriptionType) => {
this.databaseCreateNewShared(this.getSharedThroughputDefault());
});
this.collectionWithThroughputInShared = ko.observable<boolean>(false); this.collectionWithThroughputInShared = ko.observable<boolean>(false);
this.databaseIds = ko.observableArray<string>(); this.databaseIds = ko.observableArray<string>();
this.uniqueKeys = ko.observableArray<DynamicListItem>(); this.uniqueKeys = ko.observableArray<DynamicListItem>();
@ -656,7 +652,7 @@ export default class AddCollectionPane extends ContextualPaneBase {
} }
public getSharedThroughputDefault(): boolean { public getSharedThroughputDefault(): boolean {
const subscriptionType = this.container.subscriptionType && this.container.subscriptionType(); const subscriptionType = userContext.subscriptionType;
if (subscriptionType === SubscriptionType.EA || this.container.isServerlessEnabled()) { if (subscriptionType === SubscriptionType.EA || this.container.isServerlessEnabled()) {
return false; return false;
} }
@ -698,7 +694,7 @@ export default class AddCollectionPane extends ContextualPaneBase {
partitionKey: this.partitionKey(), partitionKey: this.partitionKey(),
databaseId: this.databaseId(), databaseId: this.databaseId(),
}), }),
subscriptionType: SubscriptionType[this.container.subscriptionType()], subscriptionType: userContext.subscriptionType,
subscriptionQuotaId: userContext.quotaId, subscriptionQuotaId: userContext.quotaId,
defaultsCheck: { defaultsCheck: {
storage: this.storage() === Constants.BackendDefaults.singlePartitionStorageInGb ? "f" : "u", storage: this.storage() === Constants.BackendDefaults.singlePartitionStorageInGb ? "f" : "u",
@ -802,7 +798,7 @@ export default class AddCollectionPane extends ContextualPaneBase {
uniqueKeyPolicy, uniqueKeyPolicy,
collectionWithThroughputInShared: this.collectionWithThroughputInShared(), collectionWithThroughputInShared: this.collectionWithThroughputInShared(),
}), }),
subscriptionType: SubscriptionType[this.container.subscriptionType()], subscriptionType: userContext.subscriptionType,
subscriptionQuotaId: userContext.quotaId, subscriptionQuotaId: userContext.quotaId,
defaultsCheck: { defaultsCheck: {
storage: this.storage() === Constants.BackendDefaults.singlePartitionStorageInGb ? "f" : "u", storage: this.storage() === Constants.BackendDefaults.singlePartitionStorageInGb ? "f" : "u",
@ -874,7 +870,7 @@ export default class AddCollectionPane extends ContextualPaneBase {
uniqueKeyPolicy, uniqueKeyPolicy,
collectionWithThroughputInShared: this.collectionWithThroughputInShared(), collectionWithThroughputInShared: this.collectionWithThroughputInShared(),
}), }),
subscriptionType: SubscriptionType[this.container.subscriptionType()], subscriptionType: userContext.subscriptionType,
subscriptionQuotaId: userContext.quotaId, subscriptionQuotaId: userContext.quotaId,
defaultsCheck: { defaultsCheck: {
storage: this.storage() === Constants.BackendDefaults.singlePartitionStorageInGb ? "f" : "u", storage: this.storage() === Constants.BackendDefaults.singlePartitionStorageInGb ? "f" : "u",
@ -906,7 +902,7 @@ export default class AddCollectionPane extends ContextualPaneBase {
uniqueKeyPolicy, uniqueKeyPolicy,
collectionWithThroughputInShared: this.collectionWithThroughputInShared(), collectionWithThroughputInShared: this.collectionWithThroughputInShared(),
}, },
subscriptionType: SubscriptionType[this.container.subscriptionType()], subscriptionType: userContext.subscriptionType,
subscriptionQuotaId: userContext.quotaId, subscriptionQuotaId: userContext.quotaId,
defaultsCheck: { defaultsCheck: {
storage: this.storage() === Constants.BackendDefaults.singlePartitionStorageInGb ? "f" : "u", storage: this.storage() === Constants.BackendDefaults.singlePartitionStorageInGb ? "f" : "u",

View File

@ -1,8 +1,9 @@
import * as Constants from "../../Common/Constants"; import * as Constants from "../../Common/Constants";
import { DatabaseAccount } from "../../Contracts/DataModels";
import { SubscriptionType } from "../../Contracts/SubscriptionType"; import { SubscriptionType } from "../../Contracts/SubscriptionType";
import { updateUserContext } from "../../UserContext";
import Explorer from "../Explorer"; import Explorer from "../Explorer";
import AddDatabasePane from "./AddDatabasePane"; import AddDatabasePane from "./AddDatabasePane";
import { DatabaseAccount } from "../../Contracts/DataModels";
describe("Add Database Pane", () => { describe("Add Database Pane", () => {
describe("getSharedThroughputDefault()", () => { describe("getSharedThroughputDefault()", () => {
@ -44,31 +45,41 @@ describe("Add Database Pane", () => {
}); });
it("should be true if subscription type is Benefits", () => { it("should be true if subscription type is Benefits", () => {
explorer.subscriptionType(SubscriptionType.Benefits); updateUserContext({
subscriptionType: SubscriptionType.Benefits,
});
const addDatabasePane = explorer.addDatabasePane as AddDatabasePane; const addDatabasePane = explorer.addDatabasePane as AddDatabasePane;
expect(addDatabasePane.getSharedThroughputDefault()).toBe(true); expect(addDatabasePane.getSharedThroughputDefault()).toBe(true);
}); });
it("should be false if subscription type is EA", () => { it("should be false if subscription type is EA", () => {
explorer.subscriptionType(SubscriptionType.EA); updateUserContext({
subscriptionType: SubscriptionType.EA,
});
const addDatabasePane = explorer.addDatabasePane as AddDatabasePane; const addDatabasePane = explorer.addDatabasePane as AddDatabasePane;
expect(addDatabasePane.getSharedThroughputDefault()).toBe(false); expect(addDatabasePane.getSharedThroughputDefault()).toBe(false);
}); });
it("should be true if subscription type is Free", () => { it("should be true if subscription type is Free", () => {
explorer.subscriptionType(SubscriptionType.Free); updateUserContext({
subscriptionType: SubscriptionType.Free,
});
const addDatabasePane = explorer.addDatabasePane as AddDatabasePane; const addDatabasePane = explorer.addDatabasePane as AddDatabasePane;
expect(addDatabasePane.getSharedThroughputDefault()).toBe(true); expect(addDatabasePane.getSharedThroughputDefault()).toBe(true);
}); });
it("should be true if subscription type is Internal", () => { it("should be true if subscription type is Internal", () => {
explorer.subscriptionType(SubscriptionType.Internal); updateUserContext({
subscriptionType: SubscriptionType.Internal,
});
const addDatabasePane = explorer.addDatabasePane as AddDatabasePane; const addDatabasePane = explorer.addDatabasePane as AddDatabasePane;
expect(addDatabasePane.getSharedThroughputDefault()).toBe(true); expect(addDatabasePane.getSharedThroughputDefault()).toBe(true);
}); });
it("should be true if subscription type is PAYG", () => { it("should be true if subscription type is PAYG", () => {
explorer.subscriptionType(SubscriptionType.PAYG); updateUserContext({
subscriptionType: SubscriptionType.PAYG,
});
const addDatabasePane = explorer.addDatabasePane as AddDatabasePane; const addDatabasePane = explorer.addDatabasePane as AddDatabasePane;
expect(addDatabasePane.getSharedThroughputDefault()).toBe(true); expect(addDatabasePane.getSharedThroughputDefault()).toBe(true);
}); });

View File

@ -61,11 +61,6 @@ export default class AddDatabasePane extends ContextualPaneBase {
// TODO 388844: get defaults from parent frame // TODO 388844: get defaults from parent frame
this.databaseCreateNewShared = ko.observable<boolean>(this.getSharedThroughputDefault()); this.databaseCreateNewShared = ko.observable<boolean>(this.getSharedThroughputDefault());
this.container.subscriptionType &&
this.container.subscriptionType.subscribe((subscriptionType) => {
this.databaseCreateNewShared(this.getSharedThroughputDefault());
});
this.databaseIdLabel = ko.computed<string>(() => this.databaseIdLabel = ko.computed<string>(() =>
this.container.isPreferredApiCassandra() ? "Keyspace id" : "Database id" this.container.isPreferredApiCassandra() ? "Keyspace id" : "Database id"
); );
@ -273,7 +268,7 @@ export default class AddDatabasePane extends ContextualPaneBase {
super.open(); super.open();
this.resetData(); this.resetData();
const addDatabasePaneOpenMessage = { const addDatabasePaneOpenMessage = {
subscriptionType: SubscriptionType[this.container.subscriptionType()], subscriptionType: userContext.subscriptionType,
subscriptionQuotaId: userContext.quotaId, subscriptionQuotaId: userContext.quotaId,
defaultsCheck: { defaultsCheck: {
throughput: this.throughput(), throughput: this.throughput(),
@ -299,7 +294,7 @@ export default class AddDatabasePane extends ContextualPaneBase {
shared: this.databaseCreateNewShared(), shared: this.databaseCreateNewShared(),
}), }),
offerThroughput, offerThroughput,
subscriptionType: SubscriptionType[this.container.subscriptionType()], subscriptionType: userContext.subscriptionType,
subscriptionQuotaId: userContext.quotaId, subscriptionQuotaId: userContext.quotaId,
defaultsCheck: { defaultsCheck: {
flight: userContext.addCollectionFlight, flight: userContext.addCollectionFlight,
@ -342,7 +337,7 @@ export default class AddDatabasePane extends ContextualPaneBase {
} }
public getSharedThroughputDefault(): boolean { public getSharedThroughputDefault(): boolean {
const subscriptionType = this.container.subscriptionType && this.container.subscriptionType(); const subscriptionType = userContext.subscriptionType;
if (subscriptionType === SubscriptionType.EA || this.container.isServerlessEnabled()) { if (subscriptionType === SubscriptionType.EA || this.container.isServerlessEnabled()) {
return false; return false;
@ -361,7 +356,7 @@ export default class AddDatabasePane extends ContextualPaneBase {
shared: this.databaseCreateNewShared(), shared: this.databaseCreateNewShared(),
}), }),
offerThroughput: offerThroughput, offerThroughput: offerThroughput,
subscriptionType: SubscriptionType[this.container.subscriptionType()], subscriptionType: userContext.subscriptionType,
subscriptionQuotaId: userContext.quotaId, subscriptionQuotaId: userContext.quotaId,
defaultsCheck: { defaultsCheck: {
flight: userContext.addCollectionFlight, flight: userContext.addCollectionFlight,
@ -383,7 +378,7 @@ export default class AddDatabasePane extends ContextualPaneBase {
shared: this.databaseCreateNewShared(), shared: this.databaseCreateNewShared(),
}), }),
offerThroughput: offerThroughput, offerThroughput: offerThroughput,
subscriptionType: SubscriptionType[this.container.subscriptionType()], subscriptionType: userContext.subscriptionType,
subscriptionQuotaId: userContext.quotaId, subscriptionQuotaId: userContext.quotaId,
defaultsCheck: { defaultsCheck: {
flight: userContext.addCollectionFlight, flight: userContext.addCollectionFlight,

View File

@ -5,7 +5,6 @@ import { getErrorMessage, getErrorStack } from "../../Common/ErrorHandlingUtils"
import { HashMap } from "../../Common/HashMap"; import { HashMap } from "../../Common/HashMap";
import { configContext, Platform } from "../../ConfigContext"; import { configContext, Platform } from "../../ConfigContext";
import * as DataModels from "../../Contracts/DataModels"; import * as DataModels from "../../Contracts/DataModels";
import { SubscriptionType } from "../../Contracts/SubscriptionType";
import * as ViewModels from "../../Contracts/ViewModels"; import * as ViewModels from "../../Contracts/ViewModels";
import * as AddCollectionUtility from "../../Shared/AddCollectionUtility"; import * as AddCollectionUtility from "../../Shared/AddCollectionUtility";
import * as SharedConstants from "../../Shared/Constants"; import * as SharedConstants from "../../Shared/Constants";
@ -302,7 +301,7 @@ export default class CassandraAddCollectionPane extends ContextualPaneBase {
partitionKey: "", partitionKey: "",
databaseId: this.keyspaceId(), databaseId: this.keyspaceId(),
}), }),
subscriptionType: SubscriptionType[this.container.subscriptionType()], subscriptionType: userContext.subscriptionType,
subscriptionQuotaId: userContext.quotaId, subscriptionQuotaId: userContext.quotaId,
defaultsCheck: { defaultsCheck: {
storage: "u", storage: "u",
@ -354,7 +353,7 @@ export default class CassandraAddCollectionPane extends ContextualPaneBase {
hasDedicatedThroughput: this.dedicateTableThroughput(), hasDedicatedThroughput: this.dedicateTableThroughput(),
}), }),
keyspaceHasSharedOffer: this.keyspaceHasSharedOffer(), keyspaceHasSharedOffer: this.keyspaceHasSharedOffer(),
subscriptionType: SubscriptionType[this.container.subscriptionType()], subscriptionType: userContext.subscriptionType,
subscriptionQuotaId: userContext.quotaId, subscriptionQuotaId: userContext.quotaId,
defaultsCheck: { defaultsCheck: {
storage: "u", storage: "u",
@ -398,7 +397,7 @@ export default class CassandraAddCollectionPane extends ContextualPaneBase {
hasDedicatedThroughput: this.dedicateTableThroughput(), hasDedicatedThroughput: this.dedicateTableThroughput(),
}), }),
keyspaceHasSharedOffer: this.keyspaceHasSharedOffer(), keyspaceHasSharedOffer: this.keyspaceHasSharedOffer(),
subscriptionType: SubscriptionType[this.container.subscriptionType()], subscriptionType: userContext.subscriptionType,
subscriptionQuotaId: userContext.quotaId, subscriptionQuotaId: userContext.quotaId,
defaultsCheck: { defaultsCheck: {
storage: "u", storage: "u",
@ -426,7 +425,7 @@ export default class CassandraAddCollectionPane extends ContextualPaneBase {
hasDedicatedThroughput: this.dedicateTableThroughput(), hasDedicatedThroughput: this.dedicateTableThroughput(),
}, },
keyspaceHasSharedOffer: this.keyspaceHasSharedOffer(), keyspaceHasSharedOffer: this.keyspaceHasSharedOffer(),
subscriptionType: SubscriptionType[this.container.subscriptionType()], subscriptionType: userContext.subscriptionType,
subscriptionQuotaId: userContext.quotaId, subscriptionQuotaId: userContext.quotaId,
defaultsCheck: { defaultsCheck: {
storage: "u", storage: "u",

View File

@ -815,7 +815,6 @@ exports[`Settings Pane should render Default properly 1`] = `
"title": [Function], "title": [Function],
"visible": [Function], "visible": [Function],
}, },
"subscriptionType": [Function],
"tabsManager": TabsManager { "tabsManager": TabsManager {
"activeTab": [Function], "activeTab": [Function],
"openedTabs": [Function], "openedTabs": [Function],
@ -1741,7 +1740,6 @@ exports[`Settings Pane should render Gremlin properly 1`] = `
"title": [Function], "title": [Function],
"visible": [Function], "visible": [Function],
}, },
"subscriptionType": [Function],
"tabsManager": TabsManager { "tabsManager": TabsManager {
"activeTab": [Function], "activeTab": [Function],
"openedTabs": [Function], "openedTabs": [Function],

View File

@ -815,7 +815,6 @@ exports[`Upload Items Pane should render Default properly 1`] = `
"title": [Function], "title": [Function],
"visible": [Function], "visible": [Function],
}, },
"subscriptionType": [Function],
"tabsManager": TabsManager { "tabsManager": TabsManager {
"activeTab": [Function], "activeTab": [Function],
"openedTabs": [Function], "openedTabs": [Function],

View File

@ -820,7 +820,6 @@ exports[`Delete Database Confirmation Pane submit() Should call delete database
"title": [Function], "title": [Function],
"visible": [Function], "visible": [Function],
}, },
"subscriptionType": [Function],
"tabsManager": TabsManager { "tabsManager": TabsManager {
"activeTab": [Function], "activeTab": [Function],
"openedTabs": [Function], "openedTabs": [Function],

View File

@ -42,6 +42,7 @@ const userContext: UserContext = {
features, features,
useSDKOperations, useSDKOperations,
addCollectionFlight: CollectionCreation.DefaultAddCollectionDefaultFlight, addCollectionFlight: CollectionCreation.DefaultAddCollectionDefaultFlight,
subscriptionType: CollectionCreation.DefaultSubscriptionType,
}; };
function updateUserContext(newContext: Partial<UserContext>): void { function updateUserContext(newContext: Partial<UserContext>): void {