15027: Cleans up unused imports.
[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     isNotLinking: boolean;
32     isLinkingPath: boolean;
33 }
34
35 type MainPanelRootProps = MainPanelRootDataProps & WithStyles<CssRules>;
36
37 export const MainPanelRoot = withStyles(styles)(
38     ({ classes, loading, working, user, buildInfo, uuidPrefix, isNotLinking, isLinkingPath }: MainPanelRootProps) =>
39         loading
40             ? <WorkbenchLoadingScreen />
41             : <>
42                { isNotLinking && <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 || (!user.isActive && isLinkingPath) ? <WorkbenchPanel isNotLinking={isNotLinking} isUserActive={user.isActive} /> : <InactivePanel />) : <LoginPanel /> }
50                 </Grid>
51             </>
52 );