X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/9b423a1e4ac7aa6077399da13a3d786df0eed11c..ceca6c57cc7d0357ab74abd47b80633a885ec575:/src/components/file-tree/file-tree-item.tsx

diff --git a/src/components/file-tree/file-tree-item.tsx b/src/components/file-tree/file-tree-item.tsx
index e65c6cdf..98164ad4 100644
--- a/src/components/file-tree/file-tree-item.tsx
+++ b/src/components/file-tree/file-tree-item.tsx
@@ -4,29 +4,33 @@
 
 import * as React from "react";
 import { TreeItem } from "../tree/tree";
-import { ProjectIcon, MoreOptionsIcon } from "../icon/icon";
-import { Typography, IconButton, StyleRulesCallback, withStyles, WithStyles } from "@material-ui/core";
-import { formatFileSize } from "../../common/formatters";
+import { ProjectIcon, MoreOptionsIcon, DefaultIcon, CollectionIcon } from "../icon/icon";
+import { Typography, IconButton, StyleRulesCallback, withStyles, WithStyles, Tooltip } from '@material-ui/core';
+import { formatFileSize } from "~/common/formatters";
 import { ListItemTextIcon } from "../list-item-text-icon/list-item-text-icon";
 import { FileTreeData } from "./file-tree-data";
 
-type CssRules = "root" | "spacer" | "sizeInfo" | "button";
+type CssRules = "root" | "spacer" | "sizeInfo" | "button" | "moreOptions";
 
 const fileTreeItemStyle: StyleRulesCallback<CssRules> = theme => ({
     root: {
         display: "flex",
         alignItems: "center",
-        paddingRight: `${theme.spacing.unit}px`
+        paddingRight: `${theme.spacing.unit * 1.5}px`
     },
     spacer: {
         flex: "1"
     },
     sizeInfo: {
-        marginRight: `${theme.spacing.unit * 3}px`
+        width: `${theme.spacing.unit * 8}px`
     },
     button: {
         width: theme.spacing.unit * 3,
-        height: theme.spacing.unit * 3
+        height: theme.spacing.unit * 3,
+        marginRight: theme.spacing.unit,
+    },
+    moreOptions: {
+        position: 'absolute'
     }
 });
 
@@ -40,17 +44,19 @@ export const FileTreeItem = withStyles(fileTreeItemStyle)(
             const { classes, item } = this.props;
             return <div className={classes.root}>
                 <ListItemTextIcon
-                    icon={ProjectIcon}
+                    icon={getIcon(item)}
                     name={item.data.name} />
                 <div className={classes.spacer} />
                 <Typography
                     className={classes.sizeInfo}
                     variant="caption">{formatFileSize(item.data.size)}</Typography>
-                <IconButton
-                    className={classes.button}
-                    onClick={this.handleClick}>
-                    <MoreOptionsIcon />
-                </IconButton>
+                <Tooltip title="More options">
+                    <IconButton
+                        className={classes.button}
+                        onClick={this.handleClick}>
+                        <MoreOptionsIcon className={classes.moreOptions}/>
+                    </IconButton>
+                </Tooltip>
             </div >;
         }
 
@@ -59,3 +65,14 @@ export const FileTreeItem = withStyles(fileTreeItemStyle)(
         }
     });
 
+const getIcon = (item: TreeItem<FileTreeData>) => {
+    switch (item.data.type) {
+        case 'directory':
+            return ProjectIcon;
+        case 'file':
+            return CollectionIcon;
+        default:
+            return DefaultIcon;
+    }
+};
+
