From 9d0bc86197aa0228b2b87078e4d5715d7703bdf9 Mon Sep 17 00:00:00 2001 From: Jordi Bunster Date: Thu, 29 Apr 2021 10:20:57 -0700 Subject: [PATCH] Remove 'explorer' from a few Panes (#650) While working on #549 I realized there were a few places where 'explorer' was only needed to expand the notifications console, so I stripped those out where it was easy. --- src/Explorer/Explorer.tsx | 9 +- .../CopyNotebookPane/CopyNotebookPane.tsx | 2 +- .../DeleteCollectionConfirmationPane.tsx | 2 +- ...teCollectionConfirmationPane.test.tsx.snap | 11 +- .../ExecuteSprocParamsPane.test.tsx | 4 +- .../ExecuteSprocParamsPane.tsx | 7 +- .../ExecuteSprocParamsPane.test.tsx.snap | 4 +- .../GenericRightPaneComponent.tsx | 11 +- .../Panes/LoadQueryPane/LoadQueryPane.tsx | 2 +- .../__snapshots__/LoadQueryPane.test.tsx.snap | 2 +- .../PublishNotebookPane.tsx | 2 +- .../Panes/SaveQueryPane/SaveQueryPane.tsx | 2 +- .../__snapshots__/SaveQueryPane.test.tsx.snap | 6 +- .../Panes/SettingsPane/SettingsPane.test.tsx | 3 +- .../Panes/SettingsPane/SettingsPane.tsx | 7 +- .../__snapshots__/SettingsPane.test.tsx.snap | 1041 +---------------- .../Panes/StringInputPane/StringInputPane.tsx | 2 +- .../StringInputPane.test.tsx.snap | 499 +------- .../__snapshots__/index.test.tsx.snap | 2 +- .../Tables/TableQuerySelectPanel/index.tsx | 2 +- .../Panes/UploadFilePane/UploadFilePane.tsx | 7 +- .../Panes/UploadItemsPane/UploadItemsPane.tsx | 2 +- .../UploadItemsPane.test.tsx.snap | 499 +------- 23 files changed, 79 insertions(+), 2049 deletions(-) diff --git a/src/Explorer/Explorer.tsx b/src/Explorer/Explorer.tsx index 3a090fd7e..3c9ce8659 100644 --- a/src/Explorer/Explorer.tsx +++ b/src/Explorer/Explorer.tsx @@ -2089,15 +2089,18 @@ export default class Explorer { } public openSettingPane(): void { - this.openSidePanel("Settings", ); + this.openSidePanel( + "Settings", + this.expandConsole()} closePanel={this.closeSidePanel} /> + ); } public openExecuteSprocParamsPanel(storedProcedure: StoredProcedure): void { this.openSidePanel( "Input parameters", this.expandConsole()} closePanel={() => this.closeSidePanel()} /> ); @@ -2132,7 +2135,7 @@ export default class Explorer { this.openSidePanel( "Upload File", this.expandConsole()} closePanel={this.closeSidePanel} uploadFile={(name: string, content: string) => this.uploadFile(name, content, parent)} /> diff --git a/src/Explorer/Panes/CopyNotebookPane/CopyNotebookPane.tsx b/src/Explorer/Panes/CopyNotebookPane/CopyNotebookPane.tsx index 3f4c281aa..30e6bdeb5 100644 --- a/src/Explorer/Panes/CopyNotebookPane/CopyNotebookPane.tsx +++ b/src/Explorer/Panes/CopyNotebookPane/CopyNotebookPane.tsx @@ -131,7 +131,6 @@ export const CopyNotebookPane: FunctionComponent = ({ }; const genericPaneProps: GenericRightPaneProps = { - container, formError, formErrorDetail, id: "copynotebookpane", @@ -140,6 +139,7 @@ export const CopyNotebookPane: FunctionComponent = ({ submitButtonText: "OK", onClose: closePanel, onSubmit: () => submit(), + expandConsole: () => container.expandConsole(), }; const copyNotebookPaneProps: CopyNotebookPaneProps = { diff --git a/src/Explorer/Panes/DeleteCollectionConfirmationPane/DeleteCollectionConfirmationPane.tsx b/src/Explorer/Panes/DeleteCollectionConfirmationPane/DeleteCollectionConfirmationPane.tsx index 171289999..b6864aadb 100644 --- a/src/Explorer/Panes/DeleteCollectionConfirmationPane/DeleteCollectionConfirmationPane.tsx +++ b/src/Explorer/Panes/DeleteCollectionConfirmationPane/DeleteCollectionConfirmationPane.tsx @@ -101,7 +101,6 @@ export const DeleteCollectionConfirmationPane: FunctionComponent explorer.expandConsole(), }; return ( diff --git a/src/Explorer/Panes/DeleteCollectionConfirmationPane/__snapshots__/DeleteCollectionConfirmationPane.test.tsx.snap b/src/Explorer/Panes/DeleteCollectionConfirmationPane/__snapshots__/DeleteCollectionConfirmationPane.test.tsx.snap index 8d5985440..a78871304 100644 --- a/src/Explorer/Panes/DeleteCollectionConfirmationPane/__snapshots__/DeleteCollectionConfirmationPane.test.tsx.snap +++ b/src/Explorer/Panes/DeleteCollectionConfirmationPane/__snapshots__/DeleteCollectionConfirmationPane.test.tsx.snap @@ -16,16 +16,7 @@ exports[`Delete Collection Confirmation Pane submit() should call delete collect } > { - const fakeExplorer = {} as Explorer; const fakeSproc = {} as StoredProcedure; const props = { - explorer: fakeExplorer, storedProcedure: fakeSproc, + expandConsole: (): void => undefined, closePanel: (): void => undefined, }; diff --git a/src/Explorer/Panes/ExecuteSprocParamsPane/ExecuteSprocParamsPane.tsx b/src/Explorer/Panes/ExecuteSprocParamsPane/ExecuteSprocParamsPane.tsx index ab63e4fcb..2677c6055 100644 --- a/src/Explorer/Panes/ExecuteSprocParamsPane/ExecuteSprocParamsPane.tsx +++ b/src/Explorer/Panes/ExecuteSprocParamsPane/ExecuteSprocParamsPane.tsx @@ -2,7 +2,6 @@ import { useBoolean } from "@uifabric/react-hooks"; import { IDropdownOption, IImageProps, Image, Stack, Text } from "office-ui-fabric-react"; import React, { FunctionComponent, useState } from "react"; import AddPropertyIcon from "../../../../images/Add-property.svg"; -import Explorer from "../../Explorer"; import StoredProcedure from "../../Tree/StoredProcedure"; import { GenericRightPaneComponent, @@ -11,7 +10,7 @@ import { import { InputParameter } from "./InputParameter"; interface ExecuteSprocParamsPaneProps { - explorer: Explorer; + expandConsole: () => void; storedProcedure: StoredProcedure; closePanel: () => void; } @@ -27,7 +26,7 @@ interface UnwrappedExecuteSprocParam { } export const ExecuteSprocParamsPane: FunctionComponent = ({ - explorer, + expandConsole, storedProcedure, closePanel, }: ExecuteSprocParamsPaneProps): JSX.Element => { @@ -43,7 +42,7 @@ export const ExecuteSprocParamsPane: FunctionComponent void; formError: string; formErrorDetail: string; id: string; @@ -24,7 +23,7 @@ export interface GenericRightPaneState { } export const GenericRightPaneComponent: FunctionComponent = ({ - container, + expandConsole, formError, formErrorDetail, id, @@ -72,7 +71,7 @@ export const GenericRightPaneComponent: FunctionComponent {formError} - @@ -114,10 +113,6 @@ export const GenericRightPaneComponent: FunctionComponent } }; - const showErrorDetail = (): void => { - container.expandConsole(); - }; - return (
diff --git a/src/Explorer/Panes/LoadQueryPane/LoadQueryPane.tsx b/src/Explorer/Panes/LoadQueryPane/LoadQueryPane.tsx index 6a8fed727..d2079c010 100644 --- a/src/Explorer/Panes/LoadQueryPane/LoadQueryPane.tsx +++ b/src/Explorer/Panes/LoadQueryPane/LoadQueryPane.tsx @@ -37,7 +37,7 @@ export const LoadQueryPane: FunctionComponent = ({ const title = "Load Query"; const genericPaneProps: GenericRightPaneProps = { - container: explorer, + expandConsole: () => explorer.expandConsole(), formError: formError, formErrorDetail: formErrorsDetails, id: "loadQueryPane", diff --git a/src/Explorer/Panes/LoadQueryPane/__snapshots__/LoadQueryPane.test.tsx.snap b/src/Explorer/Panes/LoadQueryPane/__snapshots__/LoadQueryPane.test.tsx.snap index ee672aa5c..badff47b7 100644 --- a/src/Explorer/Panes/LoadQueryPane/__snapshots__/LoadQueryPane.test.tsx.snap +++ b/src/Explorer/Panes/LoadQueryPane/__snapshots__/LoadQueryPane.test.tsx.snap @@ -2,7 +2,7 @@ exports[`Load Query Pane should render Default properly 1`] = ` = }; const props: GenericRightPaneProps = { - container: container, formError: formError, formErrorDetail: formErrorDetail, id: "publishnotebookpane", @@ -167,6 +166,7 @@ export const PublishNotebookPane: FunctionComponent = submitButtonText: "Publish", onSubmit: () => submit(), onClose: closePanel, + expandConsole: () => container.expandConsole(), isSubmitButtonHidden: !isCodeOfConductAccepted, }; diff --git a/src/Explorer/Panes/SaveQueryPane/SaveQueryPane.tsx b/src/Explorer/Panes/SaveQueryPane/SaveQueryPane.tsx index 949e9203f..652c58949 100644 --- a/src/Explorer/Panes/SaveQueryPane/SaveQueryPane.tsx +++ b/src/Explorer/Panes/SaveQueryPane/SaveQueryPane.tsx @@ -32,7 +32,7 @@ export const SaveQueryPane: FunctionComponent = ({ const title = "Save Query"; const { canSaveQueries } = explorer; const genericPaneProps: GenericRightPaneProps = { - container: explorer, + expandConsole: () => explorer.expandConsole(), formError: formError, formErrorDetail: formErrorsDetails, id: "saveQueryPane", diff --git a/src/Explorer/Panes/SaveQueryPane/__snapshots__/SaveQueryPane.test.tsx.snap b/src/Explorer/Panes/SaveQueryPane/__snapshots__/SaveQueryPane.test.tsx.snap index b5ed7ed77..aba5e17b8 100644 --- a/src/Explorer/Panes/SaveQueryPane/__snapshots__/SaveQueryPane.test.tsx.snap +++ b/src/Explorer/Panes/SaveQueryPane/__snapshots__/SaveQueryPane.test.tsx.snap @@ -2,11 +2,7 @@ exports[`Save Query Pane should render Default properly 1`] = ` undefined, closePanel: (): void => undefined, }; describe("Settings Pane", () => { diff --git a/src/Explorer/Panes/SettingsPane/SettingsPane.tsx b/src/Explorer/Panes/SettingsPane/SettingsPane.tsx index 02dfdd614..480f358c5 100644 --- a/src/Explorer/Panes/SettingsPane/SettingsPane.tsx +++ b/src/Explorer/Panes/SettingsPane/SettingsPane.tsx @@ -7,19 +7,18 @@ import { LocalStorageUtility, StorageKey } from "../../../Shared/StorageUtility" import * as StringUtility from "../../../Shared/StringUtility"; import { userContext } from "../../../UserContext"; import { logConsoleInfo } from "../../../Utils/NotificationConsoleUtils"; -import Explorer from "../../Explorer"; import { GenericRightPaneComponent, GenericRightPaneProps, } from "../GenericRightPaneComponent/GenericRightPaneComponent"; export interface SettingsPaneProps { - explorer: Explorer; + expandConsole: () => void; closePanel: () => void; } export const SettingsPane: FunctionComponent = ({ - explorer: container, + expandConsole, closePanel, }: SettingsPaneProps) => { const [formErrors, setFormErrors] = useState(""); @@ -107,7 +106,7 @@ export const SettingsPane: FunctionComponent = ({ }; const genericPaneProps: GenericRightPaneProps = { - container, + expandConsole, formError: formErrors, formErrorDetail: "", id: "settingspane", diff --git a/src/Explorer/Panes/SettingsPane/__snapshots__/SettingsPane.test.tsx.snap b/src/Explorer/Panes/SettingsPane/__snapshots__/SettingsPane.test.tsx.snap index 69f4ef1b7..c20b14595 100644 --- a/src/Explorer/Panes/SettingsPane/__snapshots__/SettingsPane.test.tsx.snap +++ b/src/Explorer/Panes/SettingsPane/__snapshots__/SettingsPane.test.tsx.snap @@ -2,504 +2,7 @@ exports[`Settings Pane should render Default properly 1`] = `
+ > +
+
+ Query results per page + + Enter the number of query results that should be shown per page. + +
+ +
+
= ({ } }; const genericPaneProps: GenericRightPaneProps = { - container: container, formError: formErrors, formErrorDetail: formErrorsDetails, id: "stringInputPane", @@ -101,6 +100,7 @@ export const StringInputPane: FunctionComponent = ({ submitButtonText: submitButtonLabel, onClose: closePanel, onSubmit: submit, + expandConsole: () => container.expandConsole(), }; return ( diff --git a/src/Explorer/Panes/StringInputPane/__snapshots__/StringInputPane.test.tsx.snap b/src/Explorer/Panes/StringInputPane/__snapshots__/StringInputPane.test.tsx.snap index fbdc9fc80..7fd573d15 100644 --- a/src/Explorer/Panes/StringInputPane/__snapshots__/StringInputPane.test.tsx.snap +++ b/src/Explorer/Panes/StringInputPane/__snapshots__/StringInputPane.test.tsx.snap @@ -519,504 +519,7 @@ exports[`StringInput Pane should render Create new directory properly 1`] = ` successMessage="Created directory " > (true); const genericPaneProps: GenericRightPaneProps = { - container: explorer, formError: "", formErrorDetail: "", id: "querySelectPane", @@ -41,6 +40,7 @@ export const TableQuerySelectPanel: FunctionComponent closePanel(), onSubmit: () => submit(), + expandConsole: () => explorer.expandConsole(), }; const submit = (): void => { diff --git a/src/Explorer/Panes/UploadFilePane/UploadFilePane.tsx b/src/Explorer/Panes/UploadFilePane/UploadFilePane.tsx index 70b66baea..d65301610 100644 --- a/src/Explorer/Panes/UploadFilePane/UploadFilePane.tsx +++ b/src/Explorer/Panes/UploadFilePane/UploadFilePane.tsx @@ -1,7 +1,6 @@ import React, { ChangeEvent, FunctionComponent, useState } from "react"; import { Upload } from "../../../Common/Upload/Upload"; import { logConsoleError, logConsoleInfo, logConsoleProgress } from "../../../Utils/NotificationConsoleUtils"; -import Explorer from "../../Explorer"; import { NotebookContentItem } from "../../Notebook/NotebookContentItem"; import { GenericRightPaneComponent, @@ -9,13 +8,13 @@ import { } from "../GenericRightPaneComponent/GenericRightPaneComponent"; export interface UploadFilePanelProps { - explorer: Explorer; + expandConsole: () => void; closePanel: () => void; uploadFile: (name: string, content: string) => Promise; } export const UploadFilePane: FunctionComponent = ({ - explorer: container, + expandConsole, closePanel, uploadFile, }: UploadFilePanelProps) => { @@ -93,7 +92,7 @@ export const UploadFilePane: FunctionComponent = ({ }; const genericPaneProps: GenericRightPaneProps = { - container: container, + expandConsole, formError: formErrors, formErrorDetail: formErrorsDetails, id: "uploadFilePane", diff --git a/src/Explorer/Panes/UploadItemsPane/UploadItemsPane.tsx b/src/Explorer/Panes/UploadItemsPane/UploadItemsPane.tsx index c2836ba3c..31448612f 100644 --- a/src/Explorer/Panes/UploadItemsPane/UploadItemsPane.tsx +++ b/src/Explorer/Panes/UploadItemsPane/UploadItemsPane.tsx @@ -71,7 +71,7 @@ export const UploadItemsPane: FunctionComponent = ({ }; const genericPaneProps: GenericRightPaneProps = { - container: explorer, + expandConsole: () => explorer.expandConsole(), formError, formErrorDetail, id: "uploaditemspane", diff --git a/src/Explorer/Panes/UploadItemsPane/__snapshots__/UploadItemsPane.test.tsx.snap b/src/Explorer/Panes/UploadItemsPane/__snapshots__/UploadItemsPane.test.tsx.snap index fc59040bf..c13f7f4ae 100644 --- a/src/Explorer/Panes/UploadItemsPane/__snapshots__/UploadItemsPane.test.tsx.snap +++ b/src/Explorer/Panes/UploadItemsPane/__snapshots__/UploadItemsPane.test.tsx.snap @@ -2,504 +2,7 @@ exports[`Upload Items Pane should render Default properly 1`] = `