Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Beta phase evaluation
Issue category | Task: All content entity types should have some views integration. This issue is also a base for using views for that particular admin listing |
---|---|
Issue priority | Normal, because the impact is not that high. |
Disruption | No disruption, because there is no API change. |
Problem/Motivation
We need to add a revisions ui for block_content. This would best be done with views. Hence we need views support.
Proposed resolution
Implement BlockContentViewsData class
Remaining tasks
Write patch
Tests
Reviews
User interface changes
None
API changes
None
Related Issues
#1984588: Add Block Content revision UI
#2375589: Convert custom block library page to views
Comment | File | Size | Author |
---|---|---|---|
#62 | custom-block-views-test.png | 90.33 KB | kattekrab |
#61 | interdiff.txt | 1.7 KB | jibran |
#61 | 1984582-62.patch | 46.79 KB | jibran |
Comments
Comment #1
dawehnerOh damn, I haven't seen that assigned fast enough.
I hope you can at least get inspired by this small bit.
Comment #2
larowlanLooks good to me, lets ask the bot.
Comment #3
larowlanSo after taking this for a spin we'll need to add view and delete revision link field handlers.
The ID of the custom block this revision is from
Just revision ID
The ID of the revision
Comment #4
dawehnerWell, we certainly still need some routing/menu entries to actually manage revisions, so we need this first in order to continue here.
Comment #5
xtfer CreditAttribution: xtfer commentedI'm looking at this in preparation for #1984588: Add Block Content revision UI.
The "Link to edit a custom block" handler is currently broken.
Debug:
'Missing handler: custom_block edit_link field'
in views_get_handler() (line 940 of core/modules/views/views.module).
Comment #6
xtfer CreditAttribution: xtfer commentedComment #7
dawehnerOkay let's be a little bit more honest.
Comment #8
dawehnerOkay let's be a little bit more honest.
Comment #9
xtfer CreditAttribution: xtfer commentedSimple one...
if (\Drupal::moduleHandler()->moduleExists('language')) {
These are still failing for me. Do they need to be similar to views_handler_field_entity?
Comment #10
xtfer CreditAttribution: xtfer commentedComment #11
xtfer CreditAttribution: xtfer commentedI also had to add
'id' => 'standard',
to get this relationship to work
Comment #12
xtfer CreditAttribution: xtfer commentedComment #13
tim.plunkettComment #14
xtfer CreditAttribution: xtfer commentedComment #15
Gábor HojtsyThis issue adds custom blocks views support wholesale, so better have a more accurate title.
Comment #16
damiankloip CreditAttribution: damiankloip commentedAs xtfer mentions, we need an id in here.
Drupal::moduleHandler()->...
See #2030453: Aggregate field data is not available as tokens for output rewriting, we should override usesGroupBy() here as it doesn't make sense to allow aggregation on these field handlers.
Should this be
if (($entity = $this->get_entity) && $entity->access())
?Also, seems like we might need some integration tests for this?
Comment #17
dawehnerJust fixing the problems but yeah I guess we need some tests.
Comment #18.0
(not verified) CreditAttribution: commentedUpdated issue summary.
Comment #19
jibranI'll take a look.
Comment #20
jibranLet's start fresh.
Comment #21
jibranSome questions for @dawehner.
$data['block_content']['table']['base']['access query tag'] = 'block_content_access';
@dawehner do we need these?
@dawehner do we need new field plugin link
node_language
?@dawehner @larowlan we have view link field. Do we need path field as well?
@dawehner do we need these for blocks?
@larowlan why we don't have revision uri?
@jibran injection.
@larowlan I don't think we can check these permissions? Unless I am missing something.
@jibran injection
@jibran injection.
Was ist das?
@dawehner Is this class enough or do we want more options on wizard form?
@dawehner there is no create column. Should we support this?
We have to create a new field plugin to support the revison links.
I'll add some tests next.
Comment #22
larowlanJibran++
We don't have uri because #1984588: Add Block Content revision UI and this are kind of inter-related
Comment #23
larowlan->access should work, from memory it just uses administer blocks permission.
I don't think we need view link, or path link, there is no viewing at moment, it falls back to editing.
Comment #24
jibranWorking on this.
Comment #25
jibranAdded some passing and failing tests. I'll try to look into fails next year.
Comment #26
jibran@dawehner Why these are not added by parent? We are not adding these in NodeData. I have to add these explicitly.
Comment #28
dawehnerGood question, don't know at the moment. It seems to be that you added it in #1984582-20: Add views support for custom blocks ... didn't you :P
Happy next year ...
Comment #29
jibranGreen Happy New Year!!!
It is ready for review. Please @dawehner can you please ans #21. Thanks.
Comment #30
jibranMinor doc fix.
Comment #31
jibranComment #34
jibranNow the real green :P
Comment #35
larowlanWow - awesome patch - great test coverage too!
Code review:
I guess no - if it's commented out?
$this->t is available
$this->moduleHandler is available
Can we add the link to the d.o issue for adding revision UI?
This should be 'update' there is no 'viewing' block content - see 'entity.block_content.canonical' route
And then I suppose this should default to 'Edit' - although I see we have an 'edit' one - so maybe this one can just be dropped?
Is this needed? If so can you add a comment indicating what it does differently to parent?
Do we have an issue for that?
To be honest, I think we could do this UI with views :)
Manual review coming
Comment #36
larowlanManual testing:
Add a new view (wizard)
Add some fields - delete link shows as broken/missing:
Attempt to view the saved view (table with title (linked), edit and delete links).
Comment #37
jibranFirst of all excellent review. Thanks @larowlan.
#35
Thanks for the manual testing in #36. Seriously jibran-- for this kind of mess. I have fixed it now and added a small test for it as well.
PS: Still waiting for @dawehner's re-entry in the issue :D
Comment #38
jibranUpdated the old issue summary.
Comment #39
jibranI talked to @dawehner in IRC here is the conoversation just for the record.
Removed wizards and links from the patch.
Comment #40
dawehnerCan we add a todo here which points to https://www.drupal.org/node/2322949 ?
In case we write new handlers can we please write them in ways that updates after #2322949: Implement generic entity link view field handlers are less? So for example this would be name it 'link_to_entity' or something along this lines
Can we add a todo to make that kind of integration automatic, introduced in content_translation method itself?
I highly doubt that you will EVER need that
can we drop that please? This is a really edge case feature for views.
Maybe dump question .... but are you sure that the standard integration is not enough?
Maybe next time not just c&p everything :p
Can we add a todo pointing to #2363811: Add a generic entity bundle field or actually better not even start trying to support it?
May be we could introduce a trait?
<3 all this test coverage
Comment #41
webchickComment #42
dawehnerSO yeah this needs work ...
Comment #43
jibranFor #40
Comment #45
jibranSome fixes.
Comment #47
BerdirI was helping someone to debug this at our local sprint yesterday. Looks like EntityViewsData does not generate the complete views data for revisionable entities, joins/relationships are missing. NodeViewsData is adding a bunch of stuff.
Maybe it would be easier to open a separate issue and move more logic from NodeViewsData into EntityViewsData and make that work before we complete this here.
Comment #48
dawehner@jibran
Nevertheless please create the necessary follow ups.
Comment #49
jibranWorking on this one.
Comment #50
jibranFixed the test fails. Created all the follow ups. One day we will remove
BlockContentViewsData
. @dawehner please add BE in IS.Comment #51
dawehnerAdded the BE
Comment #52
jibranPerfect now RTBC?
Comment #53
kattekrab CreditAttribution: kattekrab commentedOk - I had a bit of a play around with simplytest.me
Followed @larowlan's lead from #36 .
I didn't hit the errors he did, so that's good!
I was able to select custom block, and custom block revisions from the pull down list, which I can't do in the d8 install I've been playing with.
With patch.
Without patch.
I also made a couple of custom blocks, and managed to create a block display view of them.
I noticed a couple of other things - but not sure they are related to this particular issue, so will reach out on irc about them first.
Comment #54
larowlanThe issues identified by Donna on irc were #2406723: Duplicate fields in Views filter and field selections
See you over in #2375589: Convert custom block library page to views
Comment #55
kattekrab CreditAttribution: kattekrab commentedyup RTBC++
Comment #56
dasjoAlso tested this during #SprintWeekend and worked great so far!
When building the view i find it confusing that the block labels are named "description", buts that's totally decoupled from this ticket...
Comment #57
kattekrab CreditAttribution: kattekrab commentedYeah - I found that weird too. Why ARE the block labels called description instead of title?
Comment #58
tim.plunkettBecause it's been called "description" since box.module and block.module were merged in 2002, before Drupal 4.0.0: http://cgit.drupalcode.org/drupal/commit/?id=a4b5005640228b8f5cec843e46c...
Comment #59
kattekrab CreditAttribution: kattekrab commentedHuh.
Thanks Tim.
Comment #60
alexpottmissing scope, argument documentation, and comment is longer than 80 chars.
Let's get an
{@inheritdoc}
here.Comment #61
jibran@alexpott thanks for the review fixed everything.
Comment #62
kattekrab CreditAttribution: kattekrab commentedI did another manual test with simplytest.me
Created 3 custom blocks, made a block view of them, made a couple of revisions, made a page view of the revisions.
All works well.
Found some oddities when creating the Revisions view though - but I think that legitimately should be followed up in the postponed ticket about block revisions #1984588: Add Block Content revision UI
This issue, about adding views support for blocks, seems nailed.
Thanks all. RTBC.
Comment #63
Wim Leers#58: WOW, awesome detective work!
Comment #64
alexpottI debated about whether we should push this to 8.1 but consider it is ready and the impact extremely self contained happy to commit. Plus all entities having views integration is an extremely good thing for d8's flexibility. Committed 663c371 and pushed to 8.0.x. Thanks!
Thank you for adding the beta evaluation to the issue summary.
Comment #66
jibranYay!! custom blocks has views support now.
Thank you @alexpott for the commit.
Thank you @kattekrab and @larowlan for the reivew.
Thank you @dawehner for all the help and support.
See you all in #2375589: Convert custom block library page to views.