collapse toggle button in main app bar, redux store set up to handle state change...
[arvados-workbench2.git] / src / views / main-panel / main-panel.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { RootState } from 'store/store';
6 import { connect } from 'react-redux';
7 import parse from 'parse-duration';
8 import { MainPanelRoot, MainPanelRootDataProps } from 'views/main-panel/main-panel-root';
9 import { isSystemWorking } from 'store/progress-indicator/progress-indicator-reducer';
10 import { isWorkbenchLoading } from 'store/workbench/workbench-actions';
11 import { LinkAccountPanelStatus } from 'store/link-account-panel/link-account-panel-reducer';
12 import { matchLinkAccountRoute } from 'routes/routes';
13 import { toggleSidePanel } from "store/store";
14
15 const mapStateToProps = (state: RootState): MainPanelRootDataProps => {
16     return {
17         user: state.auth.user,
18         working: isSystemWorking(state.progressIndicator),
19         loading: isWorkbenchLoading(state),
20         buildInfo: state.appInfo.buildInfo,
21         uuidPrefix: state.auth.localCluster,
22         isNotLinking: state.linkAccountPanel.status === LinkAccountPanelStatus.NONE || state.linkAccountPanel.status === LinkAccountPanelStatus.INITIAL,
23         isLinkingPath: state.router.location ? matchLinkAccountRoute(state.router.location.pathname) !== null : false,
24         siteBanner: state.auth.config.clusterConfig.Workbench.SiteName,
25         sessionIdleTimeout: parse(state.auth.config.clusterConfig.Workbench.IdleTimeout, 's') || 0,
26         sidePanelIsCollapsed: state.sidePanel.collapsedState,
27     };
28 };
29
30 const mapDispatchToProps = (dispatch) => {
31     return {
32         toggleSidePanel: (collapsedState)=>{
33             return dispatch(toggleSidePanel(collapsedState))
34         }
35     }
36 };
37
38 export const MainPanel = connect(mapStateToProps, mapDispatchToProps)(MainPanelRoot);