X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/353db93c2540a989d3bdd3f695ee07e707bdaf7a..c69c6d43021b29186717ad30bea95cf50ee8c1e6:/src/components/tree/tree.tsx diff --git a/src/components/tree/tree.tsx b/src/components/tree/tree.tsx index 2089d1cb..fc9dbc74 100644 --- a/src/components/tree/tree.tsx +++ b/src/components/tree/tree.tsx @@ -2,16 +2,18 @@ // // SPDX-License-Identifier: AGPL-3.0 -import * as React from 'react'; +import React from 'react'; import { List, ListItem, ListItemIcon, Checkbox, Radio, Collapse } from "@material-ui/core"; import { StyleRulesCallback, withStyles, WithStyles } from '@material-ui/core/styles'; -import { ProjectIcon } from '~/components/icon/icon'; +import { CollectionIcon, DefaultIcon, DirectoryIcon, FileIcon, ProjectIcon, FilterGroupIcon } from 'components/icon/icon'; import { ReactElement } from "react"; import CircularProgress from '@material-ui/core/CircularProgress'; import classnames from "classnames"; -import { ArvadosTheme } from '~/common/custom-theme'; +import { ArvadosTheme } from 'common/custom-theme'; import { SidePanelRightArrowIcon } from '../icon/icon'; +import { ResourceKind } from 'models/resource'; +import { GroupClass } from 'models/group'; type CssRules = 'list' | 'listItem' @@ -95,6 +97,8 @@ export interface TreeItem { open: boolean; active: boolean; selected?: boolean; + initialState?: boolean; + indeterminate?: boolean; flatTree?: boolean; status: TreeItemStatus; items?: Array>; @@ -153,6 +157,9 @@ interface FlatTreeProps { getProperArrowAnimation: Function; itemsMap?: Map>; classes: any; + showSelection: any; + useRadioButtons?: boolean; + handleCheckboxChange: Function; } const FLAT_TREE_ACTIONS = { @@ -161,10 +168,43 @@ const FLAT_TREE_ACTIONS = { toggleActive: 'TOGGLE_ACTIVE', }; +const ItemIcon = React.memo(({ type, kind, active, groupClass, classes }: any) => { + let Icon = ProjectIcon; + + if (groupClass === GroupClass.FILTER) { + Icon = FilterGroupIcon; + } + + if (type) { + switch (type) { + case 'directory': + Icon = DirectoryIcon; + break; + case 'file': + Icon = FileIcon; + break; + default: + Icon = DefaultIcon; + } + } + + if (kind) { + switch (kind) { + case ResourceKind.COLLECTION: + Icon = CollectionIcon; + break; + default: + break; + } + } + + return ; +}); + const FlatTree = (props: FlatTreeProps) =>
{ - const [action, id] = getActionAndId(event, FLAT_TREE_ACTIONS.contextMenu); + const id = getActionAndId(event, FLAT_TREE_ACTIONS.contextMenu)[1]; props.onContextMenu(event, { id } as any); }} onClick={(event) => { @@ -196,9 +236,20 @@ const FlatTree = (props: FlatTreeProps) => {props.getProperArrowAnimation(item.status, item.items!)} + {props.showSelection(item) && !props.useRadioButtons && + } + {props.showSelection(item) && props.useRadioButtons && + }
- + {item.data.name} @@ -243,6 +294,7 @@ export const Tree = withStyles(styles)( {showSelection(it) && !useRadioButtons && } @@ -258,29 +310,32 @@ export const Tree = withStyles(styles)( { it.open && it.items && it.items.length > 0 && it.flatTree ? - : + + : - - - + toggleItemSelection={this.props.toggleItemSelection} /> + }
)} ;