15685: Adds missing redux-form configs for immediate validation feedback.
[arvados.git] / src / views-components / main-app-bar / main-app-bar.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 { AppBar, Toolbar, Typography, Grid } from "@material-ui/core";
7 import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core/styles';
8 import { Link } from "react-router-dom";
9 import { User } from "~/models/user";
10 import { SearchBar } from "~/views-components/search-bar/search-bar";
11 import { Routes } from '~/routes/routes';
12 import { NotificationsMenu } from "~/views-components/main-app-bar/notifications-menu";
13 import { AccountMenu } from "~/views-components/main-app-bar/account-menu";
14 import { HelpMenu } from '~/views-components/main-app-bar/help-menu';
15 import { ReactNode } from "react";
16 import { AdminMenu } from "~/views-components/main-app-bar/admin-menu";
17
18 type CssRules = 'toolbar' | 'link';
19
20 const styles: StyleRulesCallback<CssRules> = () => ({
21     link: {
22         textDecoration: 'none',
23         color: 'inherit'
24     },
25     toolbar: {
26         height: '56px'
27     }
28 });
29
30 interface MainAppBarDataProps {
31     user?: User;
32     buildInfo?: string;
33     children?: ReactNode;
34     uuidPrefix: string;
35     siteBanner: string;
36 }
37
38 export type MainAppBarProps = MainAppBarDataProps & WithStyles<CssRules>;
39
40 export const MainAppBar = withStyles(styles)(
41     (props: MainAppBarProps) => {
42         return <AppBar position="absolute">
43             <Toolbar className={props.classes.toolbar}>
44                 <Grid container justify="space-between">
45                     <Grid container item xs={3} direction="column" justify="center">
46                         <Typography variant='h6' color="inherit" noWrap>
47                             <Link to={Routes.ROOT} className={props.classes.link}>
48                                 <span dangerouslySetInnerHTML={{ __html: props.siteBanner }} /> ({props.uuidPrefix})
49                             </Link>
50                         </Typography>
51                         <Typography variant="caption" color="inherit">{props.buildInfo}</Typography>
52                     </Grid>
53                     <Grid
54                         item
55                         xs={6}
56                         container
57                         alignItems="center">
58                         {props.user && props.user.isActive && <SearchBar />}
59                     </Grid>
60                     <Grid
61                         item
62                         xs={3}
63                         container
64                         alignItems="center"
65                         justify="flex-end"
66                         wrap="nowrap">
67                         {props.user
68                             ? <>
69                                 <NotificationsMenu />
70                                 <AccountMenu />
71                                 {props.user.isAdmin && <AdminMenu />}
72                                 <HelpMenu />
73                             </>
74                             : <HelpMenu />}
75                     </Grid>
76                 </Grid>
77             </Toolbar>
78             {props.children}
79         </AppBar>;
80     }
81 );