Problem/Motivation

Ideally, content editors should still be able to see the menu settings for menu links at restricted levels in the node form but not be able to edit or remove them.

Testing steps

Needs to be tested in both Drupal 10 and Drupal 11. You can use the Tugboat environment associated with this issue to test Drupal 11 (.

Setup:
Note that the tugboat environment has steps 1-3 already configured. Users/passwords: admin and qa_editor

  1. Need two roles with admin level permissions + page editing permissions (e.g. admin and content_editor)
  2. admin role needs the "administer restricted menu levels" permission and content_editor should not have this.
  3. create a user with the content_editor role
  4. On /admin/config/user-interface/menu-level-permissions restrict the main navigation menu and select level one only

Test:

  • Admin can add/edit/delete all menu links in node forms at level 1 or level 2.
  • Editor can add links at level 2.
  • Editor cannot add links at level 1.
  • Editor can edit and remove existing links at level 2.
  • If an editor edits a node with an existing level 1 link, they either see the fields as disabled in the node form (Drupal 10) or see a message indicating that they don't have access to edit the menu because of level (Drupal 11).
  • An editor can edit a node with an existing level 1 link and save without any impact to the existing menu item.
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

jastraat created an issue. See original summary.

jastraat’s picture

Note that this will only work in Drupal 10. In Drupal 11, Drupal returns AccessResultForbidden for the menu element within the node form based on the access of the existing associated menu link content item. This means that the menu section is fully removed already from the node form.

jastraat’s picture

Issue summary: View changes
jastraat’s picture

Title: Allow editors to see but not edit level restricted menu links in the node form » Allow editors to see but not edit level-restricted menu links in the node form
cameron prince’s picture

10.5.2 Testing

Setup:

(+) Need two roles with admin level permissions + page editing permissions (e.g. admin and content_editor)
(+) admin role needs the "administer restricted menu levels" permission and content_editor should not have this.
(+) create a user with the content_editor role
(+) On /admin/config/user-interface/menu-level-permissions restrict the main navigation menu and select level one only

Test:

(+) Admin can add/edit/delete all menu links in node forms at level 1 or level 2.
(+) Editor can add links at level 2.
(+) Editor cannot add links at level 1.
(+) Editor can edit and remove existing links at level 2.
(+) If an editor edits a node with an existing level 1 link, they either see the fields as disabled in the node form (Drupal 10) or see a message indicating that they don't have access to edit the menu because of level (Drupal 11).
(+) An editor can edit a node with an existing level 1 link and save without any impact to the existing menu item.

All tests pass.

cameron prince’s picture

Status: Active » Reviewed & tested by the community

On D11 with tugboat, all tests pass as well. MR looks good.
Setting RTBC.

  • jastraat committed db502acf on 1.0.x
    Issue #3540845 by jastraat: Allow editors to see but not edit level-...
jastraat’s picture

Thank you! Merged -

jastraat’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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