Problem/Motivation
Custom blocks are now publishable, but the Custom block library page (/admin/structure/block/block-content) doesn't not reflect this change. Since the custom blocks as publish-able, make the UI close to node admin page (/admin/content):
This work was started In #2834546: UI for publishing/unpublishing block_content blocks, but it was decided to split the changes to block_content view and related into a follow up issue, because this requires an upgrade path.#2834546: UI for publishing/unpublishing block_content blocks should be committed before this issue gets in.
Proposed resolution
Introduce below changes:
1. Bulk operation form
2. Add published column
3. Add publish status filter
and write the upgrade path in this issue.
Remaining tasks
- Implementation - Done
- Manual testing - Done
- More reviews
- Commit!
User interface changes
Adds a bulk publish / unpublish actions and a new "published" column to the Custom block library page /admin/structure/block/block-content
API changes
None
Data model changes
None
Comment | File | Size | Author |
---|---|---|---|
#106 | 2909435-diff-104-106.txt | 221.28 KB | vijaycs85 |
#106 | 2909435-106.patch | 247.25 KB | vijaycs85 |
#104 | 2909435-104.patch | 25.92 KB | Manuel Garcia |
#104 | interdiff-2909435-97-104.txt | 2.66 KB | Manuel Garcia |
Comments
Comment #2
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commentedHere the part of the patch that we've split off of #2834546: UI for publishing/unpublishing block_content blocks
Quoting @dawehner on there (comment #52):
Comment #4
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commentedComment #5
jibranComment #6
jibranLet's add delete action as well.
Comment #7
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commentedRe #6
While I totally agree this would be useful to have, is this in scope? Only reason I could agree on that is to avoid having to write two upgrade paths & tests.
Also, this patch is not only adding bulk operations, it is also adding a Published column to the view, so the title is not reflecting the intention here (which is to adjust the page to the fact that custom blocks are now publishable.).
Comment #8
vijaycs85Probably we have to make changes to reflect the changes in IS (just added) as part of this ticket.
Comment #9
chr.fritschPlease don't implement your own action plugins. Better wait and push #2916740: Add generic entity actions and #2670730: Provide a delete action for each content entity type
Comment #10
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commentedOw very cool @chr.fritsch!
I say we postpone this until that gets in, and then clean up the patch here.
Comment #12
chr.fritschUnpostponed since #2916740: Add generic entity actions landed
Comment #13
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commentedBrilliant, here is #4 making use of the generic entity actions.
Comment #14
chr.fritschNice one 👏
#2670730: Provide a delete action for each content entity type is really close, so should a delete action implemented here as well?
Comment #15
chr.fritschCould also be deleted
Comment #16
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commentedAddressing #15.
Re #14 I think we could do that for all entities that have this bulk form as a follow up once that #2670730: Provide a delete action for each content entity type has landed. This issue's scope is only to deal with publish/unpublish. That said, if it lands quickly, it'd be simple enough to expand the scope here. Whatever the committers prefer I suppose, either way is fine with me.
Comment #17
chr.fritschDelete actions are in.
Comment #18
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commentedHere is a start on the upgrade path. I'm not sure if this is the right way to go about it.
It currently has two problems:
1. The order of the fields is not set properly.
2. The actions are not showing up as even selectable in the UI.
Please have a look at the screenshot to see the problems, taken after a fresh install of 8.6.x, applying #16, and running the update hook.
Comment #19
gnuschichten CreditAttribution: gnuschichten at ETECTURE GmbH commentedI have added the bulk actions to the install process and move bulk selections fields to the top.
Comment #20
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commentedBrilliant thanks @gnuschichten!
I tested the patch, and the bulk operations show up, in the right place, and fully working - we're getting close here!
One thing we still need to fix in the upgrade path is the order of the Published field, since it isn't showing up in the right place yet (see screenshot) - setting to needs work for that, and the tests we'll need to add here.
Comment #21
tstoecklerI also considered now that #2670730: Provide a delete action for each content entity type is in, whether we should also add a "Delete" action to the Custom block library. Theoretically it could be considered out of scope, but since this already contains an upgrade path to enable the bulk form, this would just be another action we would have to add as part of the upgrade path. Thoughts?
Comment #22
tstoecklerOops, didn't mean to change the status. Also removing "Needs update path" tag, as that seems to be part of the patch by now.
Comment #23
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commentedAddressing the position of the
published
field in the update path. With this, I believe the update path to be done.Now we just need the update path tests.
I am opened to including here a delete operation @tstoeckler, however we are not just adding bulk operations to this view, we are also adding the published field, so not sure what the title should be of this issue if we include the delete operation... Happy to do it here, but I'd like a committer to agree to this before putting in the time to do it.
Comment #25
chr.fritschI think this should be done in a post_update hook where we are able to use the full API
Not sure about writing the complete config object here again. May we could do something like this:
This code block is copied from config_update module.
Comment #26
tstoecklerRe #25: Generally we try to avoid reading runtime information during updates, because you don't know when they will be run. I.e. some system may not run the update until months/years later when the runtime information (in this case the block library view) has changed again. That is definitely the case for normal (non-post-)update functions. I can see how it is less relevant for post-updates, but I haven't seen something like #25 in core before. Maybe someone more into the update system (@alexpott ?!) can clarify.
In general though I think you are absolutely correct that this makes sense to do in a post-update.
Comment #27
tstoecklerTss... somehow my browser reeallly thinks this issue needs review... sorry for the noise.
Comment #28
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commentedThanks guys for taking the time to review this!
The change to needs work was done by the bot who had a test failure unrelated to this patch. #23 is passing so changing back to needs review.
Last night I started to do the update as described in #25, but made little progress. What @tstoeckler argues in #26 makes a lot of sense though, so I will stop that work and leave the patch as is for now.
Comment #29
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedLoading, updating and then saving views in a post update function has proven to be problematic (see #2917006: Views referencing missing roles fail views_post_update_revision_metadata_fields(), which is being caused by the upgrade path added in #2248983: Define the revision metadata base fields in the entity annotation in order for the storage to create them only in the revision table) because some views might be in a broken state and as a consequence they can not be saved via the (config) entity API.
So the patch from #23 is correct on both points from #25:
- it updates the views config files directly using a regular update function
- it doesn't use runtime information for generating the action config entities
Comment #30
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commentedThanks @amateescu that settles it I think then. Setting the status to Needs work for the update path tests.
Comment #31
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commentedHere's the update path test, let me know what you think :)
Comment #32
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commentedComment #33
andypostLooks great & no reason in upgrade tests
Comment #34
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commentedThanks for RTBCing, just noticed a small mistake on an assertion message of the update path test, fixing it here.
Comment #35
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commentedThere was mention in this conversation of using this patch to also add the delete action that is now also available, because we already have an update path (and doing this as a follow up would require another update path). See #6 #14 and #21. I have left this out for now because I feel that's not in scope for this issue (we are not just adding actions, but a Published exposed filter and a Published column to the table).
I leave this to the maintainers to decide on whether to do it here or as a follow up. Happy to work on it whichever way.
Comment #36
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedThe patch looks great to me! I just found a few nitpicks :)
We need to convert all the lowercase
true
andfalse
to uppercase :)Let's try to avoid a conflict with a possible pre-existing status field or filter, and use
ViewExecutable::generateHandlerId()
to generate the views handler ID. You can see an example of that in the interdiff from #2880149-115: Convert taxonomy terms to be revisionable.Coding standards nit, we need a space before
[]
.No need for this blank line.
Extra space here after
=
.We don't need to use
t()
in tests :)Comment #37
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commentedThank you so much for the review @amateescu!
Addressing #36 here.
Comment #38
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedNice! Just a few things left:
Since you are not using
$definition_update_manager
again in this function, these two lines can be merged into one :)You can use the
$fields
variable defined above instead of getting it again from the config object.You can use
$published_key
here as well.Comment #39
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commentedThanks again @amateescu - all good points. Addressing #38 here :)
Comment #40
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commentedActually addressing #38.1 properly...
Comment #41
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedI don't have anything else to complain about :)
Comment #42
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commentedComment #43
plachOverall this is looking great, however it seems we are lacking explicit test coverage for the bulk operations we are adding. Actually, we have it in the update test but not in
BlockContentListViewsTest
. Maybe we could add a trait to perform the same assertions in both places?I think deferring bulk deletion to a follow-up is a good idea, we can modify the logic in
block_content_update_8600()
to cover also that, as long as this happens before 8.6.0 is released.Aside from that, here's a code review, mostly nitpicks:
Can't we just use
array_splice
width length 0 here?Wrong indentation.
There are also quite a few missing trailing commmas. It would be nice to fix them for consistency :)
Not a huge fan of raw-asserting yes/no this way: it feels fragile. Can we use xpath with some more specific selector instead?
Also, we're mixing quote types here :)
Comment #44
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commentedThanks @plach for the review, all good points.
Introducing here the new trait, please have a look. Hopefully I'm on the right track as to what you meant here, also, naming things is hard :)
#43.1 Always thought that was a bit of a mess, and your suggestion is much cleaner, thanks.
#43.2 Fixed, cleaned up everything I saw.
#43.3 Good point, re-factored that into a method on the new trait, using xpath.
Besides this, I also added test coverage for the status filter to
BlockContentListViewsTest
, and avoided using calls to deprecated methods on the update test.Comment #46
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commentedIt appears that
array_splice
does not preserve the keys from the replacement array. Quoting the PHP documentation page:Indeed, if you do this:
Then
$input
becomes:Which is what seems to be happening now on
block_content_update_8600
.Reverting here to what we had before.
Comment #48
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commentedWhen we use the publish actions the status filter gets reset, causing the failures on #46. This should hopefully fix it.
Comment #50
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commentedTest was failing on the xpath selector, because the update test uses bartik, and
BlockContentListViewsTest
doesn't. Let's see if this selector does the trick. It's more specific so it should be less fragile I believe.Comment #51
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commentedAwesome, back to green :D
I wanted to note that the first version of this patch was split off of #2834546: UI for publishing/unpublishing block_content blocks, and that other people worked on it as well. Imho they should be credited here too, timmillwood, amateescu, and possibly others for their helpful reviews.
Comment #52
vijaycs85Manual testing
Existing site
drush updb
(screenshot )sidebar first
Fresh install with patch
Other observations
1. Revision tab looks bit weird when checkbox is not ticked. screenshot
2. Labels and fields have mismatch with content list page. screenshot
We might not able to address them in this issue, just adding here to discuss.
Code review
nice!
Minor: these assert methods are doing bit more than just asserting. they are doing certain action and asserting.
Not sure, if they are automated update. if not, feels irrelevant to this issue.
Over all, Big +1 to RTBC!
Comment #53
vijaycs85Comment #54
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commentedThank you @vijaycs85 for the manual testing, issue summary updates and suggestions.
#52.2 You're right, renaming those here.
#52.3 - That was introduced to the patch on https://www.drupal.org/project/drupal/issues/2834546#comment-12246154 - otherwise those tests fail with these changes.
Comment #55
vijaycs85@Manuel Garcia #54 looks good to me. +1 to RTBC.
Comment #56
chr.fritschDo we really need that? We didn't add one for media recently as well. And with #2909423: Get rid of BulkForm subclasses when they just override emptySelectedMessage we would get a nicer message and would have to deprecate this class again.
Comment #57
vijaycs85#56 +1
Comment #58
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commentedRe #56 you're absolutely right, we do not need this now that #2909423: Get rid of BulkForm subclasses when they just override emptySelectedMessage is getting close.
So removing that and all the things that implied, which brings down the patch size a bit. Thanks @chr.fritsch!
Comment #59
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedWe should pass
TRUE
here to signal the fact that we're dealing with trusted data.Could use an empty line :)
We could use
assertCount()
here.I don't we use the
@package
annotation in core, let's remove it.Needs the 3rd person form of the verb :)
Same as above, a new line will help with visibility.
Comment #60
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commentedThank you @amateescu for the review, all good points, addressing them here.
Comment #61
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedNice, I can't find anything else to complain about, so RTBC :)
Comment #63
MixologicTestbot Snafu.
Comment #64
vijaycs85Looks good since my last review. +1 to RTBC. did a manual test of one of the happy path (i.e. with update db) and it works as expected.
Comment #66
chr.fritschThis needed a re-roll after #2886609: Migrate translations for D6 i18n taxonomy 'localized' terms landed.
Comment #68
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commentedThanks @chr.fritsch - looks like that got reverted though, so re-uploading #60 here.
Comment #71
chr.fritschRe-roll since #2976334: Allow Custom blocks to be set as non-reusable adding access restriction based on where it was used. was committed.
Comment #72
alexpottI'm not sure I agree with #29. Yes updates that fix views to work with the current code base should be hook_update_N() but updates that are adding things that you could do via the UI should be post updates. There is never a time that post updates should be working with broken views and if they are then something has gone wrong.
Comment #73
amateescu CreditAttribution: amateescu for Pfizer, Inc. commented@alexpott, since Views doesn't enforce data integrity for the configuration of its plugins (like the problem discovered in #2917006: Views referencing missing roles fail views_post_update_revision_metadata_fields()), I don't think we can ever rely on being able to do CRUD operations on views' config entities in a post_update function, so the only option left is to update the view config objects "manually" in a regular hook_update_N() function.
Comment #74
jibranI think actions should be saved before the view is being updated, just like we normally do via UI. Am I missing something here?
Comment #75
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commentedReroll
Comment #76
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commented@jibran re #74 It'd be a 2min change to the patch, but the bulk update field is configured to use
All actions, except selected
, so saving the actions after the view causes no problems with the view itself.Comment #77
alexpott- but we need to move to a world where it does.
Comment #78
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedAgreed, but not in this issue I would hope :)
Comment #79
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedThis needs to be updated to
8700
now..Comment #80
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commentedGood catch @amateescu :)
Comment #81
larowlanunrelated?
@alexpott's comments from #72 haven't been addressed yet either
Comment #82
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commentedRe #81:
Comment #83
vijaycs85Tested manually on both scenarios (install with patch & install, apply patch & drush updb) and can see the publish checkbox on both cases. +1 to RTBC.
Only difference between this issue and #2834546: UI for publishing/unpublishing block_content blocks is, this one runs update and #2834546: UI for publishing/unpublishing block_content blocks runs post-update.
Comment #84
amateescu CreditAttribution: amateescu for Pfizer, Inc. commented@larowlan's feedback has been answered, back to RTBC :)
Comment #85
alexpottIt's possible the view has been deleted or does not exist.
Also this issue poses an interesting question. Why do we have an update path? It is possible the user has customised their view so that doing these updates is unnecessary and will cause duplicate columns. I think
Also I'm still not completely sold on @amateescu's arguments for this being hook_update_N - yes there are issues with views dependencies and they way some views plugin over store things in config but they are bugs that we should fix when we come across them.
Comment #86
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commentedRerolled, there was a conflict on
MigrateUpgrade6Test
which a 3 way merge was able to fix.Setting to needs review to trigger the tests bot, though this is still needs work (see #85).
Upgrade path is to add the new features to the block content admin form, where we are not only adding the
status
field, but also theblock_content_bulk_form
field with the new publish/unpublish actions added in this patch. So in my opinion we do need an update path to add these.Perhaps we can first check if the status field already exists on the view, and only add it if its not already there?
Comment #87
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commentedPerhaps something like this? (only adding the status field if its not there already).
Comment #88
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commentedAddressing what was mentioned in #85 - checking that the view exists prior to altering it. Not 100% sure this is the right way to do it, please have a look :)
Comment #90
vijaycs85Here is an update to check with the hash (as suggested in #85). Also created #3021158: Add an API to check configuration object status
Comment #93
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commentedComment #94
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commentedReroll of #90
Comment #96
vijaycs85Retesting the patch in #94 as the failing test (
Drupal\Tests\block_content\Functional\Update\BlockContentUpdateTest::testBlockContentPublishableUIUpdate
) doesn't exist in HEAD anymore.Comment #97
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commentedRerolled, 3 way merge did the trick.
Comment #99
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commented@vijaycs85 re #96 - testBlockContentPublishableUIUpdate is added in this patch :)
Comment #100
vijaycs85#99my bad :)
Drupal\Tests\block_content\Functional\Update\BlockContentUpdateTest::testBlockContentPublishableUIUpdate
is failing because the test is trying to use the DB dump fromdrupal-8.bare.standard.php.gz
which has the configviews.view.block_content
and doesn't match with what we have current config (i.e. changes went in in config but weren't updated indrupal-8.bare.standard.php.gz
)I am attaching the views.view.block_content.yml for reference.
Next step would be sync the config except the changes introduced in this issue to
drupal-8.bare.standard.php.gz
and run tests again.P.S: the config file generated by below code:
Comment #101
vijaycs85after further testing found that the config in DB update doesn't match with the one installed on the HEAD and I created #3062291: Config entity changes as part of install which turns out to be a duplicate of #3059545: Improve \Drupal\KernelTests\Config\DefaultConfigTest to install all optional configuration. Probably a good idea to wait for #3059545: Improve \Drupal\KernelTests\Config\DefaultConfigTest to install all optional configuration to land. it is RTBC anyway.
Comment #102
vijaycs85#3059545: Improve \Drupal\KernelTests\Config\DefaultConfigTest to install all optional configuration is in.
Comment #104
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commentedI think the issue with
BlockContentUpdateTest
will still remain though this should fix some of the failing tests.Comment #106
vijaycs85Here is an update on the update test. Works locally. I am not sure how it would help for the review as the patch and interdiff with changes on gz file are not readable.
Comment #111
capysara CreditAttribution: capysara at Bounteous commentedIs there any interest in resurrecting this? If so, I can test the last patch (and the patch in https://www.drupal.org/project/drupal/issues/2834546).
Comment #114
smustgrave CreditAttribution: smustgrave at Mobomo commentedThis will need a reroll for 9.5
Comment #115
smustgrave CreditAttribution: smustgrave at Mobomo commentedThis one needs a lot of work still I think
The update hook failed.
The bulk feature for the view I think needs a handler.
But postponing until https://www.drupal.org/project/drupal/issues/2834546 is complete.
Comment #117
smustgrave CreditAttribution: smustgrave at Mobomo commentedCombing with #2834546: UI for publishing/unpublishing block_content blocks
Will move over appropriate credit.