0

So I have Admin with all the resources that I need and it works great. But I also need one little menu item that would just open a simple form with a button.

I created Menu.js like it's described here:

https://marmelab.com/admin-on-rest//AdminResource.html#menu

And added it to my admin.

But after that I see only items that I have in that Menu, but not resources. How can I have them both: Resources and MenuItems in that menu?

Konstantin Bodnia
  • 1,372
  • 3
  • 20
  • 43

2 Answers2

2

Have a look at the framework's Menu.js for inspiration.

  • You need to loop through the passed in resources param and create <MenuItem>s for each resource
  • Add your own <MenuItem>s
  • Add the {logout} if you are using authentication

Ie:

import React from 'react';
import MenuItem from 'material-ui/MenuItem';
import { Link } from 'react-router-dom';

export default ({ resources, onMenuTap, logout }) => (
    <div>
        { resources.map(resource => {
          return <MenuItem
            key={resource.name}
            containerElement={<Link to={`/${resource.name}`} />}
            primaryText={resource.options.label}
            onTouchTap={onMenuTap}
          />
        })}

        <MenuItem key="download" containerElement={<Link to="/download" />} primaryText="Download" onTouchTap={onMenuTap} />

        {logout}
    </div>
);
jkrnak
  • 956
  • 6
  • 9
0

As shown in the documentation, you currently have to add them by yourself

Gildas Garcia
  • 6,966
  • 3
  • 15
  • 29