Remove menu render from Backend
Remove menu via backend
In the Mantis React admin, a few dashboard menus (i.e. Default, Analytics, Components) load from our mock API (GitHub repository). If you want to remove it from your admin panel, follow the steps below and remove/edit the suggested line of code.
Delete menu-items file:
dashboard.tsxdashboard.tsx[src/menu-items/dashboard.tsx]
Open the file
src/layout/Dashboard/Drawer/DrawerContent/Navigation/index.tsxand edit the below line of code.
Form:
import { Fragment, useLayoutEffect, useState } from 'react';
...
import menuItem from 'menu-items';
import { useGetMenu, useGetMenuMaster } from 'api/menu';To:
import { Fragment, useState } from 'react';
...
import menuItems from 'menu-items';
import { useGetMenuMaster } from 'api/menu';Open file
src/layout/Dashboard/Drawer/DrawerContent/Navigation/index.tsxand remove the below line of code.
import { MenuFromAPI } from 'menu-items/dashboard';
export default function Navigation() {
...
const { menuLoading } = useGetMenu();
...
const [menuItems, setMenuItems] = useState<{ items: NavItemType[] }>({ items: [] });
let dashboardMenu = MenuFromAPI();
useLayoutEffect(() => {
const isFound = menuItem.items.some((element) => {
if (element.id === 'group-dashboard') {
return true;
}
return false;
});
if (menuLoading) {
menuItem.items.splice(0, 0, dashboardMenu);
setMenuItems({ items: [...menuItem.items] });
} else if (!menuLoading && dashboardMenu?.id !== undefined && !isFound) {
menuItem.items.splice(0, 1, dashboardMenu);
setMenuItems({ items: [...menuItem.items] });
} else {
setMenuItems({ items: [...menuItem.items] });
}
// eslint-disable-next-line
}, [menuLoading]);
}Open the file
src\api\menu.tsand remove the code below.
Open file
src\api\menu.tsand edit the below line of code.
Form:
To:
In the Mantis React admin, a few dashboard menus (i.e. Default, Analytics, Components) load from our mock API (GitHub repository). If you want to remove it from your admin panel, follow the steps below and remove/edit the suggested line of code.
Delete menu-items file:
dashboard.jsxdashboard.tsx[src/menu-items/dashboard.jsx]
Open the file
src/layout/Dashboard/Drawer/DrawerContent/Navigation/index.jsxand edit the below line of code.
Form:
To:
Open file
src/layout/Dashboard/Drawer/DrawerContent/Navigation/index.jsxand remove the below line of code.
Open the file
src\api\menu.tsand remove the code below.
In the Mantis React admin, a few dashboard menus (i.e. Default, Analytics, Components) load from our mock API (GitHub repository). If you want to remove it from your admin panel, follow the steps below and remove/edit the suggested line of code.
Delete menu-items file:
dashboard.tsxdashboard.tsx[src/menu-items/dashboard.tsx]
Open the file
src/layout/Dashboard/Drawer/DrawerContent/Navigation/index.tsxand edit the below line of code.
Form:
To:
Open file
src/layout/Dashboard/Drawer/DrawerContent/Navigation/index.tsxand remove the below line of code.
Open the file
src\api\menu.tsand remove the code below.
Open file
src\api\menu.tsand edit the below line of code.
Form:
To:
In the Mantis React admin, a few dashboard menus (i.e. Default, Analytics, Components) load from our mock API (GitHub repository). If you want to remove it from your admin panel, follow the steps below and remove/edit the suggested line of code.
Delete menu-items file:
dashboard.jsxdashboard.tsx[src/menu-items/dashboard.jsx]
Open the file
src/layout/Dashboard/Drawer/DrawerContent/Navigation/index.jsxand edit the below line of code.
Form:
To:
Open file
src/layout/Dashboard/Drawer/DrawerContent/Navigation/index.jsxand remove the below line of code.
Open the file
src\api\menu.tsand remove the code below.
Last updated