Skip to content

Feat: Render non-editable preview of navigation block for editors #69855

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

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

coder-rancho
Copy link

Devnote

What?

Closes #60809

Merges: #69794 and #69806

Adds a new non-editable mode to the Navigation block that renders the block list as disabled and non-editable.

Why?

This mode will be needed to render a preview of navigation block for users (e.g. editors) that can view a navigation block but not edit it.

How?

  1. Modify the navigation rest endpoint to allow any user role with the edit_post capability to view entities.
    • Overwriting the get_items_permissions_check and get_item_permissions_check methods of the rest_controller_class of the wp_navigation post type to check whether the current user can edit_posts.
  2. Adding a user capability check before rendering the editable Navigation block preview and for users that cannot edit it rendering an alternative locked down mode.

Testing Instructions

Testing Instructions for Keyboard

  1. Login as admin role.
  2. Insert Navigation block.
  3. Logout and login as editor role.
  4. Go to the post, take over.
  5. You'll see that you can see the block but can't select or edit it.

Copy link

github-actions bot commented Apr 8, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: coder-rancho <[email protected]>
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: getdave <[email protected]>
Co-authored-by: draganescu <[email protected]>
Co-authored-by: fabiankaegy <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Apr 8, 2025
Copy link

github-actions bot commented Apr 8, 2025

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @coder-rancho! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@Mamaduka
Copy link
Member

Mamaduka commented Apr 8, 2025

Thanks for merging PRs, @coder-rancho!

Discussions from #69794 still apply here, so let's try and continue working in that direction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Navigation Affects the Navigation Block First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a preview only mode to the navigation block
2 participants