Postponed
Project:
Drupal core
Version:
main
Component:
node system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
17 Mar 2015 at 22:33 UTC
Updated:
19 Mar 2025 at 05:15 UTC
Jump to comment: Most recent, Most recent file


Comments
Comment #1
dawehnerGood idea!
We should be able to use "Empty Node Frontpage behavior" directly.
Comment #2
rosinegrean commentedComment #3
rosinegrean commentedComment #4
matteom commentedI add the "Add content" link after "No content available" text
Comment #5
josephleon commented@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
Comment #6
josephleon commentedComment #7
josephleon commentedHere is what I think the patch should be
Comment #8
josephleon commentedComment #9
Shivam Agarwal commentedPatch #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
Comment #11
rosinegrean commented@Shivam Agarwal I queued the patch from #7 for retesting. If it did not fail then, should also work for you.
Comment #12
Shivam Agarwal commented@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.
Comment #13
dawehnerIt looks a bit odd to have the
<li>here ...Comment #15
Shivam Agarwal commentedI think there was something wrong in my localhost. Patch worked good. +1 to you . Please find attached scrrenshot after applying patch.
Comment #16
alexpott#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')Comment #17
jeanfei commentedWorking on it in Drupal dev days (mentoring sprint).
Comment #18
jeanfei commentedI'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
Comment #19
jeanfei commentedforget to change the status.
Comment #21
meramo commentedThe patch applies fine but does nothing, as you've described. Changing status to continue work on it
Comment #22
jeanfei commentedI 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.
Comment #23
meramo commentedApplies 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?
Comment #24
jeanfei commentedActually, 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
Comment #25
meramo commentedTested and confirmed
Comment #26
xanoScreen 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).
Comment #27
meramo commentedChanging status
Comment #28
renrhafHello,
Here is the modified patch to have the link juste after the "no content" label.
Hopes everything is OK.
Regards
Comment #29
renrhafComment #30
jibranVery nice work on the patch.
Let's inject link_generator service and use $link_generator->generate($text, $internal_url); here.
We can also inject this now after fixing #1.
Nice.
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 ;-)
Comment #32
renrhafHello, here is the corrected patch including your asked modifications.
Any feedbacks are welcome !
Comment #34
jibranThanks for fixing the feedback this is almost ready.
This failed.
We can add assert false as well when table is not empty.
Comment #35
renrhafStrange... I tested it on my machine successfuly before making the patch.
I'll take a look ASAP.
Comment #38
renrhafHello @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...
Comment #40
jibranThanks for adding the new assert.
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.
Comment #41
renrhafHere 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...
Comment #42
renrhafComment #45
renrhafI'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 :
I don't have the error on my local installation... still investigating
Comment #48
zaporylieI will look at it later today or tomorrow.
Comment #49
renrhafThanks for your help, Zaporylie
Comment #50
zaporylieChange is rather subtle but let's see what testbot thinks about it.
Comment #53
renrhafIs there a way to test the behavior of the testbot by an other way than updating patches on drupal.org ?
Comment #54
zaporylieI 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.
Comment #55
renrhafI 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 ;)
Comment #56
zaporylieOk, let's give testbot another chance :)
Comment #57
zaporylieComment #61
renrhafHello Zaporylie, good job for the test ! Why does it work by adding a dollar after href ? What was the issue ?
Comment #62
zaporyliehref$=""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, whilehref=""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.
Comment #63
anishnirmal commentedBefore and After Screenshots
Comment #64
anishnirmal commentedComment #65
anishnirmal commentedBefore and After Screenshots
Comment #66
jibranNo need for beta eval this is simple usability bug. This is ready thanks @zaporylie for sticking with it.
Comment #67
jibranComment #68
alexpottThis 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.
Comment #69
jibran@alexpott is right.
Frontpage before the patch
Frontpage after the patch
Current patch fixes above issue.
Comment #70
jibranComment #71
yoroy commentedThe 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.
Comment #72
dawehnerWhat about just using #type link here?
Comment #73
disasm commentedI 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
Comment #74
jibranWorking on #72.
Comment #75
jibran@dawehner how about this? It's same as block content.
Comment #76
jibranComment #77
dawehnerIs there no api for that, maybe
BubbleMetadata::fromObject->applyTo()or that?Comment #78
wim leersComment #79
jibranComment #80
jibranChanged the type to link. But can't do
$access_result->applyTo($element);because ofFatal error: Call to undefined method Drupal\Core\Access\AccessResultAllowed::applyTo()Comment #81
jibranAddressed #77 and #78. Thanks @dawehner for the suggestion and thanks @Wim Leers for the help.
Comment #82
dawehnerNitpick: doesn't match.
Comment #83
jibranThanks for the review @dawehner and nice catch.
Comment #84
benjy commentedCan 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?
Comment #85
jibran@benjy here is your answer http://wimleers.com/talk-making-drupal-fly-fastest-drupal-ever-near/#/3/5?
Comment #86
benjy commentedI don't see any mention to CacheableMetadata? Also, is there not a documentation page on drupal.org for this?
Comment #87
wim leersdawehner is working on allowing to assign an
AccessResultInterfaceobject ($access_resultin 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.
Comment #88
benjy commentedThat's what I was hoping someone would say :)
Comment #89
Trupti Bhosale commentedVerified the patch in #83, the Add content link is not inline on homepage and Add Content link is not displayed on Content page.
Comment #90
Trupti Bhosale commentedComment #92
yoroy commentedComment #93
yoroy commentedComment #94
dagmarRe-rolled didn't apply for 8.2.x.
I tested this on a new installation of 8.2.x and the
Add contentlink is onadmin/contenthowever in an already installed site, even rebuilding cache the link doesn't show up. What is the intended behavior on case of upgrading?Comment #96
dagmarProbably unrelated.
Comment #99
joginderpcAs per given patch in comment #94 changes are not reflecting attached screen shot please check.
The patch is making site slogan miss align.
Comment #100
joginderpcComment #108
avpadernoComment #109
vsujeetkumar commentedRe-roll patch created.
Comment #110
vsujeetkumar commentedComment #112
abhisekmazumdarMost probably this should fix the failed test case.
Comment #113
msutharsComment #114
msutharsComment #115
msutharsI 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.
Comment #116
sja112 commentedComment #117
sja112 commentedComment #118
sja112 commentedUpdated patch to add the update hook to import content view configurations. It also includes changes recommended by the code sniffer.
Comment #120
sja112 commentedComment #122
sja112 commentedUpdated patch.
Comment #124
sja112 commentedCreated a patch to update the node configurations.
Steps:
1). Apply patch.
2). Run drush cache rebuild command.
3). Run drush update db command.
Comment #125
pameeela commentedTested 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!
Comment #126
msutharsComment #127
msuthars@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.
Comment #129
xjmI 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!
Comment #130
andypostQuick 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
the todo to fix, views now using some new way to write upgrades
Comment #131
shobhit_juyal commentedI've updated the patch for TODO item.
Comment #132
andypostNot clear which helper views updates should use now... that's why I changed this to todo in previous patch
is no-go as upgrade path because user can have the view customized already.
So the right way is load its config and process
Comment #133
sja112 commented@andypost,
I have updated the patch to update the views config. I have loaded the views config and processed it.
Please review.
Comment #134
andypostLooks good so only upgrade path tests left
Comment #135
lendudeMostly some nits
c/p left over I'm guessing?
Hmmm. I understand why, but this makes this pretty weird to use without another plugin outputting text before it.
Why not just assertEmpty()?
why not just assertCount()?
'for admin.' => 'for users with the correct permissions.'
I don't know, something like that to make it clear what is being checked.
This can be a bit more descriptive
The negative and positive assertion don't match selectors, so the negative assertion will always fail now.
Comment #136
sja112 commented@lendude, thanks for the review.
I have updated the patch to fix #135.1, #135.3, #135.6, #135.7 except,
#135.2
#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.
Comment #138
shaktikComment #139
Rkumar commented@sja112
You should try this
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.
Comment #140
shaktikHi @rahul,
just reroll patch #136, kindly review.
Changes:
Thanks,
Shakti
Comment #141
lendude@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.
Comment #142
lendude@shaktik why the reroll? It applies fine.
Back to NW for 'Needs upgrade path tests'
Comment #143
sharma.amitt16 commentedAfter applying patch it's working fine. I have modified the if conditions in NodeAdminTest.php
I modified the below code in NodeAdminTest.php.
All the test cases are passed on local which are failing in #140
Comment #144
sharma.amitt16 commentedComment #146
Rkumar commentedPatch for test case failure.
Comment #147
Rkumar commentedUpdating the correct comment id.
Patch for test case failure.
Comment #149
vsujeetkumar commentedFixed test, Please review.
Comment #151
deepak goyal commentedComment #152
deepak goyal commentedComment #153
pavnish commented@vsujeetkumar Please review this patch i have changed some test case code.
Comment #154
lendudeStill needs the upgrade path test.....
Comment #155
pameeela commentedWhen 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.
Comment #156
andypostThis 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
Comment #157
pavnish commented@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.
Comment #158
lendudeI 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
Comment #159
avpadernoYes, 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.
Comment #160
avpadernoI 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.
Comment #167
acbramley commentedSeems this should be postponed on #2453733: Create a general 'add new {entity_type}' area plugin and fix the empty behaviour for nodes, comments and files to match UX guidelines