a92e486ecf7f133c5092e62a2380a4898944bae9
[arvados-workbench2.git] / src / views / workbench / workbench.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
7 import { StyleRulesCallback, Theme, WithStyles, withStyles } from '@material-ui/core/styles';
8 import Drawer from '@material-ui/core/Drawer';
9 import AppBar from '@material-ui/core/AppBar';
10 import Toolbar from '@material-ui/core/Toolbar';
11 import Typography from '@material-ui/core/Typography';
12 import { connect } from "react-redux";
13 import Tree from "../../components/tree/tree";
14 import { Project } from "../../models/project";
15 import { RootState } from "../../store/root-reducer";
16
17 const drawerWidth = 240;
18
19 type CssRules = 'root' | 'appBar' | 'drawerPaper' | 'content' | 'toolbar';
20
21 const styles: StyleRulesCallback<CssRules> = (theme: Theme) => ({
22     root: {
23         flexGrow: 1,
24         zIndex: 1,
25         overflow: 'hidden',
26         position: 'relative',
27         display: 'flex',
28         width: '100%',
29         height: '100%'
30     },
31     appBar: {
32         zIndex: theme.zIndex.drawer + 1,
33         backgroundColor: '#692498'
34     },
35     drawerPaper: {
36         position: 'relative',
37         width: drawerWidth,
38     },
39     content: {
40         flexGrow: 1,
41         backgroundColor: theme.palette.background.default,
42         padding: theme.spacing.unit * 3,
43         minWidth: 0,
44     },
45     toolbar: theme.mixins.toolbar
46 });
47
48 interface WorkbenchProps {
49     projects: Project[]
50 }
51
52 interface WorkbenchState {
53 }
54
55 class Workbench extends React.Component<WorkbenchProps & WithStyles<CssRules>, WorkbenchState> {
56     render() {
57         const {classes} = this.props;
58
59         return (
60             <div className={classes.root}>
61                 <AppBar position="absolute" className={classes.appBar}>
62                     <Toolbar>
63                         <Typography variant="title" color="inherit" noWrap>
64                             Arvados<br/>Workbench 2
65                         </Typography>
66                     </Toolbar>
67                 </AppBar>
68                 <Drawer
69                     variant="permanent"
70                     classes={{
71                         paper: classes.drawerPaper,
72                     }}>
73                     <div className={classes.toolbar}/>
74                     <Tree items={this.props.projects} render={(p: Project) =>
75                         <span>{p.name}</span>
76                     }/>
77                 </Drawer>
78                 <main className={classes.content}>
79                     <div className={classes.toolbar}/>
80                     <Typography noWrap>Hello new workbench!</Typography>
81                 </main>
82             </div>
83         );
84     }
85 }
86
87 export default connect<WorkbenchProps>(
88     (state: RootState) => ({
89         projects: state.projects
90     })
91 )(
92     withStyles(styles)(Workbench)
93 );