mirror of
https://github.com/Telecominfraproject/wlan-cloud-ui.git
synced 2025-11-02 03:37:59 +00:00
only SuperUser can see navbar tag and access page
This commit is contained in:
@@ -71,7 +71,9 @@ const App = () => {
|
||||
<ProtectedRouteWithLayout exact path="/profiles" component={Profiles} />
|
||||
<ProtectedRouteWithLayout exact path="/alarms" component={Alarms} />
|
||||
<ProtectedRouteWithLayout exact path="/account/edit" component={EditAccount} />
|
||||
<ProtectedRouteWithLayout exact path="/accounts" component={Accounts} />
|
||||
{user.role === 'SuperUser' && (
|
||||
<ProtectedRouteWithLayout exact path="/accounts" component={Accounts} />
|
||||
)}
|
||||
</Switch>
|
||||
</ThemeProvider>
|
||||
</UserProvider>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import React, { useContext } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useLocation } from 'react-router-dom';
|
||||
import { useApolloClient } from '@apollo/react-hooks';
|
||||
@@ -9,7 +9,11 @@ import { AUTH_TOKEN } from 'constants/index';
|
||||
|
||||
import { removeItem } from 'utils/localStorage';
|
||||
|
||||
import UserContext from 'contexts/UserContext';
|
||||
|
||||
const MasterLayout = ({ children }) => {
|
||||
const { role } = useContext(UserContext);
|
||||
|
||||
const client = useApolloClient();
|
||||
const location = useLocation();
|
||||
|
||||
@@ -39,11 +43,6 @@ const MasterLayout = ({ children }) => {
|
||||
path: '/alarms',
|
||||
text: 'Alarms',
|
||||
},
|
||||
{
|
||||
key: 'accounts',
|
||||
path: '/accounts',
|
||||
text: 'Accounts',
|
||||
},
|
||||
];
|
||||
|
||||
const mobileMenuItems = [
|
||||
@@ -67,11 +66,6 @@ const MasterLayout = ({ children }) => {
|
||||
path: '/alarms',
|
||||
text: 'Alarms',
|
||||
},
|
||||
{
|
||||
key: 'accounts',
|
||||
path: '/accounts',
|
||||
text: 'Accounts',
|
||||
},
|
||||
|
||||
{
|
||||
key: 'settings',
|
||||
@@ -91,6 +85,19 @@ const MasterLayout = ({ children }) => {
|
||||
},
|
||||
];
|
||||
|
||||
if (role === 'SuperUser') {
|
||||
menuItems.push({
|
||||
key: 'accounts',
|
||||
path: '/accounts',
|
||||
text: 'Accounts',
|
||||
});
|
||||
mobileMenuItems.push({
|
||||
key: 'accounts',
|
||||
path: '/accounts',
|
||||
text: 'Accounts',
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
<Layout
|
||||
onLogout={handleLogout}
|
||||
|
||||
Reference in New Issue
Block a user