Problem/Motivation

Entity operations for menu items are hard coded in the edit menu form; add or alter operations are impossible.

Proposed resolution

Introduce a menu link list builder that provides the operations and invokes all existing hooks for other modules to alter the operations or provide custom ones. Update the menu plugins to provide relevant links.

Remaining tasks

Get proper translate route for content links.

User interface changes

none.

API changes

none.

Comments

gapple created an issue. See original summary.

gapple’s picture

gapple’s picture

Status: Active » Needs review

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Category: Bug report » Task
Issue tags: +Bug Smash Initiative, +Needs reroll

Looks like this still needs to be done. And this is not a bug, changing to a task.

quietone’s picture

Status: Needs review » Needs work

This should be NW

immaculatexavier’s picture

Assigned: Unassigned » immaculatexavier
immaculatexavier’s picture

Assigned: immaculatexavier » Unassigned
Status: Needs work » Needs review
StatusFileSize
new10.98 KB
new8.76 KB

Rerolled against #2

immaculatexavier’s picture

StatusFileSize
new10.98 KB
new1 KB

Fixed custom command line against #19

Status: Needs review » Needs work

The last submitted patch, 20: 2684577-20.patch, failed testing. View results

medha kumari’s picture

Version: 9.4.x-dev » 9.5.x-dev
Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new8.8 KB

Reroll the patch #20 with Drupal 9.5.x

Status: Needs review » Needs work

The last submitted patch, 22: 2684577-22.patch, failed testing. View results

ameymudras’s picture

Did try to review the patch, but not able to replicate the scenario correctly. Can someone provide testing steps here

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

tim-diels’s picture

Status: Needs work » Needs review
StatusFileSize
new10.61 KB
new1.76 KB
new30.42 KB
new38.67 KB

I tried latest patch #22 which is completely wrong and untested. So next time @medha-kumari I suggest you test the patch before submitting. Going to hide patch from #22.

I tried patch #20, which did also not work on latest 9.5.x.
This seems to be related due to changes between older versions and 9.5.x.

Going to hide patch #19 also as they are re-rolled in #20

I'v re-rolled the patch #20 to 9.4.x/9.5.x and tested if its working like it should.

Steps to reproduce:

  1. Install the module devel
  2. Add a link to a menu
  3. Visit the links overview for that menu
  4. Open the contextual links
  5. See that devel is NOT added

Steps to test:

  1. Apply patch
  2. Install the module devel
  3. Add a link to a menu
  4. Visit the links overview for that menu
  5. Open the contextual links
  6. See that devel is added

The scenario could be different depending on the use case.
For me the use case was that the Layout contextual link was not shown after installing Layout Builder Operation Link
Or you can add or alter contextual links yourself with hook_contextual_links_alter().

I don't have any Drupal 10 website running at the moment where I can test this and being short on time to set one up.
Also not really sure how to tackle this then. Should we create a patch for 10.x and port this to 9.x?
Anyone with more experience could shine a light?

Janvi Dasani’s picture

StatusFileSize
new8.26 KB

Added patch against #26 in 10.1.x

Status: Needs review » Needs work

The last submitted patch, 27: 2684577-27.patch, failed testing. View results

gaurav-mathur’s picture

Assigned: Unassigned » gaurav-mathur
gaurav-mathur’s picture

Assigned: gaurav-mathur » Unassigned
Status: Needs work » Needs review
StatusFileSize
new8.26 KB
new21.47 KB
new22.86 KB

Hi based on #27 i have Re-roll the patch and tested on Drupal 10.1.x
adding screenshot for the reference.
Kindly review patch
Thank you.

Status: Needs review » Needs work

The last submitted patch, 30: 2684577-30.patch, failed testing. View results

mohit_aghera’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests, -Needs steps to reproduce
StatusFileSize
new3.26 KB
new13.86 KB
new3.26 KB

Adding a test case to validate the changes made in #26
Also, added test-only patch to replicate the scenarios.

@gaurav-mathur @Janvi Dasani:
We really don't need to re-roll the patch for 10.1.x since the patch for 9.5.x is cleanly applied on 10.1.x as well.
I suggest when you do the re-roll, please add a re-roll diff as well.
Here is the guide to generate the diff of re-roll.
That helps everyone to get more idea about the difference.

I am going to hide patch in #27 and #30 since those are incorrect reroll and not required. Feel free to enable display again if you see those are not applied correctly.

The last submitted patch, 32: 2684577-32-test-only.patch, failed testing. View results

prasanth_kp’s picture

StatusFileSize
new24.97 KB
new25.51 KB

#32 Patch Applied on
10.1.x-dev and it fixes the issue.

smustgrave’s picture

Status: Needs review » Needs work

#1956134: Provide helpful editing links on "admin/structure/block" for deriver blocks (menu, views, block content, etc.) is doing something very similar.

getOperations() {
1. Should be typehinted as a new function

getResetRoute()
2. ditto

Typehint should be added for new functions in all spots.

Very nice work though!

smustgrave’s picture

Issue tags: +Needs change record

Oh will need a change record also.

mohit_aghera’s picture

Status: Needs work » Needs review
Issue tags: -Needs change record
StatusFileSize
new14.22 KB
new2.87 KB

- Added type hints in the necessary methods.
- Added a change record here https://www.drupal.org/node/3338898 (first one from me 🎉)
Tests are passing on local.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Thank you!

catch’s picture

Status: Reviewed & tested by the community » Needs work

Overall looks good, but a couple of nits:

  1. +++ b/core/lib/Drupal/Core/Menu/MenuLinkBase.php
    @@ -160,6 +167,38 @@ public function getTranslateRoute() {
     
    +  public function getOperations(): array {
    +    $operations = [];
    +
    

    This is missing phpdoc.

  2. +++ b/core/lib/Drupal/Core/Menu/MenuLinkInterface.php
    @@ -228,4 +238,16 @@ public function getEditRoute();
    +   */
    +  public function getOperations(): array;
    +
    

    OK it is because the interface method is added here. 1-1 rule so method addition is fine.

  3. +++ b/core/modules/menu_link_content/src/Plugin/Menu/MenuLinkContent.php
    @@ -185,23 +192,50 @@ public function getDescription() {
        */
       public function getTranslateRoute() {
    +    // TODO get link from ListBuilder values?
         return $this->getEntity()->toUrl('drupal:content-translation-overview');
       }
    

    Should this todo be resolved by this issue?

pooja saraah’s picture

StatusFileSize
new14.25 KB
new344 bytes

Addressed the comment #39 point 1
Keeping it in NW to address other point in #39
Attached patch against Drupal 10.1.x

mohit_aghera’s picture

Status: Needs work » Needs review
StatusFileSize
new14.28 KB
new731 bytes

- Attempting to fix the third suggestion in comment #39
Pulling translate link from operations.
I run all the test cases of `menu_link_content` module on local and those are still passing.

Status: Needs review » Needs work

The last submitted patch, 41: 2684577-41.patch, failed testing. View results

mohit_aghera’s picture

Status: Needs work » Needs review

Moving back to Needs review since last failure was un-related and was from CkEditor5 module.
I triggered re-test and it is passing now.

catch’s picture

Status: Needs review » Reviewed & tested by the community

Both of those look good!

quietone’s picture

I did some formatting and minor text changes to the Change record.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed f693212 and pushed to 10.1.x. Thanks!

  • catch committed f6932126 on 10.1.x
    Issue #2684577 by mohit_aghera, tim-diels, pooja saraah, gapple,...
catch’s picture

gapple’s picture

CR published

Status: Fixed » Closed (fixed)

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

berdir’s picture

There's a subtle API change here that broke a test in token module. Unlike the hardcoded logic before, the list builder checks access and doesn't return the edit route if the current user doesn't have access to it. The token tests didn't test this token with a logged in user, see #3360831: Fix test fail on Drupal 10.1.

rkoller’s picture

I am leaving a comment for reference and awareness. During today's usability meeting #3420206: Drupal Usability Meeting 2024-02-16 we were discussing #3387665: Warn user when entity delete will cause menu item re-parenting. During the testing we've noticed the following issue i've created a followup issue for: #3421998: Menu links created by a view have a visually and functionally broken delete option. During the meeting we've tested on a install of Drupal 11.x. While writing up the followup I've tested on a install of Drupal 10.1.0 - the problem already existed there as well.