mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-04 00:18:01 +01:00
fix: require ADMIN role to manage users
This commit is contained in:
parent
3ad447b7d9
commit
5bedf0c344
@ -1,21 +1,33 @@
|
|||||||
import React from 'react';
|
import React, { useContext } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import UsersList from './UsersList';
|
import UsersList from './UsersList';
|
||||||
import AdminMenu from '../admin-menu';
|
import AdminMenu from '../admin-menu';
|
||||||
import PageContent from '../../../component/common/PageContent/PageContent';
|
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}) => (
|
const UsersAdmin = ({history}) => {
|
||||||
<div>
|
const { hasAccess } = useContext(AccessContext);
|
||||||
<AdminMenu history={history} />
|
|
||||||
<PageContent headerContent="Users">
|
|
||||||
<UsersList />
|
|
||||||
</PageContent>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
|
|
||||||
render.propTypes = {
|
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>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
UsersAdmin.propTypes = {
|
||||||
match: PropTypes.object.isRequired,
|
match: PropTypes.object.isRequired,
|
||||||
history: PropTypes.object.isRequired,
|
history: PropTypes.object.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default render;
|
export default UsersAdmin;
|
||||||
|
Loading…
Reference in New Issue
Block a user