51287fa8c00c4445a573e837232262a435580b63
[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 import { LinkAccountPanel } from '~/views/link-account-panel/link-account-panel';
15
16 type CssRules = 'root';
17
18 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
19     root: {
20         overflow: 'hidden',
21         width: '100vw',
22         height: '100vh'
23     }
24 });
25
26 export interface MainPanelRootDataProps {
27     user?: User;
28     working: boolean;
29     loading: boolean;
30     buildInfo: string;
31     uuidPrefix: string;
32     isNotLinking: boolean;
33 }
34
35 type MainPanelRootProps = MainPanelRootDataProps & WithStyles<CssRules>;
36
37 export const MainPanelRoot = withStyles(styles)(
38     ({ classes, loading, working, user, buildInfo, uuidPrefix, isNotLinking }: MainPanelRootProps) =>
39         loading
40             ? <WorkbenchLoadingScreen />
41             : <> { isNotLinking ? <>
42                <MainAppBar
43                     user={user}
44                     buildInfo={buildInfo}
45                     uuidPrefix={uuidPrefix}>
46                     {working ? <LinearProgress color="secondary" /> : null}
47                 </MainAppBar>
48                 <Grid container direction="column" className={classes.root}>
49                     { user ? (user.isActive ? <WorkbenchPanel /> : <InactivePanel />) : <LoginPanel />}
50                </Grid>
51             </> : user ? <LinkAccountPanel/> : <LoginPanel /> } </>
52 );