Merge branch '21764-project-picker-crash' into main. Closes #21764
[arvados.git] / services / workbench2 / 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/side-panel/side-panel-action";
14 import { propertiesActions } from 'store/properties/properties-actions';
15
16 const mapStateToProps = (state: RootState): MainPanelRootDataProps => {
17     return {
18         user: state.auth.user,
19         working: isSystemWorking(state.progressIndicator),
20         loading: isWorkbenchLoading(state),
21         buildInfo: state.appInfo.buildInfo,
22         uuidPrefix: state.auth.localCluster,
23         isNotLinking: state.linkAccountPanel.status === LinkAccountPanelStatus.NONE || state.linkAccountPanel.status === LinkAccountPanelStatus.INITIAL,
24         isLinkingPath: state.router.location ? matchLinkAccountRoute(state.router.location.pathname) !== null : false,
25         siteBanner: state.auth.config.clusterConfig.Workbench.SiteName,
26         sessionIdleTimeout: parse(state.auth.config.clusterConfig.Workbench.IdleTimeout, 's') || 0,
27         sidePanelIsCollapsed: state.sidePanel.collapsedState,
28         isTransitioning: state.detailsPanel.isTransitioning,
29         currentSideWidth: state.sidePanel.currentSideWidth,
30         currentRoute: state.router.location ? state.router.location.pathname : '',
31     };
32 };
33
34 const mapDispatchToProps = (dispatch) => {
35     return {
36         toggleSidePanel: (collapsedState)=>{
37             return dispatch(toggleSidePanel(collapsedState))
38         },
39         setCurrentRouteUuid: (uuid: string) => {
40             return dispatch(propertiesActions.SET_PROPERTY({key: 'currentRouteUuid', value: uuid}))}
41     }
42 };
43
44 export const MainPanel = connect(mapStateToProps, mapDispatchToProps)(MainPanelRoot);