Problem/Motivation
In #3169203: farmOS 2.x Dashboard we added a farmOS dashboard. We briefly explored using Layout Builder at this time, but ended up going with a simpler custom Controller + hook_farm_dashboard_panes() approach, which is similar to what we had in farmOS 1.x. Then in #3188797: Dashboard layout we adopted a stacked two-column layout for the dashboard.
I'm opening this as a follow-up to those issues, so we can explore using Layout Builder more thoroughly for the farmOS dashboard.
I'd like to understand what it would require, what considerations there are, and most importantly (as it pertains to whether or not we can do this before the first beta release) what the transition from the hook-based approach to a Layout Builder approach would take (is it a breaking change? or can we somehow support both? this will determine if we need to do this before beta, or if it can wait)
Proposed resolution
TBD
Remaining tasks
TBD
User interface changes
TBD
API changes
None.
Data model changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | dashboards_demo.png | 329.73 KB | paul121 |
Comments
Comment #2
m.stentaRelated: in #3236712: Allow render custom blocks in the dashboard we made the decision to limit the current dashboard panes hook to work only with block plugins (not blocks defined via config entities). We don't really need that now, so that's OK. But using Layout Builder would presumably restore this ability and enable them to be placed in the dashboard via the UI as well.
Comment #3
paul121 commentedWe chatted about this in the most recent dev call. Continuing from what @mstenta mentioned in the Problem/motivation, we determined that a transition to using layout builder in the dashboard seems like it could be pretty straightforward.
The transition would mostly just *add* the concept of a dashboard config entity that would be used to save the layout builder configuration. A "default" dashboard would be added in config/install (maybe via an update hook as well?) which could then be further customized by users.
This would likely also deprecate/remove
hook_farm_dashboard_panes()and remove the ability for modules to always add to the dashboard (although this could still be possible via page render hook). @symbioquine mentioned that the hook could still be used to collect modules' panes and include them in a dedicated "module pane block", but a disadvantage is that this block could only be included in a single region of the dashboard. Perhaps we could reuse the hook on a new settings page to "demo" what dashboard panes are available and provided by modules.Overall taking away the ability for modules to add to the dashboard seems like "a very small price to pay for the kind of power and flexibility layout builder (and it's UI tooling) would provide" - @mstenta
Comment #4
paul121 commentedWe also discussed the
dashboardsmodule: https://www.drupal.org/project/dashboards Last night I dropped it in to give it a try.The module itself is buggy and has submodules that depend on
node.. but I was impressed with what was possible with layout builder! Attached is a screenshot of a dashboard configured the same as our current dashboard, the only difference being that our dashboard wraps each pane in adetailselement to improve the styling. We could likely accomplish the same thing with some custom styling instead of using thedetailselement.So it seems like it could be pretty easy to roll our own implementation of dashboard config entities. I did a little investigation to see how this is working, here are my notes:
SectionStorageplugins. See SectionStorageInterface and SectionStorage. Also the SectionListInterfaceentity_view_displayconfig entity to use a new class and specify a new storage class - these classes are defined here. The config entity class implementsSectionListInterfacewhile the storage class implementsSectionStorageInterface. This makes sense because theentity_view_displayis what is optionally configured to use layout builder (and saved using third party settings)SectionListInterface. There is a separate SectionStorage plugin that loads thesedashboardconfig entities.I'm sure there are other details to getting this to work, but that at least helped me understand how the core of this is working!
Comment #5
paul121 commentedAdding a screenshot of the dashboard I was able to build using the
dashboardsmodule. The "Dashboards" dropdown in the user toolbar is a nice addition!Comment #6
m.stentaThanks for the summary @paul121! I think based on these findings we don't need to make this a beta-blocker. The transition won't break things very much - it may just require a bit of configuring afterwards if folks have customized their dashboard at all.
Comment #7
pcambraI've pushed a Github repo with the work done so far on NFA: https://github.com/Cambrico/farm_ui_layout_builder
This module does basically two things:
- Overrides the templates for full pages of log, asset and plan, allowing to provide a layout per content type.
- Integrates Layout Builder routing module (made also for this) https://www.drupal.org/project/lb_routing so all "arbitrary" pages have LB capabilities: this includes by default the homepage/dashboard, and the listings of assets/logs/plans (views based)
It should be drop in, enabling it will add a LB layer on top of what's already existing and replace it with layouts.
I've included the views for plans, logs and assets in config/install, but we should discuss how these would work. The only change I made in them is to mimic the page display into a block, so if we could add that to farmos core before considering the module, that'd be fantastic, otherwise, we would need to provide additional views and displays for the export within the farm_ui_layout_builder module.
Comment #8
pcambraNote that this would, in a way, fix #3244733: Don't force two column layout on default display mode when Layout Builder is enabled as well
Comment #9
m.stentaComment #10
m.stentaComment #11
m.stenta