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