Create a default task menu link for content overview so contrib doesn't have to

Created on 22 February 2021, over 3 years ago
Updated 2 September 2024, 3 months ago

Problem/Motivation

The main content overview page /admin/content is provided by the "Content" view that ships with core's node module. This view provides a default menu tab "content" only:

Other modules want to provide menu tasks below this main "Content" tab. For example, the Content Moderation module does this so it can provide a task menu link for "Moderated Content":

When creating menu tasks like this, there needs to be a default task item defined which represents the same content as the main menu tab. In this case, that's what the "Overview" menu task is.

The problem is that Drupal core (or more specifically, the node module), is not providing this default menu task. The Content Moderation module does it in content_moderation.links.task.yml:

content_moderation.content:
  title: 'Overview'
  route_name: system.admin_content
  parent_id: system.admin_content

content_moderation.moderated_content:
  title: 'Moderated content'
  route_name: content_moderation.admin_moderated_content
  parent_id: system.admin_content
  weight: 1

As a result, if there are OTHER modules that want to provide task menu items beneath content, they also need to provide this default "Overview" item. If you have Content Moderation enabled with any other module that does this, you end up with duplicate task menu links for the overview page. This is a problem encountered in the Scheduler module: #3167193: Move "Scheduled" menu tab so it's a task under "Content" β†’

Proposed resolution

Have the node module create a default menu task for the content overview page so core modules like Content Moderation and contrib modules like Scheduler don't need to.

Drupal's menu system is intelligent enough to not show it if it's the only tab defined which is perfect. It will only show if there's some other task defined by another module.

We can just move the definition for this task out of content moderation and into node.

Remaining tasks

None

User interface changes

API changes

Data model changes

Release notes snippet

The "Overview" local task, previously defined in the content_moderation module, is now moved to the system module in core. This change centralizes the content administration interface, making it more consistent across different sites regardless of whether content_moderation is enabled.

πŸ“Œ Task
Status

RTBC

Version

11.0 πŸ”₯

Component
SystemΒ  β†’

Last updated 2 days ago

No maintainer
Created by

πŸ‡ΊπŸ‡ΈUnited States bkosborne New Jersey, USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • @joegraduate opened merge request.
  • πŸ‡ΊπŸ‡ΈUnited States joegraduate Arizona, USA

    joegraduate β†’ changed the visibility of the branch 3199682-create-a-default to hidden.

  • Status changed to Needs review 3 months ago
  • πŸ‡ΊπŸ‡ΈUnited States mlncn Minneapolis, MN, USA

    This is needs review now? Looks great to me! So many contrib modules need to try to add this, not knowing if another module already has; having core do it would be so much better!

  • Status changed to Needs work 3 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    #14 mentions a change record so moving to NW for that.

    Thanks for keeping this one going.

  • Status changed to Needs review 3 months ago
  • πŸ‡ΊπŸ‡ΈUnited States trackleft2 Tucson, AZ πŸ‡ΊπŸ‡Έ

    Added a draft change record https://www.drupal.org/node/3468153 β†’ , Hopefully I understand the issue well enough.

  • Status changed to RTBC 3 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Think that's probably one of the most detailed CR's I've seen nice!

    Tested the MR to make sure no task appears when just 1 and everything still works when a module like content moderation is installed.

    LGTM

  • πŸ‡¬πŸ‡§United Kingdom jonathan1055

    Thank you for pushing this forward. Just a few points:

    1. The Change Record credits me, Joegraduate and Catch. But I can't see any mention of Catch here in the issue. In fact I did not know that CRs had credits
    2. The Issue is crediting Joegraduate and Bkosborne. I think Bkosborne should also be listed in the Change Record
    3. What discussion do we need regarding back-porting to Drupal 10? It should be possible, and would be highly desirable. Then modules such as Scheduler and others that created their own task would be more able to do the update to remove their duplicate
  • πŸ‡ΊπŸ‡ΈUnited States trackleft2 Tucson, AZ πŸ‡ΊπŸ‡Έ

    1 + 2 Deleted the credits on the change record.
    3. Whatever you all decide is fine with me in terms of backporting. If we are willing to make this kind of change in a patch release for 11.x why not for 10.x

  • πŸ‡³πŸ‡ΏNew Zealand quietone

    Thanks for the details change record!

    I read the issue summary, comments, MR and CR. Everything is in good order. There is just one question here, about BC, mentioned in #15. There is nothing about this is the 'how to deprecate' β†’ .

    I updated the credit here.

  • πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10

    There's been a couple of mentions of BC here for sites using contrib modules or profiles that provide their own version of this.

    I think we can easily add code to \Drupal\Core\Menu\LocalTaskManager::getDefinitions that filters the definitions where parent_id = system.admin_content, title = 'Overview' and route_name: = system.admin_content. If it finds more than one, it can trigger a deprecation error.

    Question is, is that overkill?

    Setting back to NR for second opinions on this.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Probably the more "proper" way to officially throw a deprecation error.

Production build 0.71.5 2024