1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from 'react';
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, { TreeItem } from "../../components/tree/tree";
14 import { Project } from "../../models/project";
15 import { RootState } from "../../store/root-reducer";
16 import ProjectList from "../../components/project-list/project-list";
17 import { Route, Switch } from "react-router";
18 import { Link } from "react-router-dom";
20 import { actions as projectActions } from "../../store/project-action";
21 import ListItemText from "@material-ui/core/ListItemText/ListItemText";
22 import ListItemIcon from '@material-ui/core/ListItemIcon';
24 const drawerWidth = 240;
26 type CssRules = 'root' | 'appBar' | 'drawerPaper' | 'content' | 'row' | 'toolbar';
28 const styles: StyleRulesCallback<CssRules> = (theme: Theme) => ({
39 zIndex: theme.zIndex.drawer + 1,
40 backgroundColor: '#692498'
48 backgroundColor: theme.palette.background.default,
49 padding: theme.spacing.unit * 3,
55 toolbar: theme.mixins.toolbar
58 interface WorkbenchProps {
59 projects: Array<TreeItem<Project>>;
60 toggleProjectTreeItem: (id: string) => any;
63 interface WorkbenchState {
66 class Workbench extends React.Component<WorkbenchProps & WithStyles<CssRules>, WorkbenchState> {
68 const {classes, projects} = this.props;
70 <div className={classes.root}>
71 <AppBar position="absolute" className={classes.appBar}>
73 <Typography variant="title" color="inherit" noWrap>
74 Arvados<br/>Workbench 2
81 paper: classes.drawerPaper,
83 <div className={classes.toolbar}/>
84 <Tree items={projects}
85 toggleItem={this.props.toggleProjectTreeItem}
86 render={(p: Project) => <span className={classes.row}>
87 <div style={{marginTop: "3px"}}><ListItemIcon>{p.icon}</ListItemIcon></div>
88 <div><ListItemText primary={p.name}/></div>
92 <main className={classes.content}>
93 <div className={classes.toolbar}/>
95 <Route exact path="/">
96 <Typography noWrap>Hello new workbench!</Typography>
98 <Route path="/project/:name" component={ProjectList}/>
106 export default connect(
107 (state: RootState) => ({
108 projects: state.projects
110 toggleProjectTreeItem: (id: string) => projectActions.toggleProjectTreeItem(id)
113 withStyles(styles)(Workbench)