X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/66088cabf30c5291ad8894e7009d9c9af466c158..73aff80c1f97e854203f75375dbef1924671667e:/services/workbench2/src/components/tree/tree.tsx diff --git a/services/workbench2/src/components/tree/tree.tsx b/services/workbench2/src/components/tree/tree.tsx index 28f1966aa1..1f7aa8326d 100644 --- a/services/workbench2/src/components/tree/tree.tsx +++ b/services/workbench2/src/components/tree/tree.tsx @@ -5,7 +5,7 @@ import React, { useCallback, useState } from 'react'; import { List, ListItem, ListItemIcon, Checkbox, Radio, Collapse } from "@material-ui/core"; import { StyleRulesCallback, withStyles, WithStyles } from '@material-ui/core/styles'; -import { CollectionIcon, DefaultIcon, DirectoryIcon, FileIcon, ProjectIcon, FilterGroupIcon, FreezeIcon } from 'components/icon/icon'; +import { CollectionIcon, DefaultIcon, DirectoryIcon, FileIcon, ProjectIcon, ProcessIcon, FilterGroupIcon, FreezeIcon } from 'components/icon/icon'; import { ReactElement } from "react"; import CircularProgress from '@material-ui/core/CircularProgress'; import classnames from "classnames"; @@ -14,6 +14,7 @@ import { ArvadosTheme } from 'common/custom-theme'; import { SidePanelRightArrowIcon } from '../icon/icon'; import { ResourceKind } from 'models/resource'; import { GroupClass } from 'models/group'; +import { SidePanelTreeCategory } from 'store/side-panel-tree/side-panel-tree-actions'; type CssRules = 'list' | 'listItem' @@ -27,7 +28,8 @@ type CssRules = 'list' | 'checkbox' | 'childItem' | 'childItemIcon' - | 'frozenIcon'; + | 'frozenIcon' + | 'indentSpacer'; const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ list: { @@ -45,9 +47,10 @@ const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ color: theme.palette.grey["700"], height: '14px', width: '14px', + marginBottom: '0.4rem', }, toggableIcon: { - fontSize: '14px' + fontSize: '14px', }, renderContainer: { flex: 1 @@ -89,6 +92,9 @@ const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ color: theme.palette.grey["600"], marginLeft: '10px', }, + indentSpacer: { + width: '0.25rem' + } }); export enum TreeItemStatus { @@ -99,6 +105,7 @@ export enum TreeItemStatus { export interface TreeItem { data: T; + depth?: number; id: string; open: boolean; active: boolean; @@ -155,6 +162,10 @@ const getActionAndId = (event: any, initAction: string | undefined = undefined) return [action, id]; }; +const isInFavoritesTree = (item: TreeItem): boolean => { + return item.id === SidePanelTreeCategory.FAVORITES || item.id === SidePanelTreeCategory.PUBLIC_FAVORITES; +} + interface FlatTreeProps { it: TreeItem; levelIndentation: number; @@ -177,7 +188,7 @@ const FLAT_TREE_ACTIONS = { toggleActive: 'TOGGLE_ACTIVE', }; -const ItemIcon = React.memo(({ type, kind, active, groupClass, classes }: any) => { +const ItemIcon = React.memo(({ type, kind, headKind, active, groupClass, classes }: any) => { let Icon = ProjectIcon; if (groupClass === GroupClass.FILTER) { @@ -198,10 +209,14 @@ const ItemIcon = React.memo(({ type, kind, active, groupClass, classes }: any) = } if (kind) { + if(kind === ResourceKind.LINK && headKind) kind = headKind; switch (kind) { case ResourceKind.COLLECTION: Icon = CollectionIcon; break; + case ResourceKind.CONTAINER_REQUEST: + Icon = ProcessIcon; + break; default: break; } @@ -237,14 +252,17 @@ const FlatTree = (props: FlatTreeProps) => > { (props.it.items || []) - .map((item: any) =>
- - - {props.getProperArrowAnimation(item.status, item.items!)} - - + {isInFavoritesTree(props.it) ? +
+ : + + + {props.getProperArrowAnimation(item.status, item.items!)} + + } {props.showSelection(item) && !props.useRadioButtons && color="primary" />}
- + {item.data.name} @@ -326,6 +344,9 @@ export const Tree = withStyles(styles)( const { levelIndentation = 20, itemRightPadding = 20 } = props; return {items && items.map((it: TreeItem, idx: number) => { + if (isInFavoritesTree(it) && it.open === true && it.items && it.items.length) { + it = { ...it, items: it.items.filter(item => item.depth && item.depth < 3) } + } return