Problem/Motivation
Currently the empty selected message on bulk forms is configured via means of a method on the bulk form classes:
- NodeBulkForm
- UserBulkForm
- CommentBulkForm
This is something that would be very useful for site builders to be able to configure via the UI, and both NodeBulkForm and CommentBulkForm only exist to define this message in their context.
Proposed resolution
Move the message to a config setting in the BulkForm plugin.
Remaining tasks
Write a patch
Write upgrade path
Write upgrade path tests
User interface changes
User will be able to configure the empty selection message on views bulk form fields.
API changes
Deprecation of
- NodeBulkForm
- CommentBulkForm
Data model changes
New config setting for views bulk operation fields.
Comments
Comment #2
manuel garcia commentedWhile I agree this could be a good idea, I went and checked, and Comments have a different string (not just the entity label differs).
With the attached patch this would happen:
'No content selected.'becomes
No content items selected.'No users selected.'becomes
No user entities selected..'Select one or more comments to perform the update on.'becomes
No comments selected.So we will have to make a decision on whether the new messages would be good enough...
I also noticed that if I remove
NodeBulkForm.phporCommentBulkForm.phpthen the bulk form fields do not appear on the view, so I have left the empty class there.Comment #3
jibranWe need a usability review here.
Comment #5
zaporylieComment #6
lendudeYou will need to update \Drupal\node\NodeViewsData to point to the generic bulkform field, for comments too. This would also require an update path to point all existing node/comment bulk fields to the new handler id.
Comment #7
zaporylieCan we even remove these classes? Sounds like BC break as mentioned classes are not @internal
Comment #8
lendudeSince they are not marked as anything, it falls into the great big grey 'we will try not to break it' area. Since there is a base class which will most likely be used for extending, and extending these two classes makes zero sense, I think we are fine here with removing them.
Leaving them in makes this patch much easier then taking them out though, we would just need to fix the test fails in #2. I'm not a fan of leaving empty classes in without a good reason, but I'm fine with whatever others want to go with.
Comment #9
zaporylieThanks for the input. I believe potential BC break is good enough reason for leaving empty classes in place.
Even if we are not gonna remove these classes just deprecate them, views handler ids must be updated.
So IMO remaining steps are:
Removing Novice tag for now.
Comment #10
manuel garcia commentedThanks all for clarifying the steps needed here.
I feel however that a usability review is what is blocking this issue right now, as it is not clear that we actually want to do this. There may be good reasons for not displaying the messages that would be displayed if we do this (see #2.
To give an example, displaying "No user entities selected." is not going to be very friendly. Perhaps the way forward is to change the plural label of the user entity to be just "users" if we want to do this. The other 2 might be ok, but that's for the usability team to decide.
Comment #11
tobiberlinI am first time sprinter on Vienna2017 DrupalCon and will work on this
Comment #12
tobiberlinJust worked on the patch to avoid test failure
Comment #13
tobiberlinChanging status
Comment #14
manuel garcia commentedComment #15
manuel garcia commented@tobiberlin thanks for working on this, it looks like the patch came out wrong, check this page for instructions: https://www.drupal.org/node/707484
Comment #16
sfuchsbe commented@tobiberlin
I also recognized that the patch didn't apply. I just tried to rework on this. I basically didn't change anything, but created the patch with git diff. I hope you are not mad at me ;)
Comment #17
sfuchsbe commentedComment #19
manuel garcia commented@sfuchsbe is working on this at the sprints
Comment #20
sfuchsbe commentedComment #21
manuel garcia commentedOK patch on #20 looks good... thanks @sfuchsbe
This needs usability review due to the changes in the messages shown to the user (see #2).
Comment #22
Bojhan commentedThe changes proposed do not make a whole lot of sense to me. I am in agreement with jibrans first impression here.
We overall avoid 1) using the word entities in common user interfaces, 2) we try to provide "helpful" messages to get people to act appropriately.
We purposely overwrote these messages to be more helpful - see https://www.drupal.org/docs/develop/user-interface-standards/table and https://www.drupal.org/docs/develop/user-interface-standards/interface-text.
Feel free to tag it again, when a new proposal is made.
Comment #23
lendudeHow about moving the message to a config setting in the BulkForm plugin? And using that message in
\Drupal\system\Plugin\views\field\BulkForm::emptySelectedMessageif it's been set or else fall back to the default message proposed here?That would not break BC since just overriding
emptySelectedMessagewould still work too.But since that would require a schema change, it might have to wait on #2916451: Move everything related to Bulk Form to Views module
Comment #24
manuel garcia commentedThanks @Bojhan, I agree.
@Lendude that is a great idea, would also be a better developer experience in my opinion. Would that allow us to get rid of BulkForm subclasses as well?
Postponing on #2916451: Move everything related to Bulk Form to Views module for now in any case.
Comment #25
lendude@Manuel Garcia well we'd need an upgrade path that checks if a View uses any of those three plugins and if so:
- update the plugin id to the generic bulk_form
- update the 'empty message' setting to the original message in the old bulk plugin
Then we can deprecate the 3 old plugins (or remove them, but see #8/#9 for arguments against that).
Comment #26
manuel garcia commented#2916451: Move everything related to Bulk Form to Views module just got in
Comment #27
chr.fritschThis would be really helpful for #2877383: Add action support to Media module as well
Comment #28
chr.fritschRerolled the patch and implemented the proposal from #23
Comment #30
manuel garcia commentedThanks @chr.fritsch for taking that step =)
I totally love this idea, gives more power to the site builder to configure these messages.
I believe we should aim to keep the same messages we are currently showing to the user, in order to make this patch not have to deal with string changes. This means we shouldn't have to change the tests verifying that these strings appear. So we'll need an upgrade path to set these options for these three views I think?
Comment #31
lendudeGreat first steps to getting this done @chr.fritsch!
Yeah absolutely, since that was what was explicitly needed after the usability review.
So I think #28 still needs:
The first two steps should mean that all existing tests should come back green with no changes needed. This should be our goal.
Comment #32
manuel garcia commentedPerfect thanks for the clarity @Lendude - I'm gonna give this another push =)
Comment #33
manuel garcia commentedOK some progress in this direction.
Comment #34
manuel garcia commentedComment #36
chr.fritschI fixed some tests
Comment #37
chr.fritschYay, tests are green. And here is the update path
Comment #38
lendude@chr.fritsch this looks really nice. Great work on the upgrade path and test!
Couple of things:
Can we turn this into a post_update please (also update the @see in the test)? Less hassle when it gets committed and less change of naming collisions.
Shouldn't we also set the plugin_id to the generic bulk field plugin? Since the entity specific plugins no longer provide any functionality.
That would also allow us to deprecate the old entity specific plugins. Which I think we should also do here (sorry that was missing from my little todo list in #31).
Also, when as View is using the generic bulk_form plugin the value should default to something, probably an empty string (also see my next point)
I think the default should be an empty string. And this logic should go into emptySelectedMessage() for when the current value is an empty string (see my previous point). Otherwise we will have a hard time dealing with existing config, since defaults are only set when initialising the View. Also, setting this to an empty string by default would allow the empty message to be automatically updated if the plural label for an entity ever changes.
This seems like a change that might need it's own issue, not sure we can get away with just squeezing that in here.
Comment #39
chr.fritschRegarding #38:
38.2: We could do that for node and comment. The user_bulk_form still contains some code.
38.4: This change should be done in #2702683: Add plural labels to entity types which is postponed on #2813895: Combine entity type labels in an array...
Comment #41
chr.fritsch#2702683: Add plural labels to entity types landed. So lets proceed.
I rerolled the patch and fixed the comments from #38.
Comment #43
chr.fritschAdded the new deprecation warnings to the DeprecationListenerTrait
Comment #44
vijaycs85wow, nice clean up!
Minor: guess, Drupal coding standard would through warning here as "}" should appear in next line?
If we are removing the body, do we still need to keep schema?
As @catch pointed out in [2880149-124], we might want to use the helper class from #2949351: Add a helper class to make updating configuration simple
Comment #45
vijaycs85Could we also add a change record or update existing (found just https://www.drupal.org/node/2916716) to reflect this approach?
Comment #46
manuel garcia commentedRe #44.2 I believe we can, though not entirely sure, here my reasoning:
The "old" fields are still available, just that now they work differently (using the plugin
bulk_forminstead), so everything should still work. The only thing we need to deprecate is the views plugin classes I believe.Taking a stab at that to see how it would look like.
Comment #48
manuel garcia commentedI guess we do need the schema after all... or at least I can't figure out how to make
empty_selected_messageavailable to all fields using thebulk_formplugin...Comment #49
lendude@Manuel Garcia as far as I can tell, it just the
that needs to stay in, because that plugin is still in use in
views.view.user_admin_peopleComment #50
chr.fritschAll the schema has to stay because the classes will stay as well. That's also what we did when we deprecated action plugins for example.
Comment #51
manuel garcia commentedThanks for clarifying things!
So here is another attempt at further cleaning up, only removing the bulk form fields from the views data, and adding the deprecation notice to the
views.field.user_bulk_formschema.Comment #53
manuel garcia commentedOK then, we need those as well. So here's #43 and adding the deprecation notice too views.field.user_bulk_form schema. I'll stop the noise here now sorry :)
So to recap, what needs to happen here as far as I can see:
views_post_update_set_empty_selected_message().Comment #54
lendudeAdded a CR https://www.drupal.org/node/2956578
The patch needs a quick update to point to this.
And yes it would be nice to use #2949351: Add a helper class to make updating configuration simple.
Comment #55
manuel garcia commentedThanks for the CR @Lendude!
Clearly yesterday wasn't my day... we are not deprecating the user bulk form class, so removing the comment added on #53.
Updated the patch to point to the CR, and updated the CR to state the classes that we're deprecating explicitly.
Postponing on #2949351: Add a helper class to make updating configuration simple.
Comment #56
manuel garcia commentedComment #57
chr.fritsch#2949351: Add a helper class to make updating configuration simple landed, so this is unblocked now
Comment #58
chr.fritschSo I rerolled that patch and it's now using ConfigEntityUpdater
Comment #59
lendudestill missing the right 'see' to the CR
also missing the correct 'see'
Shouldn't we also set a default empty string for views using bulk_form currently?
Shame these need to be added :( But no way around this since I guess plugin discovery is triggering this?
Comment #60
chr.fritschFixed everything
Comment #62
manuel garcia commentedLooks like this broke our post_update function :S
Comment #63
manuel garcia commentedRerolled, had to manually fix these due to #2935256: Remove all usages of drupal_get_message and drupal_set_message in modules:
Comment #64
manuel garcia commentedHad a go at the failing test, but I cant figure it out...
views_post_update_set_empty_selected_message()looks sound to me, and so does the test...Comment #65
manuel garcia commentedFor now just adding coverage for the second display
'page_unapproved'on thecommentview, which also uses thecomment_bulk_formfield.Comment #68
chr.fritschI looked into the failing test and found something sad :(
In #1986606: Convert the comments administration screen to a view the comment list was moved to be a list. But it uses the current config from core/modules/comment/config/optional/views.view.comment.yml to create the view. In views_post_update_set_empty_selected_message we expect to have a comment view that still uses the comment_bulk_form plugin. But in the testViewsEmptySelectedMessageUpdate it doesn't. It already uses the bulk_form. Because that's the new value in views.view.comment.yml. So our views_post_update_set_empty_selected_message resets empty_selected_message to an empty string and that's not what we expect for the comment view.
Maybe we should open an issue to adjust the comment_post_update_enable_comment_admin_view function. It better should use the config from a year ago and not the current values.
Comment #70
manuel garcia commentedReroll, manually fixed conflict on
core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php, and changed the deprecations to mention 8.7.x instead of 8.6.x.Comment #71
manuel garcia commentedThanks a lot for the discovery on the failing test @chr.fritsch - I now understand the problem. I don't see how we can adjust
comment_post_update_enable_comment_admin_view()to use a previous version of the view though.However I think we can work around this in our post_update function, please have a look :)
Comment #74
manuel garcia commentedHumm are those deprecation notices because of the patch?
Comment #76
manuel garcia commentedWe needed to add @group legacy to our update path test, see https://www.drupal.org/node/2985785
Comment #77
joachim commentedAs much as those classes look silly, I don't think this is a good idea.
We're now violating DRY because this phrase is repeated:
More importantly though, this change deteriorates UX.
Before, I set up a comment view, and the empty select message is there for me, OOTB.
After, I have to write it myself for each view I make, or have a default value that's generic to all entity types.
Comment #78
manuel garcia commentedI don't agree that this deteriorates UX, you still get an empty selected message out of the box, being
No comments selectedfor a comments view for example. You only would need to configure it if you wanted something custom for that specific view.Comment #79
manuel garcia commentedIn fact, in my opinion this actually improves the UX, since this gives more power to the site builders who would now be able to configure the empty selection message via the UI, whereas before they couldn't.
Comment #80
manuel garcia commentedUpdated the IS to reflect more the reasons and advantages of doing this, current status of the issue, and to mention deprecation of two classes.
Comment #81
manuel garcia commentedComment #82
manuel garcia commentedReroll of #76, fixed conflicts manually on:
Comment #84
manuel garcia commentedConflicts on the other test classes made me have a look at our changes to
UserBulkFormTest, and indeed it needed updated because of the change in variable name.Comment #86
manuel garcia commentedTest failed because entity.manager service got deprecated. Took the opportunity to clean it up while I was fixing it.
Comment #88
manuel garcia commentedOK this should hopefully come back green.
Comment #89
manuel garcia commentedActually there was no need to touch
core/modules/user/tests/src/Functional/Views/BulkFormTest.phpso removing those changes in this patch.Comment #90
manuel garcia commentedSigh, removed changes from the wrong file, here is the correct patch. And this is a good example why you shouldnt be messing about on a Sunday evening instead of resting.
Comment #91
manuel garcia commentedHere is the interdiff from #84 to #90, please ignore the stuff in between.
Comment #94
manuel garcia commentedSigh, got the interdiff the wrong way around... here is what actually happened:
Apologies for the noise.
Comment #95
manuel garcia commentedComment #96
vijaycs85Manually tested the patch in #90 and everything looks good. +1 to RTBC.
Result:
1. Upgrade path ran successfully(screenshot)
2. Without and with patch has the same message and behaviour all 3 affected bulk forms: (with patch screenshot, without patch screenshot).
Comment #97
andypostwhy this strings are not one line?
why there's no check that plugin_id is a one from list?
Comment #98
manuel garcia commentedThanks for reviewing!
Re #97.1 Dont see why it should be like that, so changed them to being on the same line.
#97.2
isset($plugins[$field['plugin_id']])is checking the list, but just in case I added another check to explicitly check the$idas well.Comment #99
vijaycs85Looks like the comments in #97 have been addressed and the issue summary is up to date with a change record.
Comment #101
manuel garcia commentedRerrolled, simple conflict on
core/modules/views/views.post_update.phpComment #103
andypostRandom failure in media oembed
Comment #104
andypostComment #105
alexpottWe shouldn't be adding to this list. How come we need to? Update tests ignore legacy deprecations so this is not needed for them.
I'm guessing it is because we are deprecating plugins. We do that in the constructor to avoid plugin scanning triggering deprecations.
Comment #106
manuel garcia commentedThanks @alexpott - addressing it here.
Comment #108
andyposthttps://www.drupal.org/core/deprecation#how-plugin
Let's see how many things will be fixed, I think views_data should use new definition as well
Comment #110
andypostLet's see how it affects tests
Comment #111
manuel garcia commentedThanks @andypost!
#105 is addressed, so I'm tempted to go back to RTBC, but now I'm wondering whether the change to views_data needs an upgrade path or not?
Comment #112
manuel garcia commentedAfter refreshing my memory reading the upgrade path, we're already handling the change to existing views, and don't see how the change to views_data would require anything extra, so setting this back to RTBC.
Comment #113
catchThis doesn't cover the case of modules with default configuration.
What we've done in the past, is to add the logic on configuration save, and just loop over and save the live config in the update without any additional logic.
See views_view_presave() for some examples.
Comment #114
manuel garcia commentedThanks @catch for reviewing, you're right. Hopefully this is what you meant on #113.
Comment #116
lendudeI think the example in
\Drupal\views\Entity\View::preSaveis better, using\Drupal\views\Entity\View::fixTableNameswhich is easier to mark as @depricated and make it private, so its much clearer we are dealing with temp code that needs to be removed.Using views_view_presave makes that hard to do.
Comment #117
alexpott@catch are we sure it's worth it? The old plugins still work they are just deprecated. In the case of \Drupal\views\Entity\View::fixTableNames() we had something to fix to make it actually work so I think that's a different case.
Comment #119
andypostNeeds work to update deprecations to new format and
maybe provide here default?
Comment #121
manuel garcia commentedStraight re-roll of #114 plus switching to using createMock instead of getMock on the unit tests changes.
Comment #122
manuel garcia commentedFixing the reroll and adding a default to the option, it was requested on #119 and I think it's a good idea :)
Comment #125
manuel garcia commentedTackling tests failures.
Comment #127
manuel garcia commentedTackling one of the failing test, not sure why the other one fails, I tried the upgrade path manually and the empty selected text is saved to the view.
Also moving from views_view_presave to Views::preSave() in case there-s consensus that this is actually needed (see #116 & #117).
Comment #128
dawehnerNote: This needs to be updated to 8.8.x or even 8.9.x
Shouldn't this be 'comment_bulk_form' given the message is about comments?
Comment #130
manuel garcia commentedThanks @dawehner for the review, all good points, addressing them here.
Comment #131
manuel garcia commentedComment #133
andypostThis needs to be updated to 8.8.x or even 8.9.xIIRC we should not deprecate it for 8.9, instead it should be done in 9.0 for 10.0 removal
Comment #134
andypostPatch does 2 things
- fix deprecation message to format https://www.drupal.org/core/deprecation#how-plugin and moved to 9.0.0
- remove
fixTableNames()as #128.2 - it's a views definition for entity to provide empty messagePS: probably this method also needed to ecplude deprecated plugins from views plugin discovery!
Comment #136
xjmThis would be a minor-only change. Since 8.9.x and 9.0.x are now in beta, I'm moving this to 9.1.x. Thanks!
Comment #137
manuel garcia commentedComment #138
andypostSo it should be 9.1 and https://www.drupal.org/core/deprecation#how-class
Comment #139
jofitzRe-roll for D9.1.x
Comment #141
andypost@jofitz can you add interdiff to your patch?
It's not clean why the patch size is twice bigger then previous one
The re-roll incomplete - the version it should use is 9.1 and 9.0 in freeze
now it should be drupal:9.1.0 and 10.0.0
not sure it needed in 9.1
Comment #142
manuel garcia commentedLooks like we still need to reroll #134, so re-adding the tag.
Comment #143
aleevasTrying to fix failed tests
Comment #145
aleevasComment #146
andypostProper re-roll and fix few nits
Comment #147
andypostAnother reroll
Comment #153
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.