Update deprecated resource definitions (#331)

This commit is contained in:
Dirk Klimpel 2024-02-02 17:14:07 +01:00 committed by GitHub
parent 58e02d6dff
commit d8d393cdf6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,15 +1,20 @@
// in src/Menu.js // in src/Menu.js
import * as React from "react"; import * as React from "react";
import { useSelector } from "react-redux";
import { useMediaQuery } from "@mui/material"; import { useMediaQuery } from "@mui/material";
import { MenuItemLink, getResources } from "react-admin"; import {
MenuItemLink,
useResourceDefinitions,
useSidebarState,
} from "react-admin";
import DefaultIcon from "@mui/icons-material/ViewList"; import DefaultIcon from "@mui/icons-material/ViewList";
import LabelIcon from "@mui/icons-material/Label";
const Menu = ({ onMenuClick, logout }) => { const Menu = ({ onMenuClick, logout }) => {
const isXSmall = useMediaQuery(theme => theme.breakpoints.down("xs")); const isXSmall = useMediaQuery(theme => theme.breakpoints.down("xs"));
const open = useSelector(state => state.admin.ui.sidebarOpen); const [open] = useSidebarState();
const resources = useSelector(getResources); const resourcesDefinitions = useResourceDefinitions();
const resources = Object.keys(resourcesDefinitions).map(
name => resourcesDefinitions[name]
);
return ( return (
<div> <div>
{resources.map(resource => ( {resources.map(resource => (
@ -24,13 +29,6 @@ const Menu = ({ onMenuClick, logout }) => {
sidebarIsOpen={open} sidebarIsOpen={open}
/> />
))} ))}
<MenuItemLink
to="/custom-route"
primaryText="Miscellaneous"
leftIcon={<LabelIcon />}
onClick={onMenuClick}
sidebarIsOpen={open}
/>
{isXSmall && logout} {isXSmall && logout}
</div> </div>
); );