Remove menu render from Backend
In the Able Pro 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.tsx[../src/menu-items/dashboard.tsx]Open 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';
function isFound(arr: any, str: string) {
return arr.items.some((element: any) => {
if (element.id === str) {
return true;
}
return false;
});
}
export default function Navigation() {
...
const { menuLoading } = useGetMenu();
...
const [menuItems, setMenuItems] = useState<{ items: NavItemType[] }>({ items: [] });
let dashboardMenu = MenuFromAPI();
useLayoutEffect(() => {
if (menuLoading && !isFound(menuItem, 'group-dashboard-loading')) {
menuItem.items.splice(0, 0, dashboardMenu);
setMenuItems({ items: [...menuItem.items] });
} else if (!menuLoading && dashboardMenu?.id !== undefined && !isFound(menuItem, 'group-dashboard')) {
menuItem.items.splice(0, 1, dashboardMenu);
setMenuItems({ items: [...menuItem.items] });
} else {
setMenuItems({ items: [...menuItem.items] });
}
// eslint-disable-next-line
}, [menuLoading]);
}Open file
src\api\menu.tsand edit the below line of code.
Form:
To:
Open the file
src\api\menu.tsand remove the code below.
Delete menu-items file
dashboard.jsx[../src/menu-items/dashboard.jsx]Open file
../src/layout/Dashboard/Drawer/DrawerContent/Navigation/index.jsxand edit the below line of code.
Open file
../src/layout/Dashboard/Drawer/DrawerContent/Navigation/index.jsxand remove the below line of code.
Open the file
src\api\menu.jsand remove the code below.
Last updated