mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +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 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}) => (
 | 
			
		||||
const UsersAdmin = ({history}) => {
 | 
			
		||||
    const { hasAccess } = useContext(AccessContext);
 | 
			
		||||
    
 | 
			
		||||
    return (
 | 
			
		||||
        <div>
 | 
			
		||||
            <AdminMenu history={history} />
 | 
			
		||||
            <PageContent headerContent="Users">
 | 
			
		||||
            <UsersList />
 | 
			
		||||
                <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;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user