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.

Command icon 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

justin2pin created an issue. See original summary.

justin2pin’s picture

Status: Needs work » Needs review

MR39 adds a new private method LayoutParagraphsBuilder::buildControls() for creating the controls build array and rendering it with the layout_paragraphs_builder_controls type.

Developers can easily modify the controls array in hook_preprocess_layout_paragraphs_builder_controls().

MR includes test coverage with a test module layout_paragraphs_alter_controls_test and new test class AlterControlsTest. Refer to that module for a simple example of how this might work.

justin2pin’s picture

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

  • justin2pin committed e3cda3b on 2.0.x
    Issue #3247290: Make it easier for 3rd-party modules to alter the...
justin2pin’s picture

Status: Needs review » Fixed
RAFA3L’s picture

Thanks Justin, look much better, I tried it this morning. I sent you a message from your Drupal profile.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.