14841: Add inactive user page.
[arvados-workbench2.git] / src / views / main-panel / main-panel-root.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import * as React 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
15 type CssRules = 'root';
16
17 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
18     root: {
19         overflow: 'hidden',
20         width: '100vw',
21         height: '100vh'
22     }
23 });
24
25 export interface MainPanelRootDataProps {
26     user?: User;
27     working: boolean;
28     loading: boolean;
29     buildInfo: string;
30     uuidPrefix: string;
31 }
32
33 type MainPanelRootProps = MainPanelRootDataProps & WithStyles<CssRules>;
34
35 export const MainPanelRoot = withStyles(styles)(
36     ({ classes, loading, working, user, buildInfo, uuidPrefix }: MainPanelRootProps) =>
37         loading
38             ? <WorkbenchLoadingScreen />
39             : <>
40                 <MainAppBar
41                     user={user}
42                     buildInfo={buildInfo}
43                     uuidPrefix={uuidPrefix}>
44                     {working ? <LinearProgress color="secondary" /> : null}
45                 </MainAppBar>
46                 <Grid container direction="column" className={classes.root}>
47                     {user ? (user.isActive ? <WorkbenchPanel /> : <InactivePanel />) : <LoginPanel />}
48                 </Grid>
49             </>
50 );