mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2024-11-25 23:16:56 +00:00
Remove unused tab finder methods from Explorer (#549)
This commit is contained in:
parent
41800f9ee5
commit
f449328f26
@ -79,8 +79,6 @@ import ResourceTokenCollection from "./Tree/ResourceTokenCollection";
|
|||||||
import { ResourceTreeAdapter } from "./Tree/ResourceTreeAdapter";
|
import { ResourceTreeAdapter } from "./Tree/ResourceTreeAdapter";
|
||||||
import { ResourceTreeAdapterForResourceToken } from "./Tree/ResourceTreeAdapterForResourceToken";
|
import { ResourceTreeAdapterForResourceToken } from "./Tree/ResourceTreeAdapterForResourceToken";
|
||||||
import StoredProcedure from "./Tree/StoredProcedure";
|
import StoredProcedure from "./Tree/StoredProcedure";
|
||||||
import Trigger from "./Tree/Trigger";
|
|
||||||
import UserDefinedFunction from "./Tree/UserDefinedFunction";
|
|
||||||
|
|
||||||
BindingHandlersRegisterer.registerBindingHandlers();
|
BindingHandlersRegisterer.registerBindingHandlers();
|
||||||
// Hold a reference to ComponentRegisterer to prevent transpiler to ignore import
|
// Hold a reference to ComponentRegisterer to prevent transpiler to ignore import
|
||||||
@ -1287,49 +1285,6 @@ export default class Explorer {
|
|||||||
: this.selectedNode().collection) as ViewModels.Collection;
|
: this.selectedNode().collection) as ViewModels.Collection;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Refactor below methods, minimize dependencies and add unit tests where necessary
|
|
||||||
public findSelectedStoredProcedure(): StoredProcedure {
|
|
||||||
const selectedCollection: ViewModels.Collection = this.findSelectedCollection();
|
|
||||||
return _.find(selectedCollection.storedProcedures(), (storedProcedure: StoredProcedure) => {
|
|
||||||
const openedSprocTab = this.tabsManager.getTabs(
|
|
||||||
ViewModels.CollectionTabKind.StoredProcedures,
|
|
||||||
(tab) => tab.node && tab.node.rid === storedProcedure.rid
|
|
||||||
);
|
|
||||||
return (
|
|
||||||
storedProcedure.rid === this.selectedNode().rid ||
|
|
||||||
(!!openedSprocTab && openedSprocTab.length > 0 && openedSprocTab[0].isActive())
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public findSelectedUDF(): UserDefinedFunction {
|
|
||||||
const selectedCollection: ViewModels.Collection = this.findSelectedCollection();
|
|
||||||
return _.find(selectedCollection.userDefinedFunctions(), (userDefinedFunction: UserDefinedFunction) => {
|
|
||||||
const openedUdfTab = this.tabsManager.getTabs(
|
|
||||||
ViewModels.CollectionTabKind.UserDefinedFunctions,
|
|
||||||
(tab) => tab.node && tab.node.rid === userDefinedFunction.rid
|
|
||||||
);
|
|
||||||
return (
|
|
||||||
userDefinedFunction.rid === this.selectedNode().rid ||
|
|
||||||
(!!openedUdfTab && openedUdfTab.length > 0 && openedUdfTab[0].isActive())
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public findSelectedTrigger(): Trigger {
|
|
||||||
const selectedCollection: ViewModels.Collection = this.findSelectedCollection();
|
|
||||||
return _.find(selectedCollection.triggers(), (trigger: Trigger) => {
|
|
||||||
const openedTriggerTab = this.tabsManager.getTabs(
|
|
||||||
ViewModels.CollectionTabKind.Triggers,
|
|
||||||
(tab) => tab.node && tab.node.rid === trigger.rid
|
|
||||||
);
|
|
||||||
return (
|
|
||||||
trigger.rid === this.selectedNode().rid ||
|
|
||||||
(!!openedTriggerTab && openedTriggerTab.length > 0 && openedTriggerTab[0].isActive())
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public closeAllPanes(): void {
|
public closeAllPanes(): void {
|
||||||
this._panes.forEach((pane: ContextualPaneBase) => pane.close());
|
this._panes.forEach((pane: ContextualPaneBase) => pane.close());
|
||||||
}
|
}
|
||||||
@ -2311,10 +2266,14 @@ export default class Explorer {
|
|||||||
this.openSidePanel("Settings", <SettingsPane explorer={this} closePanel={this.closeSidePanel} />);
|
this.openSidePanel("Settings", <SettingsPane explorer={this} closePanel={this.closeSidePanel} />);
|
||||||
}
|
}
|
||||||
|
|
||||||
public openExecuteSprocParamsPanel(): void {
|
public openExecuteSprocParamsPanel(storedProcedure: StoredProcedure): void {
|
||||||
this.openSidePanel(
|
this.openSidePanel(
|
||||||
"Input parameters",
|
"Input parameters",
|
||||||
<ExecuteSprocParamsPanel explorer={this} closePanel={() => this.closeSidePanel()} />
|
<ExecuteSprocParamsPanel
|
||||||
|
explorer={this}
|
||||||
|
storedProcedure={storedProcedure}
|
||||||
|
closePanel={() => this.closeSidePanel()}
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ exports[`Excute Sproc Param Pane should render Default properly 1`] = `
|
|||||||
<ExecuteSprocParamsPanel
|
<ExecuteSprocParamsPanel
|
||||||
closePanel={[Function]}
|
closePanel={[Function]}
|
||||||
explorer={Object {}}
|
explorer={Object {}}
|
||||||
|
storedProcedure={Object {}}
|
||||||
>
|
>
|
||||||
<GenericRightPaneComponent
|
<GenericRightPaneComponent
|
||||||
container={Object {}}
|
container={Object {}}
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
import { mount } from "enzyme";
|
import { mount } from "enzyme";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import Explorer from "../../Explorer";
|
import Explorer from "../../Explorer";
|
||||||
|
import StoredProcedure from "../../Tree/StoredProcedure";
|
||||||
import { ExecuteSprocParamsPanel } from "./index";
|
import { ExecuteSprocParamsPanel } from "./index";
|
||||||
|
|
||||||
describe("Excute Sproc Param Pane", () => {
|
describe("Excute Sproc Param Pane", () => {
|
||||||
const fakeExplorer = {} as Explorer;
|
const fakeExplorer = {} as Explorer;
|
||||||
|
const fakeSproc = {} as StoredProcedure;
|
||||||
const props = {
|
const props = {
|
||||||
explorer: fakeExplorer,
|
explorer: fakeExplorer,
|
||||||
|
storedProcedure: fakeSproc,
|
||||||
closePanel: (): void => undefined,
|
closePanel: (): void => undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3,11 +3,13 @@ import { IDropdownOption, IImageProps, Image, Stack, Text } from "office-ui-fabr
|
|||||||
import React, { FunctionComponent, useState } from "react";
|
import React, { FunctionComponent, useState } from "react";
|
||||||
import AddPropertyIcon from "../../../../images/Add-property.svg";
|
import AddPropertyIcon from "../../../../images/Add-property.svg";
|
||||||
import Explorer from "../../Explorer";
|
import Explorer from "../../Explorer";
|
||||||
|
import StoredProcedure from "../../Tree/StoredProcedure";
|
||||||
import { GenericRightPaneComponent, GenericRightPaneProps } from "../GenericRightPaneComponent";
|
import { GenericRightPaneComponent, GenericRightPaneProps } from "../GenericRightPaneComponent";
|
||||||
import { InputParameter } from "./InputParameter";
|
import { InputParameter } from "./InputParameter";
|
||||||
|
|
||||||
interface ExecuteSprocParamsPaneProps {
|
interface ExecuteSprocParamsPaneProps {
|
||||||
explorer: Explorer;
|
explorer: Explorer;
|
||||||
|
storedProcedure: StoredProcedure;
|
||||||
closePanel: () => void;
|
closePanel: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,6 +25,7 @@ interface UnwrappedExecuteSprocParam {
|
|||||||
|
|
||||||
export const ExecuteSprocParamsPanel: FunctionComponent<ExecuteSprocParamsPaneProps> = ({
|
export const ExecuteSprocParamsPanel: FunctionComponent<ExecuteSprocParamsPaneProps> = ({
|
||||||
explorer,
|
explorer,
|
||||||
|
storedProcedure,
|
||||||
closePanel,
|
closePanel,
|
||||||
}: ExecuteSprocParamsPaneProps): JSX.Element => {
|
}: ExecuteSprocParamsPaneProps): JSX.Element => {
|
||||||
const [isLoading, { setTrue: setLoadingTrue, setFalse: setLoadingFalse }] = useBoolean(false);
|
const [isLoading, { setTrue: setLoadingTrue, setFalse: setLoadingFalse }] = useBoolean(false);
|
||||||
@ -77,8 +80,7 @@ export const ExecuteSprocParamsPanel: FunctionComponent<ExecuteSprocParamsPanePr
|
|||||||
}
|
}
|
||||||
setLoadingTrue();
|
setLoadingTrue();
|
||||||
const sprocParams = wrappedSprocParams && wrappedSprocParams.map((sprocParam) => sprocParam.text);
|
const sprocParams = wrappedSprocParams && wrappedSprocParams.map((sprocParam) => sprocParam.text);
|
||||||
const currentSelectedSproc = explorer.findSelectedStoredProcedure();
|
storedProcedure.execute(sprocParams, partitionValue);
|
||||||
currentSelectedSproc.execute(sprocParams, partitionValue);
|
|
||||||
setLoadingFalse();
|
setLoadingFalse();
|
||||||
closePanel();
|
closePanel();
|
||||||
};
|
};
|
||||||
|
@ -208,7 +208,7 @@ export default class StoredProcedureTab extends ScriptTabBase {
|
|||||||
iconSrc: ExecuteQueryIcon,
|
iconSrc: ExecuteQueryIcon,
|
||||||
iconAlt: label,
|
iconAlt: label,
|
||||||
onCommandClick: () => {
|
onCommandClick: () => {
|
||||||
this.collection && this.collection.container.openExecuteSprocParamsPanel();
|
this.collection && this.collection.container.openExecuteSprocParamsPanel(this.node);
|
||||||
},
|
},
|
||||||
commandButtonLabel: label,
|
commandButtonLabel: label,
|
||||||
ariaLabel: label,
|
ariaLabel: label,
|
||||||
|
Loading…
Reference in New Issue
Block a user