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!
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | bootstrap_styles-permissions-3193599-3.patch | 13.44 KB | justcaldwell |
Comments
Comment #2
mahmoud-zayed commentedHi 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
Comment #3
justcaldwellThat's great — thanks, Mahmoud!
The attached patch:
checkUserAccess()helper method to StylePluginBase.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!
Comment #4
aaronchristian commentedNice 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.
Comment #5
aaronchristian commentedComment #6
justcaldwellThanks, 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.
Comment #7
justcaldwellHi 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!
Comment #8
mahmoud-zayed commentedComment #9
mahmoud-zayed commentedSwitch the branch to target the v2.