1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00

fix: require ADMIN role to manage users

This commit is contained in:
Ivar Conradi Østhus 2021-04-21 09:35:13 +02:00
parent 3ad447b7d9
commit 5bedf0c344

View File

@ -1,21 +1,33 @@
import React from 'react';
import React, { useContext } from 'react';
import PropTypes from 'prop-types';
import UsersList from './UsersList';
import AdminMenu from '../admin-menu';
import PageContent from '../../../component/common/PageContent/PageContent';
import AccessContext from '../../../contexts/AccessContext';
import ConditionallyRender from '../../../component/common/ConditionallyRender';
import { ADMIN } from '../../../component/AccessProvider/permissions';
import { Alert } from '@material-ui/lab';
const render = ({history}) => (
<div>
<AdminMenu history={history} />
<PageContent headerContent="Users">
<UsersList />
</PageContent>
</div>
);
const UsersAdmin = ({history}) => {
const { hasAccess } = useContext(AccessContext);
return (
<div>
<AdminMenu history={history} />
<PageContent headerContent="Users">
<ConditionallyRender
condition={hasAccess(ADMIN)}
show={<UsersList />}
elseShow={<Alert severity="error">You need to be a root admin to access this section.</Alert>} />
</PageContent>
</div>
);
}
render.propTypes = {
UsersAdmin.propTypes = {
match: PropTypes.object.isRequired,
history: PropTypes.object.isRequired,
};
export default render;
export default UsersAdmin;