From cfb9a0b321ff0bec43fa0727362bf8134242fcb3 Mon Sep 17 00:00:00 2001 From: Steve Faulkner Date: Mon, 12 Oct 2020 22:10:28 -0500 Subject: [PATCH] Refactor NotificationsClient (#270) --- src/Common/NotificationsClientBase.ts | 46 ------------------- src/Common/PortalNotifications.ts | 41 +++++++++++++++++ .../Settings/SettingsComponent.test.tsx | 8 +--- .../ScaleComponent.test.tsx | 8 +--- .../SubSettingsComponent.test.tsx | 4 +- src/Explorer/Controls/Settings/TestUtils.tsx | 4 +- .../SettingsComponent.test.tsx.snap | 4 -- src/Explorer/Explorer.ts | 9 +--- src/Explorer/Panes/AddCollectionPane.test.ts | 2 +- src/Explorer/Panes/AddDatabasePane.test.ts | 4 +- .../DeleteCollectionConfirmationPane.test.ts | 4 +- .../DeleteDatabaseConfirmationPane.test.ts | 2 +- src/Explorer/Panes/SettingsPane.test.ts | 2 +- .../SplashScreenComponentAdapter.test.ts | 2 +- src/Explorer/Tabs/DocumentsTab.test.ts | 8 +--- src/Explorer/Tabs/QueryTab.test.ts | 4 +- src/Explorer/Tabs/SettingsTab.test.ts | 14 ++---- src/Explorer/Tabs/TabsManager.test.ts | 2 +- src/Explorer/Tree/Collection.ts | 3 +- src/Explorer/Tree/Database.ts | 5 +- src/Platform/Emulator/ExplorerFactory.ts | 6 +-- src/Platform/Emulator/NotificationsClient.ts | 16 ------- src/Platform/Hosted/ExplorerFactory.ts | 5 +- src/Platform/Hosted/NotificationsClient.ts | 9 ---- src/Platform/Portal/ExplorerFactory.ts | 5 +- src/Platform/Portal/NotificationsClient.ts | 9 ---- src/RouteHandlers/TabRouteHandler.test.ts | 4 +- src/Utils/AuthorizationUtils.test.ts | 2 +- 28 files changed, 75 insertions(+), 157 deletions(-) delete mode 100644 src/Common/NotificationsClientBase.ts create mode 100644 src/Common/PortalNotifications.ts delete mode 100644 src/Platform/Emulator/NotificationsClient.ts delete mode 100644 src/Platform/Hosted/NotificationsClient.ts delete mode 100644 src/Platform/Portal/NotificationsClient.ts 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/Common/PortalNotifications.ts b/src/Common/PortalNotifications.ts new file mode 100644 index 000000000..b4094dfb1 --- /dev/null +++ b/src/Common/PortalNotifications.ts @@ -0,0 +1,41 @@ +import * as DataModels from "../Contracts/DataModels"; +import * as ViewModels from "../Contracts/ViewModels"; +import { getAuthorizationHeader } from "../Utils/AuthorizationUtils"; +import { userContext } from "../UserContext"; +import { configContext, Platform } from "../ConfigContext"; + +const notificationsPath = () => { + switch (configContext.platform) { + case Platform.Hosted: + return "/api/guest/notifications"; + case Platform.Portal: + return "/api/notifications"; + default: + throw new Error(`Unknown platform: ${configContext.platform}`); + } +}; + +export const fetchPortalNotifications = async (): Promise => { + if (configContext.platform === Platform.Emulator) { + return []; + } + + const databaseAccount = userContext.databaseAccount; + const subscriptionId = userContext.subscriptionId; + const resourceGroup = userContext.resourceGroup; + const url = `${configContext.BACKEND_ENDPOINT}${notificationsPath()}?accountName=${ + databaseAccount.name + }&subscriptionId=${subscriptionId}&resourceGroup=${resourceGroup}`; + const authorizationHeader: ViewModels.AuthorizationTokenHeaderMetadata = getAuthorizationHeader(); + const headers = { [authorizationHeader.header]: authorizationHeader.token }; + + const response = await window.fetch(url, { + headers + }); + + if (!response.ok) { + throw new Error(await response.text()); + } + + return (await response.json()) as DataModels.Notification[]; +}; diff --git a/src/Explorer/Controls/Settings/SettingsComponent.test.tsx b/src/Explorer/Controls/Settings/SettingsComponent.test.tsx index 0520ea843..e9fb2c621 100644 --- a/src/Explorer/Controls/Settings/SettingsComponent.test.tsx +++ b/src/Explorer/Controls/Settings/SettingsComponent.test.tsx @@ -103,9 +103,7 @@ describe("SettingsComponent", () => { let settingsComponentInstance = new SettingsComponent(baseProps); expect(settingsComponentInstance.shouldShowKeyspaceSharedThroughputMessage()).toEqual(false); - const newContainer = new Explorer({ - notificationsClient: undefined - }); + const newContainer = new Explorer(); newContainer.isPreferredApiCassandra = ko.computed(() => true); const newCollection = { ...collection }; @@ -146,9 +144,7 @@ describe("SettingsComponent", () => { let settingsComponentInstance = new SettingsComponent(baseProps); expect(settingsComponentInstance.hasConflictResolution()).toEqual(undefined); - const newContainer = new Explorer({ - notificationsClient: undefined - }); + const newContainer = new Explorer(); newContainer.databaseAccount = ko.observable({ id: undefined, name: undefined, diff --git a/src/Explorer/Controls/Settings/SettingsSubComponents/ScaleComponent.test.tsx b/src/Explorer/Controls/Settings/SettingsSubComponents/ScaleComponent.test.tsx index 2ea1553fb..1cd52824b 100644 --- a/src/Explorer/Controls/Settings/SettingsSubComponents/ScaleComponent.test.tsx +++ b/src/Explorer/Controls/Settings/SettingsSubComponents/ScaleComponent.test.tsx @@ -12,9 +12,7 @@ import * as SharedConstants from "../../../../Shared/Constants"; import ko from "knockout"; describe("ScaleComponent", () => { - const nonNationalCloudContainer = new Explorer({ - notificationsClient: undefined - }); + const nonNationalCloudContainer = new Explorer(); nonNationalCloudContainer.getPlatformType = () => PlatformType.Portal; nonNationalCloudContainer.isRunningOnNationalCloud = () => false; @@ -87,9 +85,7 @@ describe("ScaleComponent", () => { }); it("autoScale enabled", () => { - const newContainer = new Explorer({ - notificationsClient: undefined - }); + const newContainer = new Explorer(); newContainer.databaseAccount({ id: undefined, diff --git a/src/Explorer/Controls/Settings/SettingsSubComponents/SubSettingsComponent.test.tsx b/src/Explorer/Controls/Settings/SettingsSubComponents/SubSettingsComponent.test.tsx index 487f18143..55c51e382 100644 --- a/src/Explorer/Controls/Settings/SettingsSubComponents/SubSettingsComponent.test.tsx +++ b/src/Explorer/Controls/Settings/SettingsSubComponents/SubSettingsComponent.test.tsx @@ -105,9 +105,7 @@ describe("SubSettingsComponent", () => { }); it("partitionKey not visible", () => { - const newContainer = new Explorer({ - notificationsClient: undefined - }); + const newContainer = new Explorer(); newContainer.isPreferredApiCassandra = ko.computed(() => true); const props = { ...baseProps, container: newContainer }; diff --git a/src/Explorer/Controls/Settings/TestUtils.tsx b/src/Explorer/Controls/Settings/TestUtils.tsx index f3ba7e553..92db0174c 100644 --- a/src/Explorer/Controls/Settings/TestUtils.tsx +++ b/src/Explorer/Controls/Settings/TestUtils.tsx @@ -3,9 +3,7 @@ import * as ViewModels from "../../../Contracts/ViewModels"; import Explorer from "../../Explorer"; import ko from "knockout"; -export const container = new Explorer({ - notificationsClient: undefined -}); +export const container = new Explorer(); export const collection = ({ container: container, diff --git a/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap b/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap index 26107a57e..be1d95326 100644 --- a/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap +++ b/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap @@ -1051,7 +1051,6 @@ exports[`SettingsComponent renders 1`] = ` "parameters": [Function], }, "notificationConsoleData": [Function], - "notificationsClient": undefined, "onRefreshDatabasesKeyPress": [Function], "onRefreshResourcesClick": [Function], "onSwitchToConnectionString": [Function], @@ -2358,7 +2357,6 @@ exports[`SettingsComponent renders 1`] = ` "parameters": [Function], }, "notificationConsoleData": [Function], - "notificationsClient": undefined, "onRefreshDatabasesKeyPress": [Function], "onRefreshResourcesClick": [Function], "onSwitchToConnectionString": [Function], @@ -3678,7 +3676,6 @@ exports[`SettingsComponent renders 1`] = ` "parameters": [Function], }, "notificationConsoleData": [Function], - "notificationsClient": undefined, "onRefreshDatabasesKeyPress": [Function], "onRefreshResourcesClick": [Function], "onSwitchToConnectionString": [Function], @@ -4985,7 +4982,6 @@ exports[`SettingsComponent renders 1`] = ` "parameters": [Function], }, "notificationConsoleData": [Function], - "notificationsClient": undefined, "onRefreshDatabasesKeyPress": [Function], "onRefreshResourcesClick": [Function], "onSwitchToConnectionString": [Function], diff --git a/src/Explorer/Explorer.ts b/src/Explorer/Explorer.ts index 6232cafc7..28b2dd1ce 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"; @@ -99,9 +98,6 @@ enum ShareAccessToggleState { Read } -interface ExplorerOptions { - notificationsClient: NotificationsClientBase; -} interface AdHocAccessData { readWriteUrl: string; readUrl: string; @@ -141,7 +137,6 @@ export default class Explorer { public serverId: ko.Observable; public armEndpoint: ko.Observable; public isTryCosmosDBSubscription: ko.Observable; - public notificationsClient: NotificationsClientBase; public queriesClient: QueriesClient; public tableDataClient: TableDataClient; public splitter: Splitter; @@ -270,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 }); @@ -376,7 +371,6 @@ export default class Explorer { } }); this.memoryUsageInfo = ko.observable(); - this.notificationsClient = options.notificationsClient; this.features = ko.observable(); this.serverId = ko.observable(); @@ -1910,7 +1904,6 @@ export default class Explorer { this.features(inputs.features); this.serverId(inputs.serverId); this.armEndpoint(EnvironmentUtility.normalizeArmEndpointUri(inputs.csmEndpoint || configContext.ARM_ENDPOINT)); - this.notificationsClient.setExtensionEndpoint(configContext.BACKEND_ENDPOINT); this.databaseAccount(databaseAccount); this.subscriptionType(inputs.subscriptionType); this.quotaId(inputs.quotaId); diff --git a/src/Explorer/Panes/AddCollectionPane.test.ts b/src/Explorer/Panes/AddCollectionPane.test.ts index bc2489a44..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 }); + explorer = new Explorer(); explorer.hasAutoPilotV2FeatureFlag = ko.computed(() => true); }); diff --git a/src/Explorer/Panes/AddDatabasePane.test.ts b/src/Explorer/Panes/AddDatabasePane.test.ts index 5b9d26536..1a78b5326 100644 --- a/src/Explorer/Panes/AddDatabasePane.test.ts +++ b/src/Explorer/Panes/AddDatabasePane.test.ts @@ -40,9 +40,7 @@ describe("Add Database Pane", () => { }; beforeEach(() => { - explorer = new Explorer({ - notificationsClient: null - }); + explorer = new Explorer(); }); it("should be true if subscription type is Benefits", () => { diff --git a/src/Explorer/Panes/DeleteCollectionConfirmationPane.test.ts b/src/Explorer/Panes/DeleteCollectionConfirmationPane.test.ts index 813c0fc30..4b9e9f257 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 }); + 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 }); + 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 b971c983a..a150a1a6d 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 }); + 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 dd632d84a..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 }); + 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/DocumentsTab.test.ts b/src/Explorer/Tabs/DocumentsTab.test.ts index 2e70a0825..4c8524c32 100644 --- a/src/Explorer/Tabs/DocumentsTab.test.ts +++ b/src/Explorer/Tabs/DocumentsTab.test.ts @@ -27,13 +27,9 @@ describe("Documents tab", () => { }); describe("showPartitionKey", () => { - const explorer = new Explorer({ - notificationsClient: null - }); + const explorer = new Explorer(); - const mongoExplorer = new Explorer({ - notificationsClient: null - }); + 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 d2476d526..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 }); + 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 }); + 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 e106ce58a..bbdc5056f 100644 --- a/src/Explorer/Tabs/SettingsTab.test.ts +++ b/src/Explorer/Tabs/SettingsTab.test.ts @@ -79,7 +79,7 @@ describe("Settings tab", () => { }; beforeEach(() => { - explorer = new Explorer({ notificationsClient: null }); + explorer = new Explorer(); explorer.hasAutoPilotV2FeatureFlag = ko.computed(() => true); }); @@ -178,7 +178,7 @@ describe("Settings tab", () => { let explorer: Explorer; beforeEach(() => { - explorer = new Explorer({ notificationsClient: null }); + explorer = new Explorer(); explorer.hasAutoPilotV2FeatureFlag = ko.computed(() => true); }); @@ -256,7 +256,7 @@ describe("Settings tab", () => { let explorer: Explorer; beforeEach(() => { - explorer = new Explorer({ notificationsClient: null }); + explorer = new Explorer(); explorer.hasAutoPilotV2FeatureFlag = ko.computed(() => true); }); @@ -337,9 +337,7 @@ describe("Settings tab", () => { } function getCollection(defaultApi: string, partitionKeyOption: PartitionKeyOption) { - const explorer = new Explorer({ - notificationsClient: null - }); + const explorer = new Explorer(); explorer.defaultExperience(defaultApi); explorer.hasAutoPilotV2FeatureFlag = ko.computed(() => true); @@ -469,9 +467,7 @@ describe("Settings tab", () => { describe("AutoPilot", () => { function getCollection(autoPilotTier: DataModels.AutopilotTier) { - const explorer = new Explorer({ - notificationsClient: null - }); + const explorer = new Explorer(); explorer.hasAutoPilotV2FeatureFlag = ko.computed(() => true); explorer.databaseAccount({ diff --git a/src/Explorer/Tabs/TabsManager.test.ts b/src/Explorer/Tabs/TabsManager.test.ts index 7be1e073c..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 }); + 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 7f4b69753..45aab25de 100644 --- a/src/Explorer/Tree/Collection.ts +++ b/src/Explorer/Tree/Collection.ts @@ -40,6 +40,7 @@ import { configContext } from "../../ConfigContext"; import Explorer from "../Explorer"; import { userContext } from "../../UserContext"; import TabsBase from "../Tabs/TabsBase"; +import { fetchPortalNotifications } from "../../Common/PortalNotifications"; export default class Collection implements ViewModels.Collection { public nodeKind: string; @@ -1213,7 +1214,7 @@ export default class Collection implements ViewModels.Collection { } const deferred: Q.Deferred = Q.defer(); - this.container.notificationsClient.fetchNotifications().then( + fetchPortalNotifications().then( (notifications: DataModels.Notification[]) => { if (!notifications || notifications.length === 0) { deferred.resolve(undefined); diff --git a/src/Explorer/Tree/Database.ts b/src/Explorer/Tree/Database.ts index 7ca8a23ef..9b2b88521 100644 --- a/src/Explorer/Tree/Database.ts +++ b/src/Explorer/Tree/Database.ts @@ -15,6 +15,7 @@ import Explorer from "../Explorer"; import { readCollections } from "../../Common/dataAccess/readCollections"; import { readDatabaseOffer } from "../../Common/dataAccess/readDatabaseOffer"; import { DefaultAccountExperienceType } from "../../DefaultAccountExperienceType"; +import { fetchPortalNotifications } from "../../Common/PortalNotifications"; export default class Database implements ViewModels.Database { public nodeKind: string; @@ -220,8 +221,8 @@ export default class Database implements ViewModels.Database { } const deferred: Q.Deferred = Q.defer(); - this.container.notificationsClient.fetchNotifications().then( - (notifications: DataModels.Notification[]) => { + fetchPortalNotifications().then( + notifications => { if (!notifications || notifications.length === 0) { deferred.resolve(undefined); return; diff --git a/src/Platform/Emulator/ExplorerFactory.ts b/src/Platform/Emulator/ExplorerFactory.ts index fa831b73d..6f4774b37 100644 --- a/src/Platform/Emulator/ExplorerFactory.ts +++ b/src/Platform/Emulator/ExplorerFactory.ts @@ -2,13 +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() - }); + const explorer: Explorer = new Explorer(); explorer.databaseAccount({ name: "", id: "", 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 f1e4909c7..dc1b1be2e 100644 --- a/src/Platform/Hosted/ExplorerFactory.ts +++ b/src/Platform/Hosted/ExplorerFactory.ts @@ -1,11 +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() - }); + const explorer = new Explorer(); return explorer; } 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 index 4ee33063c..06c2b0aaa 100644 --- a/src/Platform/Portal/ExplorerFactory.ts +++ b/src/Platform/Portal/ExplorerFactory.ts @@ -1,11 +1,8 @@ import Explorer from "../../Explorer/Explorer"; -import { NotificationsClient } from "./NotificationsClient"; export default class PortalExplorerFactory { public createExplorer(): Explorer { - var explorer = new Explorer({ - notificationsClient: new NotificationsClient() - }); + var explorer = new Explorer(); 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 6f6314f75..cbddd968f 100644 --- a/src/RouteHandlers/TabRouteHandler.test.ts +++ b/src/RouteHandlers/TabRouteHandler.test.ts @@ -9,9 +9,7 @@ describe("TabRouteHandler", () => { let tabRouteHandler: TabRouteHandler; beforeAll(() => { - (window).dataExplorer = new Explorer({ - notificationsClient: null - }); // 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();