Added: 'hide' unnecessary navbar items
This commit is contained in:
@@ -59,7 +59,6 @@ function Sidenav({ color, brandName, routes, ...rest }) {
|
|||||||
const items = pathname.split('/').slice(1);
|
const items = pathname.split('/').slice(1);
|
||||||
const itemParentName = items[1];
|
const itemParentName = items[1];
|
||||||
const itemName = items[items.length - 1];
|
const itemName = items[items.length - 1];
|
||||||
|
|
||||||
|
|
||||||
let textColor = 'white';
|
let textColor = 'white';
|
||||||
|
|
||||||
@@ -120,9 +119,11 @@ function Sidenav({ color, brandName, routes, ...rest }) {
|
|||||||
};
|
};
|
||||||
// Render the all the collpases from the routes.js
|
// Render the all the collpases from the routes.js
|
||||||
const renderCollapse = (collapses) =>
|
const renderCollapse = (collapses) =>
|
||||||
collapses.map(({ name, collapse, route, href, key }) => {
|
collapses.map(({ name, collapse, route, href, key, hide }) => {
|
||||||
let returnValue;
|
let returnValue;
|
||||||
|
|
||||||
|
if (hide) return null;
|
||||||
|
|
||||||
if (collapse) {
|
if (collapse) {
|
||||||
returnValue = (
|
returnValue = (
|
||||||
<SidenavItem
|
<SidenavItem
|
||||||
@@ -162,9 +163,11 @@ function Sidenav({ color, brandName, routes, ...rest }) {
|
|||||||
|
|
||||||
// Render all the routes from the routes.js (All the visible items on the Sidenav)
|
// Render all the routes from the routes.js (All the visible items on the Sidenav)
|
||||||
const renderRoutes = routes.map(
|
const renderRoutes = routes.map(
|
||||||
({ type, name, icon, title, collapse, noCollapse, key, href }) => {
|
({ type, name, icon, title, collapse, noCollapse, key, href, hide }) => {
|
||||||
let returnValue;
|
let returnValue;
|
||||||
|
|
||||||
|
if (hide) return null;
|
||||||
|
|
||||||
if (type === 'collapse') {
|
if (type === 'collapse') {
|
||||||
returnValue = href ? (
|
returnValue = href ? (
|
||||||
<Link
|
<Link
|
||||||
@@ -251,7 +254,13 @@ function Sidenav({ color, brandName, routes, ...rest }) {
|
|||||||
width={!brandName && '100%'}
|
width={!brandName && '100%'}
|
||||||
sx={(theme) => sidenavLogoLabel(theme, { miniSidenav })}
|
sx={(theme) => sidenavLogoLabel(theme, { miniSidenav })}
|
||||||
>
|
>
|
||||||
<MDTypography fontSize="2rem" component="h1" variant="button" fontWeight="bold" color={textColor}>
|
<MDTypography
|
||||||
|
fontSize="2rem"
|
||||||
|
component="h1"
|
||||||
|
variant="button"
|
||||||
|
fontWeight="bold"
|
||||||
|
color={textColor}
|
||||||
|
>
|
||||||
{brandName}
|
{brandName}
|
||||||
</MDTypography>
|
</MDTypography>
|
||||||
</MDBox>
|
</MDBox>
|
||||||
|
|||||||
@@ -99,12 +99,14 @@ const protectedRoutes = [
|
|||||||
type: 'collapse',
|
type: 'collapse',
|
||||||
name: 'Test',
|
name: 'Test',
|
||||||
key: 'Test',
|
key: 'Test',
|
||||||
|
hide: true,
|
||||||
icon: <Icon fontSize="medium">dashboard</Icon>,
|
icon: <Icon fontSize="medium">dashboard</Icon>,
|
||||||
collapse: [
|
collapse: [
|
||||||
{
|
{
|
||||||
name: 'Dashboard',
|
name: 'Dashboard',
|
||||||
key: 'dashboard',
|
key: 'dashboard',
|
||||||
route: '/dashboard',
|
route: '/dashboard',
|
||||||
|
hide: true,
|
||||||
component: <DashboardScreen />
|
component: <DashboardScreen />
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user