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.

CommentFileSizeAuthor
#5 dashboards_demo.png329.73 KBpaul121

Comments

m.stenta created an issue. See original summary.

m.stenta’s picture

Related: 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.

paul121’s picture

We 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

paul121’s picture

We also discussed the dashboards module: 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 a details element to improve the styling. We could likely accomplish the same thing with some custom styling instead of using the details element.

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:

  • A layout is composed of "sections". Thus, the core layout builder has the concept of SectionStorage plugins. See SectionStorageInterface and SectionStorage. Also the SectionListInterface
  • The core layout builder module alters the entity_view_display config entity to use a new class and specify a new storage class - these classes are defined here. The config entity class implements SectionListInterface while the storage class implements SectionStorageInterface. This makes sense because the entity_view_display is what is optionally configured to use layout builder (and saved using third party settings)
  • SO... it's not surprising to see that the dashboard config entity defined by the dashboards module directly implements SectionListInterface. There is a separate SectionStorage plugin that loads these dashboard config 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!

paul121’s picture

StatusFileSize
new329.73 KB

Adding a screenshot of the dashboard I was able to build using the dashboards module. The "Dashboards" dropdown in the user toolbar is a nice addition!

m.stenta’s picture

Issue tags: -beta blocker

Thanks 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.

pcambra’s picture

I'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.

m.stenta’s picture

Status: Active » Needs review
m.stenta’s picture

Version: 2.x-dev » 3.x-dev
m.stenta’s picture

Version: 3.x-dev » 4.x-dev