More ViewModel cleanup (#116)

This commit is contained in:
Steve Faulkner
2020-07-27 16:05:25 -05:00
committed by GitHub
parent 2e49ed45c3
commit fea321cd68
97 changed files with 492 additions and 1904 deletions

View File

@@ -22,6 +22,12 @@ import { HashMap } from "../../Common/HashMap";
import { PlatformType } from "../../PlatformType";
import { refreshCachedResources, getOrCreateDatabaseAndCollection } from "../../Common/DocumentClientUtilityBase";
export interface AddCollectionPaneOptions extends ViewModels.PaneOptions {
isPreferredApiTable: ko.Computed<boolean>;
databaseId?: string;
databaseSelfLink?: string;
}
export default class AddCollectionPane extends ContextualPaneBase {
public defaultExperience: ko.Computed<string>;
public databaseIds: ko.ObservableArray<string>;
@@ -100,7 +106,7 @@ export default class AddCollectionPane extends ContextualPaneBase {
private _databaseOffers: HashMap<DataModels.Offer>;
private _isSynapseLinkEnabled: ko.Computed<boolean>;
constructor(options: ViewModels.AddCollectionPaneOptions) {
constructor(options: AddCollectionPaneOptions) {
super(options);
this._databaseOffers = new HashMap<DataModels.Offer>();
this.hasAutoPilotV2FeatureFlag = ko.pureComputed(() => this.container.hasAutoPilotV2FeatureFlag());
@@ -619,7 +625,7 @@ export default class AddCollectionPane extends ContextualPaneBase {
this._isSynapseLinkEnabled = ko.computed(() => {
const databaseAccount =
(this.container && this.container.databaseAccount && this.container.databaseAccount()) ||
({} as ViewModels.DatabaseAccount);
({} as DataModels.DatabaseAccount);
const properties = databaseAccount.properties || ({} as DataModels.DatabaseAccountExtendedProperties);
// TODO: remove check for capability once all accounts have been migrated
@@ -1266,10 +1272,7 @@ export default class AddCollectionPane extends ContextualPaneBase {
: SharedConstants.CollectionCreation.NumberOfPartitionsInUnlimitedCollection;
}
private _convertShardKeyToPartitionKey(
shardKey: string,
configurationOverrides: ViewModels.ConfigurationOverrides
): string {
private _convertShardKeyToPartitionKey(shardKey: string): string {
if (!shardKey) {
return shardKey;
}
@@ -1331,10 +1334,7 @@ export default class AddCollectionPane extends ContextualPaneBase {
};
if (this.container.isPreferredApiMongoDB()) {
transform = (value: string) => {
return this._convertShardKeyToPartitionKey(
value,
this.container.databaseAccount().properties.configurationOverrides
);
return this._convertShardKeyToPartitionKey(value);
};
}