Problem/Motivation
Currently, controls are rendered in a very specific way this is difficult to extend. Consider using a more standardized approach that would allow developers to alter the items in the controls UI elements (i.e. removing access to move buttons, adding a Library or Clone button, etc.).
Proposed resolution
Pass a list of children items to the controls template for rendering, allowing preprocess functions to alter the children in a way that follows Drupal development conventions.
Remaining tasks
Develop and test.
User interface changes
None.
API changes
This will change the way controls are rendered and alter the existing APIs for rendering controls -- i.e. hook_preprocess_layout_paragraphs_builder_controls, the layout-paragraphs-builder-controls.html.twig template, etc.
Data model changes
None.
Issue fork layout_paragraphs-3247290
Show commands
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 #3
justin2pin commentedMR39 adds a new private method
LayoutParagraphsBuilder::buildControls()for creating the controls build array and rendering it with thelayout_paragraphs_builder_controlstype.Developers can easily modify the
controlsarray inhook_preprocess_layout_paragraphs_builder_controls().MR includes test coverage with a test module
layout_paragraphs_alter_controls_testand new test classAlterControlsTest. Refer to that module for a simple example of how this might work.Comment #4
justin2pin commentedOk - this is ready to be merged. I also simplified the structure of the controls UI buttons so they can simply be rendered as link elements, rather than html_tag elements with nested "a" and "span" tags.
Note that this issue affects APIs. Specifically, the way controls are rendered has changed. See the layout_paragraphs_builder_controls template and LayoutParagraphsBuilder::buildControls() method for more details.
Getting this into dev also unblocks other work related to better permissions management, since controls UI elements can easily be disabled / removed / etc.
Comment #6
justin2pin commentedComment #7
RAFA3L commentedThanks Justin, look much better, I tried it this morning. I sent you a message from your Drupal profile.