X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/9e4b7889a99ff2f76d8029aef3a85c4620178ba3..1a1007b664c6158c905a2fbfa998e7a5737ab7e1:/src/views-components/project-tree/project-tree.tsx

diff --git a/src/views-components/project-tree/project-tree.tsx b/src/views-components/project-tree/project-tree.tsx
index fd32ff040d..411e6dd76f 100644
--- a/src/views-components/project-tree/project-tree.tsx
+++ b/src/views-components/project-tree/project-tree.tsx
@@ -5,64 +5,43 @@
 import * as React from 'react';
 import { ReactElement } from 'react';
 import { StyleRulesCallback, Theme, WithStyles, withStyles } from '@material-ui/core/styles';
-import ListItemText from "@material-ui/core/ListItemText/ListItemText";
-import ListItemIcon from '@material-ui/core/ListItemIcon';
-import Typography from '@material-ui/core/Typography';
-
 import Tree, { TreeItem, TreeItemStatus } from '../../components/tree/tree';
-import { Project } from '../../models/project';
-
-type CssRules = 'active' | 'listItemText' | 'row' | 'treeContainer';
-
-const styles: StyleRulesCallback<CssRules> = (theme: Theme) => ({
-    active: {
-        color: '#4285F6',
-    },
-    listItemText: {
-        padding: '0px',
-    },
-    row: {
-        display: 'flex',
-        alignItems: 'center',
-        marginLeft: '20px',
-    },
-    treeContainer: {
-        marginTop: '37px',
-        overflowX: 'visible',
-        overflowY: 'auto',
-        minWidth: '240px',
-        whiteSpace: 'nowrap',
-    }
-});
+import { ProjectResource } from '../../models/project';
+import { ProjectIcon } from '../../components/icon/icon';
+import { ArvadosTheme } from '../../common/custom-theme';
+import SingleListItem from '../../components/single-list-item/single-list-item';
 
 export interface ProjectTreeProps {
-    projects: Array<TreeItem<Project>>;
-    toggleProjectTreeItem: (id: string, status: TreeItemStatus) => void;
+    projects: Array<TreeItem<ProjectResource>>;
+    toggleOpen: (id: string, status: TreeItemStatus) => void;
+    toggleActive: (id: string, status: TreeItemStatus) => void;
+    onContextMenu: (event: React.MouseEvent<HTMLElement>, item: TreeItem<ProjectResource>) => void;
 }
 
 class ProjectTree<T> extends React.Component<ProjectTreeProps & WithStyles<CssRules>> {
     render(): ReactElement<any> {
-        const {classes, projects} = this.props;
-        const {active, listItemText, row, treeContainer} = classes;
+        const { classes, projects, toggleOpen, toggleActive, onContextMenu } = this.props;
         return (
-            <div className={treeContainer}>
+            <div className={classes.root}>
                 <Tree items={projects}
-                    toggleItem={this.props.toggleProjectTreeItem}
-                    render={(project: TreeItem<Project>, level: number) =>
-                        <span className={row}>
-                            <ListItemIcon className={project.active ? active : ''}>
-                                {level === 0 ? <i className="fas fa-th"/> : <i className="fas fa-folder"/>}
-                            </ListItemIcon>
-                            <ListItemText className={listItemText} primary={
-                                <Typography className={project.active ? active : ''}>
-                                    {project.data.name}
-                                </Typography>
-                            }/>
-                        </span>
+                    onContextMenu={onContextMenu}
+                    toggleItemOpen={toggleOpen}
+                    toggleItemActive={toggleActive}
+                    render={
+                        (project: TreeItem<ProjectResource>) =>
+                            <SingleListItem icon={ProjectIcon} name={project.data.name} isActive={project.active} hasMargin={true} />
                     }/>
             </div>
         );
     }
 }
 
+type CssRules = 'root';
+
+const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
+    root: {
+        marginLeft: `${theme.spacing.unit * 1.5}px`,
+    }
+});
+
 export default withStyles(styles)(ProjectTree);
