X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/9e4aa2fd44835698c0a3e6f321a2cf88b6f11939..28ded6ac60c1317b5872a22ce827b073f26fa030:/src/components/context-menu/context-menu.tsx

diff --git a/src/components/context-menu/context-menu.tsx b/src/components/context-menu/context-menu.tsx
index 7751be49..2103a2a0 100644
--- a/src/components/context-menu/context-menu.tsx
+++ b/src/components/context-menu/context-menu.tsx
@@ -4,48 +4,55 @@
 import * as React from "react";
 import { Popover, List, ListItem, ListItemIcon, ListItemText, Divider } from "@material-ui/core";
 import { DefaultTransformOrigin } from "../popover/helpers";
+import { IconType } from "../icon/icon";
 
-export interface ContextMenuAction {
+export interface ContextMenuItem {
     name: string;
-    icon: string;
+    icon: IconType;
 }
 
-export type ContextMenuActionGroup = ContextMenuAction[];
+export type ContextMenuItemGroup = ContextMenuItem[];
 
-export interface ContextMenuProps<T> {
+export interface ContextMenuProps {
     anchorEl?: HTMLElement;
-    actions: ContextMenuActionGroup[];
-    onActionClick: (action: ContextMenuAction) => void;
+    items: ContextMenuItemGroup[];
+    onItemClick: (action: ContextMenuItem) => void;
     onClose: () => void;
 }
 
-export default class ContextMenu<T> extends React.PureComponent<ContextMenuProps<T>> {
+export class ContextMenu extends React.PureComponent<ContextMenuProps> {
     render() {
-        const { anchorEl, actions, onClose, onActionClick } = this.props;
+        const { anchorEl, items, onClose, onItemClick} = this.props;
         return <Popover
             anchorEl={anchorEl}
             open={!!anchorEl}
             onClose={onClose}
             transformOrigin={DefaultTransformOrigin}
-            anchorOrigin={DefaultTransformOrigin}>
+            anchorOrigin={DefaultTransformOrigin}
+            onContextMenu={this.handleContextMenu}>
             <List dense>
-                {actions.map((group, groupIndex) =>
+                {items.map((group, groupIndex) =>
                     <React.Fragment key={groupIndex}>
-                        {group.map((action, actionIndex) =>
+                        {group.map((item, actionIndex) =>
                             <ListItem
                                 button
                                 key={actionIndex}
-                                onClick={() => onActionClick(action)}>
+                                onClick={() => onItemClick(item)}>
                                 <ListItemIcon>
-                                    <i className={action.icon} />
+                                    <item.icon/>
                                 </ListItemIcon>
                                 <ListItemText>
-                                    {action.name}
+                                    {item.name}
                                 </ListItemText>
                             </ListItem>)}
-                        {groupIndex < actions.length - 1 && <Divider />}
+                        {groupIndex < items.length - 1 && <Divider />}
                     </React.Fragment>)}
             </List>
         </Popover>;
     }
+
+    handleContextMenu = (event: React.MouseEvent<HTMLElement>) => {
+        event.preventDefault();
+        this.props.onClose();
+    }
 }
