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 "@mui/material/Menu";
7 import IconButton from "@mui/material/IconButton";
8 import { PopoverOrigin } from "@mui/material/Popover";
9 import { Tooltip } from "@mui/material";
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 data-cy="dropdown-menu-button"
41 aria-owns={anchorEl ? id : undefined}
44 onClick={this.handleOpen}
52 open={Boolean(anchorEl)}
53 onClose={this.handleClose}
54 onClick={this.handleClose}
55 transformOrigin={this.transformOrigin}>
63 this.setState({ anchorEl: undefined });
66 handleOpen = (event: React.MouseEvent<HTMLButtonElement>) => {
67 this.setState({ anchorEl: event.currentTarget });