diff --git a/.eslintignore b/.eslintignore
index 6ad6058d4..a880fcc44 100644
--- a/.eslintignore
+++ b/.eslintignore
@@ -105,8 +105,6 @@ src/Explorer/Notebook/NotebookContainerClient.ts
src/Explorer/Notebook/NotebookContentClient.ts
src/Explorer/Notebook/NotebookContentItem.ts
src/Explorer/Notebook/NotebookUtil.ts
-src/Explorer/OpenActions.test.ts
-src/Explorer/OpenActions.ts
src/Explorer/OpenActionsStubs.ts
src/Explorer/Panes/AddDatabasePane.ts
src/Explorer/Panes/AddDatabasePane.test.ts
diff --git a/src/Explorer/Explorer.tsx b/src/Explorer/Explorer.tsx
index b1999e7fa..b9d06287d 100644
--- a/src/Explorer/Explorer.tsx
+++ b/src/Explorer/Explorer.tsx
@@ -56,7 +56,6 @@ import { DeleteDatabaseConfirmationPanel } from "./Panes/DeleteDatabaseConfirmat
import { ExecuteSprocParamsPane } from "./Panes/ExecuteSprocParamsPane/ExecuteSprocParamsPane";
import { GitHubReposPanel } from "./Panes/GitHubReposPanel/GitHubReposPanel";
import { SaveQueryPane } from "./Panes/SaveQueryPane/SaveQueryPane";
-import { SettingsPane } from "./Panes/SettingsPane/SettingsPane";
import { SetupNoteBooksPanel } from "./Panes/SetupNotebooksPanel/SetupNotebooksPanel";
import { StringInputPane } from "./Panes/StringInputPane/StringInputPane";
import { AddTableEntityPanel } from "./Panes/Tables/AddTableEntityPanel";
@@ -1599,7 +1598,4 @@ export default class Explorer {
public openTableSelectQueryPanel(queryViewModal: QueryViewModel): void {
useSidePanel.getState().openSidePanel("Select Column", );
}
- public openSettingPane(): void {
- useSidePanel.getState().openSidePanel("Settings", );
- }
}
diff --git a/src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.tsx b/src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.tsx
index 7b185fdba..2545b6ff7 100644
--- a/src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.tsx
+++ b/src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.tsx
@@ -28,6 +28,7 @@ import { CommandButtonComponentProps } from "../../Controls/CommandButton/Comman
import Explorer from "../../Explorer";
import { OpenFullScreen } from "../../OpenFullScreen";
import { LoadQueryPane } from "../../Panes/LoadQueryPane/LoadQueryPane";
+import { SettingsPane } from "../../Panes/SettingsPane/SettingsPane";
let counter = 0;
@@ -154,7 +155,7 @@ export function createControlCommandBarButtons(container: Explorer): CommandButt
{
iconSrc: SettingsIcon,
iconAlt: "Settings",
- onCommandClick: container.openSettingPane,
+ onCommandClick: () => useSidePanel.getState().openSidePanel("Settings", ),
commandButtonLabel: undefined,
ariaLabel: "Settings",
tooltipText: "Settings",
diff --git a/src/Explorer/OpenActions.test.ts b/src/Explorer/OpenActions/OpenActions.test.tsx
similarity index 97%
rename from src/Explorer/OpenActions.test.ts
rename to src/Explorer/OpenActions/OpenActions.test.tsx
index d06e8b239..10c4580a8 100644
--- a/src/Explorer/OpenActions.test.ts
+++ b/src/Explorer/OpenActions/OpenActions.test.tsx
@@ -1,7 +1,7 @@
import * as ko from "knockout";
-import { ActionContracts } from "../Contracts/ExplorerContracts";
-import * as ViewModels from "../Contracts/ViewModels";
-import Explorer from "./Explorer";
+import { ActionContracts } from "../../Contracts/ExplorerContracts";
+import * as ViewModels from "../../Contracts/ViewModels";
+import Explorer from "../Explorer";
import { handleOpenAction } from "./OpenActions";
describe("OpenActions", () => {
@@ -9,7 +9,6 @@ describe("OpenActions", () => {
let explorer: Explorer;
let database: ViewModels.Database;
let collection: ViewModels.Collection;
- let databases: ViewModels.Database[];
beforeEach(() => {
explorer = {} as Explorer;
@@ -19,7 +18,6 @@ describe("OpenActions", () => {
id: ko.observable("db"),
collections: ko.observableArray([]),
} as ViewModels.Database;
- databases = [database];
collection = {
id: ko.observable("coll"),
} as ViewModels.Collection;
@@ -68,7 +66,7 @@ describe("OpenActions", () => {
paneKind: "AddCollection",
};
- const actionHandled = handleOpenAction(action, [], explorer);
+ handleOpenAction(action, [], explorer);
expect(explorer.onNewCollectionClicked).toHaveBeenCalled();
});
@@ -78,7 +76,7 @@ describe("OpenActions", () => {
paneKind: ActionContracts.PaneKind.AddCollection,
};
- const actionHandled = handleOpenAction(action, [], explorer);
+ handleOpenAction(action, [], explorer);
expect(explorer.onNewCollectionClicked).toHaveBeenCalled();
});
});
diff --git a/src/Explorer/OpenActions.ts b/src/Explorer/OpenActions/OpenActions.tsx
similarity index 69%
rename from src/Explorer/OpenActions.ts
rename to src/Explorer/OpenActions/OpenActions.tsx
index 033cb8135..6c4b54b9e 100644
--- a/src/Explorer/OpenActions.ts
+++ b/src/Explorer/OpenActions/OpenActions.tsx
@@ -1,39 +1,36 @@
// TODO convert this file to an action registry in order to have actions and their handlers be more tightly coupled.
+import React from "react";
+import { ActionContracts } from "../../Contracts/ExplorerContracts";
+import * as ViewModels from "../../Contracts/ViewModels";
+import { useSidePanel } from "../../hooks/useSidePanel";
+import Explorer from "../Explorer";
+import { SettingsPane } from "../Panes/SettingsPane/SettingsPane";
-import { ActionContracts } from "../Contracts/ExplorerContracts";
-import * as ViewModels from "../Contracts/ViewModels";
-import Explorer from "./Explorer";
-
-export function handleOpenAction(
- action: ActionContracts.DataExplorerAction,
- databases: ViewModels.Database[],
- explorer: Explorer
-): boolean {
- if (
- action.actionType === ActionContracts.ActionType.OpenCollectionTab ||
- (action).actionType === ActionContracts.ActionType[ActionContracts.ActionType.OpenCollectionTab]
- ) {
- openCollectionTab(action, databases);
- return true;
+function generateQueryText(action: ActionContracts.OpenQueryTab, partitionKeyProperty: string): string {
+ if (!action.query) {
+ return "SELECT * FROM c";
+ } else if (action.query.text) {
+ return action.query.text;
+ } else if (!!action.query.partitionKeys && action.query.partitionKeys.length > 0) {
+ let query = "SELECT * FROM c WHERE";
+ for (let i = 0; i < action.query.partitionKeys.length; i++) {
+ const partitionKey = action.query.partitionKeys[i];
+ if (!partitionKey) {
+ // null partition key case
+ query = query.concat(` c.${partitionKeyProperty} = ${action.query.partitionKeys[i]}`);
+ } else if (typeof partitionKey !== "string") {
+ // Undefined partition key case
+ query = query.concat(` NOT IS_DEFINED(c.${partitionKeyProperty})`);
+ } else {
+ query = query.concat(` c.${partitionKeyProperty} = "${action.query.partitionKeys[i]}"`);
+ }
+ if (i !== action.query.partitionKeys.length - 1) {
+ query = query.concat(" OR");
+ }
+ }
+ return query;
}
-
- if (
- action.actionType === ActionContracts.ActionType.OpenPane ||
- (action).actionType === ActionContracts.ActionType[ActionContracts.ActionType.OpenPane]
- ) {
- openPane(action, explorer);
- return true;
- }
-
- if (
- action.actionType === ActionContracts.ActionType.OpenSampleNotebook ||
- (action).actionType === ActionContracts.ActionType[ActionContracts.ActionType.OpenSampleNotebook]
- ) {
- openFile(action, explorer);
- return true;
- }
-
- return false;
+ return "SELECT * FROM c";
}
function openCollectionTab(
@@ -65,7 +62,7 @@ function openCollectionTab(
if (
action.tabKind === ActionContracts.TabKind.SQLDocuments ||
- (action).tabKind === ActionContracts.TabKind[ActionContracts.TabKind.SQLDocuments]
+ action.tabKind === ActionContracts.TabKind[ActionContracts.TabKind.SQLDocuments]
) {
collection.onDocumentDBDocumentsClick();
break;
@@ -73,7 +70,7 @@ function openCollectionTab(
if (
action.tabKind === ActionContracts.TabKind.MongoDocuments ||
- (action).tabKind === ActionContracts.TabKind[ActionContracts.TabKind.MongoDocuments]
+ action.tabKind === ActionContracts.TabKind[ActionContracts.TabKind.MongoDocuments]
) {
collection.onMongoDBDocumentsClick();
break;
@@ -81,7 +78,7 @@ function openCollectionTab(
if (
action.tabKind === ActionContracts.TabKind.SchemaAnalyzer ||
- (action).tabKind === ActionContracts.TabKind[ActionContracts.TabKind.SchemaAnalyzer]
+ action.tabKind === ActionContracts.TabKind[ActionContracts.TabKind.SchemaAnalyzer]
) {
collection.onSchemaAnalyzerClick();
break;
@@ -89,7 +86,7 @@ function openCollectionTab(
if (
action.tabKind === ActionContracts.TabKind.TableEntities ||
- (action).tabKind === ActionContracts.TabKind[ActionContracts.TabKind.TableEntities]
+ action.tabKind === ActionContracts.TabKind[ActionContracts.TabKind.TableEntities]
) {
collection.onTableEntitiesClick();
break;
@@ -97,7 +94,7 @@ function openCollectionTab(
if (
action.tabKind === ActionContracts.TabKind.Graph ||
- (action).tabKind === ActionContracts.TabKind[ActionContracts.TabKind.Graph]
+ action.tabKind === ActionContracts.TabKind[ActionContracts.TabKind.Graph]
) {
collection.onGraphDocumentsClick();
break;
@@ -105,19 +102,19 @@ function openCollectionTab(
if (
action.tabKind === ActionContracts.TabKind.SQLQuery ||
- (action).tabKind === ActionContracts.TabKind[ActionContracts.TabKind.SQLQuery]
+ action.tabKind === ActionContracts.TabKind[ActionContracts.TabKind.SQLQuery]
) {
collection.onNewQueryClick(
collection,
- null,
- generateQueryText(action, collection.partitionKeyProperty)
+ undefined,
+ generateQueryText(action as ActionContracts.OpenQueryTab, collection.partitionKeyProperty)
);
break;
}
if (
action.tabKind === ActionContracts.TabKind.ScaleSettings ||
- (action).tabKind === ActionContracts.TabKind[ActionContracts.TabKind.ScaleSettings]
+ action.tabKind === ActionContracts.TabKind[ActionContracts.TabKind.ScaleSettings]
) {
collection.onSettingsClick();
break;
@@ -138,49 +135,54 @@ function openCollectionTab(
function openPane(action: ActionContracts.OpenPane, explorer: Explorer) {
if (
action.paneKind === ActionContracts.PaneKind.AddCollection ||
- (action).paneKind === ActionContracts.PaneKind[ActionContracts.PaneKind.AddCollection]
+ action.paneKind === ActionContracts.PaneKind[ActionContracts.PaneKind.AddCollection]
) {
explorer.onNewCollectionClicked();
} else if (
action.paneKind === ActionContracts.PaneKind.CassandraAddCollection ||
- (action).paneKind === ActionContracts.PaneKind[ActionContracts.PaneKind.CassandraAddCollection]
+ action.paneKind === ActionContracts.PaneKind[ActionContracts.PaneKind.CassandraAddCollection]
) {
explorer.openCassandraAddCollectionPane();
} else if (
action.paneKind === ActionContracts.PaneKind.GlobalSettings ||
- (action).paneKind === ActionContracts.PaneKind[ActionContracts.PaneKind.GlobalSettings]
+ action.paneKind === ActionContracts.PaneKind[ActionContracts.PaneKind.GlobalSettings]
) {
- explorer.openSettingPane();
+ useSidePanel.getState().openSidePanel("Settings", );
}
}
+export function handleOpenAction(
+ action: ActionContracts.DataExplorerAction,
+ databases: ViewModels.Database[],
+ explorer: Explorer
+): boolean {
+ if (
+ action.actionType === ActionContracts.ActionType.OpenCollectionTab ||
+ action.actionType === ActionContracts.ActionType[ActionContracts.ActionType.OpenCollectionTab]
+ ) {
+ openCollectionTab(action as ActionContracts.OpenCollectionTab, databases);
+ return true;
+ }
+
+ if (
+ action.actionType === ActionContracts.ActionType.OpenPane ||
+ action.actionType === ActionContracts.ActionType[ActionContracts.ActionType.OpenPane]
+ ) {
+ openPane(action as ActionContracts.OpenPane, explorer);
+ return true;
+ }
+
+ if (
+ action.actionType === ActionContracts.ActionType.OpenSampleNotebook ||
+ action.actionType === ActionContracts.ActionType[ActionContracts.ActionType.OpenSampleNotebook]
+ ) {
+ openFile(action as ActionContracts.OpenSampleNotebook, explorer);
+ return true;
+ }
+
+ return false;
+}
+
function openFile(action: ActionContracts.OpenSampleNotebook, explorer: Explorer) {
explorer.handleOpenFileAction(decodeURIComponent(action.path));
}
-
-function generateQueryText(action: ActionContracts.OpenQueryTab, partitionKeyProperty: string): string {
- if (!action.query) {
- return "SELECT * FROM c";
- } else if (!!action.query.text) {
- return action.query.text;
- } else if (!!action.query.partitionKeys && action.query.partitionKeys.length > 0) {
- let query = "SELECT * FROM c WHERE";
- for (let i = 0; i < action.query.partitionKeys.length; i++) {
- let partitionKey = action.query.partitionKeys[i];
- if (!partitionKey) {
- // null partition key case
- query = query.concat(` c.${partitionKeyProperty} = ${action.query.partitionKeys[i]}`);
- } else if (typeof partitionKey !== "string") {
- // Undefined partition key case
- query = query.concat(` NOT IS_DEFINED(c.${partitionKeyProperty})`);
- } else {
- query = query.concat(` c.${partitionKeyProperty} = "${action.query.partitionKeys[i]}"`);
- }
- if (i !== action.query.partitionKeys.length - 1) {
- query = query.concat(" OR");
- }
- }
- return query;
- }
- return "SELECT * FROM c";
-}
diff --git a/src/hooks/useKnockoutExplorer.ts b/src/hooks/useKnockoutExplorer.ts
index 765974cad..4d47be346 100644
--- a/src/hooks/useKnockoutExplorer.ts
+++ b/src/hooks/useKnockoutExplorer.ts
@@ -9,7 +9,7 @@ import { ActionType, DataExplorerAction } from "../Contracts/ActionContracts";
import { MessageTypes } from "../Contracts/ExplorerContracts";
import { DataExplorerInputsFrame } from "../Contracts/ViewModels";
import Explorer, { ExplorerParams } from "../Explorer/Explorer";
-import { handleOpenAction } from "../Explorer/OpenActions";
+import { handleOpenAction } from "../Explorer/OpenActions/OpenActions";
import {
AAD,
ConnectionString,