1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React, { useEffect } from 'react';
6 import { StyleRulesCallback, WithStyles, withStyles, Grid, LinearProgress } from '@material-ui/core';
7 import { User } from "models/user";
8 import { ArvadosTheme } from 'common/custom-theme';
9 import { WorkbenchPanel } from 'views/workbench/workbench';
10 import { LoginPanel } from 'views/login-panel/login-panel';
11 import { InactivePanel } from 'views/inactive-panel/inactive-panel';
12 import { WorkbenchLoadingScreen } from 'views/workbench/workbench-loading-screen';
13 import { MainAppBar } from 'views-components/main-app-bar/main-app-bar';
14 import { Routes } from 'routes/routes';
16 type CssRules = 'root';
18 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
26 export interface MainPanelRootDataProps {
32 isNotLinking: boolean;
33 isLinkingPath: boolean;
35 sessionIdleTimeout: number;
36 sidePanelIsCollapsed: boolean;
37 isTransitioning: boolean;
38 currentSideWidth: number;
42 interface MainPanelRootDispatchProps {
43 toggleSidePanel: () => void,
44 setCurrentRouteUuid: (uuid: string | null) => void;
47 type MainPanelRootProps = MainPanelRootDataProps & MainPanelRootDispatchProps & WithStyles<CssRules>;
49 export const MainPanelRoot = withStyles(styles)(
50 ({ classes, loading, working, user, buildInfo, uuidPrefix,
51 isNotLinking, isLinkingPath, siteBanner, sessionIdleTimeout,
52 sidePanelIsCollapsed, isTransitioning, currentSideWidth, currentRoute, setCurrentRouteUuid}: MainPanelRootProps) =>{
55 const splitRoute = currentRoute.split('/');
56 const uuid = splitRoute[splitRoute.length - 1];
57 if(Object.values(Routes).includes(`/${uuid}`) === false) {
58 setCurrentRouteUuid(uuid);
60 setCurrentRouteUuid(null);
62 // eslint-disable-next-line react-hooks/exhaustive-deps
66 ? <WorkbenchLoadingScreen />
68 {isNotLinking && <MainAppBar
71 uuidPrefix={uuidPrefix}
72 siteBanner={siteBanner}
73 sidePanelIsCollapsed={sidePanelIsCollapsed}
76 ? <LinearProgress color="secondary" data-cy="linear-progress" />
79 <Grid container direction="column" className={classes.root}>
81 ? (user.isActive || (!user.isActive && isLinkingPath)
83 isNotLinking={isNotLinking}
84 isUserActive={user.isActive}
85 sessionIdleTimeout={sessionIdleTimeout}
86 sidePanelIsCollapsed={sidePanelIsCollapsed}
87 isTransitioning={isTransitioning}
88 currentSideWidth={currentSideWidth}/>