Remove Explorer.defaultExperience (#680)

Co-authored-by: Steve Faulkner <southpolesteve@gmail.com>
This commit is contained in:
Hardikkumar Nai
2021-05-05 23:30:01 +05:30
committed by GitHub
parent d1d28885d0
commit fdd12b41c4
26 changed files with 77 additions and 277 deletions

View File

@@ -13,7 +13,6 @@ const createTestDatabaseAccount = (): DataModels.DatabaseAccount => {
gremlinEndpoint: null,
tableEndpoint: null,
},
tags: "testTags",
type: "testType",
};
};
@@ -30,7 +29,6 @@ const createTestMongo32DatabaseAccount = (): DataModels.DatabaseAccount => {
gremlinEndpoint: null,
tableEndpoint: null,
},
tags: "testTags",
type: "testType",
};
};
@@ -48,7 +46,6 @@ const createTestMongo36DatabaseAccount = (): DataModels.DatabaseAccount => {
tableEndpoint: null,
mongoEndpoint: "https://testMongoEndpoint.azure.com/",
},
tags: "testTags",
type: "testType",
};
};
@@ -65,7 +62,6 @@ const createTestCassandraDatabaseAccount = (): DataModels.DatabaseAccount => {
gremlinEndpoint: null,
tableEndpoint: null,
},
tags: "testTags",
type: "testType",
};
};

View File

@@ -1,14 +1,14 @@
import { shallow } from "enzyme";
import ko from "knockout";
import React from "react";
import { ScaleComponent, ScaleComponentProps } from "./ScaleComponent";
import { container, collection } from "../TestUtils";
import { ThroughputInputAutoPilotV3Component } from "./ThroughputInputComponents/ThroughputInputAutoPilotV3Component";
import Explorer from "../../../Explorer";
import * as Constants from "../../../../Common/Constants";
import * as DataModels from "../../../../Contracts/DataModels";
import { throughputUnit } from "../SettingsRenderUtils";
import * as SharedConstants from "../../../../Shared/Constants";
import ko from "knockout";
import Explorer from "../../../Explorer";
import { throughputUnit } from "../SettingsRenderUtils";
import { collection, container } from "../TestUtils";
import { ScaleComponent, ScaleComponentProps } from "./ScaleComponent";
import { ThroughputInputAutoPilotV3Component } from "./ThroughputInputComponents/ThroughputInputAutoPilotV3Component";
describe("ScaleComponent", () => {
const nonNationalCloudContainer = new Explorer();
@@ -87,7 +87,6 @@ describe("ScaleComponent", () => {
location: undefined,
type: undefined,
kind: "documentdb",
tags: undefined,
properties: {
documentEndpoint: undefined,
tableEndpoint: undefined,

View File

@@ -424,7 +424,6 @@ exports[`SettingsComponent renders 1`] = `
},
"databaseAccount": [Function],
"databases": [Function],
"defaultExperience": [Function],
"deleteCollectionText": [Function],
"deleteDatabaseText": [Function],
"gitHubClient": GitHubClient {
@@ -1710,7 +1709,6 @@ exports[`SettingsComponent renders 1`] = `
},
"databaseAccount": [Function],
"databases": [Function],
"defaultExperience": [Function],
"deleteCollectionText": [Function],
"deleteDatabaseText": [Function],
"gitHubClient": GitHubClient {
@@ -3009,7 +3007,6 @@ exports[`SettingsComponent renders 1`] = `
},
"databaseAccount": [Function],
"databases": [Function],
"defaultExperience": [Function],
"deleteCollectionText": [Function],
"deleteDatabaseText": [Function],
"gitHubClient": GitHubClient {
@@ -4295,7 +4292,6 @@ exports[`SettingsComponent renders 1`] = `
},
"databaseAccount": [Function],
"databases": [Function],
"defaultExperience": [Function],
"deleteCollectionText": [Function],
"deleteDatabaseText": [Function],
"gitHubClient": GitHubClient {

View File

@@ -79,7 +79,6 @@ describe("ContainerSampleGenerator", () => {
location: "foo",
type: "foo",
kind: "foo",
tags: [],
properties: {
documentEndpoint: "bar",
gremlinEndpoint: "foo",

View File

@@ -115,11 +115,6 @@ export default class Explorer {
* */
public databaseAccount: ko.Observable<DataModels.DatabaseAccount>;
public collectionCreationDefaults: ViewModels.CollectionCreationDefaults = SharedConstants.CollectionCreationDefaults;
/**
* @deprecated
* Use userContext.apiType instead
* */
public defaultExperience: ko.Observable<string>;
public isFixedCollectionWithSharedThroughputSupported: ko.Computed<boolean>;
/**
* @deprecated
@@ -376,17 +371,6 @@ export default class Explorer {
bounds: splitterBounds,
direction: SplitterDirection.Vertical,
});
this.defaultExperience = ko.observable<string>();
// this.databaseAccount.subscribe((databaseAccount) => {
// const defaultExperience: string = DefaultExperienceUtility.getDefaultExperienceFromDatabaseAccount(
// databaseAccount
// );
// this.defaultExperience(defaultExperience);
// // TODO. Remove this entirely
// updateUserContext({
// apiType: DefaultExperienceUtility.mapDefaultExperienceStringToEnum(defaultExperience),
// });
// });
this.isFixedCollectionWithSharedThroughputSupported = ko.computed(() => {
if (userContext.features.enableFixedCollectionWithSharedThroughput) {

View File

@@ -20,7 +20,6 @@ describe("Add Collection Pane", () => {
enableFreeTier: false,
},
type: undefined,
tags: [],
};
const mockFreeTierDatabaseAccount: DatabaseAccount = {
@@ -36,7 +35,6 @@ describe("Add Collection Pane", () => {
enableFreeTier: true,
},
type: undefined,
tags: [],
};
beforeEach(() => {
@@ -44,7 +42,13 @@ describe("Add Collection Pane", () => {
});
it("should be true if graph API and partition key is not /id nor /label", () => {
explorer.defaultExperience(Constants.DefaultAccountExperience.Graph.toLowerCase());
updateUserContext({
databaseAccount: {
properties: {
capabilities: [{ name: "EnableGremlin" }],
},
} as DatabaseAccount,
});
const addCollectionPane = explorer.addCollectionPane as AddCollectionPane;
addCollectionPane.partitionKey("/blah");
expect(addCollectionPane.isValid()).toBe(true);
@@ -58,7 +62,6 @@ describe("Add Collection Pane", () => {
},
} as DatabaseAccount,
});
const addCollectionPane = explorer.addCollectionPane as AddCollectionPane;
addCollectionPane.partitionKey("/id");
expect(addCollectionPane.isValid()).toBe(false);

View File

@@ -21,7 +21,6 @@ describe("Add Database Pane", () => {
enableFreeTier: false,
},
type: undefined,
tags: [],
};
const mockFreeTierDatabaseAccount: DatabaseAccount = {
@@ -37,7 +36,6 @@ describe("Add Database Pane", () => {
enableFreeTier: true,
},
type: undefined,
tags: [],
};
beforeEach(() => {

View File

@@ -413,7 +413,6 @@ exports[`GitHub Repos Panel should render Default properly 1`] = `
},
"databaseAccount": [Function],
"databases": [Function],
"defaultExperience": [Function],
"deleteCollectionText": [Function],
"deleteDatabaseText": [Function],
"gitHubClient": GitHubClient {

View File

@@ -403,7 +403,6 @@ exports[`StringInput Pane should render Create new directory properly 1`] = `
},
"databaseAccount": [Function],
"databases": [Function],
"defaultExperience": [Function],
"deleteCollectionText": [Function],
"deleteDatabaseText": [Function],
"gitHubClient": GitHubClient {

View File

@@ -401,7 +401,6 @@ exports[`Delete Database Confirmation Pane submit() Should call delete database
},
"databaseAccount": [Function],
"databases": [Function],
"defaultExperience": [Function],
"deleteCollectionText": [Function],
"deleteDatabaseText": [Function],
"gitHubClient": GitHubClient {

View File

@@ -1,5 +1,5 @@
import * as ko from "knockout";
import * as Constants from "../../Common/Constants";
import { DatabaseAccount } from "../../Contracts/DataModels";
import * as ViewModels from "../../Contracts/ViewModels";
import { updateUserContext } from "../../UserContext";
import { CommandButtonComponentProps } from "../Controls/CommandButton/CommandButtonComponent";
@@ -27,7 +27,13 @@ describe("Documents tab", () => {
describe("showPartitionKey", () => {
const explorer = new Explorer();
const mongoExplorer = new Explorer();
mongoExplorer.defaultExperience(Constants.DefaultAccountExperience.MongoDB);
updateUserContext({
databaseAccount: {
properties: {
capabilities: [{ name: "EnableGremlin" }],
},
} as DatabaseAccount,
});
const collectionWithoutPartitionKey = <ViewModels.Collection>(<unknown>{
id: ko.observable<string>("foo"),

View File

@@ -3,6 +3,7 @@ import * as DataModels from "../../Contracts/DataModels";
import * as ViewModels from "../../Contracts/ViewModels";
import { ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants";
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
import { userContext } from "../../UserContext";
import Explorer from "../Explorer";
import { NotebookClientV2 } from "../Notebook/NotebookClientV2";
import TabsBase from "./TabsBase";
@@ -29,7 +30,7 @@ export default class NotebookTabBase extends TabsBase {
NotebookTabBase.clientManager = new NotebookClientV2({
connectionInfo: this.container.notebookServerInfo(),
databaseAccountName: this.container.databaseAccount().name,
defaultExperience: this.container.defaultExperience(),
defaultExperience: userContext.apiType,
contentProvider: this.container.notebookManager?.notebookContentProvider,
});
}

View File

@@ -23,7 +23,6 @@ describe("Tabs manager tests", () => {
location: "",
type: "",
kind: "",
tags: "",
properties: undefined,
});

View File

@@ -1,10 +1,10 @@
import * as DataModels from "../../Contracts/DataModels";
import * as ko from "knockout";
import Database from "./Database";
import Explorer from "../Explorer";
import { HttpStatusCodes } from "../../Common/Constants";
import * as DataModels from "../../Contracts/DataModels";
import { JunoClient } from "../../Juno/JunoClient";
import { userContext, updateUserContext } from "../../UserContext";
import { updateUserContext, userContext } from "../../UserContext";
import Explorer from "../Explorer";
import Database from "./Database";
const createMockContainer = (): Explorer => {
const mockContainer = new Explorer();
@@ -19,7 +19,6 @@ updateUserContext({
name: "fakeName",
location: "fakeLocation",
type: "fakeType",
tags: undefined,
kind: "fakeKind",
properties: {
documentEndpoint: "fakeEndpoint",