Remove method Explorer.openSettingPane (#880)
This commit is contained in:
parent
c632342a43
commit
c980af9a5c
|
@ -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
|
||||
|
|
|
@ -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", <TableQuerySelectPanel queryViewModel={queryViewModal} />);
|
||||
}
|
||||
public openSettingPane(): void {
|
||||
useSidePanel.getState().openSidePanel("Settings", <SettingsPane />);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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", <SettingsPane />),
|
||||
commandButtonLabel: undefined,
|
||||
ariaLabel: "Settings",
|
||||
tooltipText: "Settings",
|
||||
|
|
|
@ -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<ViewModels.Collection>([]),
|
||||
} 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();
|
||||
});
|
||||
});
|
|
@ -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 ||
|
||||
(<any>action).actionType === ActionContracts.ActionType[ActionContracts.ActionType.OpenCollectionTab]
|
||||
) {
|
||||
openCollectionTab(<ActionContracts.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 ||
|
||||
(<any>action).actionType === ActionContracts.ActionType[ActionContracts.ActionType.OpenPane]
|
||||
) {
|
||||
openPane(<ActionContracts.OpenPane>action, explorer);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (
|
||||
action.actionType === ActionContracts.ActionType.OpenSampleNotebook ||
|
||||
(<any>action).actionType === ActionContracts.ActionType[ActionContracts.ActionType.OpenSampleNotebook]
|
||||
) {
|
||||
openFile(<ActionContracts.OpenSampleNotebook>action, explorer);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return "SELECT * FROM c";
|
||||
}
|
||||
|
||||
function openCollectionTab(
|
||||
|
@ -65,7 +62,7 @@ function openCollectionTab(
|
|||
|
||||
if (
|
||||
action.tabKind === ActionContracts.TabKind.SQLDocuments ||
|
||||
(<any>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 ||
|
||||
(<any>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 ||
|
||||
(<any>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 ||
|
||||
(<any>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 ||
|
||||
(<any>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 ||
|
||||
(<any>action).tabKind === ActionContracts.TabKind[ActionContracts.TabKind.SQLQuery]
|
||||
action.tabKind === ActionContracts.TabKind[ActionContracts.TabKind.SQLQuery]
|
||||
) {
|
||||
collection.onNewQueryClick(
|
||||
collection,
|
||||
null,
|
||||
generateQueryText(<ActionContracts.OpenQueryTab>action, collection.partitionKeyProperty)
|
||||
undefined,
|
||||
generateQueryText(action as ActionContracts.OpenQueryTab, collection.partitionKeyProperty)
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
if (
|
||||
action.tabKind === ActionContracts.TabKind.ScaleSettings ||
|
||||
(<any>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 ||
|
||||
(<any>action).paneKind === ActionContracts.PaneKind[ActionContracts.PaneKind.AddCollection]
|
||||
action.paneKind === ActionContracts.PaneKind[ActionContracts.PaneKind.AddCollection]
|
||||
) {
|
||||
explorer.onNewCollectionClicked();
|
||||
} else if (
|
||||
action.paneKind === ActionContracts.PaneKind.CassandraAddCollection ||
|
||||
(<any>action).paneKind === ActionContracts.PaneKind[ActionContracts.PaneKind.CassandraAddCollection]
|
||||
action.paneKind === ActionContracts.PaneKind[ActionContracts.PaneKind.CassandraAddCollection]
|
||||
) {
|
||||
explorer.openCassandraAddCollectionPane();
|
||||
} else if (
|
||||
action.paneKind === ActionContracts.PaneKind.GlobalSettings ||
|
||||
(<any>action).paneKind === ActionContracts.PaneKind[ActionContracts.PaneKind.GlobalSettings]
|
||||
action.paneKind === ActionContracts.PaneKind[ActionContracts.PaneKind.GlobalSettings]
|
||||
) {
|
||||
explorer.openSettingPane();
|
||||
useSidePanel.getState().openSidePanel("Settings", <SettingsPane />);
|
||||
}
|
||||
}
|
||||
|
||||
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";
|
||||
}
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue