X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/6653b7a7edbac351f5b3734114d6b5904dda1acc..b7322ddccea570a1c563da84215daed067273859:/src/views-components/side-panel/side-panel.tsx

diff --git a/src/views-components/side-panel/side-panel.tsx b/src/views-components/side-panel/side-panel.tsx
index 12e82dfb10..2509e56eaa 100644
--- a/src/views-components/side-panel/side-panel.tsx
+++ b/src/views-components/side-panel/side-panel.tsx
@@ -2,18 +2,20 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import * as React from 'react';
+import React from 'react';
 import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core/styles';
-import { ArvadosTheme } from '~/common/custom-theme';
-import { SidePanelTree, SidePanelTreeProps } from '~/views-components/side-panel-tree/side-panel-tree';
-import { compose, Dispatch } from 'redux';
+import { ArvadosTheme } from 'common/custom-theme';
+import { SidePanelTree, SidePanelTreeProps } from 'views-components/side-panel-tree/side-panel-tree';
+import { Dispatch } from 'redux';
 import { connect } from 'react-redux';
-import { navigateFromSidePanel } from '../../store/side-panel/side-panel-action';
-import { Grid } from '@material-ui/core';
-import { SidePanelButton } from '~/views-components/side-panel-button/side-panel-button';
-import { RootState } from '~/store/store';
+import { navigateFromSidePanel } from 'store/side-panel/side-panel-action';
+import { Grid, Tooltip, IconButton  } from '@material-ui/core';
+import { SidePanelButton } from 'views-components/side-panel-button/side-panel-button';
+import { RootState } from 'store/store';
+import MenuIcon from "@material-ui/icons/Menu";
+import SidePanelToggle from 'views-components/side-panel-toggle/side-panel-toggle';
 
-const DRAWER_WITDH = 240;
+const DRAWER_WIDTH = 240;
 
 type CssRules = 'root';
 
@@ -23,7 +25,7 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
         borderRight: `1px solid ${theme.palette.divider}`,
         height: '100%',
         overflowX: 'auto',
-        width: DRAWER_WITDH,
+        width: DRAWER_WIDTH,
     }
 });
 
@@ -33,14 +35,22 @@ const mapDispatchToProps = (dispatch: Dispatch): SidePanelTreeProps => ({
     }
 });
 
-const mapStateToProps = (state: RootState) => ({
+const mapStateToProps = ({ router, sidePanel }: RootState) => ({
+    currentRoute: router.location ? router.location.pathname : '',
+    isCollapsed: sidePanel.collapsedState
 });
 
 export const SidePanel = withStyles(styles)(
     connect(mapStateToProps, mapDispatchToProps)(
-    ({ classes, ...props }: WithStyles<CssRules> & SidePanelTreeProps) =>
-    <Grid item xs>
-        <SidePanelButton />
-        <SidePanelTree {...props} />
-    </Grid>
-));
+        ({ classes, ...props }: WithStyles<CssRules> & SidePanelTreeProps & { currentRoute: string }) =>
+            <Grid item xs>
+                {props.isCollapsed ? <SidePanelToggle /> :
+                <>
+                    <Grid style={{display: 'flex', justifyContent: 'space-between', flexWrap: 'wrap-reverse'}}>
+                        <SidePanelButton key={props.currentRoute} />
+                        <SidePanelToggle/>
+                    </Grid>
+                    <SidePanelTree {...props} />
+                </>}
+            </Grid>
+    ));
