Problem/Motivation
The generic ActionBulkForm provides a mostly unnecessary field handler that is redundant with the more specific bulk handlers provided by Node and User module. This results in a confusing option for end users who don't know if they should choose "Action: Bulk update" or "User: Bulk update".

The arrangement of ActionBulkForm is also confusing for developers, as the class itself is provided by Views in \Drupal\views\Plugin\views\field\BulkForm however it is exposed to the end-users by Action module in action_views_data(). It would be less confusing for developers if the class and the exposure to Views were both owned by the same module, rather than one module directly using another's field handler.
Proposed resolution
Move the functionality from the ActionBulkForm to the BulkFormBase class and remove ActionBulkForm from action_views_data() (actually the whole function/file can be removed, since this is the only handler exposed by Action module).
User interface changes
The "Action: Bulk update" would no longer be available in the Views interface.
API changes
Modules wishing to use bulk operations will need to extend BulkFormBase for each entity needing to be supported.
Related Issues
#1851082: Add a base bulk form handler class
#1851086: Replace admin/people with a View
#1895160: Convert admin/content to a View, keep a non-views fallback with no bulk operations
| Comment | File | Size | Author |
|---|---|---|---|
| #36 | 2049573-36.patch | 32.25 KB | damiankloip |
Comments
Comment #1
pcambraHere's a first take, probably we'll get some test errors due to #2049569: Delete multiple for nodes is broken
Comment #2
pcambraComment #4
pcambraComment #5
dawehnerLet's use @inheritdoc here.
I am wondering whether the string should be overridden for users.
Comment #6
pcambraLet's see how this looks like.
Comment #7
dawehnerI am not sure whether we talked about that already, but I would like to move this to views out of system. (I am not sure whether you consider this out of scope here).
Comment #8
pcambraAgreed, opened #2058869: Move bulkFormBase out of system module to views module for that purpose
Comment #9
dawehnerThat is perfect now.
Can't you make some changes to get it to a one-liner, forget a word or something like that :p
Comment #10
longwaveHow about "Returns the message to be displayed when there are no selected items."?
Comment #11
pcambraThis just got in #2020979: Bulk action form no longer allows actions to be selected :(
Comment #12
pcambraHere's a rebase after #11 that replaces the comment by @longwave suggestion on #10
Comment #13
dawehnerEven the @return need a description :(
Comment #14
pcambraHere we go!
Comment #15
dawehnerAdded an issue summary, so I can RTBC it!
Comment #16
alexpottSo at the moment this patch does do much because #2020979: Bulk action form no longer allows actions to be selected changed
class NodeBulkForm extends ActionBulkForm {:)The question now becomes should we do this? If so should NodeBulkForm extend BulkFormBase again?
Comment #17
pcambraI wonder the exact same thing, the initial purpose of this was to make the action selection form available without the action module to be enabled, so I don't know if this is wanted still or not.
Comment #17.0
pcambraAdded issue summary.
Comment #18
quicksketchThe situation in core has changed a bit since this was filed. Since
ActionBulkForm(previously known asBulkForm) is now extended by Node and User modules, we have a new problem that could be resolved with this same solution, so I updated the issue summary to focus on this problem. Out-of-the-box, currently there are *two* options for bulk operations for both nodes and users, one called "Action: Bulk update" and the other called "Content: Bulk update" (or "User: Bulk update"). From the appearance of things, the *only* difference between these is the validation errors are more specific on the Content/User variants.From an end-user perspective, having two nearly identical fields for the most common data types adds unneeded confusion. If we continue with the solution proposed here of moving/merging BulkForm into BulkFormBase, we could remove BulkForm entirely from hook_views_data() and cut the dependency tree down one level. This would have the effect of requiring other entity types to provide their own classes that extend BulkFormBase like User and Node have done, but I would think that would be a good thing considering some entity types (i.e. Taxonomy terms) don't have any available actions at all (though that may change after #1839516: Introduce entity operation providers, I believe).
Comment #19
dawehnerThis rerolls the last patch as well as adds on action bulk form per entity type. Additional node/user alters the entry in order to set its own plugin ID.
Comment #20
damiankloip commentedGenerally this is looking like a pretty sensible idea. However, can we also do this? and remove the need for basically the same code (in different places) for BulkFormBase and (User/Node bulk forms)?
It would be nice if we didn't need the User and Node bulk forms too, as it's alters, and field handlers - whilst not accomplishing too much.
Just to defend the current state of things (prior to this patch); all of this stuff was written when actions were still just a part of the action module. So I guess now some of it does look a bit crazy :)
Comment #21
tim.plunkettSure that works. Though why inject the whole entity manager and not the action storage?
Comment #22
damiankloip commentedWhy not indeed.
Comment #23
tim.plunkettLooks great!
Comment #26
tim.plunkettUpdated the unit tests.
Comment #27
damiankloip commentedGreat, thanks! Sorry for adding that init() method :p
Comment #28
dawehnerThank you for updating the unit test!
Comment #29
alexpottHow come we've not removed ActionBulkForm? I can't find an usages.
Comment #30
damiankloip commentedActionBulkForm is used to generate a bulk action field for all entity types. See views.views.inc
Comment #31
alexpottWell ActionBulkForm is an empty class so BulkFormBase is not very abstract then :)
Can't we remove ActionBulkForm and make BulkFormBase concrete and use it in views_views_data() instead of ActionBulkForm?
Comment #32
damiankloip commentedHere we go. removed ActionBulkForm and renamed BulkFormBase to BulkForm. How about that?
Comment #33
alexpottworks for me
Comment #34
dawehnerIt works for alex and me
Comment #35
alexpottComment #36
damiankloip commentedHere's a reroll.
Comment #37
dawehnerand back.
Comment #38
alexpottCommitted dd4890b and pushed to 8.x. Thanks!