diff --git a/src/Explorer/Panes/CopyNotebookPane.tsx b/src/Explorer/Panes/CopyNotebookPane.tsx index 3a013849c..a3ea0816c 100644 --- a/src/Explorer/Panes/CopyNotebookPane.tsx +++ b/src/Explorer/Panes/CopyNotebookPane.tsx @@ -12,7 +12,7 @@ import Explorer from "../Explorer"; import { NotebookContentItem, NotebookContentItemType } from "../Notebook/NotebookContentItem"; import { ResourceTreeAdapter } from "../Tree/ResourceTreeAdapter"; import { CopyNotebookPaneComponent, CopyNotebookPaneProps } from "./CopyNotebookPaneComponent"; -import { RightPaneWrapper, RightPaneWrapperProps } from "./RightPaneWrapper/RightPaneWrapper"; +import { RightPaneForm, RightPaneFormProps } from "./RightPaneForm/RightPaneForm"; interface Location { type: "MyNotebooks" | "GitHub"; @@ -51,7 +51,7 @@ export class CopyNotebookPaneAdapter implements ReactAdapter { return undefined; } - const genericPaneProps: RightPaneWrapperProps = { + const genericPaneProps: RightPaneFormProps = { container: this.container, formError: this.formError, formErrorDetail: this.formErrorDetail, @@ -70,9 +70,9 @@ export class CopyNotebookPaneAdapter implements ReactAdapter { }; return ( - + - + ); } diff --git a/src/Explorer/Panes/DeleteCollectionConfirmationPanel/index.tsx b/src/Explorer/Panes/DeleteCollectionConfirmationPanel/index.tsx index 2aeb1d98f..dd4a6e0d4 100644 --- a/src/Explorer/Panes/DeleteCollectionConfirmationPanel/index.tsx +++ b/src/Explorer/Panes/DeleteCollectionConfirmationPanel/index.tsx @@ -11,7 +11,7 @@ import * as TelemetryProcessor from "../../../Shared/Telemetry/TelemetryProcesso import { userContext } from "../../../UserContext"; import * as NotificationConsoleUtils from "../../../Utils/NotificationConsoleUtils"; import Explorer from "../../Explorer"; -import { RightPaneWrapper, RightPaneWrapperProps } from "../RightPaneWrapper/RightPaneWrapper"; +import { RightPaneForm, RightPaneFormProps } from "../RightPaneForm/RightPaneForm"; export interface DeleteCollectionConfirmationPanelProps { explorer: Explorer; collectionName: string; @@ -97,7 +97,7 @@ export const DeleteCollectionConfirmationPanel: FunctionComponent +
@@ -147,6 +147,6 @@ export const DeleteCollectionConfirmationPanel: FunctionComponent
- + ); }; diff --git a/src/Explorer/Panes/ExecuteSprocParamsPanel/index.tsx b/src/Explorer/Panes/ExecuteSprocParamsPanel/index.tsx index f14a34436..900ab56c0 100644 --- a/src/Explorer/Panes/ExecuteSprocParamsPanel/index.tsx +++ b/src/Explorer/Panes/ExecuteSprocParamsPanel/index.tsx @@ -4,7 +4,7 @@ import React, { FunctionComponent, useState } from "react"; import AddPropertyIcon from "../../../../images/Add-property.svg"; import Explorer from "../../Explorer"; import StoredProcedure from "../../Tree/StoredProcedure"; -import { RightPaneWrapper, RightPaneWrapperProps } from "../RightPaneWrapper/RightPaneWrapper"; +import { GenericRightPaneComponent, GenericRightPaneProps } from "../GenericRightPaneComponent"; import { InputParameter } from "./InputParameter"; interface ExecuteSprocParamsPaneProps { @@ -39,7 +39,7 @@ export const ExecuteSprocParamsPanel: FunctionComponent +
- +
); }; diff --git a/src/Explorer/Panes/GenericRightPaneComponent/index.tsx b/src/Explorer/Panes/GenericRightPaneComponent/index.tsx new file mode 100644 index 000000000..409711e8a --- /dev/null +++ b/src/Explorer/Panes/GenericRightPaneComponent/index.tsx @@ -0,0 +1,135 @@ +import { IconButton, PrimaryButton } from "office-ui-fabric-react/lib/Button"; +import React, { FunctionComponent, ReactNode } from "react"; +import ErrorRedIcon from "../../../../images/error_red.svg"; +import LoadingIndicatorIcon from "../../../../images/LoadingIndicator_3Squares.gif"; +import { KeyCodes } from "../../../Common/Constants"; +import Explorer from "../../Explorer"; + +export interface GenericRightPaneProps { + container: Explorer; + formError: string; + formErrorDetail: string; + id: string; + isExecuting: boolean; + onClose: () => void; + onSubmit: () => void; + submitButtonText: string; + title: string; + isSubmitButtonHidden?: boolean; + children?: ReactNode; +} + +export interface GenericRightPaneState { + panelHeight: number; +} + +export const GenericRightPaneComponent: FunctionComponent = ({ + container, + formError, + formErrorDetail, + id, + isExecuting, + onClose, + onSubmit, + submitButtonText, + title, + isSubmitButtonHidden, + children, +}: GenericRightPaneProps) => { + const getPanelHeight = (): number => { + const notificationConsoleElement: HTMLElement = document.getElementById("explorerNotificationConsole"); + return window.innerHeight - $(notificationConsoleElement).height(); + }; + + const panelHeight: number = getPanelHeight(); + + const renderPanelHeader = (): JSX.Element => { + return ( +
+ + {title} + + +
+ ); + }; + + const renderErrorSection = (): JSX.Element => { + return ( + + ); + }; + + const renderPanelFooter = (): JSX.Element => { + return ( +
+
+ +
+
+ ); + }; + + const renderLoadingScreen = (): JSX.Element => { + return ( + + ); + }; + + const onKeyDown = (event: React.KeyboardEvent): void => { + if (event.keyCode === KeyCodes.Escape) { + onClose(); + event.stopPropagation(); + } + }; + + const showErrorDetail = (): void => { + container.expandConsole(); + }; + + return ( +
+
+
+
+ {renderPanelHeader()} + {renderErrorSection()} + {children} + {renderPanelFooter()} +
+ {renderLoadingScreen()} +
+
+ ); +}; diff --git a/src/Explorer/Panes/LoadQueryPanel/index.tsx b/src/Explorer/Panes/LoadQueryPanel/index.tsx index fbc7c450e..0b2816c04 100644 --- a/src/Explorer/Panes/LoadQueryPanel/index.tsx +++ b/src/Explorer/Panes/LoadQueryPanel/index.tsx @@ -8,7 +8,7 @@ import { logConsoleError, logConsoleInfo, logConsoleProgress } from "../../../Ut import Explorer from "../../Explorer"; import QueryTab from "../../Tabs/QueryTab"; import { Collection } from "..//../../Contracts/ViewModels"; -import { RightPaneWrapper, RightPaneWrapperProps } from "../RightPaneWrapper/RightPaneWrapper"; +import { GenericRightPaneComponent, GenericRightPaneProps } from "../GenericRightPaneComponent"; interface LoadQueryPanelProps { explorer: Explorer; @@ -33,7 +33,7 @@ export const LoadQueryPanel: FunctionComponent = ({ }; const title = "Load Query"; - const genericPaneProps: RightPaneWrapperProps = { + const genericPaneProps: GenericRightPaneProps = { container: explorer, formError: formError, formErrorDetail: formErrorsDetails, @@ -104,7 +104,7 @@ export const LoadQueryPanel: FunctionComponent = ({ }; return ( - +
@@ -129,6 +129,6 @@ export const LoadQueryPanel: FunctionComponent = ({
-
+ ); }; diff --git a/src/Explorer/Panes/PublishNotebookPaneAdapter.tsx b/src/Explorer/Panes/PublishNotebookPaneAdapter.tsx index 9c4bcf22a..2e57d99e4 100644 --- a/src/Explorer/Panes/PublishNotebookPaneAdapter.tsx +++ b/src/Explorer/Panes/PublishNotebookPaneAdapter.tsx @@ -14,7 +14,7 @@ import { GalleryTab } from "../Controls/NotebookGallery/GalleryViewerComponent"; import Explorer from "../Explorer"; import * as FileSystemUtil from "../Notebook/FileSystemUtil"; import { PublishNotebookPaneComponent, PublishNotebookPaneProps } from "./PublishNotebookPaneComponent"; -import { RightPaneWrapper, RightPaneWrapperProps } from "./RightPaneWrapper/RightPaneWrapper"; +import { RightPaneForm, RightPaneFormProps } from "./RightPaneForm/RightPaneForm"; export class PublishNotebookPaneAdapter implements ReactAdapter { parameters: ko.Observable; @@ -44,7 +44,7 @@ export class PublishNotebookPaneAdapter implements ReactAdapter { return undefined; } - const props: RightPaneWrapperProps = { + const props: RightPaneFormProps = { container: this.container, formError: this.formError, formErrorDetail: this.formErrorDetail, @@ -74,7 +74,7 @@ export class PublishNotebookPaneAdapter implements ReactAdapter { }; return ( - + {!this.isCodeOfConductAccepted ? (
)} - + ); } diff --git a/src/Explorer/Panes/RightPaneWrapper/RightPaneWrapper.test.tsx b/src/Explorer/Panes/RightPaneForm/RightPaneForm.test.tsx similarity index 80% rename from src/Explorer/Panes/RightPaneWrapper/RightPaneWrapper.test.tsx rename to src/Explorer/Panes/RightPaneForm/RightPaneForm.test.tsx index de7ca9f1f..6e0bfe27e 100644 --- a/src/Explorer/Panes/RightPaneWrapper/RightPaneWrapper.test.tsx +++ b/src/Explorer/Panes/RightPaneForm/RightPaneForm.test.tsx @@ -2,7 +2,7 @@ import { fireEvent, render, screen } from "@testing-library/react"; import { mount, ReactWrapper } from "enzyme"; import React from "react"; import Explorer from "../../Explorer"; -import { RightPaneWrapper } from "./RightPaneWrapper"; +import { RightPaneForm } from "./RightPaneForm"; const onClose = jest.fn(); const onSubmit = jest.fn(); @@ -24,26 +24,26 @@ describe("Load Query Pane", () => { let wrapper: ReactWrapper; it("should render Default properly", () => { - wrapper = mount(); + wrapper = mount(); expect(wrapper).toMatchSnapshot(); }); it("should call close method click cancel icon", () => { - render(); + render(); fireEvent.click(screen.getByTestId("closePaneBtn")); expect(onClose).toHaveBeenCalled(); }); it("should call submit method enter in form", () => { - render(); + render(); fireEvent.click(screen.getByTestId("submit")); expect(onSubmit).toHaveBeenCalled(); }); it("should call submit method click on submit button", () => { - render(); + render(); fireEvent.click(screen.getByTestId("submit")); expect(onSubmit).toHaveBeenCalled(); }); it("should render error in header", () => { - render(); + render(); expect(screen.getByTestId("errorIcon")).toBeDefined(); expect(screen.getByTestId("panelmessage").innerHTML).toEqual("file already Exist"); }); diff --git a/src/Explorer/Panes/RightPaneWrapper/RightPaneWrapper.tsx b/src/Explorer/Panes/RightPaneForm/RightPaneForm.tsx similarity index 95% rename from src/Explorer/Panes/RightPaneWrapper/RightPaneWrapper.tsx rename to src/Explorer/Panes/RightPaneForm/RightPaneForm.tsx index ee79e91bc..23af7787a 100644 --- a/src/Explorer/Panes/RightPaneWrapper/RightPaneWrapper.tsx +++ b/src/Explorer/Panes/RightPaneForm/RightPaneForm.tsx @@ -6,7 +6,7 @@ import { PanelFooterComponent } from "../PanelFooterComponent"; import { PanelInfoErrorComponent, PanelInfoErrorProps } from "../PanelInfoErrorComponent"; import { PanelLoadingScreen } from "../PanelLoadingScreen"; -export interface RightPaneWrapperProps { +export interface RightPaneFormProps { container: Explorer; formError: string; formErrorDetail: string; @@ -24,7 +24,7 @@ export interface GenericRightPaneState { panelHeight: number; } -export const RightPaneWrapper: FunctionComponent = ({ +export const RightPaneForm: FunctionComponent = ({ container, formError, formErrorDetail, @@ -36,7 +36,7 @@ export const RightPaneWrapper: FunctionComponent = ({ title, isSubmitButtonHidden = false, children, -}: RightPaneWrapperProps) => { +}: RightPaneFormProps) => { const getPanelHeight = (): number => { const notificationConsoleElement: HTMLElement = document.getElementById("explorerNotificationConsole"); return window.innerHeight - $(notificationConsoleElement).height(); diff --git a/src/Explorer/Panes/RightPaneWrapper/__snapshots__/RightPaneWrapper.test.tsx.snap b/src/Explorer/Panes/RightPaneForm/__snapshots__/RightPaneWrapper.test.tsx.snap similarity index 100% rename from src/Explorer/Panes/RightPaneWrapper/__snapshots__/RightPaneWrapper.test.tsx.snap rename to src/Explorer/Panes/RightPaneForm/__snapshots__/RightPaneWrapper.test.tsx.snap diff --git a/src/Explorer/Panes/SaveQueryPanel/index.tsx b/src/Explorer/Panes/SaveQueryPanel/index.tsx index 9fd209675..a4e5bc559 100644 --- a/src/Explorer/Panes/SaveQueryPanel/index.tsx +++ b/src/Explorer/Panes/SaveQueryPanel/index.tsx @@ -9,7 +9,7 @@ import { traceFailure, traceStart, traceSuccess } from "../../../Shared/Telemetr import { logConsoleError } from "../../../Utils/NotificationConsoleUtils"; import Explorer from "../../Explorer"; import QueryTab from "../../Tabs/QueryTab"; -import { RightPaneWrapper, RightPaneWrapperProps } from "../RightPaneWrapper/RightPaneWrapper"; +import { GenericRightPaneComponent, GenericRightPaneProps } from "../GenericRightPaneComponent"; interface SaveQueryPanelProps { explorer: Explorer; @@ -28,7 +28,7 @@ export const SaveQueryPanel: FunctionComponent = ({ const setupSaveQueriesText = `For compliance reasons, we save queries in a container in your Azure Cosmos account, in a separate database called “${SavedQueries.DatabaseName}”. To proceed, we need to create a container in your account, estimated additional cost is $0.77 daily.`; const title = "Save Query"; const { canSaveQueries } = explorer; - const genericPaneProps: RightPaneWrapperProps = { + const genericPaneProps: GenericRightPaneProps = { container: explorer, formError: formError, formErrorDetail: formErrorsDetails, @@ -146,7 +146,7 @@ export const SaveQueryPanel: FunctionComponent = ({ }; return ( - +
{!canSaveQueries() ? ( @@ -163,6 +163,6 @@ export const SaveQueryPanel: FunctionComponent = ({ )}
-
+ ); }; diff --git a/src/Explorer/Panes/SettingsPane/index.tsx b/src/Explorer/Panes/SettingsPane/index.tsx index 816a0577b..4894f5fb4 100644 --- a/src/Explorer/Panes/SettingsPane/index.tsx +++ b/src/Explorer/Panes/SettingsPane/index.tsx @@ -8,7 +8,7 @@ import * as StringUtility from "../../../Shared/StringUtility"; import { userContext } from "../../../UserContext"; import { logConsoleInfo } from "../../../Utils/NotificationConsoleUtils"; import Explorer from "../../Explorer"; -import { RightPaneWrapper, RightPaneWrapperProps } from "../RightPaneWrapper/RightPaneWrapper"; +import { RightPaneForm, RightPaneFormProps } from "../RightPaneForm/RightPaneForm"; export interface SettingsPaneProps { explorer: Explorer; @@ -103,7 +103,7 @@ export const SettingsPane: FunctionComponent = ({ setGraphAutoVizDisabled(option.key); }; - const genericPaneProps: RightPaneWrapperProps = { + const genericPaneProps: RightPaneFormProps = { container, formError: formErrors, formErrorDetail: "", @@ -128,7 +128,7 @@ export const SettingsPane: FunctionComponent = ({ setPageOption(option.key); }; return ( - +
{shouldShowQueryPageOptions && (
@@ -248,6 +248,6 @@ export const SettingsPane: FunctionComponent = ({
-
+ ); }; diff --git a/src/Explorer/Panes/Tables/TableQuerySelectPanel/index.tsx b/src/Explorer/Panes/Tables/TableQuerySelectPanel/index.tsx index 23653f2af..76a54db6c 100644 --- a/src/Explorer/Panes/Tables/TableQuerySelectPanel/index.tsx +++ b/src/Explorer/Panes/Tables/TableQuerySelectPanel/index.tsx @@ -4,7 +4,7 @@ import { userContext } from "../../../../UserContext"; import Explorer from "../../../Explorer"; import * as Constants from "../../../Tables/Constants"; import QueryViewModel from "../../../Tables/QueryBuilder/QueryViewModel"; -import { RightPaneWrapper, RightPaneWrapperProps } from "../../RightPaneWrapper/RightPaneWrapper"; +import { GenericRightPaneComponent, GenericRightPaneProps } from "../../GenericRightPaneComponent"; interface TableQuerySelectPanelProps { explorer: Explorer; @@ -28,7 +28,7 @@ export const TableQuerySelectPanel: FunctionComponent(true); - const genericPaneProps: RightPaneWrapperProps = { + const genericPaneProps: GenericRightPaneProps = { container: explorer, formError: "", formErrorDetail: "", @@ -125,7 +125,7 @@ export const TableQuerySelectPanel: FunctionComponent +
Select the columns that you want to query. @@ -150,6 +150,6 @@ export const TableQuerySelectPanel: FunctionComponent
- +
); }; diff --git a/src/Explorer/Panes/UploadFilePane/index.tsx b/src/Explorer/Panes/UploadFilePane/index.tsx index b76792c68..af28784bb 100644 --- a/src/Explorer/Panes/UploadFilePane/index.tsx +++ b/src/Explorer/Panes/UploadFilePane/index.tsx @@ -3,7 +3,7 @@ import { Upload } from "../../../Common/Upload"; import { logConsoleError, logConsoleInfo, logConsoleProgress } from "../../../Utils/NotificationConsoleUtils"; import Explorer from "../../Explorer"; import { NotebookContentItem } from "../../Notebook/NotebookContentItem"; -import { RightPaneWrapper, RightPaneWrapperProps } from "../RightPaneWrapper/RightPaneWrapper"; +import { RightPaneForm, RightPaneFormProps } from "../RightPaneForm/RightPaneForm"; export interface UploadFilePanelProps { explorer: Explorer; @@ -89,7 +89,7 @@ export const UploadFilePane: FunctionComponent = ({ return uploadFile(file.name, fileContent); }; - const genericPaneProps: RightPaneWrapperProps = { + const genericPaneProps: RightPaneFormProps = { container: container, formError: formErrors, formErrorDetail: formErrorsDetails, @@ -102,10 +102,10 @@ export const UploadFilePane: FunctionComponent = ({ }; return ( - +
-
+ ); }; diff --git a/src/Explorer/Panes/UploadItemsPane/index.tsx b/src/Explorer/Panes/UploadItemsPane/index.tsx index 8918088bf..7821c9ee5 100644 --- a/src/Explorer/Panes/UploadItemsPane/index.tsx +++ b/src/Explorer/Panes/UploadItemsPane/index.tsx @@ -6,7 +6,7 @@ import { userContext } from "../../../UserContext"; import { logConsoleError } from "../../../Utils/NotificationConsoleUtils"; import Explorer from "../../Explorer"; import { getErrorMessage } from "../../Tables/Utilities"; -import { RightPaneWrapper, RightPaneWrapperProps } from "../RightPaneWrapper/RightPaneWrapper"; +import { RightPaneForm, RightPaneFormProps } from "../RightPaneForm/RightPaneForm"; export interface UploadItemsPaneProps { explorer: Explorer; @@ -67,7 +67,7 @@ export const UploadItemsPane: FunctionComponent = ({ setFiles(event.target.files); }; - const genericPaneProps: RightPaneWrapperProps = { + const genericPaneProps: RightPaneFormProps = { container: explorer, formError, formErrorDetail, @@ -110,7 +110,7 @@ export const UploadItemsPane: FunctionComponent = ({ }; return ( - +
= ({
)}
- + ); };