16068: Merge branch 'main' of git.arvados.org:arvados-workbench2 into 16068-merge...
[arvados-workbench2.git] / src / views-components / side-panel / side-panel.tsx
index 12e82dfb102f9ade1df6cd928a19c1957b7ebe3b..218b624cd5675585120cf1b8d34b1322a0ff62c0 100644 (file)
@@ -2,16 +2,16 @@
 //
 // 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 { 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 { SidePanelButton } from 'views-components/side-panel-button/side-panel-button';
+import { RootState } from 'store/store';
 
 const DRAWER_WITDH = 240;
 
@@ -33,14 +33,15 @@ const mapDispatchToProps = (dispatch: Dispatch): SidePanelTreeProps => ({
     }
 });
 
-const mapStateToProps = (state: RootState) => ({
+const mapStateToProps = ({ router }: RootState) => ({
+    currentRoute: router.location ? router.location.pathname : '',
 });
 
 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>
+                <SidePanelButton key={props.currentRoute} />
+                <SidePanelTree {...props} />
+            </Grid>
+    ));