[ARVADOS-WORKBENCH2] created: 2.1.0-171-g534df712

Git user git at public.arvados.org
Thu Jan 21 20:58:36 UTC 2021


        at  534df712c4cfc3f6574dee1f4906bb7f6cc70be9 (commit)


commit 534df712c4cfc3f6574dee1f4906bb7f6cc70be9
Author: Daniel Kutyła <daniel.kutyla at contractors.roche.com>
Date:   Thu Jan 21 21:56:38 2021 +0100

    17264: Added generic component to get resource icon
    
    Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla at contractors.roche.com>

diff --git a/src/components/tree/tree.tsx b/src/components/tree/tree.tsx
index 2089d1cb..908ee28c 100644
--- a/src/components/tree/tree.tsx
+++ b/src/components/tree/tree.tsx
@@ -5,13 +5,14 @@
 import * as 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 } 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 { SidePanelRightArrowIcon } from '../icon/icon';
+import { ResourceKind } from '~/models/resource';
 
 type CssRules = 'list'
     | 'listItem'
@@ -161,6 +162,35 @@ const FLAT_TREE_ACTIONS = {
     toggleActive: 'TOGGLE_ACTIVE',
 };
 
+const ItemIcon = React.memo(({type, kind, active, classes}: any) => {
+    let Icon = ProjectIcon;
+
+        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 <Icon className={classnames({ [classes.active]: active }, classes.childItemIcon)} />;
+});
+
 const FlatTree = (props: FlatTreeProps) =>
     <div
         onContextMenu={(event) => {
@@ -198,7 +228,7 @@ const FlatTree = (props: FlatTreeProps) =>
                     </i>
                     <div data-action={FLAT_TREE_ACTIONS.toggleActive} className={props.classes.renderContainer}>
                         <span style={{ display: 'flex', alignItems: 'center' }}>
-                            <ProjectIcon className={classnames({ [props.classes.active]: item.active }, props.classes.childItemIcon)} />
+                            <ItemIcon type={item.data.type} active={item.active} kind={item.data.kind} classes={props.classes} />
                             <span style={{ fontSize: '0.875rem' }}>
                                 {item.data.name}
                             </span>

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list