mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-19 17:01:13 +00:00
Refactor Data Access Utility (#112)
This commit is contained in:
@@ -52,7 +52,7 @@ import { isInvalidParentFrameOrigin } from "../Utils/MessageValidation";
|
||||
import { IGalleryItem } from "../Juno/JunoClient";
|
||||
import { LoadQueryPane } from "./Panes/LoadQueryPane";
|
||||
import * as Logger from "../Common/Logger";
|
||||
import { MessageHandler } from "../Common/MessageHandler";
|
||||
import { sendMessage, sendCachedDataMessage, handleCachedDataMessage } from "../Common/MessageHandler";
|
||||
import { NotebookContentItem, NotebookContentItemType } from "./Notebook/NotebookContentItem";
|
||||
import { NotebookUtil } from "./Notebook/NotebookUtil";
|
||||
import { NotebookWorkspaceManager } from "../NotebookWorkspaceManager/NotebookWorkspaceManager";
|
||||
@@ -1607,7 +1607,7 @@ export default class Explorer {
|
||||
|
||||
public async getArcadiaToken(): Promise<string> {
|
||||
return new Promise<string>((resolve: (token: string) => void, reject: (error: any) => void) => {
|
||||
MessageHandler.sendCachedDataMessage<string>(MessageTypes.GetArcadiaToken, undefined /** params **/).then(
|
||||
sendCachedDataMessage<string>(MessageTypes.GetArcadiaToken, undefined /** params **/).then(
|
||||
(token: string) => {
|
||||
resolve(token);
|
||||
},
|
||||
@@ -1645,11 +1645,11 @@ export default class Explorer {
|
||||
}
|
||||
|
||||
public async createWorkspace(): Promise<string> {
|
||||
return MessageHandler.sendCachedDataMessage(MessageTypes.CreateWorkspace, undefined /** params **/);
|
||||
return sendCachedDataMessage(MessageTypes.CreateWorkspace, undefined /** params **/);
|
||||
}
|
||||
|
||||
public async createSparkPool(workspaceId: string): Promise<string> {
|
||||
return MessageHandler.sendCachedDataMessage(MessageTypes.CreateSparkPool, [workspaceId]);
|
||||
return sendCachedDataMessage(MessageTypes.CreateSparkPool, [workspaceId]);
|
||||
}
|
||||
|
||||
public async initNotebooks(databaseAccount: DataModels.DatabaseAccount): Promise<void> {
|
||||
@@ -1845,7 +1845,7 @@ export default class Explorer {
|
||||
}
|
||||
}
|
||||
if (message.actionType === ActionContracts.ActionType.TransmitCachedData) {
|
||||
MessageHandler.handleCachedDataMessage(message);
|
||||
handleCachedDataMessage(message);
|
||||
return;
|
||||
}
|
||||
if (message.type) {
|
||||
@@ -2041,7 +2041,7 @@ export default class Explorer {
|
||||
|
||||
public signInAad = () => {
|
||||
TelemetryProcessor.trace(Action.SignInAad, undefined, { area: "Explorer" });
|
||||
MessageHandler.sendMessage({
|
||||
sendMessage({
|
||||
type: MessageTypes.AadSignIn
|
||||
});
|
||||
};
|
||||
@@ -2052,21 +2052,21 @@ export default class Explorer {
|
||||
};
|
||||
|
||||
public clickHostedAccountSwitch = () => {
|
||||
MessageHandler.sendMessage({
|
||||
sendMessage({
|
||||
type: MessageTypes.UpdateAccountSwitch,
|
||||
click: true
|
||||
});
|
||||
};
|
||||
|
||||
public clickHostedDirectorySwitch = () => {
|
||||
MessageHandler.sendMessage({
|
||||
sendMessage({
|
||||
type: MessageTypes.UpdateDirectoryControl,
|
||||
click: true
|
||||
});
|
||||
};
|
||||
|
||||
public refreshDatabaseAccount = () => {
|
||||
MessageHandler.sendMessage({
|
||||
sendMessage({
|
||||
type: MessageTypes.RefreshDatabaseAccount
|
||||
});
|
||||
};
|
||||
|
||||
@@ -14,7 +14,7 @@ import * as TableConstants from "./Constants";
|
||||
import * as TableEntityProcessor from "./TableEntityProcessor";
|
||||
import * as ViewModels from "../../Contracts/ViewModels";
|
||||
import { MessageTypes } from "../../Contracts/ExplorerContracts";
|
||||
import { MessageHandler } from "../../Common/MessageHandler";
|
||||
import { sendMessage } from "../../Common/MessageHandler";
|
||||
import DocumentClientUtilityBase from "../../Common/DocumentClientUtilityBase";
|
||||
import Explorer from "../Explorer";
|
||||
|
||||
@@ -738,7 +738,7 @@ export class CassandraAPIDataClient extends TableDataClient {
|
||||
|
||||
private _checkForbiddenError(reason: any) {
|
||||
if (reason && reason.code === Constants.HttpStatusCodes.Forbidden) {
|
||||
MessageHandler.sendMessage({
|
||||
sendMessage({
|
||||
type: MessageTypes.ForbiddenError,
|
||||
reason: typeof reason === "string" ? "reason" : JSON.stringify(reason)
|
||||
});
|
||||
|
||||
@@ -2,7 +2,6 @@ import * as ko from "knockout";
|
||||
import * as ViewModels from "../../Contracts/ViewModels";
|
||||
import * as Constants from "../../Common/Constants";
|
||||
import DocumentsTab from "./DocumentsTab";
|
||||
import { DataAccessUtility } from "../../Platform/Portal/DataAccessUtility";
|
||||
import Explorer from "../Explorer";
|
||||
import DocumentClientUtilityBase from "../../Common/DocumentClientUtilityBase";
|
||||
|
||||
@@ -15,7 +14,7 @@ describe("Documents tab", () => {
|
||||
tabKind: ViewModels.CollectionTabKind.Documents,
|
||||
title: "",
|
||||
tabPath: "",
|
||||
documentClientUtility: new DocumentClientUtilityBase(new DataAccessUtility()),
|
||||
documentClientUtility: new DocumentClientUtilityBase(),
|
||||
selfLink: "",
|
||||
hashLocation: "",
|
||||
isActive: ko.observable<boolean>(false),
|
||||
@@ -98,7 +97,7 @@ describe("Documents tab", () => {
|
||||
tabKind: ViewModels.CollectionTabKind.Documents,
|
||||
title: "",
|
||||
tabPath: "",
|
||||
documentClientUtility: new DocumentClientUtilityBase(new DataAccessUtility()),
|
||||
documentClientUtility: new DocumentClientUtilityBase(),
|
||||
selfLink: "",
|
||||
hashLocation: "",
|
||||
isActive: ko.observable<boolean>(false),
|
||||
@@ -117,7 +116,7 @@ describe("Documents tab", () => {
|
||||
tabKind: ViewModels.CollectionTabKind.Documents,
|
||||
title: "",
|
||||
tabPath: "",
|
||||
documentClientUtility: new DocumentClientUtilityBase(new DataAccessUtility()),
|
||||
documentClientUtility: new DocumentClientUtilityBase(),
|
||||
selfLink: "",
|
||||
hashLocation: "",
|
||||
isActive: ko.observable<boolean>(false),
|
||||
@@ -136,7 +135,7 @@ describe("Documents tab", () => {
|
||||
tabKind: ViewModels.CollectionTabKind.Documents,
|
||||
title: "",
|
||||
tabPath: "",
|
||||
documentClientUtility: new DocumentClientUtilityBase(new DataAccessUtility()),
|
||||
documentClientUtility: new DocumentClientUtilityBase(),
|
||||
selfLink: "",
|
||||
hashLocation: "",
|
||||
isActive: ko.observable<boolean>(false),
|
||||
@@ -155,7 +154,7 @@ describe("Documents tab", () => {
|
||||
tabKind: ViewModels.CollectionTabKind.Documents,
|
||||
title: "",
|
||||
tabPath: "",
|
||||
documentClientUtility: new DocumentClientUtilityBase(new DataAccessUtility()),
|
||||
documentClientUtility: new DocumentClientUtilityBase(),
|
||||
selfLink: "",
|
||||
hashLocation: "",
|
||||
isActive: ko.observable<boolean>(false),
|
||||
@@ -174,7 +173,7 @@ describe("Documents tab", () => {
|
||||
tabKind: ViewModels.CollectionTabKind.Documents,
|
||||
title: "",
|
||||
tabPath: "",
|
||||
documentClientUtility: new DocumentClientUtilityBase(new DataAccessUtility()),
|
||||
documentClientUtility: new DocumentClientUtilityBase(),
|
||||
selfLink: "",
|
||||
hashLocation: "",
|
||||
isActive: ko.observable<boolean>(false),
|
||||
|
||||
@@ -7,7 +7,6 @@ import Database from "../Tree/Database";
|
||||
import DocumentClientUtilityBase from "../../Common/DocumentClientUtilityBase";
|
||||
import Explorer from "../Explorer";
|
||||
import SettingsTab from "../Tabs/SettingsTab";
|
||||
import { DataAccessUtility } from "../../Platform/Portal/DataAccessUtility";
|
||||
|
||||
describe("Settings tab", () => {
|
||||
const baseCollection: DataModels.Collection = {
|
||||
@@ -189,7 +188,7 @@ describe("Settings tab", () => {
|
||||
tabKind: ViewModels.CollectionTabKind.Settings,
|
||||
title: "Scale & Settings",
|
||||
tabPath: "",
|
||||
documentClientUtility: new DocumentClientUtilityBase(new DataAccessUtility()),
|
||||
documentClientUtility: new DocumentClientUtilityBase(),
|
||||
|
||||
selfLink: "",
|
||||
hashLocation: "",
|
||||
@@ -213,7 +212,7 @@ describe("Settings tab", () => {
|
||||
tabKind: ViewModels.CollectionTabKind.Settings,
|
||||
title: "Scale & Settings",
|
||||
tabPath: "",
|
||||
documentClientUtility: new DocumentClientUtilityBase(new DataAccessUtility()),
|
||||
documentClientUtility: new DocumentClientUtilityBase(),
|
||||
|
||||
selfLink: "",
|
||||
hashLocation: "",
|
||||
@@ -232,7 +231,7 @@ describe("Settings tab", () => {
|
||||
tabKind: ViewModels.CollectionTabKind.Settings,
|
||||
title: "Scale & Settings",
|
||||
tabPath: "",
|
||||
documentClientUtility: new DocumentClientUtilityBase(new DataAccessUtility()),
|
||||
documentClientUtility: new DocumentClientUtilityBase(),
|
||||
|
||||
selfLink: "",
|
||||
hashLocation: "",
|
||||
@@ -271,7 +270,7 @@ describe("Settings tab", () => {
|
||||
tabKind: ViewModels.CollectionTabKind.Settings,
|
||||
title: "Scale & Settings",
|
||||
tabPath: "",
|
||||
documentClientUtility: new DocumentClientUtilityBase(new DataAccessUtility()),
|
||||
documentClientUtility: new DocumentClientUtilityBase(),
|
||||
|
||||
selfLink: "",
|
||||
hashLocation: "",
|
||||
@@ -288,7 +287,7 @@ describe("Settings tab", () => {
|
||||
tabKind: ViewModels.CollectionTabKind.Settings,
|
||||
title: "Scale & Settings",
|
||||
tabPath: "",
|
||||
documentClientUtility: new DocumentClientUtilityBase(new DataAccessUtility()),
|
||||
documentClientUtility: new DocumentClientUtilityBase(),
|
||||
|
||||
selfLink: "",
|
||||
hashLocation: "",
|
||||
@@ -314,7 +313,7 @@ describe("Settings tab", () => {
|
||||
tabKind: ViewModels.CollectionTabKind.Settings,
|
||||
title: "Scale & Settings",
|
||||
tabPath: "",
|
||||
documentClientUtility: new DocumentClientUtilityBase(new DataAccessUtility()),
|
||||
documentClientUtility: new DocumentClientUtilityBase(),
|
||||
|
||||
selfLink: "",
|
||||
hashLocation: "",
|
||||
@@ -395,7 +394,7 @@ describe("Settings tab", () => {
|
||||
tabKind: ViewModels.CollectionTabKind.Settings,
|
||||
title: "Scale & Settings",
|
||||
tabPath: "",
|
||||
documentClientUtility: new DocumentClientUtilityBase(new DataAccessUtility()),
|
||||
documentClientUtility: new DocumentClientUtilityBase(),
|
||||
|
||||
selfLink: "",
|
||||
hashLocation: "",
|
||||
@@ -541,7 +540,7 @@ describe("Settings tab", () => {
|
||||
tabKind: ViewModels.CollectionTabKind.Settings,
|
||||
title: "Scale & Settings",
|
||||
tabPath: "",
|
||||
documentClientUtility: new DocumentClientUtilityBase(new DataAccessUtility()),
|
||||
documentClientUtility: new DocumentClientUtilityBase(),
|
||||
|
||||
selfLink: "",
|
||||
hashLocation: "",
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import * as ko from "knockout";
|
||||
import * as ViewModels from "../../Contracts/ViewModels";
|
||||
import { DataAccessUtility } from "../../Platform/Portal/DataAccessUtility";
|
||||
import { TabsManager } from "./TabsManager";
|
||||
import DocumentClientUtilityBase from "../../Common/DocumentClientUtilityBase";
|
||||
import DocumentsTab from "./DocumentsTab";
|
||||
@@ -64,7 +63,7 @@ describe("Tabs manager tests", () => {
|
||||
collection,
|
||||
title: "",
|
||||
tabPath: "",
|
||||
documentClientUtility: new DocumentClientUtilityBase(new DataAccessUtility()),
|
||||
documentClientUtility: new DocumentClientUtilityBase(),
|
||||
selfLink: "",
|
||||
hashLocation: "",
|
||||
isActive: ko.observable<boolean>(false),
|
||||
|
||||
Reference in New Issue
Block a user