Merge branch '17256-File-selection-dialog-browser-tests'
authorDaniel Kutyła <daniel.kutyla@contractors.roche.com>
Mon, 25 Jan 2021 21:03:25 +0000 (22:03 +0100)
committerDaniel Kutyła <daniel.kutyla@contractors.roche.com>
Mon, 25 Jan 2021 21:03:37 +0000 (22:03 +0100)
closes #17256

Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla@contractors.roche.com>

src/components/icon/icon.tsx
src/components/tree/tree.tsx

index bceee5043589c0d8b94b0e278fe8543177ff373e..9eb60332e7261e0ba75f40bc62334432d988c4ff 100644 (file)
@@ -10,6 +10,7 @@ import ArrowDropDown from '@material-ui/icons/ArrowDropDown';
 import BubbleChart from '@material-ui/icons/BubbleChart';
 import Build from '@material-ui/icons/Build';
 import Cached from '@material-ui/icons/Cached';
+import DescriptionIcon from '@material-ui/icons/Description';
 import ChevronLeft from '@material-ui/icons/ChevronLeft';
 import CloudUpload from '@material-ui/icons/CloudUpload';
 import Code from '@material-ui/icons/Code';
@@ -106,7 +107,7 @@ export const EditSavedQueryIcon: IconType = (props) => <Create {...props} />;
 export const ExpandIcon: IconType = (props) => <ExpandMoreIcon {...props} />;
 export const ErrorIcon: IconType = (props) => <ErrorRoundedIcon style={{ color: '#ff0000' }} {...props} />;
 export const FavoriteIcon: IconType = (props) => <Star {...props} />;
-export const FileIcon: IconType = (props) => <LibraryBooks {...props} />;
+export const FileIcon: IconType = (props) => <DescriptionIcon {...props} />;
 export const HelpIcon: IconType = (props) => <Help {...props} />;
 export const HelpOutlineIcon: IconType = (props) => <HelpOutline {...props} />;
 export const ImportContactsIcon: IconType = (props) => <ImportContacts {...props} />;
index 2089d1cb54d1e86b0deead0297b5f9f6aa852111..908ee28ca8b24a139c21ef76358a6cbeaa723c5b 100644 (file)
@@ -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>