Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom menu items #37

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Add custom menu items #37

wants to merge 3 commits into from

Conversation

erakli
Copy link

@erakli erakli commented Apr 17, 2022

Quick way to add custom menu items without Resource.

Usage:

import * as UI from 'ra-ui-materialui';
import TreeMenu from '@bb-tech/ra-treemenu';
import Settings from '@material-ui/icons/Settings';

const CustomMenuItems = [
  <UI.MenuItemLink
    to="/settings"
    primaryText="Settings"
    leftIcon={<Settings />}
  />,
];

const CustomLayout = (props) => {
  TreeMenu.defaultProps.customMenuItems = CustomMenuItems;
  return <UI.Layout {...props} menu={TreeMenu} />;
};

const App = (props) => (
  <Admin
    layout={(props) => <CustomLayout {...props} />}
    {...props}
  >
    {props.children}
  </Admin>
);

Better way is to support custom menu items inside menu but I didn't investigate this option because

  • there is RA v4 where CustomRoutes component exists
  • I don't know how to update the code of the lib for this

@erakli
Copy link
Author

erakli commented Apr 24, 2022

@ak-bigbasket Take a look please

@makivlach
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants