Closed (fixed)
Project:
farmOS
Version:
2.0.0-alpha2
Component:
User interface
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
20 Sep 2021 at 11:34 UTC
Updated:
6 Oct 2021 at 19:29 UTC
Jump to comment: Most recent
The current behaviour of the Dashboard controller only allow to render blocks of type block content.
Try to add a custom block id in the hook_farm_dashboard_panes() and the controller will return Call to a member function getPlugin() on null
Implement a solution to render custom blocks in addition to content blocks.
- Add new key in hook_farm_dashboard_panes to manage custom blocks.
- Implements the behaviour to render custom blocks in the dashboard controller.
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #1
evamtinezevamtinez created an issue.
Comment #2
evamtinezAdded new key to hook_farm_dashboard_panes() to differentiate content blocks from plugin blocks and used that key to render the custom blocks in the dashboard controller.
Comment #4
evamtinezComment #5
m.stentaThanks @evamtinez! This looks good to me! I'll wait to see if @paul121 has any thoughts before merging this.
Also: since most of our existing blocks are plugins, I think we could refactor those to use this approach, rather than providing config entities.
Comment #6
m.stentaHmm, on second thought - should we just refactor our existing code to use plugins ALWAYS? That was the original intention.
And then maybe we punt on supporting blocks created via the UI (config entities) until we have a full-featured dashboard builder based on Layout Builder? Just thinking out loud...
What do you think @paul121?
Comment #7
m.stentaAh hmm now that I look closer at our existing blocks, I think we will need to keep support for config entities too... because our
dashboard_mapblock has some settings. So maybe we will need both mechanisms anyway.Comment #8
m.stentaWith that in mind, I think this is good to go! I'll just wait to give @paul121 a chance to review.
I'll prepare a follow-up commit that refactors some of our dashboard blocks to use the
block_pluginapproach instead ofblock+ config entity.Thanks again @evamtinez!
Comment #9
m.stenta@evamtinez - Ah actually I'm not sure if this is working as expected.
I tried using this approach for our "Metrics" dashboard block, but I'm getting the following error when I view the dashboard:
User error: "0" is an invalid render array key in Drupal\Core\Render\Element::children()Setting this back to "Needs work".
Comment #10
m.stentaSorry - my mistake - I needed to pull your two latest commits. Working fine for me now. :-)
Comment #11
evamtinezYou're welcome @m.stenta and thank you for testing it.
Comment #13
m.stentaI talked this over with @paul121 and we decided to just use your approach for ALL block handling @evamtinez. In other words: instead of separate
blockandblock_pluginoptions, we will ONLY haveblock, but it will expect a block plugin ID, and will use the code you provided.I've added a commit that makes this change after yours, and adapted our existing dashboard blocks to take this approach.
One disadvantage of doing this is that it's no longer possible to include blocks that are created via the UI. But our thought is that this would really only be useful if you could also place them in the dashboard via the UI as well, with something like Layout Builder. So I created a follow-up issue to discuss that: #3238637: Use layout builder for farmOS dashboard