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, WithStyles, withStyles } from '@material-ui/core/styles';
8 import { Tree, TreeItem, TreeItemStatus } from '~/components/tree/tree';
9 import { ProjectResource } from '~/models/project';
10 import { ProjectIcon } from '~/components/icon/icon';
11 import { ArvadosTheme } from '~/common/custom-theme';
12 import { ListItemTextIcon } from '~/components/list-item-text-icon/list-item-text-icon';
14 type CssRules = 'root';
16 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
18 marginLeft: `${theme.spacing.unit * 1.5}px`,
22 export interface ProjectTreeProps<T> {
23 projects: Array<TreeItem<ProjectResource>>;
24 toggleOpen: (event: React.MouseEvent<HTMLElement>, item: TreeItem<T>) => void;
25 toggleActive: (event: React.MouseEvent<HTMLElement>, item: TreeItem<T>) => void;
26 onContextMenu: (event: React.MouseEvent<HTMLElement>, item: TreeItem<ProjectResource>) => void;
29 export const ProjectTree = withStyles(styles)(
30 class ProjectTreeGeneric<T> extends React.Component<ProjectTreeProps<T> & WithStyles<CssRules>> {
31 render(): ReactElement<any> {
32 const { classes, projects, toggleOpen, toggleActive, onContextMenu } = this.props;
34 <div className={classes.root}>
35 <Tree items={projects}
36 onContextMenu={onContextMenu}
37 toggleItemOpen={toggleOpen}
38 toggleItemActive={toggleActive}
40 (project: TreeItem<ProjectResource>) =>
43 name={project.data.name}
44 isActive={project.active}