1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from 'react';
6 import { Menu, IconButton } from '@material-ui/core';
7 import { PopoverOrigin } from '@material-ui/core/Popover';
10 interface DropdownMenuProps {
12 icon: React.ComponentType;
15 class DropdownMenu extends React.Component<DropdownMenuProps> {
21 transformOrigin: PopoverOrigin = {
27 const { icon: Icon, id, children } = this.props;
28 const { anchorEl } = this.state;
32 aria-owns={anchorEl ? id : undefined}
35 onClick={this.handleOpen}
43 open={Boolean(anchorEl)}
44 onClose={this.handleClose}
45 onClick={this.handleClose}
46 anchorOrigin={this.transformOrigin}
47 transformOrigin={this.transformOrigin}
56 this.setState({ anchorEl: undefined });
59 handleOpen = (event: React.MouseEvent<HTMLButtonElement>) => {
60 this.setState({ anchorEl: event.currentTarget });
65 export default DropdownMenu;