Add link to add a new entity in an empty entity list controller table

Created on 29 September 2012, over 12 years ago
Updated 24 January 2023, over 2 years ago

Posted by xjm

This issue is a followup for #1781372: Add an API for listing (configuration) entities and #1783964: Allow entity types to provide menu items .

Problem/Motivation

Proposed resolution

Remaining tasks

User interface changes

Current behavior

Intended behavior

Feature request
Status

Needs work

Version

10.1

Component
Entity 

Last updated 3 days ago

Created by

Live updates comments and jobs are added and updated live.
  • Usability

    Makes Drupal easier to use. Preferred over UX, D7UX, etc.

  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

  • VDC

    Related to the Views in Drupal Core initiative.

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.

  • 🇮🇳India ayush.khare

    Reroll #110 for 10.1.x

  • 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10
    1. +++ b/core/lib/Drupal/Core/Entity/EntityListBuilder.php
      @@ -65,11 +82,17 @@ public static function createInstance(ContainerInterface $container, EntityTypeI
      +    $this->linkGenerator = $link_generator;
      

      Is the disruption of injecting the link generator worth it?

      All the other links we generate in this class (e.g. in operations) don't need/use it so that makes me feel we may not need it.

      That would dramatically reduce the complexity of this patch and the disruption to contrib.

    2. +++ b/core/lib/Drupal/Core/Entity/EntityListBuilder.php
      @@ -248,4 +269,61 @@ protected function ensureDestination(Url $url) {
      +        Url::fromUri('internal:' . $this->entityType->getLinkTemplate('add-page'))
      ...
      +        Url::fromUri('internal:' . $this->entityType->getLinkTemplate('add-form'))
      

      Is internal: our only option here?

      \Drupal\Core\Entity\Controller\EntityController::addPage uses Link::createFromRoute

    3. +++ b/core/lib/Drupal/Core/Entity/EntityListBuilder.php
      @@ -248,4 +269,61 @@ protected function ensureDestination(Url $url) {
      +    elseif ($this->entityType->hasLinkTemplate('add-form')) {
      

      This could return an exception if there is no add page link template, but there is an add-form link template but it requires additional parameters. So we probably would need a try/catch here.

      Also, we don't need elseif, there's a return above.

    4. Coming from 🐛 Remove duplicate "add block" link from block content type view's "Results not found" message Postponed I was expecting to see something here for admin lists that are built with views, as in reality most content-entity list builders are overridden with a view. It would be good to get an issue summary update here to address what the intended course of action is there.
  • 🇦🇺Australia acbramley

    I would like to unblock 🐛 Remove duplicate "add block" link from block content type view's "Results not found" message Postponed which was postponed based on #121.4

    IMO having duplicate links on a page that go to the same place isn't necessary. The action buttons are a much more prominent pattern in core and things like Node and Media don't and haven't had an Add link in the views table so people will be used to using the Add content/media buttons.

    If we still want the duplicate link in the list controller table that this issue is adding I think that's fine, but adding a generic area plugin for views seems like a much larger task and should either be agreed as a won't fix or moved to a separate issue?

Production build 0.71.5 2024