RFC: View hooks beyond Deface #4594
Replies: 3 comments
-
Super excited about replacing deface with smaller replaceable pieces!!! 😍 The one consideration/downside that immediately comes to mind is that partials are really slow 🐌 (for each one of them has to build an instance of ActionView with its context, included modules, etc.). So I would use the technique you proposed, but with something like On that topic I think we don't even need to wait for |
Beta Was this translation helpful? Give feedback.
-
I like the idea and I'm happy to start a conversation about this but I have some concerns, which I think are some of the reasons why we are still relying on Deface: 1. Backward compatibility with existing Deface hooks A Deface hook at the moment has a 2. Multiple overrides in the same partial from different extensions The more we split views, the less probable is that two extensions override the same partials but this is still a thing to consider. I think the majority of place where this happens is into shared spaces like menus or tabs, but for those, I think we need to provide an interface in core to easily change them via code configuration and not via Deface (something similar to what we have done here). 3. How to find partials to override I think this approach will introduce a new problem, similar to the
problem. When we need to override a partial to add our custom stuff, we need to understand which version of the partial we are currently using. This means scanning all extensions and understand where the current version comes from, taking into account gems load order (Gemfile sorting?). An alternative approach that I was thinking about lately is:
What do you think? |
Beta Was this translation helpful? Give feedback.
-
Thanks @elia and @kennyadsl !
I very much like that
Yes, a mayor version for sure 👍
Absolutely 💯
This should be easier to solve if we use code (
Yes, and clients as well. Anyhow, I still think we need to start working on changing the admin into a more maintainable and likewise customizable way. |
Beta Was this translation helpful? Give feedback.
-
The problem
Extensions and stores want to make additions (or even changes) to the admin views. As of yet, the defacto standard for this is Deface. Deface brings a lot of other problems - first and foremost it hides view changes into places where they are hard to track down or introduces "where does this checkbox coming from?" problems. Also it is barely known outside the Spree/Solidus ecosystem. Additionally we need to maintain HTML hooks (
data-hook
) that exist solely for Deface to work properly. That makes admin views refactoring very hard.Proposal
I am proposing an idea that originally came up from @mamhoff while working with him on a client store that makes lots of changes to the Solidus admin. We removed Deface from that store a while ago and introduced another way to make admin view changes maintainable:
Rails partials
By splitting up the admin views into smaller chunks we make it easier for us to keep our admin maintainable during Solidus updates.
This is how it works
The Admin Orders table for example.
We split the
admin/orders/index.html.erb
template into several partials:1. The filter fields
2. The table
3. The table row
Summary
For index views I propose implementing a pattern like:
For edit views I propose implementing a pattern like:
I think adopting this into core will make future changes to the admin easier for us and extension maintainers as well as stores. Sure, this is a lot of work and there will be many cases where need to find a good solution for, but still I think it is worth it.
Beta Was this translation helpful? Give feedback.
All reactions