Skip to content

Commit

Permalink
Update menu for billing page (#4525)
Browse files Browse the repository at this point in the history
## About the changes

- [x] Show admin menu on billing page in cloud offering. Category menu
was not showing up because we have 2 different pages for billing (hosted
or not)
  - [x] Fix menu tab padding
 
https://linear.app/unleash/issue/1-1266/update-menu-for-billing-page
  • Loading branch information
Tymek authored Aug 18, 2023
1 parent 26e7267 commit 208ca05
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 39 deletions.
2 changes: 1 addition & 1 deletion frontend/src/component/admin/adminRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export const adminRoutes: INavigationMenuItem[] = [
{
path: '/admin/admin-invoices',
title: 'Billing & invoices',
menu: { adminSettings: true, mode: ['pro'], billing: true },
menu: { adminSettings: true, billing: true },
group: 'instance',
},
{
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/component/admin/invoice/InvoiceList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ const InvoiceList = () => {
</div>
</PageContent>
}
elseShow={<div>{isLoaded && 'No invoices to show.'}</div>}
elseShow={
<PageContent>{isLoaded && 'No invoices to show.'}</PageContent>
}
/>
);
};
Expand Down
1 change: 1 addition & 0 deletions frontend/src/component/admin/menu/AdminTabsMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const AdminTabsMenu: VFC = () => {
>
{tabs.map(tab => (
<Tab
sx={{ padding: 0 }}
key={tab.route}
value={tab.route?.split('/')?.[2]}
label={
Expand Down
50 changes: 15 additions & 35 deletions frontend/src/component/admin/menu/CenteredNavLink.tsx
Original file line number Diff line number Diff line change
@@ -1,41 +1,21 @@
import { Theme } from '@mui/material';
import React, { FC } from 'react';
import { styled } from '@mui/material';
import { FC } from 'react';
import { NavLink } from 'react-router-dom';
import { useTheme } from '@mui/material/styles';

const createNavLinkStyle = (props: {
isActive: boolean;
theme: Theme;
}): React.CSSProperties => {
const navLinkStyle = {
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
width: '100%',
textDecoration: 'none',
color: 'inherit',
padding: props.theme.spacing(1.5, 3),
};

const activeNavLinkStyle: React.CSSProperties = {
const StyledNavLink = styled(NavLink)(({ theme }) => ({
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
width: '100%',
height: '100%',
textDecoration: 'none',
color: 'inherit',
padding: theme.spacing(0, 5),
'&.active': {
fontWeight: 'bold',
borderRadius: '3px',
padding: props.theme.spacing(1.5, 3),
};

return props.isActive
? { ...navLinkStyle, ...activeNavLinkStyle }
: navLinkStyle;
};
},
}));

export const CenteredNavLink: FC<{ to: string }> = ({ to, children }) => {
const theme = useTheme();
return (
<NavLink
to={to}
style={({ isActive }) => createNavLinkStyle({ isActive, theme })}
>
{children}
</NavLink>
);
return <StyledNavLink to={to}>{children}</StyledNavLink>;
};
1 change: 1 addition & 0 deletions frontend/src/component/admin/network/Network.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export const Network = () => {
<span>{label}</span>
</CenteredNavLink>
}
sx={{ padding: 0 }}
/>
))}
</Tabs>
Expand Down
1 change: 1 addition & 0 deletions frontend/src/component/admin/roles/RolesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export const RolesPage = () => {
</span>
</CenteredNavLink>
}
sx={{ padding: 0 }}
/>
))}
</Tabs>
Expand Down
13 changes: 12 additions & 1 deletion frontend/src/component/admin/useAdminRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,19 @@ export const useAdminRoutes = () => {
const showEnterpriseOptionsInPro = Boolean(
uiConfig?.flags?.frontendNavigationUpdate
);
const routes = [...adminRoutes];

return adminRoutes
if (uiConfig.flags.UNLEASH_CLOUD) {
const adminBillingMenuItem = adminRoutes.findIndex(
route => route.title === 'Billing & invoices'
);
routes[adminBillingMenuItem] = {
...routes[adminBillingMenuItem],
path: '/admin/billing',
};
}

return routes
.filter(filterByConfig(uiConfig))
.filter(route =>
filterAdminRoutes(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ export const NavigationMenu = ({
}
arrow
placement="left"
key={option.path}
>
<MenuItem
key={option.path}
component={StyledLink}
to={option.path}
onClick={handleClose}
Expand Down

0 comments on commit 208ca05

Please sign in to comment.