diff --git a/src/Common/NotificationsClientBase.ts b/src/Common/NotificationsClientBase.ts deleted file mode 100644 index e530fb216..000000000 --- a/src/Common/NotificationsClientBase.ts +++ /dev/null @@ -1,46 +0,0 @@ -import "jquery"; -import * as Q from "q"; -import * as DataModels from "../Contracts/DataModels"; -import * as ViewModels from "../Contracts/ViewModels"; -import { getAuthorizationHeader } from "../Utils/AuthorizationUtils"; -import { userContext } from "../UserContext"; - -export class NotificationsClientBase { - private _extensionEndpoint: string; - private _notificationsApiSuffix: string; - - protected constructor(notificationsApiSuffix: string) { - this._notificationsApiSuffix = notificationsApiSuffix; - } - - public fetchNotifications(): Q.Promise { - const deferred: Q.Deferred = Q.defer(); - const databaseAccount = userContext.databaseAccount; - const subscriptionId = userContext.subscriptionId; - const resourceGroup = userContext.resourceGroup; - const url = `${this._extensionEndpoint}${this._notificationsApiSuffix}?accountName=${databaseAccount.name}&subscriptionId=${subscriptionId}&resourceGroup=${resourceGroup}`; - const authorizationHeader: ViewModels.AuthorizationTokenHeaderMetadata = getAuthorizationHeader(); - const headers: any = {}; - headers[authorizationHeader.header] = authorizationHeader.token; - - $.ajax({ - url: url, - type: "GET", - headers: headers, - cache: false - }).then( - (notifications: DataModels.Notification[], textStatus: string, xhr: JQueryXHR) => { - deferred.resolve(notifications); - }, - (xhr: JQueryXHR, textStatus: string, error: any) => { - deferred.reject(xhr.responseText); - } - ); - - return deferred.promise; - } - - public setExtensionEndpoint(extensionEndpoint: string): void { - this._extensionEndpoint = extensionEndpoint; - } -} diff --git a/src/Explorer/Explorer.ts b/src/Explorer/Explorer.ts index 377d31cb7..f128ef762 100644 --- a/src/Explorer/Explorer.ts +++ b/src/Explorer/Explorer.ts @@ -82,7 +82,6 @@ import { toRawContentUri, fromContentUri } from "../Utils/GitHubUtils"; import UserDefinedFunction from "./Tree/UserDefinedFunction"; import StoredProcedure from "./Tree/StoredProcedure"; import Trigger from "./Tree/Trigger"; -import { NotificationsClientBase } from "../Common/NotificationsClientBase"; import { ContextualPaneBase } from "./Panes/ContextualPaneBase"; import TabsBase from "./Tabs/TabsBase"; import { CommandButtonComponentProps } from "./Controls/CommandButton/CommandButtonComponent"; @@ -98,7 +97,6 @@ enum ShareAccessToggleState { } interface ExplorerOptions { - notificationsClient: NotificationsClientBase; isEmulator: boolean; } interface AdHocAccessData { @@ -133,7 +131,6 @@ export default class Explorer { public isPreferredApiTable: ko.Computed; public isFixedCollectionWithSharedThroughputSupported: ko.Computed; public isServerlessEnabled: ko.Computed; - public isEmulator: boolean; public isAccountReady: ko.Observable; public canSaveQueries: ko.Computed; public features: ko.Observable; @@ -141,7 +138,6 @@ export default class Explorer { public extensionEndpoint: ko.Observable; public armEndpoint: ko.Observable; public isTryCosmosDBSubscription: ko.Observable; - public notificationsClient: NotificationsClientBase; public queriesClient: QueriesClient; public tableDataClient: TableDataClient; public splitter: Splitter; @@ -269,7 +265,7 @@ export default class Explorer { private static readonly MaxNbDatabasesToAutoExpand = 5; - constructor(options: ExplorerOptions) { + constructor() { const startKey: number = TelemetryProcessor.traceStart(Action.InitializeDataExplorer, { dataExplorerArea: Constants.Areas.ResourceTree }); @@ -375,8 +371,6 @@ export default class Explorer { } }); this.memoryUsageInfo = ko.observable(); - this.notificationsClient = options.notificationsClient; - this.isEmulator = options.isEmulator; this.features = ko.observable(); this.serverId = ko.observable(); @@ -1939,7 +1933,6 @@ export default class Explorer { this.serverId(inputs.serverId); this.extensionEndpoint(inputs.extensionEndpoint || ""); this.armEndpoint(EnvironmentUtility.normalizeArmEndpointUri(inputs.csmEndpoint || configContext.ARM_ENDPOINT)); - this.notificationsClient.setExtensionEndpoint(this.extensionEndpoint()); this.databaseAccount(databaseAccount); this.subscriptionType(inputs.subscriptionType); this.quotaId(inputs.quotaId); diff --git a/src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.ts b/src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.ts index 57042c659..f0b70053e 100644 --- a/src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.ts +++ b/src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.ts @@ -194,7 +194,7 @@ export class CommandBarComponentButtonFactory { buttons.push(fullScreenButton); } - if (!container.hasOwnProperty("isEmulator") || !container.isEmulator) { + if (configContext.platform !== Platform.Emulator) { const label = "Feedback"; const feedbackButtonOptions: CommandButtonComponentProps = { iconSrc: FeedbackIcon, diff --git a/src/Explorer/Panes/AddCollectionPane.test.ts b/src/Explorer/Panes/AddCollectionPane.test.ts index f156540d2..8fd6e697f 100644 --- a/src/Explorer/Panes/AddCollectionPane.test.ts +++ b/src/Explorer/Panes/AddCollectionPane.test.ts @@ -40,7 +40,7 @@ describe("Add Collection Pane", () => { }; beforeEach(() => { - explorer = new Explorer({ notificationsClient: null, isEmulator: false }); + explorer = new Explorer(); explorer.hasAutoPilotV2FeatureFlag = ko.computed(() => true); }); diff --git a/src/Explorer/Panes/AddCollectionPane.ts b/src/Explorer/Panes/AddCollectionPane.ts index 458831769..898522e61 100644 --- a/src/Explorer/Panes/AddCollectionPane.ts +++ b/src/Explorer/Panes/AddCollectionPane.ts @@ -329,7 +329,7 @@ export default class AddCollectionPane extends ContextualPaneBase { this.canRequestSupport = ko.pureComputed(() => { if ( - !this.container.isEmulator && + configContext.platform !== Platform.Emulator && !this.container.isTryCosmosDBSubscription() && this.container.getPlatformType() !== PlatformType.Portal ) { @@ -341,7 +341,7 @@ export default class AddCollectionPane extends ContextualPaneBase { }); this.costsVisible = ko.pureComputed(() => { - return !this.container.isEmulator; + return configContext.platform !== Platform.Emulator; }); this.maxCollectionsReached = ko.computed(() => { diff --git a/src/Explorer/Panes/AddDatabasePane.test.ts b/src/Explorer/Panes/AddDatabasePane.test.ts index 58f123b5a..1a78b5326 100644 --- a/src/Explorer/Panes/AddDatabasePane.test.ts +++ b/src/Explorer/Panes/AddDatabasePane.test.ts @@ -40,10 +40,7 @@ describe("Add Database Pane", () => { }; beforeEach(() => { - explorer = new Explorer({ - notificationsClient: null, - isEmulator: false - }); + explorer = new Explorer(); }); it("should be true if subscription type is Benefits", () => { diff --git a/src/Explorer/Panes/AddDatabasePane.ts b/src/Explorer/Panes/AddDatabasePane.ts index c489f19c0..1c2ba658a 100644 --- a/src/Explorer/Panes/AddDatabasePane.ts +++ b/src/Explorer/Panes/AddDatabasePane.ts @@ -17,6 +17,7 @@ import { ContextualPaneBase } from "./ContextualPaneBase"; import { PlatformType } from "../../PlatformType"; import { refreshCachedOffers, refreshCachedResources, createDatabase } from "../../Common/DocumentClientUtilityBase"; import { userContext } from "../../UserContext"; +import { configContext, Platform } from "../../ConfigContext"; export default class AddDatabasePane extends ContextualPaneBase { public defaultExperience: ko.Computed; @@ -179,7 +180,7 @@ export default class AddDatabasePane extends ContextualPaneBase { this.canRequestSupport = ko.pureComputed(() => { if ( - !this.container.isEmulator && + configContext.platform !== Platform.Emulator && !this.container.isTryCosmosDBSubscription() && this.container.getPlatformType() !== PlatformType.Portal ) { @@ -202,7 +203,7 @@ export default class AddDatabasePane extends ContextualPaneBase { }); this.costsVisible = ko.pureComputed(() => { - return !this.container.isEmulator; + return configContext.platform !== Platform.Emulator; }); this.throughputSpendAckVisible = ko.pureComputed(() => { diff --git a/src/Explorer/Panes/CassandraAddCollectionPane.ts b/src/Explorer/Panes/CassandraAddCollectionPane.ts index 00097e86f..0dbee71e8 100644 --- a/src/Explorer/Panes/CassandraAddCollectionPane.ts +++ b/src/Explorer/Panes/CassandraAddCollectionPane.ts @@ -12,6 +12,7 @@ import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstan import { CassandraAPIDataClient } from "../Tables/TableDataClient"; import { ContextualPaneBase } from "./ContextualPaneBase"; import { HashMap } from "../../Common/HashMap"; +import { configContext, Platform } from "../../ConfigContext"; export default class CassandraAddCollectionPane extends ContextualPaneBase { public createTableQuery: ko.Observable; @@ -231,11 +232,11 @@ export default class CassandraAddCollectionPane extends ContextualPaneBase { }); this.costsVisible = ko.pureComputed(() => { - return !this.container.isEmulator; + return configContext.platform !== Platform.Emulator; }); this.canRequestSupport = ko.pureComputed(() => { - if (!this.container.isEmulator && !this.container.isTryCosmosDBSubscription()) { + if (configContext.platform !== Platform.Emulator && !this.container.isTryCosmosDBSubscription()) { const offerThroughput: number = this.throughput(); return offerThroughput <= 100000; } diff --git a/src/Explorer/Panes/DeleteCollectionConfirmationPane.test.ts b/src/Explorer/Panes/DeleteCollectionConfirmationPane.test.ts index abb1c41fe..00dc2abcf 100644 --- a/src/Explorer/Panes/DeleteCollectionConfirmationPane.test.ts +++ b/src/Explorer/Panes/DeleteCollectionConfirmationPane.test.ts @@ -17,7 +17,7 @@ describe("Delete Collection Confirmation Pane", () => { let explorer: Explorer; beforeEach(() => { - explorer = new Explorer({ notificationsClient: null, isEmulator: false }); + explorer = new Explorer(); }); it("should be true if 1 database and 1 collection", () => { @@ -56,7 +56,7 @@ describe("Delete Collection Confirmation Pane", () => { describe("shouldRecordFeedback()", () => { it("should return true if last collection and database does not have shared throughput else false", () => { - let fakeExplorer = new Explorer({ notificationsClient: null, isEmulator: false }); + let fakeExplorer = new Explorer(); fakeExplorer.isNotificationConsoleExpanded = ko.observable(false); fakeExplorer.refreshAllDatabases = () => Q.resolve(); diff --git a/src/Explorer/Panes/DeleteDatabaseConfirmationPane.test.ts b/src/Explorer/Panes/DeleteDatabaseConfirmationPane.test.ts index fc8a73259..be902ce7f 100644 --- a/src/Explorer/Panes/DeleteDatabaseConfirmationPane.test.ts +++ b/src/Explorer/Panes/DeleteDatabaseConfirmationPane.test.ts @@ -22,7 +22,7 @@ describe("Delete Database Confirmation Pane", () => { }); beforeEach(() => { - explorer = new Explorer({ notificationsClient: null, isEmulator: false }); + explorer = new Explorer(); }); it("should be true if only 1 database", () => { diff --git a/src/Explorer/Panes/SettingsPane.test.ts b/src/Explorer/Panes/SettingsPane.test.ts index f9f167372..19cbc65f0 100644 --- a/src/Explorer/Panes/SettingsPane.test.ts +++ b/src/Explorer/Panes/SettingsPane.test.ts @@ -7,7 +7,7 @@ describe("Settings Pane", () => { let explorer: Explorer; beforeEach(() => { - explorer = new Explorer({ notificationsClient: null, isEmulator: false }); + explorer = new Explorer(); }); it("should be true for SQL API", () => { diff --git a/src/Explorer/SplashScreen/SplashScreenComponentAdapter.test.ts b/src/Explorer/SplashScreen/SplashScreenComponentAdapter.test.ts index 45f3a4165..998d9ef86 100644 --- a/src/Explorer/SplashScreen/SplashScreenComponentAdapter.test.ts +++ b/src/Explorer/SplashScreen/SplashScreenComponentAdapter.test.ts @@ -6,7 +6,7 @@ import Explorer from "../Explorer"; jest.mock("../Explorer"); const createExplorer = () => { - const mock = new Explorer({} as any); + const mock = new Explorer(); mock.selectedNode = ko.observable(); mock.isNotebookEnabled = ko.observable(false); mock.addCollectionText = ko.observable("add collection"); diff --git a/src/Explorer/Tabs/DatabaseSettingsTab.ts b/src/Explorer/Tabs/DatabaseSettingsTab.ts index 75915b25b..7df89f5c6 100644 --- a/src/Explorer/Tabs/DatabaseSettingsTab.ts +++ b/src/Explorer/Tabs/DatabaseSettingsTab.ts @@ -20,6 +20,7 @@ import { updateOffer } from "../../Common/DocumentClientUtilityBase"; 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( @@ -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() ) { diff --git a/src/Explorer/Tabs/DocumentsTab.test.ts b/src/Explorer/Tabs/DocumentsTab.test.ts index 51753969f..4c8524c32 100644 --- a/src/Explorer/Tabs/DocumentsTab.test.ts +++ b/src/Explorer/Tabs/DocumentsTab.test.ts @@ -27,15 +27,9 @@ describe("Documents tab", () => { }); describe("showPartitionKey", () => { - const explorer = new Explorer({ - notificationsClient: null, - isEmulator: false - }); + const explorer = new Explorer(); - const mongoExplorer = new Explorer({ - notificationsClient: null, - isEmulator: false - }); + const mongoExplorer = new Explorer(); mongoExplorer.defaultExperience(Constants.DefaultAccountExperience.MongoDB); const collectionWithoutPartitionKey = ({ diff --git a/src/Explorer/Tabs/QueryTab.test.ts b/src/Explorer/Tabs/QueryTab.test.ts index d63eb25c2..58e1505c7 100644 --- a/src/Explorer/Tabs/QueryTab.test.ts +++ b/src/Explorer/Tabs/QueryTab.test.ts @@ -49,7 +49,7 @@ describe("Query Tab", () => { let explorer: Explorer; beforeEach(() => { - explorer = new Explorer({ notificationsClient: null, isEmulator: false }); + explorer = new Explorer(); }); 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(); }); it("should be visible when using a supported API", () => { diff --git a/src/Explorer/Tabs/SettingsTab.test.ts b/src/Explorer/Tabs/SettingsTab.test.ts index 67242446c..664ef727e 100644 --- a/src/Explorer/Tabs/SettingsTab.test.ts +++ b/src/Explorer/Tabs/SettingsTab.test.ts @@ -78,7 +78,7 @@ describe("Settings tab", () => { }; beforeEach(() => { - explorer = new Explorer({ notificationsClient: null, isEmulator: false }); + explorer = new Explorer(); explorer.hasAutoPilotV2FeatureFlag = ko.computed(() => true); }); @@ -177,7 +177,7 @@ describe("Settings tab", () => { let explorer: Explorer; beforeEach(() => { - explorer = new Explorer({ notificationsClient: null, isEmulator: false }); + explorer = new Explorer(); explorer.hasAutoPilotV2FeatureFlag = ko.computed(() => true); }); @@ -255,7 +255,7 @@ describe("Settings tab", () => { let explorer: Explorer; beforeEach(() => { - explorer = new Explorer({ notificationsClient: null, isEmulator: false }); + explorer = new Explorer(); explorer.hasAutoPilotV2FeatureFlag = ko.computed(() => true); }); @@ -336,10 +336,7 @@ describe("Settings tab", () => { } function getCollection(defaultApi: string, partitionKeyOption: PartitionKeyOption) { - const explorer = new Explorer({ - notificationsClient: null, - isEmulator: false - }); + const explorer = new Explorer(); explorer.defaultExperience(defaultApi); explorer.hasAutoPilotV2FeatureFlag = ko.computed(() => true); @@ -471,10 +468,7 @@ describe("Settings tab", () => { describe("AutoPilot", () => { function getCollection(autoPilotTier: DataModels.AutopilotTier) { - const explorer = new Explorer({ - notificationsClient: null, - isEmulator: false - }); + const explorer = new Explorer(); explorer.hasAutoPilotV2FeatureFlag = ko.computed(() => true); explorer.databaseAccount({ diff --git a/src/Explorer/Tabs/SettingsTab.ts b/src/Explorer/Tabs/SettingsTab.ts index f3f24fd0a..ce959ef05 100644 --- a/src/Explorer/Tabs/SettingsTab.ts +++ b/src/Explorer/Tabs/SettingsTab.ts @@ -21,6 +21,8 @@ import { updateOffer, updateCollection } from "../../Common/DocumentClientUtilit import { CommandButtonComponentProps } from "../Controls/CommandButton/CommandButtonComponent"; import { userContext } from "../../UserContext"; import { updateOfferThroughputBeyondLimit } from "../../Common/dataAccess/updateOfferThroughputBeyondLimit"; +import { config } from "process"; +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 +456,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 +486,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(() => { @@ -500,7 +502,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; } @@ -707,7 +709,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; } @@ -878,7 +880,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 = diff --git a/src/Explorer/Tabs/TabsManager.test.ts b/src/Explorer/Tabs/TabsManager.test.ts index 00f132c97..cf1662734 100644 --- a/src/Explorer/Tabs/TabsManager.test.ts +++ b/src/Explorer/Tabs/TabsManager.test.ts @@ -16,7 +16,7 @@ describe("Tabs manager tests", () => { let documentsTab: DocumentsTab; beforeAll(() => { - explorer = new Explorer({ notificationsClient: undefined, isEmulator: false }); + explorer = new Explorer(); explorer.databaseAccount = ko.observable({ id: "test", name: "test", diff --git a/src/Explorer/Tree/Collection.ts b/src/Explorer/Tree/Collection.ts index 121bc686f..752b14e5f 100644 --- a/src/Explorer/Tree/Collection.ts +++ b/src/Explorer/Tree/Collection.ts @@ -559,7 +559,6 @@ export default class Collection implements ViewModels.Collection { }); const tabTitle = !this.offer() ? "Settings" : "Scale & Settings"; - const pendingNotificationsPromise: Q.Promise = this._getPendingThroughputSplitNotification(); const matchingTabs = this.container.tabsManager.getTabs(ViewModels.CollectionTabKind.Settings, tab => { return tab.collection && tab.collection.rid === this.rid; }); @@ -575,9 +574,8 @@ export default class Collection implements ViewModels.Collection { tabTitle: tabTitle }); - Q.all([pendingNotificationsPromise, this.readSettings()]).then( + Q.all([this.readSettings()]).then( (data: any) => { - const pendingNotification: DataModels.Notification = data && data[0]; settingsTab = new SettingsTab({ tabKind: ViewModels.CollectionTabKind.Settings, title: !this.offer() ? "Settings" : "Scale & Settings", @@ -592,7 +590,6 @@ export default class Collection implements ViewModels.Collection { onUpdateTabsButtons: this.container.onUpdateTabsButtons }); this.container.tabsManager.activateNewTab(settingsTab); - settingsTab.pendingNotification(pendingNotification); }, (error: any) => { TelemetryProcessor.traceFailure( @@ -616,16 +613,7 @@ export default class Collection implements ViewModels.Collection { } ); } else { - pendingNotificationsPromise.then( - (pendingNotification: DataModels.Notification) => { - settingsTab.pendingNotification(pendingNotification); - this.container.tabsManager.activateTab(settingsTab); - }, - (error: any) => { - settingsTab.pendingNotification(undefined); - this.container.tabsManager.activateTab(settingsTab); - } - ); + this.container.tabsManager.activateTab(settingsTab); } }; @@ -1283,48 +1271,6 @@ export default class Collection implements ViewModels.Collection { return deferred.promise; } - private _getPendingThroughputSplitNotification(): Q.Promise { - if (!this.container) { - return Q.resolve(undefined); - } - - const deferred: Q.Deferred = Q.defer(); - this.container.notificationsClient.fetchNotifications().then( - (notifications: DataModels.Notification[]) => { - if (!notifications || notifications.length === 0) { - deferred.resolve(undefined); - return; - } - - const pendingNotification = _.find(notifications, (notification: DataModels.Notification) => { - const throughputUpdateRegExp: RegExp = new RegExp("Throughput update (.*) in progress"); - return ( - notification.kind === "message" && - notification.collectionName === this.id() && - notification.description && - throughputUpdateRegExp.test(notification.description) - ); - }); - - deferred.resolve(pendingNotification); - }, - (error: any) => { - Logger.logError( - JSON.stringify({ - error: JSON.stringify(error), - accountName: this.container && this.container.databaseAccount(), - databaseName: this.databaseId, - collectionName: this.id() - }), - "Settings tree node" - ); - deferred.resolve(undefined); - } - ); - - return deferred.promise; - } - private _logUploadDetailsInConsole(uploadDetails: UploadDetails): void { const uploadDetailsRecords: UploadDetailsRecord[] = uploadDetails.data; const numFiles: number = uploadDetailsRecords.length; diff --git a/src/Explorer/Tree/Database.ts b/src/Explorer/Tree/Database.ts index d92e0c9bc..1faa6c028 100644 --- a/src/Explorer/Tree/Database.ts +++ b/src/Explorer/Tree/Database.ts @@ -52,7 +52,6 @@ export default class Database implements ViewModels.Database { dataExplorerArea: Constants.Areas.ResourceTree }); - const pendingNotificationsPromise: Q.Promise = this._getPendingThroughputSplitNotification(); const matchingTabs = this.container.tabsManager.getTabs( ViewModels.CollectionTabKind.DatabaseSettings, tab => tab.rid === this.rid @@ -66,9 +65,8 @@ export default class Database implements ViewModels.Database { dataExplorerArea: Constants.Areas.Tab, tabTitle: "Scale" }); - Q.all([pendingNotificationsPromise, this.readSettings()]).then( - (data: any) => { - const pendingNotification: DataModels.Notification = data && data[0]; + Q.all([this.readSettings()]).then( + () => { settingsTab = new DatabaseSettingsTab({ tabKind: ViewModels.CollectionTabKind.DatabaseSettings, title: "Scale", @@ -83,7 +81,6 @@ export default class Database implements ViewModels.Database { onUpdateTabsButtons: this.container.onUpdateTabsButtons }); - settingsTab.pendingNotification(pendingNotification); this.container.tabsManager.activateNewTab(settingsTab); }, (error: any) => { @@ -108,16 +105,7 @@ export default class Database implements ViewModels.Database { } ); } else { - pendingNotificationsPromise.then( - (pendingNotification: DataModels.Notification) => { - settingsTab.pendingNotification(pendingNotification); - this.container.tabsManager.activateTab(settingsTab); - }, - (error: any) => { - settingsTab.pendingNotification(undefined); - this.container.tabsManager.activateTab(settingsTab); - } - ); + this.container.tabsManager.activateTab(settingsTab); } }; @@ -293,49 +281,6 @@ export default class Database implements ViewModels.Database { return _.find(this.collections(), (collection: ViewModels.Collection) => collection.id() === collectionId); } - private _getPendingThroughputSplitNotification(): Q.Promise { - if (!this.container) { - return Q.resolve(undefined); - } - - const deferred: Q.Deferred = Q.defer(); - this.container.notificationsClient.fetchNotifications().then( - (notifications: DataModels.Notification[]) => { - if (!notifications || notifications.length === 0) { - deferred.resolve(undefined); - return; - } - - const pendingNotification = _.find(notifications, (notification: DataModels.Notification) => { - const throughputUpdateRegExp: RegExp = new RegExp("Throughput update (.*) in progress"); - return ( - notification.kind === "message" && - !notification.collectionName && - notification.databaseName === this.id() && - notification.description && - throughputUpdateRegExp.test(notification.description) - ); - }); - - deferred.resolve(pendingNotification); - }, - (error: any) => { - Logger.logError( - JSON.stringify({ - error: JSON.stringify(error), - accountName: this.container && this.container.databaseAccount(), - databaseName: this.id(), - collectionName: this.id() - }), - "Settings tree node" - ); - deferred.resolve(undefined); - } - ); - - return deferred.promise; - } - private getDeltaCollections( updatedCollectionsList: DataModels.Collection[] ): { toAdd: DataModels.Collection[]; toDelete: Collection[] } { diff --git a/src/Platform/Emulator/ExplorerFactory.ts b/src/Platform/Emulator/ExplorerFactory.ts index 8614d063e..6f4774b37 100644 --- a/src/Platform/Emulator/ExplorerFactory.ts +++ b/src/Platform/Emulator/ExplorerFactory.ts @@ -2,14 +2,9 @@ import { AccountKind, TagNames, DefaultAccountExperience } from "../../Common/Co import Explorer from "../../Explorer/Explorer"; -import { NotificationsClient } from "./NotificationsClient"; - export default class EmulatorExplorerFactory { public static createExplorer(): Explorer { - const explorer: Explorer = new Explorer({ - notificationsClient: new NotificationsClient(), - isEmulator: true - }); + const explorer: Explorer = new Explorer(); explorer.databaseAccount({ name: "", id: "", diff --git a/src/Platform/Emulator/Main.ts b/src/Platform/Emulator/Main.ts index 08b32237d..29ec1fafe 100644 --- a/src/Platform/Emulator/Main.ts +++ b/src/Platform/Emulator/Main.ts @@ -1,6 +1,24 @@ -import EmulatorExplorerFactory from "./ExplorerFactory"; import Explorer from "../../Explorer/Explorer"; +import { AccountKind, DefaultAccountExperience, TagNames } from "../../Common/Constants"; export function initializeExplorer(): Explorer { - return EmulatorExplorerFactory.createExplorer(); + const explorer: Explorer = new Explorer(); + explorer.databaseAccount({ + name: "", + id: "", + location: "", + type: "", + kind: AccountKind.DocumentDB, + tags: { + [TagNames.defaultExperience]: DefaultAccountExperience.DocumentDB + }, + properties: { + documentEndpoint: "", + tableEndpoint: "", + gremlinEndpoint: "", + cassandraEndpoint: "" + } + }); + explorer.isAccountReady(true); + return explorer; } diff --git a/src/Platform/Emulator/NotificationsClient.ts b/src/Platform/Emulator/NotificationsClient.ts deleted file mode 100644 index 87c82420c..000000000 --- a/src/Platform/Emulator/NotificationsClient.ts +++ /dev/null @@ -1,16 +0,0 @@ -import Q from "q"; -import * as DataModels from "../../Contracts/DataModels"; -import { NotificationsClientBase } from "../../Common/NotificationsClientBase"; - -export class NotificationsClient extends NotificationsClientBase { - private static readonly _notificationsApiSuffix: string = "/api/notifications"; - - public constructor() { - super(NotificationsClient._notificationsApiSuffix); - } - - public fetchNotifications(): Q.Promise { - // no notifications for the emulator - return Q([]); - } -} diff --git a/src/Platform/Hosted/ExplorerFactory.ts b/src/Platform/Hosted/ExplorerFactory.ts index 22fb13a43..d76445183 100644 --- a/src/Platform/Hosted/ExplorerFactory.ts +++ b/src/Platform/Hosted/ExplorerFactory.ts @@ -1,14 +1,8 @@ import Explorer from "../../Explorer/Explorer"; -import { NotificationsClient } from "./NotificationsClient"; export default class HostedExplorerFactory { public createExplorer(): Explorer { - const explorer = new Explorer({ - notificationsClient: new NotificationsClient(), - isEmulator: false - }); - - return explorer; + return new Explorer(); } public static reInitializeDocumentClientUtilityForExplorer(explorer: Explorer): void { diff --git a/src/Platform/Hosted/NotificationsClient.ts b/src/Platform/Hosted/NotificationsClient.ts deleted file mode 100644 index 5277f1d49..000000000 --- a/src/Platform/Hosted/NotificationsClient.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { NotificationsClientBase } from "../../Common/NotificationsClientBase"; - -export class NotificationsClient extends NotificationsClientBase { - private static readonly _notificationsApiSuffix: string = "/api/guest/notifications"; - - public constructor() { - super(NotificationsClient._notificationsApiSuffix); - } -} diff --git a/src/Platform/Portal/ExplorerFactory.ts b/src/Platform/Portal/ExplorerFactory.ts deleted file mode 100644 index bf1eac162..000000000 --- a/src/Platform/Portal/ExplorerFactory.ts +++ /dev/null @@ -1,13 +0,0 @@ -import Explorer from "../../Explorer/Explorer"; -import { NotificationsClient } from "./NotificationsClient"; - -export default class PortalExplorerFactory { - public createExplorer(): Explorer { - var explorer = new Explorer({ - notificationsClient: new NotificationsClient(), - isEmulator: false - }); - - return explorer; - } -} diff --git a/src/Platform/Portal/Main.ts b/src/Platform/Portal/Main.ts index cfce9ac2f..1e9af9e29 100644 --- a/src/Platform/Portal/Main.ts +++ b/src/Platform/Portal/Main.ts @@ -1,10 +1,8 @@ -import PortalExplorerFactory from "./ExplorerFactory"; import "../../Explorer/Tables/DataTable/DataTableBindingManager"; import Explorer from "../../Explorer/Explorer"; export function initializeExplorer(): Explorer { - const portalExplorerFactory = new PortalExplorerFactory(); - const explorer = portalExplorerFactory.createExplorer(); + const explorer = new Explorer(); window.addEventListener("message", explorer.handleMessage.bind(explorer), false); return explorer; diff --git a/src/Platform/Portal/NotificationsClient.ts b/src/Platform/Portal/NotificationsClient.ts deleted file mode 100644 index 84f490e28..000000000 --- a/src/Platform/Portal/NotificationsClient.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { NotificationsClientBase } from "../../Common/NotificationsClientBase"; - -export class NotificationsClient extends NotificationsClientBase { - private static readonly _notificationsApiSuffix: string = "/api/notifications"; - - public constructor() { - super(NotificationsClient._notificationsApiSuffix); - } -} diff --git a/src/RouteHandlers/TabRouteHandler.test.ts b/src/RouteHandlers/TabRouteHandler.test.ts index 6cf0d82fb..cbddd968f 100644 --- a/src/RouteHandlers/TabRouteHandler.test.ts +++ b/src/RouteHandlers/TabRouteHandler.test.ts @@ -9,10 +9,7 @@ describe("TabRouteHandler", () => { let tabRouteHandler: TabRouteHandler; beforeAll(() => { - (window).dataExplorer = new Explorer({ - notificationsClient: null, - isEmulator: false - }); // create a mock to avoid null refs + (window).dataExplorer = new Explorer(); // create a mock to avoid null refs }); beforeEach(() => { diff --git a/src/Utils/AuthorizationUtils.test.ts b/src/Utils/AuthorizationUtils.test.ts index 1b97443f9..c3836bd5d 100644 --- a/src/Utils/AuthorizationUtils.test.ts +++ b/src/Utils/AuthorizationUtils.test.ts @@ -60,7 +60,7 @@ describe("AuthorizationUtils", () => { }); describe("displayTokenRenewalPromptForStatus()", () => { - let explorer = new Explorer({} as any) as jest.Mocked; + let explorer = new Explorer() as jest.Mocked; beforeEach(() => { jest.clearAllMocks(); diff --git a/tsconfig.strict.json b/tsconfig.strict.json index 055d811a2..aa6f57a88 100644 --- a/tsconfig.strict.json +++ b/tsconfig.strict.json @@ -1,79 +1,81 @@ { - "extends": "./tsconfig.json", - "compilerOptions": { - "noEmit": true, - "strictNullChecks": true, - "strict": true, - "noUnusedLocals": true - }, - "files": [ - "./src/AuthType.ts", - "./src/Bindings/BindingHandlersRegisterer.ts", - "./src/Bindings/ReactBindingHandler.ts", - "./src/Common/ArrayHashMap.ts", - "./src/Common/Constants.ts", - "./src/Common/DeleteFeedback.ts", - "./src/Common/HashMap.ts", - "./src/Common/HeadersUtility.ts", - "./src/Common/Logger.ts", - "./src/Common/MessageHandler.ts", - "./src/Common/MongoUtility.ts", - "./src/Common/ObjectCache.ts", - "./src/Common/ThemeUtility.ts", - "./src/Common/UrlUtility.ts", - "./src/Common/dataAccess/sendNotificationForError.ts", - "./src/ConfigContext.ts", - "./src/Contracts/ActionContracts.ts", - "./src/Contracts/DataModels.ts", - "./src/Contracts/Diagnostics.ts", - "./src/Contracts/ExplorerContracts.ts", - "./src/Contracts/Versions.ts", - "./src/Controls/Heatmap/Heatmap.ts", - "./src/Controls/Heatmap/HeatmapDatatypes.ts", - "./src/Definitions/globals.d.ts", - "./src/Definitions/html.d.ts", - "./src/Definitions/jquery-ui.d.ts", - "./src/Definitions/jquery.d.ts", - "./src/Definitions/plotly.js-cartesian-dist.d-min.ts", - "./src/Definitions/svg.d.ts", - "./src/Explorer/Controls/ErrorDisplayComponent/ErrorDisplayComponent.ts", - "./src/Explorer/Controls/GitHub/GitHubStyleConstants.ts", - "./src/Explorer/Controls/SmartUi/InputUtils.ts", - "./src/Explorer/Notebook/FileSystemUtil.ts", - "./src/Explorer/Notebook/NTeractUtil.ts", - "./src/Explorer/Notebook/NotebookComponent/actions.ts", - "./src/Explorer/Notebook/NotebookComponent/loadTransform.ts", - "./src/Explorer/Notebook/NotebookComponent/reducers.ts", - "./src/Explorer/Notebook/NotebookComponent/types.ts", - "./src/Explorer/Notebook/NotebookContentItem.ts", - "./src/Explorer/Notebook/NotebookUtil.ts", - "./src/Explorer/Panes/PaneComponents.ts", - "./src/Explorer/Panes/Tables/Validators/EntityPropertyNameValidator.ts", - "./src/Explorer/Panes/Tables/Validators/EntityPropertyValidationCommon.ts", - "./src/Explorer/Tables/Constants.ts", - "./src/Explorer/Tables/QueryBuilder/DateTimeUtilities.ts", - "./src/Explorer/Tabs/TabComponents.ts", - "./src/GitHub/GitHubConnector.ts", - "./src/Index.ts", - "./src/NotebookWorkspaceManager/NotebookWorkspaceResourceProviderMockClients.ts", - "./src/PlatformType.ts", - "./src/ReactDevTools.ts", - "./src/ResourceProvider/IResourceProviderClient.ts", - "./src/Shared/ExplorerSettings.ts", - "./src/Shared/StorageUtility.ts", - "./src/Shared/StringUtility.ts", - "./src/Shared/Telemetry/TelemetryConstants.ts", - "./src/Shared/Telemetry/TelemetryProcessor.ts", - "./src/Shared/appInsights.ts", - "./src/UserContext.ts", - "./src/Utils/GitHubUtils.ts", - "./src/Utils/MessageValidation.ts", - "./src/Utils/OfferUtils.ts", - "./src/Utils/StringUtils.ts", - "./src/Utils/arm/generatedClients/2020-04-01/types.ts", - "./src/quickstart.ts", - "./src/setupTests.ts", - "./src/workers/upload/definitions.ts" - ], - "include": [] -} + "extends": "./tsconfig.json", + "compilerOptions": { + "noEmit": true, + "strictNullChecks": true, + "strict": true, + "noUnusedLocals": true + }, + "files": [ + "./src/AuthType.ts", + "./src/Bindings/BindingHandlersRegisterer.ts", + "./src/Bindings/ReactBindingHandler.ts", + "./src/Common/ArrayHashMap.ts", + "./src/Common/Constants.ts", + "./src/Common/DeleteFeedback.ts", + "./src/Common/HashMap.ts", + "./src/Common/HeadersUtility.ts", + "./src/Common/Logger.ts", + "./src/Common/MessageHandler.ts", + "./src/Common/MongoUtility.ts", + "./src/Common/ObjectCache.ts", + "./src/Common/ThemeUtility.ts", + "./src/Common/UrlUtility.ts", + "./src/Common/dataAccess/sendNotificationForError.ts", + "./src/ConfigContext.ts", + "./src/Contracts/ActionContracts.ts", + "./src/Contracts/DataModels.ts", + "./src/Contracts/Diagnostics.ts", + "./src/Contracts/ExplorerContracts.ts", + "./src/Contracts/Versions.ts", + "./src/Controls/Heatmap/Heatmap.ts", + "./src/Controls/Heatmap/HeatmapDatatypes.ts", + "./src/DefaultAccountExperienceType.ts", + "./src/Definitions/globals.d.ts", + "./src/Definitions/html.d.ts", + "./src/Definitions/jquery-ui.d.ts", + "./src/Definitions/jquery.d.ts", + "./src/Definitions/plotly.js-cartesian-dist.d-min.ts", + "./src/Definitions/svg.d.ts", + "./src/Explorer/Controls/ErrorDisplayComponent/ErrorDisplayComponent.ts", + "./src/Explorer/Controls/GitHub/GitHubStyleConstants.ts", + "./src/Explorer/Controls/SmartUi/InputUtils.ts", + "./src/Explorer/Notebook/FileSystemUtil.ts", + "./src/Explorer/Notebook/NTeractUtil.ts", + "./src/Explorer/Notebook/NotebookComponent/actions.ts", + "./src/Explorer/Notebook/NotebookComponent/loadTransform.ts", + "./src/Explorer/Notebook/NotebookComponent/reducers.ts", + "./src/Explorer/Notebook/NotebookComponent/types.ts", + "./src/Explorer/Notebook/NotebookContentItem.ts", + "./src/Explorer/Notebook/NotebookUtil.ts", + "./src/Explorer/Panes/PaneComponents.ts", + "./src/Explorer/Panes/Tables/Validators/EntityPropertyNameValidator.ts", + "./src/Explorer/Panes/Tables/Validators/EntityPropertyValidationCommon.ts", + "./src/Explorer/Tables/Constants.ts", + "./src/Explorer/Tables/QueryBuilder/DateTimeUtilities.ts", + "./src/Explorer/Tabs/TabComponents.ts", + "./src/GitHub/GitHubConnector.ts", + "./src/Index.ts", + "./src/NotebookWorkspaceManager/NotebookWorkspaceResourceProviderMockClients.ts", + "./src/PlatformType.ts", + "./src/ReactDevTools.ts", + "./src/ResourceProvider/IResourceProviderClient.ts", + "./src/Shared/ExplorerSettings.ts", + "./src/Shared/StorageUtility.ts", + "./src/Shared/StringUtility.ts", + "./src/Shared/Telemetry/TelemetryConstants.ts", + "./src/Shared/Telemetry/TelemetryProcessor.ts", + "./src/Shared/appInsights.ts", + "./src/UserContext.ts", + "./src/Utils/Base64Utils.ts", + "./src/Utils/GitHubUtils.ts", + "./src/Utils/MessageValidation.ts", + "./src/Utils/OfferUtils.ts", + "./src/Utils/StringUtils.ts", + "./src/Utils/arm/generatedClients/2020-04-01/types.ts", + "./src/quickstart.ts", + "./src/setupTests.ts", + "./src/workers/upload/definitions.ts" + ], + "include": [] +} \ No newline at end of file