Problem/Motivation

Views bulk actions load entities directly instead of using the plugin manager.

The core action is a plugin with a manager. It also has an internal way of handling the different "types" of plugins.
See \Drupal\Core\Action\ActionManager

However when views generates the bulk action form it relies on the loading of the action config entities directly, causing plugins that are derived/defined in code not to be displayed.

See \views_views_data() the stanza below // Registers an action bulk form per entity.

Steps to reproduce

  1. Install Drupal with standard profile
  2. Create at least one node
  3. Add a new Action plugin class to the standard namespace (with type "node"). Example action plugin attached
  4. Flush the caches
  5. Review the available bulk actions on /admin/content

Expected: The new action is visible in the dropdown
Actual: It's not visible (since it doesn't have an underlying config entity)

Proposed resolution

Use the manager plugin instead of the loading of the action entities directly.

The forced adding of extra config entities has the potential to generate a lot of bloated extra code to provide a very simple functionality. Compared to the deriver logic. An example can be found here: https://www.drupal.org/node/2912390

Remaining tasks

Make existing config entity implementations compatible with this logic.

Test coverage.

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-2912390

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

suranga.gamage created an issue. See original summary.

suranga.gamage’s picture

Issue summary: View changes
suranga.gamage’s picture

StatusFileSize
new3.84 KB

Simple patch that swaps out the direct loading for the plugin manager based building of the forms.

suranga.gamage’s picture

Status: Active » Needs review
suranga.gamage’s picture

Issue summary: View changes
suranga.gamage’s picture

Issue summary: View changes
suranga.gamage’s picture

StatusFileSize
new6.1 KB

Fix the submit for the bulk action form.

Still to do/validate
- Check or this still respects bulk
- Validate that only actions that don't require extra options are displayed.

Status: Needs review » Needs work

The last submitted patch, 7: 2912390-7-use-pluginmanager.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

mstrelan’s picture

Title: Views bulk actions load entities directly instead of using the plugin manager provided by drupal core. » Action plugins not available in views bulk actions
Issue summary: View changes
Issue tags: +Bug Smash Initiative, +Needs tests
StatusFileSize
new651 bytes
new6.18 KB

I've reviewed this for Bug Smash Initiative. I was able to reproduce the issue and have update the issue summary a bit to try make it a bit clearer, including an example action plugin. Had to re-roll the patch which I've also attached. We need to add test coverage as the next step.

Can you clarify why is meant by "Make existing config entity implementations compatible with this logic."?

ameymudras’s picture

Status: Needs work » Needs review
StatusFileSize
new6.61 KB
new2.02 KB

Trying to fix CCF with the above patch

smustgrave’s picture

Status: Needs review » Needs work

Not ready for review as this still needs tests and open question in #19

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

adaragao’s picture

Doesn't work with Drupal 10.3.2

adaragao’s picture

Doesn't work with Drupal 10.3.2

adaragao’s picture

Please delete this and the previous comment. I had a network problem and submitted the same post multiple times. Sorry.

sahana _n’s picture

StatusFileSize
new176 bytes
new6.93 KB
new429 bytes

Hi,

1. I rerolled the patch.
2. I modified the module and created the config file. (system.action.action_name.yml)

I was able to see the action in the dropdown.
If I missed anything, please let me know. I would greatly appreciate any guidance.

sahana _n’s picture

Status: Needs work » Needs review

smustgrave’s picture

Status: Needs review » Needs work

Previously tagged for tests which are still needed

adaragao’s picture

Thank you sahana _n.

But still, composer install wasn't able to apply the patch.

I'm I missing something ?

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.