Follow up from #2375589: Convert custom block library page to views

The empty table text at admin/content "No content available" needs to be updated to add a link for "Add content" per https://www.drupal.org/node/1146122

Before and After Screenshots

1. Before Patch
before applying patch

2. After Patch
After applying patch

CommentFileSizeAuthor
#157 2454309-155.patch7.4 KBpavnish
#157 interdiff_149_155.txt2.65 KBpavnish
#153 interdiff_149_153.txt1.78 KBpavnish
#153 2454309-153.patch7.16 KBpavnish
#149 interdiff_147-149.txt663 bytesvsujeetkumar
#149 2454309_149.patch7.29 KBvsujeetkumar
#147 interdiff_144_147.txt752 bytesRkumar
#147 2454309-147.patch7.5 KBRkumar
#146 interdiff_144_145.txt752 bytesRkumar
#146 2454309-145.patch7.5 KBRkumar
#144 2454309-144.patch7.33 KBsharma.amitt16
#140 2846614-140.patch7.38 KBshaktik
#139 Screenshot 2020-05-13 at 3.56.11 PM.png16.19 KBRkumar
#136 interdiff-2846614-133-136.txt2.67 KBsja112
#136 2846614-136.patch7.38 KBsja112
#133 interdiff-2846614-130-133.txt1.51 KBsja112
#133 2846614-133.patch7.42 KBsja112
#131 interdiff_130-131.txt1.49 KBshobhit_juyal
#131 2454309-131.patch6.81 KBshobhit_juyal
#130 2846614-130.patch6.31 KBandypost
#130 interdiff.txt5.61 KBandypost
#124 2454309-124.patch8.06 KBsja112
#122 2454309-121.patch8.44 KBsja112
#120 2454309-114.patch4.89 KBsja112
#118 2454309-113.patch4.76 KBsja112
#112 interdiff.2454309.109-112.txt703 bytesabhisekmazumdar
#112 2454309-112.patch6.82 KBabhisekmazumdar
#109 2454309_109.patch6.79 KBvsujeetkumar
#100 slogan.png44.15 KBjoginderpc
#99 Welcome to drupal 8 drupal 8.png44.15 KBjoginderpc
#99 add-content.png46.38 KBjoginderpc
#94 add_add_content_link-2454309-94.patch6.74 KBdagmar
#89 Patch_applied.JPG53.12 KBTrupti Bhosale
#89 after_patch_2.JPG94.15 KBTrupti Bhosale
#89 after_patch_1.JPG100.06 KBTrupti Bhosale
#83 add_add_content_link-2454309-83.patch6.72 KBjibran
#83 interdiff.txt607 bytesjibran
#81 add_add_content_link-2454309-81.patch6.72 KBjibran
#81 interdiff.txt1.69 KBjibran
#80 add_add_content_link-2454309-80.patch6.79 KBjibran
#80 interdiff.txt1.32 KBjibran
#75 add_add_content_link-2454309-75.patch6.77 KBjibran
#75 interdiff.txt2.62 KBjibran
#69 add_add_content_link-2454309-69.patch6.38 KBjibran
#69 interdiff.txt6.71 KBjibran
#69 screenshot-d8.dev 2015-05-02 18-48-02.png66.39 KBjibran
#69 screenshot-d8.dev 2015-05-02 18-47-22.png66.28 KBjibran
#63 after.png18.83 KBanishnirmal
#63 before.png17.39 KBanishnirmal
#56 add_add_content_link-2454309-56.patch5.78 KBzaporylie
#56 test-only-add_add_content_link-2454309-56.patch1.18 KBzaporylie
#56 interdiff-50-56.txt714 byteszaporylie
#50 add_add_content_link-2454309-50.patch5.78 KBzaporylie
#50 test-only-add_add_content_link-2454309-50.patch1.2 KBzaporylie
#50 interdiff-41-50.txt1.35 KBzaporylie
#41 interdiff-2454309-38-41.txt1.12 KBrenrhaf
#41 add_add_content_link-2454309-41-testonly.patch1.12 KBrenrhaf
#41 add_add_content_link-2454309-41.patch5.74 KBrenrhaf
#38 interdiff-2454309-32-38.txt645 bytesrenrhaf
#38 add_add_content_link-2454309-38.patch5.69 KBrenrhaf
#32 interdiff-2454309-22-28.txt5.37 KBrenrhaf
#32 add_add_content_link-2454309-32.patch5.5 KBrenrhaf
#28 no-content.png8.96 KBrenrhaf
#28 interdiff-2454309-22-28.txt4.14 KBrenrhaf
#28 add_add_content_link-2454309-28.patch4.27 KBrenrhaf
#26 Screen Shot 2015-04-16 at 10.56.32.png103.52 KBxano
#22 add_add_content_link-2454309-22.patch3.05 KBjeanfei
#18 2454309-18-add-content-link.patch2.97 KBjeanfei
#15 after_patch.png26.79 KBShivam Agarwal
#7 add_add_content_link-2454309-7.patch777 bytesjosephleon
#4 add_content_link2454309-4.png68.3 KBmatteom
#4 add_content_link2454309-4.patch773 bytesmatteom
#3 add_content_link-2454309-3.patch945 bytesrosinegrean

Comments

dawehner’s picture

Issue tags: +VDC, +Novice

Good idea!

We should be able to use "Empty Node Frontpage behavior" directly.

rosinegrean’s picture

Assigned: Unassigned » rosinegrean
rosinegrean’s picture

Status: Active » Needs review
StatusFileSize
new945 bytes
matteom’s picture

StatusFileSize
new773 bytes
new68.3 KB

I add the "Add content" link after "No content available" text

josephleon’s picture

@matteom #4

The patch is throwing an error

drupal[8.0.x*] $ git apply -v add_content_link2454309-4.patch
Checking patch core/modules/node/config/install/views.view.content.yml...
error: core/modules/node/config/install/views.view.content.yml: No such file or directory

josephleon’s picture

Status: Needs review » Needs work
josephleon’s picture

StatusFileSize
new777 bytes

Here is what I think the patch should be

josephleon’s picture

Status: Needs work » Needs review
Shivam Agarwal’s picture

Status: Needs review » Needs work

Patch #7 is showing following error when tried to apply :

Checking patch core/modules/node/config/optional/views.view.content.yml...
error: core/modules/node/config/optional/views.view.content.yml: No such file or directory

Status: Needs work » Needs review
rosinegrean’s picture

@Shivam Agarwal I queued the patch from #7 for retesting. If it did not fail then, should also work for you.

Shivam Agarwal’s picture

@prics #11 But we can't always rely on bot because I have seen patches which are applied cleanly but are failed during testing by bot and vice versa too.

dawehner’s picture

It looks a bit odd to have the <li> here ...

Shivam Agarwal’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new26.79 KB

I think there was something wrong in my localhost. Patch worked good. +1 to you . Please find attached scrrenshot after applying patch.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

#13 is not addressed plus I guess we should add a test. Also the title in views data looks wrong 'title' => t('Empty Node Frontpage behavior')

jeanfei’s picture

Working on it in Drupal dev days (mentoring sprint).

jeanfei’s picture

Issue summary: View changes
StatusFileSize
new2.97 KB

I've modified the 'Empty Node Frontpage behavior' to 'Empty Node List' (used both in frontpage and content views).
I wrote a test to check if the link "Add content" is present for the content view but, doesn't seems to work locally...
I don't really understand why node_listing_empty plugin is not present in the view result.
If someone can help me ? thanks

jeanfei’s picture

Status: Needs work » Needs review

forget to change the status.

Status: Needs review » Needs work

The last submitted patch, 18: 2454309-18-add-content-link.patch, failed testing.

meramo’s picture

The patch applies fine but does nothing, as you've described. Changing status to continue work on it

jeanfei’s picture

Status: Needs work » Needs review
StatusFileSize
new3.05 KB

I rewrite the tests to check if 'Add content' link is available when no content found, and removed if there is some content.
The link was not visible before because the user was not logged in with the correct user accesses.

meramo’s picture

Applies great against the latest head, however no sign of the link at /admin/content
Steps to reproduce:
- Log in as user #1
- Remove all content or a content from the given filter, i.e. "Type: Published"
- Go to /admin/content and expect to see the "Add content" link

Trying to figure out why it's happening

Anyone else to review?

jeanfei’s picture

Actually, if you apply the patch, and re-install your drupal8, the link will be available in /admin/content page.
If you already have an installed drupal8, you'll have to export your configuration, and apply the diff in views.view.content.yml :
- drush cex -y
- diff sites/default/files/config_eYNsEP31-zCz2iy3VPrjwlf5KZWqbzqCUTBkEz2BY-SiHIqf5Hv8tN_AQ7Vi1nrtPa6q9YQWyA/staging/views.view.content.yml core/modules/node/config/optional/views.view.content.yml and add the node_listing_empty part
- drush cim -y

meramo’s picture

Tested and confirmed

xano’s picture

StatusFileSize
new103.52 KB

Screen shot:

I don't think there should be a list. Instead, the link should be its own sentence right after the message that there is no content yet, similarly to what we do in list builders (what you see when you disable views).

meramo’s picture

Status: Needs review » Needs work

Changing status

renrhaf’s picture

Assigned: rosinegrean » Unassigned
Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new4.27 KB
new4.14 KB
new8.96 KB

Hello,

Here is the modified patch to have the link juste after the "no content" label.
Hopes everything is OK.

Regards

renrhaf’s picture

Issue summary: View changes
jibran’s picture

Status: Needs review » Needs work

Very nice work on the patch.

  1. +++ b/core/modules/node/src/Plugin/views/area/ListingEmpty.php
    @@ -64,17 +64,11 @@ public static function create(ContainerInterface $container, array $configuratio
    +        $link = \Drupal::l($this->t('Add content.'), Url::fromRoute('node.add_page'));
    

    Let's inject link_generator service and use $link_generator->generate($text, $internal_url); here.

  2. +++ b/core/modules/node/src/Plugin/views/area/ListingEmpty.php
    @@ -64,17 +64,11 @@ public static function create(ContainerInterface $container, array $configuratio
         $account = \Drupal::currentUser();
    

    We can also inject this now after fixing #1.

  3. +++ b/core/modules/node/src/Plugin/views/area/ListingEmpty.php
    @@ -64,17 +64,11 @@ public static function create(ContainerInterface $container, array $configuratio
    +        $element = array('#markup' => '&nbsp;' . $link);
    

    Nice.

  4. +++ b/core/modules/node/src/Tests/Views/ContentPageTest.php
    @@ -0,0 +1,52 @@
    + * Contains \Drupal\node\Tests\Views\ContentPageTest.
    

    Why can't we use an existing NodeAdminTest::testContentAdminPages() for this page? Delete all nodes in that test and assert. Let's not add one more test if we can avoid adding it ;-)

The last submitted patch, 28: add_add_content_link-2454309-28.patch, failed testing.

renrhaf’s picture

Status: Needs work » Needs review
StatusFileSize
new5.5 KB
new5.37 KB

Hello, here is the corrected patch including your asked modifications.
Any feedbacks are welcome !

Status: Needs review » Needs work

The last submitted patch, 32: add_add_content_link-2454309-32.patch, failed testing.

jibran’s picture

Issue tags: -Needs tests

Thanks for fixing the feedback this is almost ready.

  1. +++ b/core/modules/node/src/Tests/NodeAdminTest.php
    @@ -193,6 +193,16 @@ function testContentAdminPages() {
    +    $this->assertResponse(200);
    

    This failed.

  2. +++ b/core/modules/node/src/Tests/NodeAdminTest.php
    @@ -193,6 +193,16 @@ function testContentAdminPages() {
    +    $this->assertTrue(count($this->cssSelect('.view-content .views-empty a[href="/node/add"]')) == 1);
    

    We can add assert false as well when table is not empty.

renrhaf’s picture

Strange... I tested it on my machine successfuly before making the patch.
I'll take a look ASAP.

The last submitted patch, 32: add_add_content_link-2454309-32.patch, failed testing.

renrhaf’s picture

Status: Needs work » Needs review
StatusFileSize
new5.69 KB
new645 bytes

Hello @jibran,

I've added the case when the link mustn't be present, I thought it was not worth it because it's more testing that the ".view-empty" div is not present but ok.
I still have the problem with the test failing on the QA, and passing on my local installation.

Do you think it has something to do with the server configuration ? I'm not sure but I already had some problems on my symfony apps when using Xpath, and got different results on different servers... but got no clue about the origin of this issue...

Status: Needs review » Needs work

The last submitted patch, 38: add_add_content_link-2454309-38.patch, failed testing.

jibran’s picture

Thanks for adding the new assert.

+++ b/core/modules/node/src/Tests/NodeAdminTest.php
@@ -193,6 +193,19 @@ function testContentAdminPages() {
+    $this->assertResponse(200);

Just remove it. We don't have to check this at all and please upload the test only patch to confirm the fail and then we are good for RTBC.

renrhaf’s picture

Here is the modified patch, with interdiff and test only patch.
Hopes this will pass the test now as I don't know how to correct this if not...

renrhaf’s picture

Status: Needs work » Needs review

The last submitted patch, 41: add_add_content_link-2454309-41.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 41: add_add_content_link-2454309-41-testonly.patch, failed testing.

renrhaf’s picture

I'll take a look on https://www.drupal.org/project/testbot - to try to check why it passes locally but not on the test bot. If you already have some idea, I'm eager to know them :)

Update:

Running tests like this :

php scripts/run-tests.sh --url "http://drupal8.loc" --verbose --class "Drupal\node\Tests\NodeAdminTest"

I don't have the error on my local installation... still investigating

The last submitted patch, 41: add_add_content_link-2454309-41.patch, failed testing.

zaporylie’s picture

Assigned: Unassigned » zaporylie

I will look at it later today or tomorrow.

renrhaf’s picture

Thanks for your help, Zaporylie

zaporylie’s picture

Assigned: zaporylie » Unassigned
Status: Needs work » Needs review
Issue tags: +drupaldevdays
StatusFileSize
new1.35 KB
new1.2 KB
new5.78 KB

Change is rather subtle but let's see what testbot thinks about it.

Status: Needs review » Needs work

The last submitted patch, 50: add_add_content_link-2454309-50.patch, failed testing.

The last submitted patch, 50: test-only-add_add_content_link-2454309-50.patch, failed testing.

renrhaf’s picture

Is there a way to test the behavior of the testbot by an other way than updating patches on drupal.org ?

zaporylie’s picture

I guess it's all about PHP version. I'm testing it with php 5.5.9, testbot has php 5.4.39 (read more). I will try to look at it closer but first I need to take a rest after ddd :) You can ping me about it on IRC tomorrow.

renrhaf’s picture

I have to check but my configuration was the same for PHP version.
I think it's related to xpath configuration but I'm not sure.
I'll investigate too when I got some time. Take a good rest, the DDD was really fun but also a bit tiresome ;)

zaporylie’s picture

Ok, let's give testbot another chance :)

zaporylie’s picture

Status: Needs work » Needs review

The last submitted patch, 56: test-only-add_add_content_link-2454309-56.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 56: add_add_content_link-2454309-56.patch, failed testing.

Status: Needs work » Needs review
renrhaf’s picture

Hello Zaporylie, good job for the test ! Why does it work by adding a dollar after href ? What was the issue ?

zaporylie’s picture

Issue tags: +Needs beta evaluation

href$="" means that href should ends with value (in our case "node/add"), doesn't matter if path is index.php?q=node/add, localhost/sitefolder/node/add or localhost/node/add, while href="" is looking for perfect match.

According to testbot specification, testbot webroot is in a subdirectory and clean URLs are disabled so link to "Add content" looks like that: <a href="checkout/?q=node/add">Add content</a> while we were looking for perfect match to <a href="/node/add">Add content</a>

I think we are ready for RTBC now. It would be great to add beta evaluation and print screens for "before" and "after" to issue summary.

anishnirmal’s picture

Issue summary: View changes
StatusFileSize
new17.39 KB
new18.83 KB

Before and After Screenshots

anishnirmal’s picture

Issue summary: View changes
anishnirmal’s picture

Issue summary: View changes

Before and After Screenshots

jibran’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs beta evaluation

No need for beta eval this is simple usability bug. This is ready thanks @zaporylie for sticking with it.

jibran’s picture

Issue tags: +Usability
alexpott’s picture

Status: Reviewed & tested by the community » Needs work

This changes how the front page looks when there is no content. Is this by design? If so it's not mentioned in any of the comments. And there are no screenshots of this part of the change on the issue.

jibran’s picture

Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new66.28 KB
new66.39 KB
new6.71 KB
new6.38 KB

@alexpott is right.

Frontpage before the patch

Frontpage after the patch


Current patch fixes above issue.

yoroy’s picture

The list item always looked a bit overdone to me. Seems fine to change this link from a list item to an inline link, because that makes it consistent with the 'empty' pattern we use in tables.

dawehner’s picture

+++ b/core/modules/node/src/Plugin/views/area/AdminListingEmpty.php
@@ -0,0 +1,99 @@
+        $link = $this->linkGenerator->generate($this->t('Add content.'), Url::fromRoute('node.add_page'));
+        $element = array('#markup' => '&nbsp;' . $link);

What about just using #type link here?

disasm’s picture

Issue tags: -Novice

I am removing the Novice tag from this issue because there are no clear action items in this task.

I’m using this documentation as a source: https://www.drupal.org/core-mentoring/novice-tasks#avoid

jibran’s picture

Assigned: Unassigned » jibran

Working on #72.

jibran’s picture

StatusFileSize
new2.62 KB
new6.77 KB

@dawehner how about this? It's same as block content.

jibran’s picture

Assigned: jibran » Unassigned
dawehner’s picture

+++ b/core/modules/node/src/Plugin/views/area/AdminListingEmpty.php
@@ -0,0 +1,106 @@
+        '#cache' => [
+          'contexts' => $access_result->getCacheContexts(),
+          'tags' => $access_result->getCacheTags(),
+          'max-age' => $access_result->getCacheMaxAge(),
+        ],

Is there no api for that, maybe BubbleMetadata::fromObject->applyTo() or that?

wim leers’s picture

Status: Needs review » Needs work
+++ b/core/modules/node/src/Plugin/views/area/AdminListingEmpty.php
@@ -87,13 +87,20 @@ public static function create(ContainerInterface $container, array $configuratio
+      $access_result = $this->accessManager->checkNamedRoute('node.add_page', array(), $this->currentUser, TRUE);
+      $element = [
+        '#markup' => '&nbsp;' . $this->linkGenerator->generate($this->t('Add content.'), Url::fromRoute('node.add_page')),
+        '#access' => $access_result->isAllowed(),
+        '#cache' => [
+          'contexts' => $access_result->getCacheContexts(),
+          'tags' => $access_result->getCacheTags(),
+          'max-age' => $access_result->getCacheMaxAge(),
+        ],
+      ];
$access_result = …;
$element = [
  '#type' => 'link',
  '#title' => $this->t('Add content'),
  '#url' => Url::fromRoute('node.add_page'),
  '#access' => $access_result->isAllowed(),
];
$access_result->applyTo($element);
jibran’s picture

Assigned: Unassigned » jibran
jibran’s picture

Assigned: jibran » Unassigned
Status: Needs work » Needs review
StatusFileSize
new1.32 KB
new6.79 KB

Changed the type to link. But can't do $access_result->applyTo($element); because of Fatal error: Call to undefined method Drupal\Core\Access\AccessResultAllowed::applyTo()

jibran’s picture

StatusFileSize
new1.69 KB
new6.72 KB

Addressed #77 and #78. Thanks @dawehner for the suggestion and thanks @Wim Leers for the help.

dawehner’s picture

+++ b/core/modules/node/src/Plugin/views/area/AdminListingEmpty.php
@@ -0,0 +1,106 @@
+ * Contains \Drupal\node\Plugin\views\area\AdminListingEmpty.
...
+   * Constructs a new ListingEmpty.

Nitpick: doesn't match.

jibran’s picture

StatusFileSize
new607 bytes
new6.72 KB

Thanks for the review @dawehner and nice catch.

benjy’s picture

+++ b/core/modules/node/src/Plugin/views/area/AdminListingEmpty.php
@@ -0,0 +1,106 @@
+      /** @var \Drupal\Core\Access\AccessResultInterface|\Drupal\Core\Cache\CacheableDependencyInterface $access_result */
+      $access_result = $this->accessManager->checkNamedRoute('node.add_page', array(), $this->currentUser, TRUE);
+      $element = [
+        '#type' => 'link',
+        '#title' => $this->t('Add content'),
+        '#url' => Url::fromRoute('node.add_page'),
+        '#access' => $access_result->isAllowed(),
+        '#prefix' => '&nbsp;',
+      ];
+      CacheableMetadata::createFromObject($access_result)->applyTo($element);

Can someone explain this a bit? Is this what is needed to create a link from code without breaking caching? Is there documentation for this kind of stuff somewhere?

jibran’s picture

Is this what is needed to create a link from code without breaking caching?

@benjy here is your answer http://wimleers.com/talk-making-drupal-fly-fastest-drupal-ever-near/#/3/5?

benjy’s picture

I don't see any mention to CacheableMetadata? Also, is there not a documentation page on drupal.org for this?

wim leers’s picture

dawehner is working on allowing to assign an AccessResultInterface object ($access_result in the above) to #access, so that that silly dance is no longer necessary. That'll take the painfulness away.

Documentation is at https://www.drupal.org/developing/api/8/render/arrays/cacheability. This particular example isn't documented there because the painfulness will be removed.

benjy’s picture

This particular example isn't documented there because the painfulness will be removed.

That's what I was hoping someone would say :)

Trupti Bhosale’s picture

StatusFileSize
new100.06 KB
new94.15 KB
new53.12 KB

Verified the patch in #83, the Add content link is not inline on homepage and Add Content link is not displayed on Content page.

Trupti Bhosale’s picture

Status: Needs review » Needs work

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.

yoroy’s picture

Issue tags: +ux-workflow
yoroy’s picture

Version: 8.1.x-dev » 8.2.x-dev
dagmar’s picture

Status: Needs work » Needs review
StatusFileSize
new6.74 KB

Re-rolled didn't apply for 8.2.x.

I tested this on a new installation of 8.2.x and the Add content link is on admin/content however in an already installed site, even rebuilding cache the link doesn't show up. What is the intended behavior on case of upgrading?

Status: Needs review » Needs work

The last submitted patch, 94: add_add_content_link-2454309-94.patch, failed testing.

dagmar’s picture

Status: Needs work » Needs review

Probably unrelated.

Status: Needs review » Needs work

The last submitted patch, 94: add_add_content_link-2454309-94.patch, failed testing.

The last submitted patch, 94: add_add_content_link-2454309-94.patch, failed testing.

joginderpc’s picture

Issue tags: +re-work on patch
StatusFileSize
new46.38 KB
new44.15 KB

As per given patch in comment #94 changes are not reflecting attached screen shot please check.

add content not visible.

The patch is making site slogan miss align.

slogan miss align

joginderpc’s picture

StatusFileSize
new44.15 KB

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

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now 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.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now 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.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now 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.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now 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.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now 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.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.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.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

avpaderno’s picture

Issue tags: -re-work on patch +Needs reroll
vsujeetkumar’s picture

Status: Needs work » Needs review
StatusFileSize
new6.79 KB

Re-roll patch created.

vsujeetkumar’s picture

Issue tags: -Needs reroll

Status: Needs review » Needs work

The last submitted patch, 109: 2454309_109.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

abhisekmazumdar’s picture

Status: Needs work » Needs review
StatusFileSize
new6.82 KB
new703 bytes

Most probably this should fix the failed test case.

msuthars’s picture

Assigned: Unassigned » msuthars
msuthars’s picture

Issue tags: +DIACWApril2020
msuthars’s picture

Assigned: msuthars » Unassigned
Status: Needs review » Needs work

I reviewed the patch #112 and found that it will only work when a user freshly installs Drupal 8.9.x, It will not work for them who upgrade from the lower version to 8.9.x. So need to write an update hook to import/update that (in patch) nodes configurations.

sja112’s picture

Assigned: Unassigned » sja112
sja112’s picture

Assigned: sja112 » Unassigned
sja112’s picture

Assigned: Unassigned » sja112
Status: Needs work » Needs review
StatusFileSize
new4.76 KB

Updated patch to add the update hook to import content view configurations. It also includes changes recommended by the code sniffer.

Status: Needs review » Needs work

The last submitted patch, 118: 2454309-113.patch, failed testing. View results

sja112’s picture

Status: Needs work » Needs review
StatusFileSize
new4.89 KB

Status: Needs review » Needs work

The last submitted patch, 120: 2454309-114.patch, failed testing. View results

sja112’s picture

Status: Needs work » Needs review
StatusFileSize
new8.44 KB

Updated patch.

Status: Needs review » Needs work

The last submitted patch, 122: 2454309-121.patch, failed testing. View results

sja112’s picture

Status: Needs work » Needs review
StatusFileSize
new8.06 KB

Created a patch to update the node configurations.

Steps:
1). Apply patch.
2). Run drush cache rebuild command.
3). Run drush update db command.

pameeela’s picture

Tested manually and the patch works - the Add content link appears when there is no content and no longer appears once there is content.

Someone else will have to do a code review as that's outside my area!

msuthars’s picture

Assigned: sja112 » msuthars
msuthars’s picture

Assigned: msuthars » Unassigned
Status: Needs review » Reviewed & tested by the community

@sja112 Patch #124 looks fine for me. I tested it with fresh drupal installation & with the existing installed drupal site and it works well for both. Code also looks fine for me.

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

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now 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.

xjm’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll

I so thought this was fixed years ago. Nice work!

It looks like the patch does not apply to 9.1.x, so we will need a reroll for that. Thanks!

andypost’s picture

Issue tags: -Needs reroll +Needs upgrade path tests, +Needs upgrade path
StatusFileSize
new5.61 KB
new6.31 KB

Quick re-roll and few fixes
- default view still needs work (moved to post update hook and added TODO)
- keep constructor slimmer and string translation is one of deficiencies via trait

Still needs work for upgrade hook and upgrade tests as the changed view primary for listing content

+++ b/core/modules/node/node.post_update.php
@@ -14,3 +14,16 @@ function node_removed_post_updates() {
+  // TODO update 'views.view.content' view.

the todo to fix, views now using some new way to write upgrades

shobhit_juyal’s picture

StatusFileSize
new6.81 KB
new1.49 KB

I've updated the patch for TODO item.

andypost’s picture

Not clear which helper views updates should use now... that's why I changed this to todo in previous patch

+++ b/core/modules/node/node.post_update.php
@@ -14,3 +17,20 @@ function node_removed_post_updates() {
+  $optional_install_path = $module_handler->getModule('node')->getPath() . '/' . InstallStorage::CONFIG_OPTIONAL_DIRECTORY;
...
+  $config_storage->write('views.view.content', $source->read('views.view.content'));

is no-go as upgrade path because user can have the view customized already.
So the right way is load its config and process

sja112’s picture

Status: Needs work » Needs review
StatusFileSize
new7.42 KB
new1.51 KB

@andypost,

I have updated the patch to update the views config. I have loaded the views config and processed it.

Please review.

andypost’s picture

Status: Needs review » Needs work
Issue tags: -Needs upgrade path

Looks good so only upgrade path tests left

lendude’s picture

Mostly some nits

  1. +++ b/core/modules/node/node.post_update.php
    @@ -14,3 +14,38 @@ function node_removed_post_updates() {
    +    // Go through all the entity fields on each display and find ones currently using 'date' as the plugin.
    

    c/p left over I'm guessing?

  2. +++ b/core/modules/node/src/Plugin/views/area/AdminListingEmpty.php
    @@ -0,0 +1,75 @@
    +        '#prefix' => '&nbsp;',
    

    Hmmm. I understand why, but this makes this pretty weird to use without another plugin outputting text before it.

  3. +++ b/core/modules/node/tests/src/Functional/NodeAdminTest.php
    @@ -207,6 +207,20 @@ public function testContentAdminPages() {
    +    $this->assertTrue(is_array($link) && empty($link), 'Did not find "Add Content" link in view.');
    

    Why not just assertEmpty()?

  4. +++ b/core/modules/node/tests/src/Functional/NodeAdminTest.php
    @@ -207,6 +207,20 @@ public function testContentAdminPages() {
    +    $this->assertTrue(is_array($link) && !empty($link) && count($link) == 1, 'Found "Add Content" link in view.');
    

    why not just assertCount()?

  5. +++ b/core/modules/node/src/NodeViewsData.php
    @@ -192,6 +192,14 @@ public function getViewsData() {
    +      'help' => $this->t('Provides a link to the node add overview page for admin.'),
    

    'for admin.' => 'for users with the correct permissions.'
    I don't know, something like that to make it clear what is being checked.

  6. +++ b/core/modules/node/config/schema/node.views.schema.yml
    @@ -4,6 +4,10 @@ views.area.node_listing_empty:
    +  label: 'Node link'
    

    This can be a bit more descriptive

  7. +++ b/core/modules/node/tests/src/Functional/NodeAdminTest.php
    @@ -207,6 +207,20 @@ public function testContentAdminPages() {
    +    $link = $this->cssSelect('.view-content .views-empty a[href="/node/add"]');
    ...
    +    $link = $this->cssSelect('.view-content .views-empty a[href$="/node/add"]');
    

    The negative and positive assertion don't match selectors, so the negative assertion will always fail now.

sja112’s picture

Status: Needs work » Needs review
StatusFileSize
new7.38 KB
new2.67 KB

@lendude, thanks for the review.

I have updated the patch to fix #135.1, #135.3, #135.6, #135.7 except,

#135.2

this pretty weird to use without another plugin outputting text before it.

#135.4, #135.5 about the use of assertCount and assertEmpty. Because here I am performing '&&' operation I am getting results in boolean that's why I have used assertTrue instead of these methods.

Did not find "Add Content" link in view.
Failed asserting that a boolean is empty.

Status: Needs review » Needs work

The last submitted patch, 136: 2846614-136.patch, failed testing. View results

shaktik’s picture

Assigned: Unassigned » shaktik
Rkumar’s picture

StatusFileSize
new16.19 KB

@sja112
You should try this

Patch

Because a[href$="node/add"], It will match any links that end in given format.
I am assuming that's why your test cases is getting failed.

shaktik’s picture

Status: Needs work » Needs review
StatusFileSize
new7.38 KB

Hi @rahul,

just reroll patch #136, kindly review.

Changes:

-    $link = $this->cssSelect('.view-content .views-empty a[href="/node/add"]');
+    $link = $this->cssSelect('.view-content .views-empty a[href$="/node/add"]');

Thanks,
Shakti

lendude’s picture

+++ b/core/modules/node/tests/src/Functional/NodeAdminTest.php
@@ -207,6 +207,20 @@ public function testContentAdminPages() {
+    $this->assertTrue(is_array($link) && empty($link), 'Did not find "Add Content" link in view.');
...
+    $this->assertTrue(is_array($link) && !empty($link) && count($link) == 1, 'Found "Add Content" link in view.');

@sja112 Re:#135.4/.5 Yes I see why you need assertTrue if you do the && thing, but why would you do the && thing? We don't care that it is an array, we only care that it's empty. Testing if cssSelect () returns an array is testing the test framework, which is not the scope of this test.
Same goes for the second assertion, we only care about the count being 1, we don't care about any of those other things since they will also lead to assertCount to fail if they are not true for some weird reason.

The && leads to extra complexity which we don't need, hence, we should take them out.

lendude’s picture

Component: user interface text » node system
Assigned: shaktik » Unassigned
Status: Needs review » Needs work

@shaktik why the reroll? It applies fine.

Back to NW for 'Needs upgrade path tests'

sharma.amitt16’s picture

After applying patch it's working fine. I have modified the if conditions in NodeAdminTest.php

I modified the below code in NodeAdminTest.php.


// Verify that the 'Add content' link is not available when content has been created.
    $link = $this->cssSelect('.view-content .views-empty a[href="/node/add"]');
+  $this->assertTrue(empty($link), 'Did not find "Add Content" link in view.');

    // Remove all content.
    foreach (\Drupal::entityTypeManager()->getStorage('node')->loadMultiple() as $entity) {
      $entity->delete();
    }

    // Verify that the 'Add content' link is available when no content has been created.
    $this->drupalGet('admin/content');
    $link = $this->cssSelect('.view-content .views-empty a[href="/node/add"]');
+    $this->assertTrue(count($link) == 1, 'Found "Add Content" link in view.');

All the test cases are passed on local which are failing in #140

root@b1dad303faf2:/var/www/html# phpunit --configuration=core --filter testContentAdminPages core/modules/node/tests/src/Functional/NodeAdminTest.php
PHPUnit 8.5.4 by Sebastian Bergmann and contributors.

Testing Drupal\Tests\node\Functional\NodeAdminTest
.                                                                   1 / 1 (100%)

Time: 5.85 minutes, Memory: 8.00 MB

OK (1 test, 86 assertions)

HTML output was generated
http://localhost:81/sites/simpletest/browser_output/Drupal_Tests_node_Functional_NodeAdminTest-1-52944308.html
http://localhost:81/sites/simpletest/browser_output/Drupal_Tests_node_Functional_NodeAdminTest-2-52944308.html

sharma.amitt16’s picture

Status: Needs work » Needs review
StatusFileSize
new7.33 KB

Status: Needs review » Needs work

The last submitted patch, 144: 2454309-144.patch, failed testing. View results

Rkumar’s picture

StatusFileSize
new7.5 KB
new752 bytes

Patch for test case failure.

Rkumar’s picture

Status: Needs work » Needs review
StatusFileSize
new7.5 KB
new752 bytes

Updating the correct comment id.
Patch for test case failure.

Status: Needs review » Needs work

The last submitted patch, 147: 2454309-147.patch, failed testing. View results

vsujeetkumar’s picture

Status: Needs work » Needs review
StatusFileSize
new7.29 KB
new663 bytes

Fixed test, Please review.

Status: Needs review » Needs work

The last submitted patch, 149: 2454309_149.patch, failed testing. View results

deepak goyal’s picture

Assigned: Unassigned » deepak goyal
deepak goyal’s picture

Assigned: deepak goyal » Unassigned
pavnish’s picture

Status: Needs work » Needs review
StatusFileSize
new7.16 KB
new1.78 KB

@vsujeetkumar Please review this patch i have changed some test case code.

lendude’s picture

Status: Needs review » Needs work

Still needs the upgrade path test.....

pameeela’s picture

Status: Needs work » Closed (won't fix)
Issue tags: -ux-workflow +Bug Smash Initiative

When I created this issue 5+ years ago it seemed straightforward. Obviously that was not the case!

Given that 1) this page already features prominently an ‘Add content’ button; 2) this was an attempt to replace something that has now been missing for more than 5 years; 3) it only affects sites that have zero nodes; and 4) it requires an upgrade path, I am going to mark this ‘Closed (won’t fix)’.

Thanks so much to everyone who has contributed to this issue over the years.

Instead of feeling discouraged that this issue has been closed, I want you to encourage you to reallocate your efforts to another issue that can really improve Drupal. That is the intention, just to make sure that the effort we all put in is worthwhile.

andypost’s picture

Category: Bug report » Task
Status: Closed (won't fix) » Needs work
Issue tags: +Needs issue summary update

This is actually not a bug, but task and also a blocker for #2453733: Create a general 'add new {entity_type}' area plugin and fix the empty behaviour for nodes, comments and files to match UX guidelines (or indirect) #2454311: Add "Add a file" link to empty table text at admin/content/files

Core has no support for this kind of action links in views, so it's regression from D7 era (which is still supported)

If we call it regression then it's bug, if feature parity then task...

Anyway it needs to update summary and current state of the patch

pavnish’s picture

StatusFileSize
new2.65 KB
new7.4 KB

@Lendude Sorry for the #153 the patch is not tested "Add content" link on table I apologies for the same and also fixed the test case for "Add content" link inside the table.

lendude’s picture

I don't see how this is a blocker for #2453733: Create a general 'add new {entity_type}' area plugin and fix the empty behaviour for nodes, comments and files to match UX guidelines?

Why would we create a node specific handler first? Why not create the generic handler first and then implement that for node? If we do the node specific one first, we are going to have to do the whole @deprecated dance with it to replace it with the generic handler once that lands.

I would mark this 'duplicate' and put our efforts into #2453733: Create a general 'add new {entity_type}' area plugin and fix the empty behaviour for nodes, comments and files to match UX guidelines

avpaderno’s picture

Yes, it makes more sense to create the generic plugin valid for every entity (which means this issue is a duplicate of the other one.)
It would make sense to have two issues if the classes implementing the handlers were different and not extending the same base class, but I think this is not the case.

avpaderno’s picture

I don't also think that implementing the handler for nodes is faster than creating the handler for every entity. If it were faster, I could understand the decision to implement the handler for nodes first.

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

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

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

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

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

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

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

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now 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.

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.

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

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

acbramley’s picture

Title: Add "Add content" link to empty table text at admin/content » [PP-1] Add "Add content" link to empty table text at admin/content
Status: Needs work » Postponed

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.