简体   繁体   中英

How can I use both Resource and MenuItem in Admin menu

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?

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>
);

如文档所示,您当前必须自己添加它们

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM