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 shouldShowSidebarLink to registerOperatorRoute #329

Merged

Conversation

loan-laux
Copy link
Contributor

Impact: minor
Type: feature

Issue

There's currently no clean way for developers to programmatically decide whether to show their reaction-admin plugin's link in the sidebar depending on the current shop.

Solution

Introduce the shouldShowSidebarLink option for registerOperatorRoute. shouldShowSidebarLink takes a function that should expect the current shop as its only argument and should return true if the sidebar link should be shown, or false if it shouldn't.

Example usage for a link should only be shown when viewing the primary shop:


registerOperatorRoute({
  group: "navigation",
  mainComponent: SomePlugin,
  path: "/some-plugin",
  shouldShowSidebarLink: (currentShop) => currentShop.shopType === "primary"
});

Breaking changes

None.

Testing

  1. Register a route using shouldShowSidebarLink.
  2. Make sure the route link show up (or doesn't) as you expect it to in the sidebar.

Signed-off-by: Loan Laux <loan@outgrow.io>
Signed-off-by: Loan Laux <loan@outgrow.io>
Signed-off-by: Loan Laux <loan@outgrow.io>
@rosshadden rosshadden merged commit 784927a into reactioncommerce:trunk Oct 6, 2020
@mikemurray mikemurray mentioned this pull request Dec 4, 2020
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