1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-05-08 01:15:49 +02:00
unleash.unleash/frontend/src/component/menu/Header/NavigationMenu/NavigationMenu.tsx
Tymoteusz Czech 87e75d10b2
Update PRO plan menu (#4409)
<!-- Thanks for creating a PR! To make it easier for reviewers and
everyone else to understand what your changes relate to, please add some
relevant content to the headings below. Feel free to ignore or delete
sections that you don't think are relevant. Thank you! ❤️ -->

## About the changes
Update menu for Pro customers - show enterprise options with plan
upgrade suggestion page.


![image](https://github.com/Unleash/unleash/assets/2625371/0b670b48-a2fc-4973-89ce-5d0b0c36b81a)
2023-08-04 11:57:36 +02:00

101 lines
3.1 KiB
TypeScript

import { Divider } from '@mui/material';
import { Menu, MenuItem, styled } from '@mui/material';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
import { INavigationMenuItem } from 'interfaces/route';
import { Link } from 'react-router-dom';
import { EnterpriseBadge } from '../../../common/EnterpriseBadge/EnterpriseBadge';
interface INavigationMenuProps {
options: INavigationMenuItem[];
id: string;
anchorEl: any;
handleClose: () => void;
style: Object;
}
const StyledLink = styled(Link)(({ theme }) => ({
textDecoration: 'none',
alignItems: 'center',
display: 'flex',
color: 'inherit',
height: '100%',
width: '100%',
'&&': {
// Override MenuItem's built-in padding.
padding: theme.spacing(1, 2),
},
}));
const StyledSpan = styled('span')(({ theme }) => ({
width: '12.5px',
height: '12.5px',
display: 'block',
backgroundColor: theme.palette.primary.main,
marginRight: theme.spacing(2),
borderRadius: '2px',
}));
const StyledBadgeContainer = styled('div')(({ theme }) => ({
marginLeft: 'auto',
paddingLeft: theme.spacing(2),
display: 'flex',
}));
export const NavigationMenu = ({
options,
id,
handleClose,
anchorEl,
style,
}: INavigationMenuProps) => {
const { uiConfig } = useUiConfig();
const showUpdatedMenu = uiConfig?.flags?.frontendNavigationUpdate;
return (
<Menu
id={id}
onClose={handleClose}
anchorEl={anchorEl}
open={Boolean(anchorEl)}
style={style}
>
{options
.map((option, i) => [
<ConditionallyRender
key={`${option.path}-divider`}
condition={Boolean(
showUpdatedMenu &&
options[i - 1]?.group &&
options[i - 1]?.group !== option.group
)}
show={<Divider variant="middle" />}
elseShow={null}
/>,
<MenuItem
key={option.path}
component={StyledLink}
to={option.path}
onClick={handleClose}
>
<StyledSpan />
{option.title}
<ConditionallyRender
condition={Boolean(
option.menu.showEnterpriseBadge &&
showUpdatedMenu
)}
show={
<StyledBadgeContainer>
<EnterpriseBadge />
</StyledBadgeContainer>
}
/>
</MenuItem>,
])
.flat()
.filter(Boolean)}
</Menu>
);
};