-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[admin] Embed SolidusAdmin routes in SolidusAdmin components #5504
Conversation
Codecov Report
@@ Coverage Diff @@
## main #5504 +/- ##
=======================================
Coverage 88.93% 88.94%
=======================================
Files 622 622
Lines 14918 14921 +3
=======================================
+ Hits 13268 13271 +3
Misses 1650 1650
📣 Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should not mix in the route helpers as regular methods, but use a prefix instead (ie routes
).
def self.inherited(child) | ||
super | ||
child.include SolidusAdmin::Engine.routes.url_helpers | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I would prefer a method routes
, so that we can a) extend it and b) easily separate the routes from regular methods in the components.
@@ -31,7 +31,7 @@ | |||
</div> | |||
<%= render component("sidebar/account_nav").new( | |||
user_label: helpers.current_solidus_admin_user.email, | |||
account_path: solidus_admin.account_path, | |||
account_path: account_path, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be easier to understand where this method comes from by prefixing it with routes
, like with helpers
.
account_path: account_path, | |
account_path: routes.account_path, |
@tvdeyen I see the point, the current implementation is based purely on the existing VC implementation that includes them by default. That said, as a counterpoint, I would offer that routes already are separated by using exclusively the |
The VC folks made helpers available with the |
@tvdeyen I was referring to this https://github.com/ViewComponent/view_component/blob/main/lib/view_component/base.rb#L477-L481. Routes along with some helpers[1] are included in the base, the only reason we initially went with separate routes helpers was to mimic Rails having engine scopes. But we're working from within the engine, and if anything would make sense to have the engine routes immediately available and the host app routes available through 1: |
We might be working from another engine (extensions) or even the main Rails app. If this is still possible, ok. But I think the interface would be much easier if we can inherit from a Solidus component and simply override or extend the |
Maybe you could provide a reason where you see the advantage in mixing this as module instead of using a proxy method. Is there a bug you want to fix? You just proved a lot of reasons for avoiding the proxy method. Where are the pros of the module mix in? Can you give an example? |
@tvdeyen it's quite simply less overhead and noise, i.e. removing the redundancy of typing |
I do not agree with this, tbh. Less magic, extensibility and explicitness is way more important, imo. Especially in open source projects. |
Summary
SolidusAdmin routes should be available by default.
Probably will require a last minute rebase to account for any newly merged PR.
Checklist
Check out our PR guidelines for more details.
The following are mandatory for all PRs:
The following are not always needed: