change main app bar - remove props
[arvados-workbench2.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 "~/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 { AnonymousMenu } from "~/views-components/main-app-bar/anonymous-menu";
15 import { HelpMenu } from './help-menu';
16 import { ReactNode } from "react";
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     // searchText: string;
32     // searchDebounce?: number;
33     user?: User;
34     buildInfo?: string;
35     children?: ReactNode;
36 }
37
38 // export interface MainAppBarActionProps {
39 //     onSearch: (searchText: string) => void;
40 // }
41
42 export type MainAppBarProps = MainAppBarDataProps & WithStyles<CssRules>;
43
44 export const MainAppBar = withStyles(styles)(
45     (props: MainAppBarProps) => {
46         return <AppBar position="absolute">
47             <Toolbar className={props.classes.toolbar}>
48                 <Grid container justify="space-between">
49                     <Grid container item xs={3} direction="column" justify="center">
50                         <Typography variant="title" color="inherit" noWrap>
51                             <Link to={Routes.ROOT} className={props.classes.link}>
52                                 arvados workbench
53                             </Link>
54                         </Typography>
55                         <Typography variant="caption" color="inherit">{props.buildInfo}</Typography>
56                     </Grid>
57                     <Grid
58                         item
59                         xs={6}
60                         container
61                         alignItems="center">
62                         {/* {props.user && <SearchBar
63                             value={props.searchText}
64                             onSearch={props.onSearch}
65                             debounce={props.searchDebounce}
66                         />
67                         } */}
68                     </Grid>
69                     <Grid
70                         item
71                         xs={3}
72                         container
73                         alignItems="center"
74                         justify="flex-end"
75                         wrap="nowrap">
76                         {props.user
77                             ? <>
78                                 <NotificationsMenu />
79                                 <AccountMenu />
80                                 <HelpMenu />
81                             </>
82                             : <HelpMenu />}
83                     </Grid>
84                 </Grid>
85             </Toolbar>
86             {props.children}
87         </AppBar>;
88     }
89 );