-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Template: Only show post template actions to users with correct capabilities #33392
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your work here @walbo ! This is something we should fix indeed.
Currently for handling of templates
we use the edit_theme_options
capability. I think we should use the same permission check here. In order to do that I guess we should add an __experimentalUserCanEditThemeOptions
or something like that here with post-editor
context, set it editor-settings
and in use-block-editor-settings.js
and finally use this value to conditionally show/hide the controls.
I'd love some thoughts about this from @gziolo .
I'm not sure if there are any permissions tied to a related REST resource here. In that case, we could use gutenberg/packages/core-data/src/selectors.js Lines 682 to 685 in 3c84158
In general, it would be great to have a higher level selector that lets us check permission through REST API, rather than overload settings for that purpose. |
It's tied to the templates REST api. Updated the permission check to use Can you confirm this is correct usage @gziolo ? |
I'm not sure this is 100% correct but it requires folks with better caps knowledge than me to chime in :) . If you try this:
In admin and author roles are all |
I'm not sure if that is correct. Let's wait for feedback from other folks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚢
Description
Post template actions shows on user that doesn't have correct capabilities. Ex editors has a
New
button but when they try to create a new template nothing happens. (See screenshot)How has this been tested?
Locally with a
editor
user and with aadminitrator
user.Screenshots
Before
After
Types of changes
Bug fix. Only show post template actions for users with correct capabilities
Checklist:
*.native.js
files for terms that need renaming or removal).