Problem/Motivation

It would be useful to implement per-style plugin permissions (e.g. edit background media, edit scroll effects, etc.) so styles can be enabled, but restricted to roles/users as needed.

For example, I can see allowing most users to access to border, margin, padding and text alignment, but I would want to restrict use of background images/video and scroll effects to users with appropriate skills/training (e.g. designers, site builders, admins).

Proposed resolution

Create 'edit' permissions for each style plugin. Add appropriate '#access' values to style form elements.

I'm currently doing this in a custom module with hook_form_BASE_FORM_ID_alter(). I'd be glad to work on a patch, but wanted to see if the maintainers are interested before I start.

Thanks!

Comments

justcaldwell created an issue. See original summary.

mahmoud-zayed’s picture

Status: Active » Needs work

Hi justcaldwell,

It will be a nice feature, and I agree with you make the permission per plugin, looking forward to seeing a patch for it!

Thanks,
Mahmoud

justcaldwell’s picture

Title: Consider adding permissions per style » Add per-style permissions
Status: Needs work » Needs review
StatusFileSize
new13.44 KB

That's great — thanks, Mahmoud!

The attached patch:

  1. Dynamically creates a 'use' permission for each style plugin (/src/Permissions/StylesPermissions).
  2. Adds a checkUserAccess() helper method to StylePluginBase.
  3. Sets '#access' values as needed on all the current plugins.
  4. Sets appropriate '#access' values for style group details elements.

If/when new style plugins are added, permissions will be created automatically, and the checkUserAccess() method should make it easy for developers to manage access to form elements as needed.

If this moves forward, Bootstrap Layout Builder and Layout Builder Blocks would both need a minor tweak to ensure the Styles tab doesn't display if the user can't access any styles. I can post that code in separate issues on those modules.

Thanks very much for all these modules — I'm looking forward to your feedback!

aaronchristian’s picture

Nice work Michael!

I'm not aware of any other platforms that allow for permission-based site building.

Some much needed, and a very welcome enhancement to the module.

aaronchristian’s picture

Assigned: Unassigned » mahmoud-zayed
justcaldwell’s picture

Thanks, Aaron!

The associated patches for Bootstrap Layout Builder and Layout Builder Blocks are at #3194086: Support per-style permissions (3193599) and #3194087: Support per-style permissions (3193599). Let me know if there's anything else I can do.

justcaldwell’s picture

Hi Aaron and Mahmoud! Since this hasn't made it in to v2, I'm hoping maybe permissions will be included in the v3 release. If so, any rough timeline on when that might be available?

Thanks!

mahmoud-zayed’s picture

Version: 1.0.x-dev » 2.0.x-dev
mahmoud-zayed’s picture

Switch the branch to target the v2.