14720: Federated login chooser wip
[arvados.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 { WorkbenchLoadingScreen } from '~/views/workbench/workbench-loading-screen';
12 import { MainAppBar } from '~/views-components/main-app-bar/main-app-bar';
13
14 type CssRules = 'root';
15
16 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
17     root: {
18         overflow: 'hidden',
19         width: '100vw',
20         height: '100vh'
21     }
22 });
23
24 export interface MainPanelRootDataProps {
25     user?: User;
26     working: boolean;
27     loading: boolean;
28     buildInfo: string;
29     uuidPrefix: string;
30 }
31
32 type MainPanelRootProps = MainPanelRootDataProps & WithStyles<CssRules>;
33
34 export const MainPanelRoot = withStyles(styles)(
35     ({ classes, loading, working, user, buildInfo, uuidPrefix }: MainPanelRootProps) =>
36         loading
37             ? <WorkbenchLoadingScreen />
38             : <>
39                 <MainAppBar
40                     user={user}
41                     buildInfo={buildInfo}
42                     uuidPrefix={uuidPrefix}>
43                     {working ? <LinearProgress color="secondary" /> : null}
44                 </MainAppBar>
45                 <Grid container direction="column" className={classes.root}>
46                     {user ? <WorkbenchPanel /> : <LoginPanel />}
47                 </Grid>
48             </>
49 );