2021-02-24 11:03:18 +01:00
|
|
|
import React from 'react';
|
2022-02-08 11:44:41 +01:00
|
|
|
import { NavLink, useLocation } from 'react-router-dom';
|
2022-05-02 15:52:41 +02:00
|
|
|
import { Paper, Tab, Tabs } from '@mui/material';
|
2022-03-28 10:49:59 +02:00
|
|
|
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
2022-05-25 23:26:05 +02:00
|
|
|
import { useInstanceStatus } from 'hooks/api/getters/useInstanceStatus/useInstanceStatus';
|
2021-03-30 15:14:02 +02:00
|
|
|
|
|
|
|
const navLinkStyle = {
|
|
|
|
display: 'flex',
|
|
|
|
justifyContent: 'center',
|
|
|
|
alignItems: 'center',
|
|
|
|
width: '100%',
|
|
|
|
textDecoration: 'none',
|
|
|
|
color: 'inherit',
|
|
|
|
padding: '0.8rem 1.5rem',
|
|
|
|
};
|
|
|
|
|
2022-02-08 11:44:41 +01:00
|
|
|
const activeNavLinkStyle: React.CSSProperties = {
|
2021-03-30 15:14:02 +02:00
|
|
|
fontWeight: 'bold',
|
|
|
|
borderRadius: '3px',
|
|
|
|
padding: '0.8rem 1.5rem',
|
|
|
|
};
|
|
|
|
|
2022-05-05 13:42:18 +02:00
|
|
|
const createNavLinkStyle = (props: {
|
|
|
|
isActive: boolean;
|
|
|
|
}): React.CSSProperties => {
|
|
|
|
return props.isActive
|
|
|
|
? { ...navLinkStyle, ...activeNavLinkStyle }
|
|
|
|
: navLinkStyle;
|
|
|
|
};
|
|
|
|
|
2022-02-08 11:44:41 +01:00
|
|
|
function AdminMenu() {
|
2022-01-14 15:50:02 +01:00
|
|
|
const { uiConfig } = useUiConfig();
|
2022-02-08 11:44:41 +01:00
|
|
|
const { pathname } = useLocation();
|
2022-05-25 23:26:05 +02:00
|
|
|
const { isBilling } = useInstanceStatus();
|
2022-01-14 15:50:02 +01:00
|
|
|
const { flags } = uiConfig;
|
2021-12-14 10:36:19 +01:00
|
|
|
|
2021-02-24 11:03:18 +01:00
|
|
|
return (
|
2022-01-14 15:50:02 +01:00
|
|
|
<Paper
|
|
|
|
style={{
|
|
|
|
marginBottom: '1rem',
|
|
|
|
borderRadius: '12.5px',
|
|
|
|
boxShadow: 'none',
|
|
|
|
}}
|
|
|
|
>
|
2021-05-18 12:59:48 +02:00
|
|
|
<Tabs centered value={pathname}>
|
|
|
|
<Tab
|
|
|
|
value="/admin/users"
|
|
|
|
label={
|
2022-05-05 13:42:18 +02:00
|
|
|
<NavLink to="/admin/users" style={createNavLinkStyle}>
|
2021-04-16 11:31:47 +02:00
|
|
|
<span>Users</span>
|
2021-05-18 12:59:48 +02:00
|
|
|
</NavLink>
|
|
|
|
}
|
2022-02-08 11:44:41 +01:00
|
|
|
/>
|
2022-07-22 09:31:08 +02:00
|
|
|
{flags.UG && (
|
|
|
|
<Tab
|
|
|
|
value="/admin/groups"
|
|
|
|
label={
|
|
|
|
<NavLink
|
|
|
|
to="/admin/groups"
|
|
|
|
style={createNavLinkStyle}
|
|
|
|
>
|
|
|
|
<span>Groups</span>
|
|
|
|
</NavLink>
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
)}
|
2022-01-14 15:50:02 +01:00
|
|
|
{flags.RE && (
|
2021-12-14 10:36:19 +01:00
|
|
|
<Tab
|
|
|
|
value="/admin/roles"
|
|
|
|
label={
|
|
|
|
<NavLink
|
|
|
|
to="/admin/roles"
|
2022-05-05 13:42:18 +02:00
|
|
|
style={createNavLinkStyle}
|
2021-12-14 10:36:19 +01:00
|
|
|
>
|
2022-05-26 16:27:20 +02:00
|
|
|
<span>Project roles</span>
|
2021-12-14 10:36:19 +01:00
|
|
|
</NavLink>
|
|
|
|
}
|
2022-02-08 11:44:41 +01:00
|
|
|
/>
|
2021-12-14 10:36:19 +01:00
|
|
|
)}
|
|
|
|
|
2021-05-18 12:59:48 +02:00
|
|
|
<Tab
|
|
|
|
value="/admin/api"
|
|
|
|
label={
|
2022-05-05 13:42:18 +02:00
|
|
|
<NavLink to="/admin/api" style={createNavLinkStyle}>
|
2022-05-26 16:27:20 +02:00
|
|
|
API access
|
2021-05-18 12:59:48 +02:00
|
|
|
</NavLink>
|
|
|
|
}
|
2022-02-08 11:44:41 +01:00
|
|
|
/>
|
2021-05-18 12:59:48 +02:00
|
|
|
<Tab
|
|
|
|
value="/admin/auth"
|
|
|
|
label={
|
2022-05-05 13:42:18 +02:00
|
|
|
<NavLink to="/admin/auth" style={createNavLinkStyle}>
|
2022-05-26 16:27:20 +02:00
|
|
|
Single sign-on
|
2021-05-18 12:59:48 +02:00
|
|
|
</NavLink>
|
2021-04-16 11:31:47 +02:00
|
|
|
}
|
2022-02-08 11:44:41 +01:00
|
|
|
/>
|
2022-05-25 23:26:05 +02:00
|
|
|
{isBilling && (
|
|
|
|
<Tab
|
|
|
|
value="/admin/billing"
|
|
|
|
label={
|
|
|
|
<NavLink
|
|
|
|
to="/admin/billing"
|
|
|
|
style={createNavLinkStyle}
|
|
|
|
>
|
|
|
|
Billing
|
|
|
|
</NavLink>
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
)}
|
2021-04-16 11:31:47 +02:00
|
|
|
</Tabs>
|
|
|
|
</Paper>
|
2021-02-24 11:03:18 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default AdminMenu;
|