mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-19 17:52:45 +02:00
* fix: setup new routes * fix: copy toggle * fix: link to correct project * fix: redirect oss to default * fix: update tests * fix: edit path * fix: remove invalid property * fix: add project to test data * fix: update paths to use features * fix: update test data * fix: update snapshots * fix: only show button to add toggle if you have access * fix: change heading * fix: use new route * fix: archive view * fix: update snapshots * fix: sorting headers * fix: list headers * fix: only show span if revive is present * fix: add border to list * fix: update snapshots * fix: remove console log
71 lines
1.6 KiB
JavaScript
71 lines
1.6 KiB
JavaScript
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import { Menu } from '@material-ui/core';
|
|
import { ArrowDropDown } from '@material-ui/icons';
|
|
|
|
import { DropdownButton } from '..';
|
|
|
|
import styles from '../common.module.scss';
|
|
|
|
const DropdownMenu = ({
|
|
renderOptions,
|
|
id,
|
|
title,
|
|
callback,
|
|
icon = <ArrowDropDown />,
|
|
label,
|
|
style,
|
|
startIcon,
|
|
...rest
|
|
}) => {
|
|
const [anchor, setAnchor] = React.useState(null);
|
|
|
|
const handleOpen = e => setAnchor(e.currentTarget);
|
|
|
|
const handleClose = e => {
|
|
if (callback && typeof callback === 'function') {
|
|
callback(e);
|
|
}
|
|
|
|
setAnchor(null);
|
|
};
|
|
|
|
return (
|
|
<>
|
|
<DropdownButton
|
|
id={id}
|
|
label={label}
|
|
title={title}
|
|
startIcon={startIcon}
|
|
onClick={handleOpen}
|
|
style={style}
|
|
aria-controls={id}
|
|
aria-haspopup="true"
|
|
icon={icon}
|
|
{...rest}
|
|
/>
|
|
<Menu
|
|
id={id}
|
|
className={styles.dropdownMenu}
|
|
onClick={handleClose}
|
|
anchorEl={anchor}
|
|
open={Boolean(anchor)}
|
|
>
|
|
{renderOptions()}
|
|
</Menu>
|
|
</>
|
|
);
|
|
};
|
|
|
|
DropdownMenu.propTypes = {
|
|
renderOptions: PropTypes.func,
|
|
id: PropTypes.string,
|
|
title: PropTypes.string,
|
|
callback: PropTypes.func,
|
|
icon: PropTypes.object,
|
|
label: PropTypes.string,
|
|
startIcon: PropTypes.object,
|
|
};
|
|
|
|
export default DropdownMenu;
|