Motivation

Provide options to lock down a region within a section so that blocks in that region cannot be added/moved/deleted.

Proposed resolution

For any locked regions in a section, all operations are forbidden by the access controller and contextual links, etc., are removed for unprivileged users.

User interface changes

Add checkboxes for each region to the section configuration form.

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

muriqui created an issue. See original summary.

muriqui’s picture

Status: Active » Needs review
StatusFileSize
new8.38 KB

Here's the MR as a patch for those who may want to try it out.

jonzhang’s picture

Status: Needs review » Needs work
StatusFileSize
new10.86 KB

All the lock functions are working correctly. But the configuration icon is still showing when the block is locked. And the links are not clickable neither giving error messages which may confuse the end user.

Please see screenshot attached.
config menu shows up

muriqui’s picture

Status: Needs work » Needs review
StatusFileSize
new26.77 KB
new21.89 KB

OK, updated to address a condition wherein the contextual links weren't filtered properly, and to prevent other blocks from being moved into the locked region via the "Move" menu. Also fixed the config schema and added tests.

swentel’s picture

Wow, that's impressive, never thought about going that far as in locking regions :)

I'm checking the work to be done for D10 support, I'll probably start committing those things first, will come back after that to this one.

swentel’s picture

Priority: Normal » Major
StatusFileSize
new26.88 KB

WOOOOOO, I've tested this, this is SO awesome :)

Current patch is partially broken because I've committed #3304761: Group lock settings in a details element, attached a new version to see what the test bot thinks.

Going to look at the code and tests a bit further now, this will definitely go in!

swentel’s picture

Ok, I don't have any remarks on the code or tests, they look great!

The only thing I wonder is whether the UI should make the feature a bit more clearer/explicit:

This makes it a bit more clearer to me, because I can imagine people will come up with feature requests like 'But I want to only lock move or delete'. (even though I will point them to #3109715: Allow to add locks to components for that feature).

As English is not my native language, suggestions very welcome, after that, commit and release ! :)

dmitry.korhov’s picture

If there are no remarks and all looks great then can we have this merged?

dmitry.korhov’s picture

Status: Needs review » Reviewed & tested by the community
luke.leber’s picture

I think that having the same granularity with override locking as default locking might make for a more robust feature here.

What about sites where owners want lesser privileged users to be able to update overridden block content, but not rearrange them?

dalemoore’s picture

This is so awesome, and puts Layout Builder on closer parity with what WordPress can do with locking different parts of the Full Site Editor. I haven't tested this yet but will soon...

brentg’s picture

I've added the patch from @sonfd as a file here so it gets listed on top of the page

chesterr’s picture

Assigned: Unassigned » chesterr

Changed title and added description for better user understanding.

panchuk’s picture

Assigned: chesterr » panchuk
Status: Reviewed & tested by the community » Needs review

I want to review latest MR ASAP and deploy it in the new 2.0.x branch.

After that, we can create some RC releases with the feature.

panchuk’s picture

Okay, I finally configured the environment for the running of the tests.

I found that LayoutBuilderLockTest::testLock() fell because of the missing $blockId parameter in LayoutBuilderLockTest::checkBlockRouteAccess() method.

It looks like in Drupal 8/9 there was a way to fetch it via a magic method:

$blockId = $blockId ?? $this->body_field_block_uuid;

Going to investigate previous commits to the LayoutBuilderLockTest class, and maybe will find something related.

panchuk’s picture

Okay, finally I've fixed all the tests. The problem was with the body_field_block_uuid property, which was renamed in previous commits, but not updated in each place of code.

In addition, there were new style issues with the readme file. Disabled cspell checks for the maintainer's section.

Rewritten javascript of the module. Instead of jQuery, I used pure JS and removed outdated dependency core/jquery.

  • Panchuk committed 74b0f632 on 2.0.x authored by muriqui
    Issue #3314133 by Panchuk, muriqui, Chesterr, swentel, brentg, JonZhang...
panchuk’s picture

Assigned: panchuk » Unassigned
Status: Needs review » Fixed

Merged into 2.x, going to create RC.
Thanks, everyone for your contribution.

Status: Fixed » Closed (fixed)

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