16086: Adds default value on string array validator.
[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     siteBanner: string;
34 }
35
36 type MainPanelRootProps = MainPanelRootDataProps & WithStyles<CssRules>;
37
38 export const MainPanelRoot = withStyles(styles)(
39     ({ classes, loading, working, user, buildInfo, uuidPrefix,
40         isNotLinking, isLinkingPath, siteBanner }: MainPanelRootProps) =>
41         loading
42             ? <WorkbenchLoadingScreen />
43             : <>
44                 {isNotLinking && <MainAppBar
45                     user={user}
46                     buildInfo={buildInfo}
47                     uuidPrefix={uuidPrefix}
48                     siteBanner={siteBanner}>
49                     {working ? <LinearProgress color="secondary" /> : null}
50                 </MainAppBar>}
51                 <Grid container direction="column" className={classes.root}>
52                     {user ? (user.isActive || (!user.isActive && isLinkingPath) ? <WorkbenchPanel isNotLinking={isNotLinking} isUserActive={user.isActive} /> : <InactivePanel />) : <LoginPanel />}
53                 </Grid>
54             </>
55 );