diff --git a/frontend/src/components/context-menu/context-menu.js b/frontend/src/components/context-menu/context-menu.js index 777b579c91..4a14a18e74 100644 --- a/frontend/src/components/context-menu/context-menu.js +++ b/frontend/src/components/context-menu/context-menu.js @@ -1,5 +1,6 @@ import React from 'react'; import PropTypes from 'prop-types'; +import { Dropdown, DropdownMenu, DropdownToggle, DropdownItem } from 'reactstrap'; import listener from './globalEventListener'; import { hideMenu } from './actions'; import { callIfExists } from './helpers'; @@ -24,6 +25,8 @@ class ContextMenu extends React.Component { isVisible: false, currentObject: null, menuList: [], + isSubMenuShown: false, + currentItem: '' }; } @@ -183,6 +186,28 @@ class ContextMenu extends React.Component { event.stopPropagation(); }; + onDropDownMouseMove = (e) => { + if (this.state.isSubMenuShown && e.target && e.target.className === 'dropdown-item') { + this.setState({ + isSubMenuShown: false + }); + } + }; + + toggleSubMenu = (e) => { + e.stopPropagation(); + this.setState({ + isSubMenuShown: !this.state.isSubMenuShown + }); + }; + + toggleSubMenuShown = (item) => { + this.setState({ + isSubMenuShown: true, + currentItem: item.key + }); + }; + render() { const inlineStyle = { position: 'fixed', opacity: 0, pointerEvents: 'none', display: 'block' }; return ( @@ -190,6 +215,37 @@ class ContextMenu extends React.Component { {this.state.menuList.map((menuItem, index) => { if (menuItem === 'Divider') { return
; + } else if (menuItem.subOpList) { + return ( + {e.stopPropagation();}} + > + + {menuItem.value} + + + + {menuItem.subOpList.map((item, index) => { + if (item == 'Divider') { + return ; + } else { + return ( + {item.value} + ); + } + })} + + + ); } else { return (