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

Can't add two (or more) menu entries for same resource #27

Open
TCM5 opened this issue Jul 7, 2021 · 3 comments
Open

Can't add two (or more) menu entries for same resource #27

TCM5 opened this issue Jul 7, 2021 · 3 comments
Labels
enhancement Enhancement to an existing feature (major or minor)

Comments

@TCM5
Copy link

TCM5 commented Jul 7, 2021

Because menu tree is built based on mapped resources the current implmentation will not allow the following features:

  • Add two or more menu entries for same resource
    For example, it's a common use case to have two menus that references the same resource but will redirect to a filtered list like this:
<MenuItemLink
        to={`/products`}
        primaryText={translate(`resources.products.name`, {
            smart_count: 2,
        })}
        leftIcon={<products.icon />}
 />
<MenuItemLink
      to="/products?filter=category==1"
          primaryText="smartphones"
          leftIcon={<products.icon />}
      />
  • Add a custom menu (non-resource based). For example, a preferences menu.
  • Specific ordering based on some criteria (this is not necessary a problem because we can re-arrange resources mapping to solve this)
@TCM5 TCM5 added the bug Something isn't working label Jul 7, 2021
@harshit-budhraja
Copy link
Contributor

@TCM5 What could be a use-case where you'd want to add more than one menu with the same resource name? The name prop in <Resource>, by react-admin's design, is supposed to be unique as it is responsible for the app's routing as well as determines the API Endpoint. Can you please help me with more details?

Ref: https://marmelab.com/react-admin/Resource.html#name

@sivaavkd This cannot be classified as a bug. Can you please change the label from bug to something more relevant?

@TCM5
Copy link
Author

TCM5 commented Jul 8, 2021

@TCM5 What could be a use-case where you'd want to add more than one menu with the same resource name? The name prop in <Resource>, by react-admin's design, is supposed to be unique as it is responsible for the app's routing as well as determines the API Endpoint. Can you please help me with more details?

Ref: https://marmelab.com/react-admin/Resource.html#name

@sivaavkd This cannot be classified as a bug. Can you please change the label from bug to something more relevant?

Hi @harshit-budhraja , sorry for the incomplete/misleading initial thread. I already have update it with a complete description.

Btw, the bug label was auto-assigned and I can't change it. If you can, please do.

@TCM5 TCM5 changed the title Can't add same resource to the tree Can't add two (or more) menu entries for same resource Jul 8, 2021
@sivaavkd sivaavkd added enhancement Enhancement to an existing feature (major or minor) and removed bug Something isn't working labels Jul 14, 2021
@sivaavkd
Copy link
Collaborator

I just tried below code and I was able to create a menu item pointing to a custom menu (point 2 above).

<Resource icon={MoveToInboxIcon} name="preferences" options={{ "label": "Preferences", "windowTitle": "Admin - Preferences" }} list={Preferences}/>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement to an existing feature (major or minor)
Projects
None yet
Development

No branches or pull requests

3 participants