Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update menu for billing page #4525

Merged
merged 4 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 },
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logic to show menu item is already handled by useInstanceStatus(), no need to specify "mode"

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