mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-19 17:01:13 +00:00
Remove window.dataExplorerPlatform (#279)
More cleanup for #253 - Remove window.dataExplorerPlatform - Remove explorer factories
This commit is contained in:
@@ -5,7 +5,6 @@ import { container, collection } from "../TestUtils";
|
||||
import { ThroughputInputAutoPilotV3Component } from "./ThroughputInputComponents/ThroughputInputAutoPilotV3Component";
|
||||
import Explorer from "../../../Explorer";
|
||||
import * as Constants from "../../../../Common/Constants";
|
||||
import { PlatformType } from "../../../../PlatformType";
|
||||
import * as DataModels from "../../../../Contracts/DataModels";
|
||||
import { throughputUnit } from "../SettingsRenderUtils";
|
||||
import * as SharedConstants from "../../../../Shared/Constants";
|
||||
@@ -13,7 +12,6 @@ import ko from "knockout";
|
||||
|
||||
describe("ScaleComponent", () => {
|
||||
const nonNationalCloudContainer = new Explorer();
|
||||
nonNationalCloudContainer.getPlatformType = () => PlatformType.Portal;
|
||||
nonNationalCloudContainer.isRunningOnNationalCloud = () => false;
|
||||
|
||||
const targetThroughput = 6000;
|
||||
@@ -119,7 +117,7 @@ describe("ScaleComponent", () => {
|
||||
|
||||
it("getThroughputTitle", () => {
|
||||
let scaleComponent = new ScaleComponent(baseProps);
|
||||
expect(scaleComponent.getThroughputTitle()).toEqual("Throughput (6,000 - 40,000 RU/s)");
|
||||
expect(scaleComponent.getThroughputTitle()).toEqual("Throughput (6,000 - unlimited RU/s)");
|
||||
|
||||
let newProps = { ...baseProps, container: nonNationalCloudContainer };
|
||||
scaleComponent = new ScaleComponent(newProps);
|
||||
@@ -132,7 +130,7 @@ describe("ScaleComponent", () => {
|
||||
|
||||
it("canThroughputExceedMaximumValue", () => {
|
||||
let scaleComponent = new ScaleComponent(baseProps);
|
||||
expect(scaleComponent.canThroughputExceedMaximumValue()).toEqual(false);
|
||||
expect(scaleComponent.canThroughputExceedMaximumValue()).toEqual(true);
|
||||
|
||||
const newProps = { ...baseProps, container: nonNationalCloudContainer };
|
||||
scaleComponent = new ScaleComponent(newProps);
|
||||
|
||||
@@ -5,7 +5,6 @@ import * as ViewModels from "../../../../Contracts/ViewModels";
|
||||
import * as DataModels from "../../../../Contracts/DataModels";
|
||||
import * as SharedConstants from "../../../../Shared/Constants";
|
||||
import Explorer from "../../../Explorer";
|
||||
import { PlatformType } from "../../../../PlatformType";
|
||||
import {
|
||||
getTextFieldStyles,
|
||||
subComponentStackProps,
|
||||
@@ -78,7 +77,7 @@ export class ScaleComponent extends React.Component<ScaleComponentProps> {
|
||||
};
|
||||
|
||||
public getMaxRUThroughputInputLimit = (): number => {
|
||||
if (this.props.container?.getPlatformType() === PlatformType.Hosted && this.props.collection.partitionKey) {
|
||||
if (configContext.platform === Platform.Hosted && this.props.collection.partitionKey) {
|
||||
return SharedConstants.CollectionCreation.DefaultCollectionRUs1Million;
|
||||
}
|
||||
|
||||
@@ -100,8 +99,7 @@ export class ScaleComponent extends React.Component<ScaleComponentProps> {
|
||||
|
||||
public canThroughputExceedMaximumValue = (): boolean => {
|
||||
const isPublicAzurePortal: boolean =
|
||||
this.props.container.getPlatformType() === PlatformType.Portal &&
|
||||
!this.props.container.isRunningOnNationalCloud();
|
||||
configContext.platform === Platform.Portal && !this.props.container.isRunningOnNationalCloud();
|
||||
const hasPartitionKey = !!this.props.collection.partitionKey;
|
||||
|
||||
return isPublicAzurePortal && hasPartitionKey;
|
||||
|
||||
@@ -39,13 +39,13 @@ exports[`ScaleComponent renders with correct intiial notification 1`] = `
|
||||
}
|
||||
>
|
||||
<ThroughputInputAutoPilotV3Component
|
||||
canExceedMaximumValue={false}
|
||||
canExceedMaximumValue={true}
|
||||
getThroughputWarningMessage={[Function]}
|
||||
isAutoPilotSelected={false}
|
||||
isEmulator={false}
|
||||
isEnabled={true}
|
||||
isFixed={false}
|
||||
label="Throughput (6,000 - 40,000 RU/s)"
|
||||
label="Throughput (6,000 - unlimited RU/s)"
|
||||
maxAutoPilotThroughput={4000}
|
||||
maxAutoPilotThroughputBaseline={4000}
|
||||
maximum={40000}
|
||||
|
||||
@@ -37,7 +37,7 @@ import { BindingHandlersRegisterer } from "../Bindings/BindingHandlersRegisterer
|
||||
import { BrowseQueriesPane } from "./Panes/BrowseQueriesPane";
|
||||
import { CassandraAPIDataClient, TableDataClient, TablesAPIDataClient } from "./Tables/TableDataClient";
|
||||
import { CommandBarComponentAdapter } from "./Menus/CommandBar/CommandBarComponentAdapter";
|
||||
import { configContext, updateConfigContext } from "../ConfigContext";
|
||||
import { configContext, Platform, updateConfigContext } from "../ConfigContext";
|
||||
import { ConsoleData, ConsoleDataType } from "./Menus/NotificationConsole/NotificationConsoleComponent";
|
||||
import { decryptJWTToken, getAuthorizationHeader } from "../Utils/AuthorizationUtils";
|
||||
import { DefaultExperienceUtility } from "../Shared/DefaultExperienceUtility";
|
||||
@@ -58,7 +58,6 @@ import { NotebookUtil } from "./Notebook/NotebookUtil";
|
||||
import { NotebookWorkspaceManager } from "../NotebookWorkspaceManager/NotebookWorkspaceManager";
|
||||
import { NotificationConsoleComponentAdapter } from "./Menus/NotificationConsole/NotificationConsoleComponentAdapter";
|
||||
import * as NotificationConsoleUtils from "../Utils/NotificationConsoleUtils";
|
||||
import { PlatformType } from "../PlatformType";
|
||||
import { QueriesClient } from "../Common/QueriesClient";
|
||||
import { QuerySelectPane } from "./Panes/Tables/QuerySelectPane";
|
||||
import { RenewAdHocAccessPane } from "./Panes/RenewAdHocAccessPane";
|
||||
@@ -565,9 +564,7 @@ export default class Explorer {
|
||||
|
||||
this.isHostedDataExplorerEnabled = ko.computed<boolean>(
|
||||
() =>
|
||||
this.getPlatformType() === PlatformType.Portal &&
|
||||
!this.isRunningOnNationalCloud() &&
|
||||
!this.isPreferredApiGraph()
|
||||
configContext.platform === Platform.Portal && !this.isRunningOnNationalCloud() && !this.isPreferredApiGraph()
|
||||
);
|
||||
this.isRightPanelV2Enabled = ko.computed<boolean>(() =>
|
||||
this.isFeatureEnabled(Constants.Features.enableRightPanelV2)
|
||||
@@ -1793,7 +1790,7 @@ export default class Explorer {
|
||||
const message: any = event.data.data;
|
||||
const inputs: ViewModels.DataExplorerInputsFrame = message.inputs;
|
||||
|
||||
const isRunningInPortal = window.dataExplorerPlatform == PlatformType.Portal;
|
||||
const isRunningInPortal = configContext.platform === Platform.Portal;
|
||||
const isRunningInDevMode = process.env.NODE_ENV === "development";
|
||||
if (inputs && configContext.BACKEND_ENDPOINT && isRunningInPortal && isRunningInDevMode) {
|
||||
inputs.extensionEndpoint = configContext.PROXY_PATH;
|
||||
@@ -2009,10 +2006,6 @@ export default class Explorer {
|
||||
this._panes.forEach((pane: ContextualPaneBase) => pane.close());
|
||||
}
|
||||
|
||||
public getPlatformType(): PlatformType {
|
||||
return window.dataExplorerPlatform;
|
||||
}
|
||||
|
||||
public isRunningOnNationalCloud(): boolean {
|
||||
return (
|
||||
this.serverId() === Constants.ServerIds.blackforest ||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import * as ViewModels from "../../../Contracts/ViewModels";
|
||||
import { PlatformType } from "../../../PlatformType";
|
||||
import { Action, ActionModifiers } from "../../../Shared/Telemetry/TelemetryConstants";
|
||||
import { Areas } from "../../../Common/Constants";
|
||||
import * as TelemetryProcessor from "../../../Shared/Telemetry/TelemetryProcessor";
|
||||
@@ -159,7 +158,7 @@ export class CommandBarComponentButtonFactory {
|
||||
|
||||
public static createControlCommandBarButtons(container: Explorer): CommandButtonComponentProps[] {
|
||||
const buttons: CommandButtonComponentProps[] = [];
|
||||
if (window.dataExplorerPlatform === PlatformType.Hosted) {
|
||||
if (configContext.platform === Platform.Hosted) {
|
||||
return buttons;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,8 +14,6 @@ import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstan
|
||||
import { configContext, Platform } from "../../ConfigContext";
|
||||
import { ContextualPaneBase } from "./ContextualPaneBase";
|
||||
import { DynamicListItem } from "../Controls/DynamicList/DynamicListComponent";
|
||||
import { HashMap } from "../../Common/HashMap";
|
||||
import { PlatformType } from "../../PlatformType";
|
||||
import { refreshCachedResources } from "../../Common/DocumentClientUtilityBase";
|
||||
import { createCollection } from "../../Common/dataAccess/createCollection";
|
||||
|
||||
@@ -327,7 +325,7 @@ export default class AddCollectionPane extends ContextualPaneBase {
|
||||
if (
|
||||
configContext.platform !== Platform.Emulator &&
|
||||
!this.container.isTryCosmosDBSubscription() &&
|
||||
this.container.getPlatformType() !== PlatformType.Portal
|
||||
configContext.platform !== Platform.Portal
|
||||
) {
|
||||
const offerThroughput: number = this._getThroughput();
|
||||
return offerThroughput <= 100000;
|
||||
|
||||
@@ -11,7 +11,6 @@ import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
||||
import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants";
|
||||
import { ContextualPaneBase } from "./ContextualPaneBase";
|
||||
import { createDatabase } from "../../Common/dataAccess/createDatabase";
|
||||
import { PlatformType } from "../../PlatformType";
|
||||
import { configContext, Platform } from "../../ConfigContext";
|
||||
|
||||
export default class AddDatabasePane extends ContextualPaneBase {
|
||||
@@ -183,7 +182,7 @@ export default class AddDatabasePane extends ContextualPaneBase {
|
||||
if (
|
||||
configContext.platform !== Platform.Emulator &&
|
||||
!this.container.isTryCosmosDBSubscription() &&
|
||||
this.container.getPlatformType() !== PlatformType.Portal
|
||||
configContext.platform !== Platform.Portal
|
||||
) {
|
||||
const offerThroughput: number = this.throughput();
|
||||
return offerThroughput <= 100000;
|
||||
|
||||
@@ -13,7 +13,6 @@ import SaveIcon from "../../../images/save-cosmos.svg";
|
||||
import TabsBase from "./TabsBase";
|
||||
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
||||
import { Action } from "../../Shared/Telemetry/TelemetryConstants";
|
||||
import { PlatformType } from "../../PlatformType";
|
||||
import { RequestOptions } from "@azure/cosmos/dist-esm";
|
||||
import Explorer from "../Explorer";
|
||||
import { updateOffer } from "../../Common/dataAccess/updateOffer";
|
||||
@@ -200,16 +199,14 @@ export default class DatabaseSettingsTab extends TabsBase implements ViewModels.
|
||||
return configContext.platform !== Platform.Emulator;
|
||||
});
|
||||
|
||||
this.shouldDisplayPortalUsePrompt = ko.pureComputed<boolean>(
|
||||
() => this.container.getPlatformType() === PlatformType.Hosted
|
||||
);
|
||||
this.shouldDisplayPortalUsePrompt = ko.pureComputed<boolean>(() => configContext.platform === Platform.Hosted);
|
||||
this.canThroughputExceedMaximumValue = ko.pureComputed<boolean>(
|
||||
() => this.container.getPlatformType() === PlatformType.Portal && !this.container.isRunningOnNationalCloud()
|
||||
() => configContext.platform === Platform.Portal && !this.container.isRunningOnNationalCloud()
|
||||
);
|
||||
this.canRequestSupport = ko.pureComputed(() => {
|
||||
if (
|
||||
configContext.platform === Platform.Emulator ||
|
||||
this.container.getPlatformType() === PlatformType.Hosted ||
|
||||
configContext.platform === Platform.Hosted ||
|
||||
this.canThroughputExceedMaximumValue()
|
||||
) {
|
||||
return false;
|
||||
@@ -273,7 +270,7 @@ export default class DatabaseSettingsTab extends TabsBase implements ViewModels.
|
||||
});
|
||||
|
||||
this.maxRUThroughputInputLimit = ko.pureComputed<number>(() => {
|
||||
if (this.container && this.container.getPlatformType() === PlatformType.Hosted) {
|
||||
if (configContext.platform === Platform.Hosted) {
|
||||
return SharedConstants.CollectionCreation.DefaultCollectionRUs1Million;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,10 +10,9 @@ import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstan
|
||||
import { ConsoleDataType } from "../Menus/NotificationConsole/NotificationConsoleComponent";
|
||||
import { HashMap } from "../../Common/HashMap";
|
||||
import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils";
|
||||
import { PlatformType } from "../../PlatformType";
|
||||
import Explorer from "../Explorer";
|
||||
import { userContext } from "../../UserContext";
|
||||
import { configContext } from "../../ConfigContext";
|
||||
import { configContext, Platform } from "../../ConfigContext";
|
||||
|
||||
export default class MongoShellTab extends TabsBase {
|
||||
public url: ko.Computed<string>;
|
||||
@@ -31,7 +30,7 @@ export default class MongoShellTab extends TabsBase {
|
||||
const accountName = account && account.name;
|
||||
const mongoEndpoint = account && (account.properties.mongoEndpoint || account.properties.documentEndpoint);
|
||||
|
||||
this._runtimeEndpoint = window.dataExplorerPlatform === PlatformType.Hosted ? configContext.BACKEND_ENDPOINT : "";
|
||||
this._runtimeEndpoint = configContext.platform === Platform.Hosted ? configContext.BACKEND_ENDPOINT : "";
|
||||
const extensionEndpoint: string = configContext.BACKEND_ENDPOINT || this._runtimeEndpoint || "";
|
||||
let baseUrl = "/content/mongoshell/dist/";
|
||||
if (this._container.serverId() === "localhost") {
|
||||
|
||||
@@ -14,7 +14,6 @@ import SaveIcon from "../../../images/save-cosmos.svg";
|
||||
import TabsBase from "./TabsBase";
|
||||
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
||||
import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants";
|
||||
import { PlatformType } from "../../PlatformType";
|
||||
import { RequestOptions } from "@azure/cosmos/dist-esm";
|
||||
import Explorer from "../Explorer";
|
||||
import { updateOffer } from "../../Common/dataAccess/updateOffer";
|
||||
@@ -494,7 +493,7 @@ export default class SettingsTab extends TabsBase implements ViewModels.WaitsFor
|
||||
|
||||
this.canThroughputExceedMaximumValue = ko.pureComputed<boolean>(() => {
|
||||
const isPublicAzurePortal: boolean =
|
||||
this.container.getPlatformType() === PlatformType.Portal && !this.container.isRunningOnNationalCloud();
|
||||
configContext.platform === Platform.Portal && !this.container.isRunningOnNationalCloud();
|
||||
const hasPartitionKey = !!this.collection.partitionKey;
|
||||
|
||||
return isPublicAzurePortal && hasPartitionKey;
|
||||
@@ -513,7 +512,7 @@ export default class SettingsTab extends TabsBase implements ViewModels.WaitsFor
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.container.getPlatformType() === PlatformType.Hosted) {
|
||||
if (configContext.platform === Platform.Hosted) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -526,7 +525,7 @@ export default class SettingsTab extends TabsBase implements ViewModels.WaitsFor
|
||||
});
|
||||
|
||||
this.shouldDisplayPortalUsePrompt = ko.pureComputed<boolean>(
|
||||
() => this.container.getPlatformType() === PlatformType.Hosted && !!this.collection.partitionKey
|
||||
() => configContext.platform === Platform.Hosted && !!this.collection.partitionKey
|
||||
);
|
||||
|
||||
this.minRUs = ko.computed<number>(() => {
|
||||
@@ -597,7 +596,7 @@ export default class SettingsTab extends TabsBase implements ViewModels.WaitsFor
|
||||
});
|
||||
|
||||
this.maxRUThroughputInputLimit = ko.pureComputed<number>(() => {
|
||||
if (this.container && this.container.getPlatformType() === PlatformType.Hosted && this.collection.partitionKey) {
|
||||
if (configContext.platform === Platform.Hosted && this.collection.partitionKey) {
|
||||
return SharedConstants.CollectionCreation.DefaultCollectionRUs1Million;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ import { readCollectionQuotaInfo } from "../../Common/dataAccess/readCollectionQ
|
||||
import * as Logger from "../../Common/Logger";
|
||||
import * as DataModels from "../../Contracts/DataModels";
|
||||
import * as ViewModels from "../../Contracts/ViewModels";
|
||||
import { PlatformType } from "../../PlatformType";
|
||||
import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants";
|
||||
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
||||
import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils";
|
||||
@@ -36,7 +35,7 @@ import DocumentId from "./DocumentId";
|
||||
import StoredProcedure from "./StoredProcedure";
|
||||
import Trigger from "./Trigger";
|
||||
import UserDefinedFunction from "./UserDefinedFunction";
|
||||
import { configContext } from "../../ConfigContext";
|
||||
import { configContext, Platform } from "../../ConfigContext";
|
||||
import Explorer from "../Explorer";
|
||||
import { userContext } from "../../UserContext";
|
||||
import TabsBase from "../Tabs/TabsBase";
|
||||
@@ -1030,9 +1029,8 @@ export default class Collection implements ViewModels.Collection {
|
||||
}
|
||||
|
||||
public uploadFiles = (fileList: FileList): Q.Promise<UploadDetails> => {
|
||||
const platformType: string = PlatformType[(<any>window).dataExplorerPlatform];
|
||||
// TODO: right now web worker is not working with AAD flow. Use main thread for upload for now until we have backend upload capability
|
||||
if (platformType === PlatformType[PlatformType.Hosted] && window.authType === AuthType.AAD) {
|
||||
if (configContext.platform === Platform.Hosted && window.authType === AuthType.AAD) {
|
||||
return this._uploadFilesCors(fileList);
|
||||
}
|
||||
const documentUploader: Worker = new UploadWorker();
|
||||
|
||||
Reference in New Issue
Block a user