mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
7093b49962
* feat: add billing page to admin * some adjustments to billing page * add BillingHistory, remove invoices, misc improvements * refactor based on instanceStatus logic, add dialog * fix: cleanup * some refactoring and alignment with figma * add extend, isBilling, refactoring and misc improvements * fix: update tests * refactor: reorganize billing into smaller components, misc improvements * add STRIPE flag, some refactoring and adapting to comments and discussion * adapt BillingHistory slightly, refactor TextCell * Update src/hooks/api/getters/useInstanceStatus/useInstanceStatus.ts Co-authored-by: Tymoteusz Czech <2625371+Tymek@users.noreply.github.com> * refactor: address PR comments * fix: adjust divider color * fix: update snaps * refactor: address PR comments * fix: update snaps * fix: amountFormatted typo Co-authored-by: Tymoteusz Czech <2625371+Tymek@users.noreply.github.com> Co-authored-by: Fredrik Strand Oseberg <fredrik.no@gmail.com>
103 lines
3.0 KiB
TypeScript
103 lines
3.0 KiB
TypeScript
import React from 'react';
|
|
import { NavLink, useLocation } from 'react-router-dom';
|
|
import { Paper, Tab, Tabs } from '@mui/material';
|
|
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
|
import { useInstanceStatus } from 'hooks/api/getters/useInstanceStatus/useInstanceStatus';
|
|
|
|
const navLinkStyle = {
|
|
display: 'flex',
|
|
justifyContent: 'center',
|
|
alignItems: 'center',
|
|
width: '100%',
|
|
textDecoration: 'none',
|
|
color: 'inherit',
|
|
padding: '0.8rem 1.5rem',
|
|
};
|
|
|
|
const activeNavLinkStyle: React.CSSProperties = {
|
|
fontWeight: 'bold',
|
|
borderRadius: '3px',
|
|
padding: '0.8rem 1.5rem',
|
|
};
|
|
|
|
const createNavLinkStyle = (props: {
|
|
isActive: boolean;
|
|
}): React.CSSProperties => {
|
|
return props.isActive
|
|
? { ...navLinkStyle, ...activeNavLinkStyle }
|
|
: navLinkStyle;
|
|
};
|
|
|
|
function AdminMenu() {
|
|
const { uiConfig } = useUiConfig();
|
|
const { pathname } = useLocation();
|
|
const { isBilling } = useInstanceStatus();
|
|
const { flags } = uiConfig;
|
|
|
|
return (
|
|
<Paper
|
|
style={{
|
|
marginBottom: '1rem',
|
|
borderRadius: '12.5px',
|
|
boxShadow: 'none',
|
|
}}
|
|
>
|
|
<Tabs centered value={pathname}>
|
|
<Tab
|
|
value="/admin/users"
|
|
label={
|
|
<NavLink to="/admin/users" style={createNavLinkStyle}>
|
|
<span>Users</span>
|
|
</NavLink>
|
|
}
|
|
/>
|
|
{flags.RE && (
|
|
<Tab
|
|
value="/admin/roles"
|
|
label={
|
|
<NavLink
|
|
to="/admin/roles"
|
|
style={createNavLinkStyle}
|
|
>
|
|
<span>Project Roles</span>
|
|
</NavLink>
|
|
}
|
|
/>
|
|
)}
|
|
|
|
<Tab
|
|
value="/admin/api"
|
|
label={
|
|
<NavLink to="/admin/api" style={createNavLinkStyle}>
|
|
API Access
|
|
</NavLink>
|
|
}
|
|
/>
|
|
<Tab
|
|
value="/admin/auth"
|
|
label={
|
|
<NavLink to="/admin/auth" style={createNavLinkStyle}>
|
|
Single Sign-On
|
|
</NavLink>
|
|
}
|
|
/>
|
|
{isBilling && (
|
|
<Tab
|
|
value="/admin/billing"
|
|
label={
|
|
<NavLink
|
|
to="/admin/billing"
|
|
style={createNavLinkStyle}
|
|
>
|
|
Billing
|
|
</NavLink>
|
|
}
|
|
/>
|
|
)}
|
|
</Tabs>
|
|
</Paper>
|
|
);
|
|
}
|
|
|
|
export default AdminMenu;
|