Remove Explorer.isEmulator (#256)

This commit is contained in:
Steve Faulkner
2020-10-09 11:18:50 -05:00
committed by GitHub
parent 5191ae3f3a
commit 14cdf19efb
26 changed files with 47 additions and 63 deletions

View File

@@ -20,6 +20,7 @@ import { updateOffer } from "../../Common/dataAccess/updateOffer";
import { CommandButtonComponentProps } from "../Controls/CommandButton/CommandButtonComponent";
import { userContext } from "../../UserContext";
import { updateOfferThroughputBeyondLimit } from "../../Common/dataAccess/updateOfferThroughputBeyondLimit";
import { configContext, Platform } from "../../ConfigContext";
const updateThroughputBeyondLimitWarningMessage: string = `
You are about to request an increase in throughput beyond the pre-allocated capacity.
@@ -196,7 +197,7 @@ export default class DatabaseSettingsTab extends TabsBase implements ViewModels.
});
this.costsVisible = ko.computed(() => {
return !this.container.isEmulator;
return configContext.platform !== Platform.Emulator;
});
this.shouldDisplayPortalUsePrompt = ko.pureComputed<boolean>(
@@ -207,7 +208,7 @@ export default class DatabaseSettingsTab extends TabsBase implements ViewModels.
);
this.canRequestSupport = ko.pureComputed(() => {
if (
!!this.container.isEmulator ||
configContext.platform === Platform.Emulator ||
this.container.getPlatformType() === PlatformType.Hosted ||
this.canThroughputExceedMaximumValue()
) {

View File

@@ -28,13 +28,11 @@ describe("Documents tab", () => {
describe("showPartitionKey", () => {
const explorer = new Explorer({
notificationsClient: null,
isEmulator: false
notificationsClient: null
});
const mongoExplorer = new Explorer({
notificationsClient: null,
isEmulator: false
notificationsClient: null
});
mongoExplorer.defaultExperience(Constants.DefaultAccountExperience.MongoDB);

View File

@@ -49,7 +49,7 @@ describe("Query Tab", () => {
let explorer: Explorer;
beforeEach(() => {
explorer = new Explorer({ notificationsClient: null, isEmulator: false });
explorer = new Explorer({ notificationsClient: null });
});
it("should be true for accounts using SQL API", () => {
@@ -69,7 +69,7 @@ describe("Query Tab", () => {
let explorer: Explorer;
beforeEach(() => {
explorer = new Explorer({ notificationsClient: null, isEmulator: false });
explorer = new Explorer({ notificationsClient: null });
});
it("should be visible when using a supported API", () => {

View File

@@ -79,7 +79,7 @@ describe("Settings tab", () => {
};
beforeEach(() => {
explorer = new Explorer({ notificationsClient: null, isEmulator: false });
explorer = new Explorer({ notificationsClient: null });
explorer.hasAutoPilotV2FeatureFlag = ko.computed<boolean>(() => true);
});
@@ -178,7 +178,7 @@ describe("Settings tab", () => {
let explorer: Explorer;
beforeEach(() => {
explorer = new Explorer({ notificationsClient: null, isEmulator: false });
explorer = new Explorer({ notificationsClient: null });
explorer.hasAutoPilotV2FeatureFlag = ko.computed<boolean>(() => true);
});
@@ -256,7 +256,7 @@ describe("Settings tab", () => {
let explorer: Explorer;
beforeEach(() => {
explorer = new Explorer({ notificationsClient: null, isEmulator: false });
explorer = new Explorer({ notificationsClient: null });
explorer.hasAutoPilotV2FeatureFlag = ko.computed<boolean>(() => true);
});
@@ -338,8 +338,7 @@ describe("Settings tab", () => {
function getCollection(defaultApi: string, partitionKeyOption: PartitionKeyOption) {
const explorer = new Explorer({
notificationsClient: null,
isEmulator: false
notificationsClient: null
});
explorer.defaultExperience(defaultApi);
explorer.hasAutoPilotV2FeatureFlag = ko.computed<boolean>(() => true);
@@ -471,8 +470,7 @@ describe("Settings tab", () => {
describe("AutoPilot", () => {
function getCollection(autoPilotTier: DataModels.AutopilotTier) {
const explorer = new Explorer({
notificationsClient: null,
isEmulator: false
notificationsClient: null
});
explorer.hasAutoPilotV2FeatureFlag = ko.computed<boolean>(() => true);

View File

@@ -22,6 +22,7 @@ import { updateCollection } from "../../Common/dataAccess/updateCollection";
import { CommandButtonComponentProps } from "../Controls/CommandButton/CommandButtonComponent";
import { userContext } from "../../UserContext";
import { updateOfferThroughputBeyondLimit } from "../../Common/dataAccess/updateOfferThroughputBeyondLimit";
import { configContext, Platform } from "../../ConfigContext";
const ttlWarning: string = `
The system will automatically delete items based on the TTL value (in seconds) you provide, without needing a delete operation explicitly issued by a client application.
@@ -454,7 +455,7 @@ export default class SettingsTab extends TabsBase implements ViewModels.WaitsFor
});
this.rupmVisible = ko.computed(() => {
if (this.container.isEmulator) {
if (configContext.platform === Platform.Emulator) {
return false;
}
if (this.container.isFeatureEnabled(Constants.Features.enableRupm)) {
@@ -484,7 +485,7 @@ export default class SettingsTab extends TabsBase implements ViewModels.WaitsFor
});
this.costsVisible = ko.computed(() => {
return !this.container.isEmulator;
return configContext.platform !== Platform.Emulator;
});
this.isTryCosmosDBSubscription = ko.computed<boolean>(() => {
@@ -500,7 +501,7 @@ export default class SettingsTab extends TabsBase implements ViewModels.WaitsFor
});
this.canRequestSupport = ko.pureComputed(() => {
if (this.container.isEmulator) {
if (configContext.platform === Platform.Emulator) {
return false;
}
@@ -711,7 +712,7 @@ export default class SettingsTab extends TabsBase implements ViewModels.WaitsFor
}
const isThroughputGreaterThanMaxRus = this.throughput() > this.maxRUs();
const isEmulator = this.container.isEmulator;
const isEmulator = configContext.platform === Platform.Emulator;
if (isThroughputGreaterThanMaxRus && isEmulator) {
return false;
}
@@ -881,7 +882,8 @@ export default class SettingsTab extends TabsBase implements ViewModels.WaitsFor
this.maxRUs() <= SharedConstants.CollectionCreation.DefaultCollectionRUs1Million &&
this.throughput() > SharedConstants.CollectionCreation.DefaultCollectionRUs1Million;
const throughputExceedsMaxValue: boolean = !this.container.isEmulator && this.throughput() > this.maxRUs();
const throughputExceedsMaxValue: boolean =
configContext.platform !== Platform.Emulator && this.throughput() > this.maxRUs();
const ttlOptionDirty: boolean = this.timeToLive.editableIsDirty();
const ttlOrIndexingPolicyFieldsDirty: boolean =

View File

@@ -16,7 +16,7 @@ describe("Tabs manager tests", () => {
let documentsTab: DocumentsTab;
beforeAll(() => {
explorer = new Explorer({ notificationsClient: undefined, isEmulator: false });
explorer = new Explorer({ notificationsClient: undefined });
explorer.databaseAccount = ko.observable<DataModels.DatabaseAccount>({
id: "test",
name: "test",