1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from 'react';
6 import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core/styles';
7 import { ArvadosTheme } from 'common/custom-theme';
8 import { SidePanelTree, SidePanelTreeProps } from 'views-components/side-panel-tree/side-panel-tree';
9 import { Dispatch } from 'redux';
10 import { connect } from 'react-redux';
11 import { navigateFromSidePanel } from 'store/side-panel/side-panel-action';
12 import { Grid, Tooltip, IconButton } from '@material-ui/core';
13 import { SidePanelButton } from 'views-components/side-panel-button/side-panel-button';
14 import { RootState } from 'store/store';
15 import MenuIcon from "@material-ui/icons/Menu";
17 const DRAWER_WIDTH = 240;
19 type CssRules = 'root';
21 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
23 background: theme.palette.background.paper,
24 borderRight: `1px solid ${theme.palette.divider}`,
31 const mapDispatchToProps = (dispatch: Dispatch): SidePanelTreeProps => ({
32 onItemActivation: id => {
33 dispatch<any>(navigateFromSidePanel(id));
37 const mapStateToProps = ({ router }: RootState) => ({
38 currentRoute: router.location ? router.location.pathname : '',
41 export const SidePanel = withStyles(styles)(
42 connect(mapStateToProps, mapDispatchToProps)(
43 ({ classes, ...props }: WithStyles<CssRules> & SidePanelTreeProps & { currentRoute: string }) =>
45 <SidePanelButton key={props.currentRoute} />
46 <SidePanelTree {...props} />
50 type collapseButtonIconProps = {
51 sidePanelIsCollapsed: boolean;
52 toggleSidePanel: (collapsedState: boolean) => void
55 const collapseButtonIconStyles = {
59 paddingBottom: '0.25rem'
63 export const CollapseLeftPanelTrigger = (props: collapseButtonIconProps) =>{
64 return <Tooltip disableFocusListener title="Toggle Side Panel">
65 <IconButton onClick={()=>{props.toggleSidePanel(props.sidePanelIsCollapsed)}}>
66 <MenuIcon style={collapseButtonIconStyles.menuIcon} aria-label="Toggle Side Panel" />