1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from 'react';
6 import { ReactElement } from 'react';
7 import { StyleRulesCallback, Theme, WithStyles, withStyles } from '@material-ui/core/styles';
8 import ListItemText from "@material-ui/core/ListItemText/ListItemText";
9 import ListItemIcon from '@material-ui/core/ListItemIcon';
10 import Typography from '@material-ui/core/Typography';
12 import Tree, { TreeItem } from '../tree/tree';
13 import { Project } from '../../models/project';
15 type CssRules = 'active' | 'listItemText' | 'row' | 'treeContainer';
17 const styles: StyleRulesCallback<CssRules> = (theme: Theme) => ({
38 export interface ProjectTreeProps {
39 projects: Array<TreeItem<Project>>;
40 toggleProjectTreeItem: (id: string) => void;
43 class ProjectTree<T> extends React.Component<ProjectTreeProps & WithStyles<CssRules>> {
44 render(): ReactElement<any> {
45 const {classes, projects} = this.props;
46 const {active, listItemText, row, treeContainer} = classes;
48 <div className={treeContainer}>
49 <Tree items={projects}
50 toggleItem={this.props.toggleProjectTreeItem}
51 render={(project: TreeItem<Project>, level: number) =>
52 <span className={row}>
53 <ListItemIcon className={project.active ? active : ''}>
54 {level === 0 ? <i className="fas fa-th"/> : <i className="fas fa-folder"/>}
56 <ListItemText className={listItemText} primary={
57 <Typography className={project.active ? active : ''}>
68 export default withStyles(styles)(ProjectTree);