From 5d1b659e2fd36c486fc2f4790ad133b7ba2ef9b4 Mon Sep 17 00:00:00 2001 From: Steve Faulkner Date: Mon, 17 May 2021 10:40:23 -0500 Subject: [PATCH] Revert "Migrate Collapse/Open Resource Tree to React (#733)" (#792) This reverts commit d7c62ac7f17501f3c8b85943d3f190ac07ff1cf8. --- less/documentDB.less | 6 +- less/tree.less | 1 - src/Common/CollapsedResourceTree.tsx | 35 ------ src/Common/ResourceTree.tsx | 59 ---------- .../SettingsComponent.test.tsx.snap | 8 ++ src/Explorer/Explorer.tsx | 23 +++- .../GitHubReposPanel.test.tsx.snap | 2 + .../StringInputPane.test.tsx.snap | 2 + ...eteDatabaseConfirmationPanel.test.tsx.snap | 2 + src/Main.tsx | 106 +++++++++++++++--- 10 files changed, 124 insertions(+), 120 deletions(-) delete mode 100644 src/Common/CollapsedResourceTree.tsx delete mode 100644 src/Common/ResourceTree.tsx diff --git a/less/documentDB.less b/less/documentDB.less index 5fc2f8571..e58206818 100644 --- a/less/documentDB.less +++ b/less/documentDB.less @@ -2099,7 +2099,7 @@ a:link { display: flex; flex: 1 1 auto; overflow-x: auto; - overflow-y: hidden; + overflow-y: auto; height: 100%; } @@ -3085,7 +3085,3 @@ settings-pane { padding-left: @SmallSpace; } } -.hiddenMain { - visibility: hidden; - height: 0px; -} \ No newline at end of file diff --git a/less/tree.less b/less/tree.less index e60bcf69c..56a5ee38e 100644 --- a/less/tree.less +++ b/less/tree.less @@ -3,7 +3,6 @@ .resourceTree { height: 100%; - width: 20%; flex: 0 0 auto; .main { height: 100%; diff --git a/src/Common/CollapsedResourceTree.tsx b/src/Common/CollapsedResourceTree.tsx deleted file mode 100644 index ea1ee6a32..000000000 --- a/src/Common/CollapsedResourceTree.tsx +++ /dev/null @@ -1,35 +0,0 @@ -import React, { FunctionComponent } from "react"; -import arrowLeftImg from "../../images/imgarrowlefticon.svg"; - -export interface CollapsedResourceTreeProps { - toggleLeftPaneExpanded: () => void; - isLeftPaneExpanded: boolean; -} - -export const CollapsedResourceTree: FunctionComponent = ({ - toggleLeftPaneExpanded, - isLeftPaneExpanded, -}: CollapsedResourceTreeProps): JSX.Element => { - return ( -
-
-
    -
  • - - Expand - - - - -
  • -
-
-
- ); -}; diff --git a/src/Common/ResourceTree.tsx b/src/Common/ResourceTree.tsx deleted file mode 100644 index 9aae283ea..000000000 --- a/src/Common/ResourceTree.tsx +++ /dev/null @@ -1,59 +0,0 @@ -import React, { FunctionComponent } from "react"; -import arrowLeftImg from "../../images/imgarrowlefticon.svg"; -import refreshImg from "../../images/refresh-cosmos.svg"; -import { AuthType } from "../AuthType"; -import { userContext } from "../UserContext"; - -export interface ResourceTreeProps { - toggleLeftPaneExpanded: () => void; - isLeftPaneExpanded: boolean; -} - -export const ResourceTree: FunctionComponent = ({ - toggleLeftPaneExpanded, - isLeftPaneExpanded, -}: ResourceTreeProps): JSX.Element => { - return ( -
- {/* Collections Window - - Start */} -
- {/* Collections Window Title/Command Bar - Start */} -
-
- -
- - Refresh tree - - - Hide - -
-
-
- {userContext.authType === AuthType.ResourceToken ? ( -
- ) : ( -
- )} -
- {/* Collections Window - End */} -
- ); -}; diff --git a/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap b/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap index 7a23e0a3a..adfb92b42 100644 --- a/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap +++ b/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap @@ -879,6 +879,7 @@ exports[`SettingsComponent renders 1`] = ` "isAutoscaleDefaultEnabled": [Function], "isFixedCollectionWithSharedThroughputSupported": [Function], "isHostedDataExplorerEnabled": [Function], + "isLeftPaneExpanded": [Function], "isMongoIndexingEnabled": [Function], "isNotebookEnabled": [Function], "isNotebooksEnabledForAccount": [Function], @@ -945,6 +946,7 @@ exports[`SettingsComponent renders 1`] = ` "activeTab": [Function], "openedTabs": [Function], }, + "toggleLeftPaneExpandedKeyPress": [Function], }, "databaseId": "test", "defaultTtl": [Function], @@ -1817,6 +1819,7 @@ exports[`SettingsComponent renders 1`] = ` "isAutoscaleDefaultEnabled": [Function], "isFixedCollectionWithSharedThroughputSupported": [Function], "isHostedDataExplorerEnabled": [Function], + "isLeftPaneExpanded": [Function], "isMongoIndexingEnabled": [Function], "isNotebookEnabled": [Function], "isNotebooksEnabledForAccount": [Function], @@ -1883,6 +1886,7 @@ exports[`SettingsComponent renders 1`] = ` "activeTab": [Function], "openedTabs": [Function], }, + "toggleLeftPaneExpandedKeyPress": [Function], } } isAutoPilotSelected={false} @@ -2768,6 +2772,7 @@ exports[`SettingsComponent renders 1`] = ` "isAutoscaleDefaultEnabled": [Function], "isFixedCollectionWithSharedThroughputSupported": [Function], "isHostedDataExplorerEnabled": [Function], + "isLeftPaneExpanded": [Function], "isMongoIndexingEnabled": [Function], "isNotebookEnabled": [Function], "isNotebooksEnabledForAccount": [Function], @@ -2834,6 +2839,7 @@ exports[`SettingsComponent renders 1`] = ` "activeTab": [Function], "openedTabs": [Function], }, + "toggleLeftPaneExpandedKeyPress": [Function], }, "databaseId": "test", "defaultTtl": [Function], @@ -3706,6 +3712,7 @@ exports[`SettingsComponent renders 1`] = ` "isAutoscaleDefaultEnabled": [Function], "isFixedCollectionWithSharedThroughputSupported": [Function], "isHostedDataExplorerEnabled": [Function], + "isLeftPaneExpanded": [Function], "isMongoIndexingEnabled": [Function], "isNotebookEnabled": [Function], "isNotebooksEnabledForAccount": [Function], @@ -3772,6 +3779,7 @@ exports[`SettingsComponent renders 1`] = ` "activeTab": [Function], "openedTabs": [Function], }, + "toggleLeftPaneExpandedKeyPress": [Function], } } geospatialConfigType="Geometry" diff --git a/src/Explorer/Explorer.tsx b/src/Explorer/Explorer.tsx index 0643f90a7..85a377370 100644 --- a/src/Explorer/Explorer.tsx +++ b/src/Explorer/Explorer.tsx @@ -131,6 +131,7 @@ export default class Explorer { public databases: ko.ObservableArray; public selectedDatabaseId: ko.Computed; public selectedCollectionId: ko.Computed; + public isLeftPaneExpanded: ko.Observable; public selectedNode: ko.Observable; private resourceTree: ResourceTreeAdapter; @@ -222,7 +223,6 @@ export default class Explorer { }); } }); - this.isNotebooksEnabledForAccount = ko.observable(false); this.isNotebooksEnabledForAccount.subscribe((isEnabledForAccount: boolean) => this.refreshCommandBarButtons()); this.isSparkEnabledForAccount = ko.observable(false); @@ -327,6 +327,7 @@ export default class Explorer { } return true; }); + this.isLeftPaneExpanded = ko.observable(true); this.selectedNode = ko.observable(); this.selectedNode.subscribe((nodeSelected: ViewModels.TreeNode) => { // Make sure switching tabs restores tabs display @@ -645,8 +646,16 @@ export default class Explorer { this.setIsNotificationConsoleExpanded(true); } - public collapseConsole(): void { - this.setIsNotificationConsoleExpanded(false); + public toggleLeftPaneExpanded() { + this.isLeftPaneExpanded(!this.isLeftPaneExpanded()); + + if (this.isLeftPaneExpanded()) { + document.getElementById("expandToggleLeftPaneButton").focus(); + this.splitter.expandLeft(); + } else { + document.getElementById("collapseToggleLeftPaneButton").focus(); + this.splitter.collapseLeft(); + } } public refreshDatabaseForResourceToken(): Q.Promise { @@ -765,6 +774,14 @@ export default class Explorer { this.refreshNotebookList(); }; + public toggleLeftPaneExpandedKeyPress = (source: any, event: KeyboardEvent): boolean => { + if (event.keyCode === Constants.KeyCodes.Space || event.keyCode === Constants.KeyCodes.Enter) { + this.toggleLeftPaneExpanded(); + return false; + } + return true; + }; + // Facade public provideFeedbackEmail = () => { window.open(Constants.Urls.feedbackEmail, "_blank"); diff --git a/src/Explorer/Panes/GitHubReposPanel/__snapshots__/GitHubReposPanel.test.tsx.snap b/src/Explorer/Panes/GitHubReposPanel/__snapshots__/GitHubReposPanel.test.tsx.snap index 3ddac360f..417bbd332 100644 --- a/src/Explorer/Panes/GitHubReposPanel/__snapshots__/GitHubReposPanel.test.tsx.snap +++ b/src/Explorer/Panes/GitHubReposPanel/__snapshots__/GitHubReposPanel.test.tsx.snap @@ -868,6 +868,7 @@ exports[`GitHub Repos Panel should render Default properly 1`] = ` "isAutoscaleDefaultEnabled": [Function], "isFixedCollectionWithSharedThroughputSupported": [Function], "isHostedDataExplorerEnabled": [Function], + "isLeftPaneExpanded": [Function], "isMongoIndexingEnabled": [Function], "isNotebookEnabled": [Function], "isNotebooksEnabledForAccount": [Function], @@ -934,6 +935,7 @@ exports[`GitHub Repos Panel should render Default properly 1`] = ` "activeTab": [Function], "openedTabs": [Function], }, + "toggleLeftPaneExpandedKeyPress": [Function], }, "getRepo": [Function], "pinRepo": [Function], diff --git a/src/Explorer/Panes/StringInputPane/__snapshots__/StringInputPane.test.tsx.snap b/src/Explorer/Panes/StringInputPane/__snapshots__/StringInputPane.test.tsx.snap index 2bec097e8..77a3af75a 100644 --- a/src/Explorer/Panes/StringInputPane/__snapshots__/StringInputPane.test.tsx.snap +++ b/src/Explorer/Panes/StringInputPane/__snapshots__/StringInputPane.test.tsx.snap @@ -858,6 +858,7 @@ exports[`StringInput Pane should render Create new directory properly 1`] = ` "isAutoscaleDefaultEnabled": [Function], "isFixedCollectionWithSharedThroughputSupported": [Function], "isHostedDataExplorerEnabled": [Function], + "isLeftPaneExpanded": [Function], "isMongoIndexingEnabled": [Function], "isNotebookEnabled": [Function], "isNotebooksEnabledForAccount": [Function], @@ -924,6 +925,7 @@ exports[`StringInput Pane should render Create new directory properly 1`] = ` "activeTab": [Function], "openedTabs": [Function], }, + "toggleLeftPaneExpandedKeyPress": [Function], } } inProgressMessage="Creating directory " diff --git a/src/Explorer/Panes/__snapshots__/DeleteDatabaseConfirmationPanel.test.tsx.snap b/src/Explorer/Panes/__snapshots__/DeleteDatabaseConfirmationPanel.test.tsx.snap index 8cbd0e904..44a530919 100644 --- a/src/Explorer/Panes/__snapshots__/DeleteDatabaseConfirmationPanel.test.tsx.snap +++ b/src/Explorer/Panes/__snapshots__/DeleteDatabaseConfirmationPanel.test.tsx.snap @@ -858,6 +858,7 @@ exports[`Delete Database Confirmation Pane submit() Should call delete database "isHostedDataExplorerEnabled": [Function], "isLastCollection": [Function], "isLastNonEmptyDatabase": [Function], + "isLeftPaneExpanded": [Function], "isMongoIndexingEnabled": [Function], "isNotebookEnabled": [Function], "isNotebooksEnabledForAccount": [Function], @@ -926,6 +927,7 @@ exports[`Delete Database Confirmation Pane submit() Should call delete database "activeTab": [Function], "openedTabs": [Function], }, + "toggleLeftPaneExpandedKeyPress": [Function], } } openNotificationConsole={[Function]} diff --git a/src/Main.tsx b/src/Main.tsx index c4c3be41c..b99d951b0 100644 --- a/src/Main.tsx +++ b/src/Main.tsx @@ -14,6 +14,8 @@ import "../externals/jquery.typeahead.min.js"; import "../images/CosmosDB_rgb_ui_lighttheme.ico"; import "../images/favicon.ico"; import hdeConnectImage from "../images/HdeConnectCosmosDB.svg"; +import arrowLeftImg from "../images/imgarrowlefticon.svg"; +import refreshImg from "../images/refresh-cosmos.svg"; import "../less/documentDB.less"; import "../less/forms.less"; import "../less/infobox.less"; @@ -25,8 +27,7 @@ import "../less/TableStyles/EntityEditor.less"; import "../less/TableStyles/fulldatatables.less"; import "../less/TableStyles/queryBuilder.less"; import "../less/tree.less"; -import { CollapsedResourceTree } from "./Common/CollapsedResourceTree"; -import { ResourceTree } from "./Common/ResourceTree"; +import { AuthType } from "./AuthType"; import "./Explorer/Controls/Accordion/AccordionComponent.less"; import "./Explorer/Controls/CollapsiblePanel/CollapsiblePanelComponent.less"; import { Dialog, DialogProps } from "./Explorer/Controls/Dialog"; @@ -53,6 +54,7 @@ import { useSidePanel } from "./hooks/useSidePanel"; import { useTabs } from "./hooks/useTabs"; import "./Libs/jquery"; import "./Shared/appInsights"; +import { userContext } from "./UserContext"; initializeIcons(); @@ -61,7 +63,6 @@ const App: React.FunctionComponent = () => { const [notificationConsoleData, setNotificationConsoleData] = useState(undefined); //TODO: Refactor so we don't need to pass the id to remove a console data const [inProgressConsoleDataIdToBeDeleted, setInProgressConsoleDataIdToBeDeleted] = useState(""); - const [isLeftPaneExpanded, setIsLeftPaneExpanded] = useState(true); const [dialogProps, setDialogProps] = useState(); const [showDialog, setShowDialog] = useState(false); @@ -91,15 +92,6 @@ const App: React.FunctionComponent = () => { const config = useConfig(); const explorer = useKnockoutExplorer(config?.platform, explorerParams); - const toggleLeftPaneExpanded = () => { - setIsLeftPaneExpanded(!isLeftPaneExpanded); - if (isLeftPaneExpanded) { - document.getElementById("expandToggleLeftPaneButton").focus(); - } else { - document.getElementById("collapseToggleLeftPaneButton").focus(); - } - }; - if (!explorer) { return ; } @@ -115,13 +107,93 @@ const App: React.FunctionComponent = () => {
{/* Collections Tree Expanded - Start */} - +
+ {/* Collections Window - - Start */} +
+ {/* Collections Window Title/Command Bar - Start */} +
+
+ +
+ + + + + Hide + +
+
+
+ {userContext.authType === AuthType.ResourceToken ? ( +
+ ) : ( +
+ )} +
+ {/* Collections Window - End */} +
{/* Collections Tree Expanded - End */} {/* Collections Tree Collapsed - Start */} - +
+
+
    +
  • + + Expand + + + + +
  • +
+
+
{/* Collections Tree Collapsed - End */}
{/* Splitter - Start */}