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