1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-06 00:07:44 +01:00
unleash.unleash/frontend/src/component/admin/menu/AdminMenu.tsx

138 lines
4.5 KiB
TypeScript
Raw Normal View History

2022-12-07 12:52:17 +01:00
import { useLocation } from 'react-router-dom';
import { Paper, styled, Tab, Tabs } from '@mui/material';
2022-03-28 10:49:59 +02:00
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
import { useInstanceStatus } from 'hooks/api/getters/useInstanceStatus/useInstanceStatus';
2022-12-07 12:52:17 +01:00
import { CenteredNavLink } from './CenteredNavLink';
const StyledPaper = styled(Paper)(({ theme }) => ({
marginBottom: '1rem',
borderRadius: '12.5px',
boxShadow: 'none',
padding: '0 2rem',
}));
function AdminMenu() {
const { uiConfig, isEnterprise } = useUiConfig();
const { pathname } = useLocation();
const { isBilling } = useInstanceStatus();
const { flags, networkViewEnabled } = uiConfig;
const activeTab = pathname.split('/')[2];
return (
<StyledPaper>
<Tabs
value={activeTab}
variant="scrollable"
scrollButtons="auto"
allowScrollButtonsMobile
>
<Tab
value="users"
label={
2022-12-07 12:52:17 +01:00
<CenteredNavLink to="/admin/users">
<span>Users</span>
2022-12-07 12:52:17 +01:00
</CenteredNavLink>
}
/>
{isEnterprise() && (
<Tab
value="service-accounts"
label={
<CenteredNavLink to="/admin/service-accounts">
<span>Service accounts</span>
</CenteredNavLink>
}
/>
)}
{flags.UG && (
<Tab
value="groups"
label={
2022-12-07 12:52:17 +01:00
<CenteredNavLink to="/admin/groups">
<span>Groups</span>
2022-12-07 12:52:17 +01:00
</CenteredNavLink>
}
/>
)}
feat/rbac roles (#562) * feat: create screen * fix: import accordion summary * feat: add accordions * fix: add codebox * feat: select permissions * fix: permission checker * fix: update permission checker * feat: wire up role list * fix: change icon color in project roles list * fix: add color to icon in project roles * add confirm dialog on role deletion * feat: add created screen * fix: cleanup * fix: update access permissions * fix: update admin panel * feat: add edit screen * fix: use color from palette and show toast when fails * fix: refactor * feat: validation * feat: implement checked all * fix: experimental toast * fix: error handling * fix: toast * feat: unique name validation * fix: update toasts * fix: remove toast * fix: reset flag * fix: remove unused vars * fix: update tests * feat: add error icon for toast * fix: replace wrong import for setToastData * feat: Patch keying on ui to handle uniqueness for permissions across multiple envs * fix: hasAccess handles * * fix: update permission switch * fix: use flag for environments rbac * fix: do not include check all keys in payload * fix: filter roles * fix: account for new permissions in variants list * fix: use effect on length property * fix: set polling interval on user * 4.5.0-beta.0 * fix: set initial permissions correctly to avoid race condition * fix: handle activeEnvironment when it is null * fix: remove unused imports * fix: unused imports * fix: Include missing project in hasAccess for deleteinng a tag * fix: Move add/delete tag to use update feature permissions * fix: use rest parameter * fix: remove sandbox from scripts * 4.6.0-beta.1 * fix: remove loading deduping * fix: disable editing on builtin roles * fix: check all * fix: feature overview environment * fix: refetch user on project create * fix: update snaphots * fix: frontend permissions * fix: delete create confirm * fix: remove unused permission * 4.6.0-beta.4 * fix: update permissions * fix: permissions * fix: set error to string * 4.6.0-beta.5 * fix: add permissions for project view * fix: add permissions to useEffect deps * fix: update permission for move feature toggle * fix: add permissions data to useEffect * fix: move settings * fix: key on confetti * fix: refetch project permissions on environment create/delete * fix: optional coalescing error object * fix: remove logging error * fix: reorder disable importance in permissionbutton * fix: add project roles to menu * fix: add disabled check to revive * fix: update snapshots * fix: change text to select all * fix: change text to select * 4.6.0-beta.6 Co-authored-by: Fredrik Oseberg <fredrik.no@gmail.com> Co-authored-by: sighphyre <liquidwicked64@gmail.com>
2022-01-14 15:50:02 +01:00
{flags.RE && (
<Tab
value="roles"
label={
2022-12-07 12:52:17 +01:00
<CenteredNavLink to="/admin/roles">
<span>Project roles</span>
2022-12-07 12:52:17 +01:00
</CenteredNavLink>
}
/>
)}
<Tab
value="api"
label={
2022-12-07 12:52:17 +01:00
<CenteredNavLink to="/admin/api">
API access
2022-12-07 12:52:17 +01:00
</CenteredNavLink>
}
/>
{uiConfig.flags.embedProxyFrontend && (
<Tab
value="cors"
label={
2022-12-07 12:52:17 +01:00
<CenteredNavLink to="/admin/cors">
CORS origins
2022-12-07 12:52:17 +01:00
</CenteredNavLink>
}
/>
)}
<Tab
value="auth"
label={
2022-12-07 12:52:17 +01:00
<CenteredNavLink to="/admin/auth">
Single sign-on
2022-12-07 12:52:17 +01:00
</CenteredNavLink>
}
/>
<Tab
value="instance"
label={
2022-12-07 12:52:17 +01:00
<CenteredNavLink to="/admin/instance">
Instance stats
2022-12-07 12:52:17 +01:00
</CenteredNavLink>
}
/>
{networkViewEnabled && (
<Tab
value="network"
label={
<CenteredNavLink to="/admin/network">
Network
</CenteredNavLink>
}
/>
)}
<Tab
value="maintenance"
label={
<CenteredNavLink to="/admin/maintenance">
Maintenance
</CenteredNavLink>
}
/>
2022-12-21 12:23:44 +01:00
{isBilling && (
<Tab
value="billing"
label={
2022-12-07 12:52:17 +01:00
<CenteredNavLink to="/admin/billing">
Billing
2022-12-07 12:52:17 +01:00
</CenteredNavLink>
}
/>
)}
</Tabs>
</StyledPaper>
);
}
export default AdminMenu;