X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/9a59fad2b6a97af963728a5111395f9caa71802f..59171e2cf2ce2740825be7b19d580a2bfa0081f5:/src/components/collection-panel-files/collection-panel-files.tsx?ds=sidebyside

diff --git a/src/components/collection-panel-files/collection-panel-files.tsx b/src/components/collection-panel-files/collection-panel-files.tsx
index 42408270..4b631a6a 100644
--- a/src/components/collection-panel-files/collection-panel-files.tsx
+++ b/src/components/collection-panel-files/collection-panel-files.tsx
@@ -8,7 +8,7 @@ import { connect } from 'react-redux';
 import { FixedSizeList } from "react-window";
 import AutoSizer from "react-virtualized-auto-sizer";
 import servicesProvider from 'common/service-provider';
-import { CustomizeTableIcon, DownloadIcon } from 'components/icon/icon';
+import { CustomizeTableIcon, DownloadIcon, MoreOptionsIcon } from 'components/icon/icon';
 import { SearchInput } from 'components/search-input/search-input';
 import {
     ListItemIcon,
@@ -60,6 +60,8 @@ type CssRules = "backButton"
     | "pathPanelPathWrapper"
     | "uploadButton"
     | "uploadIcon"
+    | "moreOptionsButton"
+    | "moreOptions"
     | "loader"
     | "wrapper"
     | "dataWrapper"
@@ -207,7 +209,18 @@ const styles: StyleRulesCallback<CssRules> = (theme: Theme) => ({
     },
     uploadButton: {
         float: 'right',
-    }
+    },
+    moreOptionsButton: {
+        width: theme.spacing.unit * 3,
+        height: theme.spacing.unit * 3,
+        marginRight: theme.spacing.unit,
+        marginTop: 'auto',
+        marginBottom: 'auto',
+        justifyContent: 'center',
+    },
+    moreOptions: {
+        position: 'absolute'
+    },
 });
 
 const pathPromise = {};
@@ -375,17 +388,23 @@ export const CollectionPanelFiles = withStyles(styles)(connect((state: RootState
     const handleClick = React.useCallback(
         (event: any) => {
             let isCheckbox = false;
+            let isMoreButton = false;
             let elem = event.target;
 
             if (elem.type === 'checkbox') {
                 isCheckbox = true;
             }
+            // The "More options" button click event could be triggered on its
+            // internal graphic element.
+            else if ((elem.dataset && elem.dataset.id === 'moreOptions') || (elem.parentNode && elem.parentNode.dataset && elem.parentNode.dataset.id === 'moreOptions')) {
+                isMoreButton = true;
+            }
 
             while (elem && elem.dataset && !elem.dataset.item) {
                 elem = elem.parentNode;
             }
 
-            if (elem && elem.dataset && !isCheckbox) {
+            if (elem && elem.dataset && !isCheckbox && !isMoreButton) {
                 const { parentPath, subfolderPath, breadcrumbPath, type } = elem.dataset;
 
                 if (breadcrumbPath) {
@@ -418,6 +437,14 @@ export const CollectionPanelFiles = withStyles(styles)(connect((state: RootState
                 const item = collectionPanelFiles[id];
                 props.onSelectionToggle(event, item);
             }
+            if (isMoreButton) {
+                const { id } = elem.dataset;
+                const item: any = {
+                    id,
+                    data: rightData.find((elem) => elem.id === id),
+                };
+                onItemMenuOpen(event, item, isWritable);
+            }
         },
         [path, setPath, collectionPanelFiles] // eslint-disable-line react-hooks/exhaustive-deps
     );
@@ -512,7 +539,7 @@ export const CollectionPanelFiles = withStyles(styles)(connect((state: RootState
                     : <div className={classes.rowEmpty}>No directories available</div>
                     }}
                 </AutoSizer>
-                : <div className={classes.row}><CircularProgress className={classes.loader} size={30} /></div> }
+                : <div data-cy="collection-loader" className={classes.row}><CircularProgress className={classes.loader} size={30} /></div> }
                 </div>
             </div>
             <div className={classes.rightPanel} data-cy="collection-files-right-panel">
@@ -551,6 +578,15 @@ export const CollectionPanelFiles = withStyles(styles)(connect((state: RootState
                                         marginLeft: 'auto', marginRight: '1rem' }}>
                                         { formatFileSize(size) }
                                     </span>
+                                    <Tooltip title="More options" disableFocusListener>
+                                        <IconButton data-id='moreOptions'
+                                            data-cy='file-item-options-btn'
+                                            className={classes.moreOptionsButton}>
+                                            <MoreOptionsIcon
+                                                data-id='moreOptions'
+                                                className={classes.moreOptions} />
+                                        </IconButton>
+                                    </Tooltip>
                                 </div>
                             } }</FixedSizeList>
                         : <div className={classes.rowEmpty}>This collection is empty</div>
