1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import 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;
40 aria-owns={anchorEl ? id : undefined}
43 onClick={this.handleOpen}>
50 open={Boolean(anchorEl)}
51 onClose={this.handleClose}
52 onClick={this.handleClose}
53 transformOrigin={this.transformOrigin}>
61 this.setState({ anchorEl: undefined });
64 handleOpen = (event: React.MouseEvent<HTMLButtonElement>) => {
65 this.setState({ anchorEl: event.currentTarget });