X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/be367b79043799fba28e3546791e8ac3c90bacdc..aa48015966dd61d462f43a1a336b1700c78624aa:/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 b4caef23d0..4953022d66 100644
--- a/src/views-components/side-panel/side-panel.tsx
+++ b/src/views-components/side-panel/side-panel.tsx
@@ -9,14 +9,14 @@ import { SidePanelTree, SidePanelTreeProps } from 'views-components/side-panel-t
 import { Dispatch } from 'redux';
 import { connect } from 'react-redux';
 import { navigateFromSidePanel } from 'store/side-panel/side-panel-action';
-import { Grid, Tooltip, IconButton  } from '@material-ui/core';
+import { Grid } 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_WIDTH = 240;
 
-type CssRules = 'root';
+type CssRules = 'root' | 'topButtonContainer';
 
 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
     root: {
@@ -25,6 +25,10 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
         height: '100%',
         overflowX: 'auto',
         width: DRAWER_WIDTH,
+    },
+    topButtonContainer: {
+        display: 'flex',
+        justifyContent: 'space-between'
     }
 });
 
@@ -34,36 +38,22 @@ const mapDispatchToProps = (dispatch: Dispatch): SidePanelTreeProps => ({
     }
 });
 
-const mapStateToProps = ({ router }: 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 & { currentRoute: string }) =>
             <Grid item xs>
-                <SidePanelButton key={props.currentRoute} />
-                <SidePanelTree {...props} />
+                {props.isCollapsed ? <SidePanelToggle /> :
+                <>
+                    <Grid className={classes.topButtonContainer}>
+                        <SidePanelButton key={props.currentRoute} />
+                        <SidePanelToggle/>
+                    </Grid>
+                    <SidePanelTree {...props} />
+                </>}
             </Grid>
     ));
-
-type collapseButtonIconProps = {
-    sidePanelIsCollapsed: boolean;
-    toggleSidePanel: (collapsedState: boolean) => void
-}
-
-const collapseButtonIconStyles = {
-    menuIcon: {
-        height: '4rem',
-        width: '4rem', 
-        paddingBottom: '0.25rem'
-    }
-}
-
-export const CollapseLeftPanelTrigger = (props: collapseButtonIconProps) =>{ 
-    return <Tooltip disableFocusListener title="Toggle Side Panel">
-                <IconButton onClick={()=>{props.toggleSidePanel(props.sidePanelIsCollapsed)}}>
-                    <MenuIcon style={collapseButtonIconStyles.menuIcon} aria-label="Toggle Side Panel" />
-                </IconButton>
-            </Tooltip>
-    };
\ No newline at end of file
