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 from '@material-ui/core/Menu';
7 import IconButton from '@material-ui/core/IconButton';
8 import { PopoverOrigin } from '@material-ui/core/Popover';
9 import { Tooltip } from '@material-ui/core';
11 interface DropdownMenuProps {
13 icon: React.ReactElement<any>;
17 interface DropdownMenuState {
21 export class DropdownMenu extends React.Component<DropdownMenuProps, DropdownMenuState> {
26 transformOrigin: PopoverOrigin = {
32 const { icon, id, children, title } = this.props;
33 const { anchorEl } = this.state;
36 <Tooltip title={title}>
38 aria-owns={anchorEl ? id : undefined}
41 onClick={this.handleOpen}>
48 open={Boolean(anchorEl)}
49 onClose={this.handleClose}
50 onClick={this.handleClose}
51 transformOrigin={this.transformOrigin}>
59 this.setState({ anchorEl: undefined });
62 handleOpen = (event: React.MouseEvent<HTMLButtonElement>) => {
63 this.setState({ anchorEl: event.currentTarget });