Problem/Motivation

When applying a bulk form operation in views it displays the action message in the confirmation screen. For example, deleting nodes from the admin/content listing provided by views:

Proposed resolution

The action message should be skip when there's a confirmation message to be displayed.

Remaining tasks

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Bug because the message displayed when bulk deleting nodes is misleading/wrong.
Issue priority Normal because it's wrong, but not blocking anything else.
Unfrozen changes None
Prioritized changes The main goal of this issue is fixing a bug.
Disruption None

Comments

pcambra’s picture

Component: action.module » views.module
Status: Active » Needs review
StatusFileSize
new1.3 KB

This is a views thing, it seems.

Status: Needs review » Needs work

The last submitted patch, 1: 2400143-confirmation-form.patch, failed testing.

pcambra’s picture

Status: Needs work » Needs review
Issue tags: +Quick fix
dawehner’s picture

Do we need some kind of test coverage here?

dawehner’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

.

geertvd’s picture

Status: Needs work » Needs review
StatusFileSize
new741 bytes
new1.91 KB

Added test, I also had to reroll the original patch.

The last submitted patch, 6: 2400143-6-test.patch, failed testing.

koence’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new76.77 KB
new57.78 KB
new79.1 KB
new104.49 KB
new45.66 KB
new144.36 KB

Action message in the confirmation page/form is no longer shown after the patch is applied.

before patch

select content to be deleted

action message IS visible in confirmation page

delete confirmed

after patch

select content to be deleted

no action message visible in confirmation page

delete confirmed

sutharsan’s picture

Issue tags: -Needs tests
alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/action/src/Tests/BulkFormTest.php
@@ -148,6 +148,9 @@ public function testBulkForm() {
+    // Make sure we don't show an action message while we are still
+    // on the confirmation page.
+    $this->assertNoText(t('Delete content was applied to 5 items.'));
     $this->drupalPostForm(NULL, array(), t('Delete'));

Can we add a positive assertion of the text after the post. An assertNoText with a corresponding assertion can easily have false positives if the underlying code changes.

geertvd’s picture

Status: Needs work » Needs review
StatusFileSize
new794 bytes
new1.96 KB
new609 bytes

The last submitted patch, 11: 2400143-11-test.patch, failed testing.

Anonymous’s picture

Status: Needs review » Needs work

The patch looks good, and the proposal from #10 was added properly.

I do have some nitpicks on the comments though:

  1. +++ b/core/modules/action/src/Tests/BulkFormTest.php
    @@ -148,7 +148,11 @@ public function testBulkForm() {
    +    // Make sure we don't show an action message while we are still
    +    // on the confirmation page.
    

    This wrapping should be 80 chars.

  2. +++ b/core/modules/system/src/Plugin/views/field/BulkForm.php
    @@ -288,13 +288,16 @@ public function viewsFormSubmit(&$form, FormStateInterface $form_state) {
    +        // there is not a confirmation form.
    

    'not a' should be 'no'

geertvd’s picture

Status: Needs work » Needs review
StatusFileSize
new1.57 KB
new794 bytes
new1.96 KB

Fixed nitpicks.

Anonymous’s picture

Issue summary: View changes

Great! I tested this manually and can confirm it works as expected (cf screenshots #8).

Added a beta evaluation to the summary.

RTBC if green.

The last submitted patch, 14: 2400143-14-test.patch, failed testing.

Anonymous’s picture

Status: Needs review » Reviewed & tested by the community
xjm’s picture

Status: Reviewed & tested by the community » Needs work

Nice work! Thanks for the beta evaluation, the screenshots, and the test-only patch.

  1. +++ b/core/modules/action/src/Tests/BulkFormTest.php
    @@ -148,7 +148,11 @@ public function testBulkForm() {
    +    // Make sure we don't show an action message while we are still on the
    +    // confirmation page.
    +    $this->assertNoText(t('Delete content was applied to 5 items.'));
    

    Following up on @alexpott's feedback in #10. Instead of or in addition to the assertNoText(), could we maybe check drupal_get_messages() or something along those lines? Just to confirm that there are no messages, regardless of what exactly we may make the message text in the future.

  2. +++ b/core/modules/system/src/Plugin/views/field/BulkForm.php
    @@ -291,13 +291,16 @@ public function viewsFormSubmit(&$form, FormStateInterface $form_state) {
    +      else {
    +        // Don't display the message unless there are some elements affected and
    +        // there is no confirmation form.
    +        $count = count(array_filter($form_state->getValue($this->options['id'])));
    +        if ($count) {
    +          drupal_set_message($this->formatPlural($count, '%action was applied to @count item.', '%action was applied to @count items.', array(
    +            '%action' => $action->label(),
    +          )));
    +        }
    

    Also, I don't think there is test coverage for this code path. Can we add that as well?

geertvd’s picture

Status: Needs work » Needs review
StatusFileSize
new823 bytes
new861 bytes
new2.02 KB
  1. I decided to just check if a container with class "messages--status" exists, since drupal_get_messages() will always be empty after messages are displayed.
  2. This actually has test coverage in the same method already.
    $this->assertText('Make content sticky was applied to 10 items.');
    $this->assertText('Unpublish content was applied to 1 item.');
    

The last submitted patch, 19: 2400143-19-test.patch, failed testing.

Anonymous’s picture

Status: Needs review » Reviewed & tested by the community

1. Clever! I see we do a similar thing in ContentTranslationSyncImageTest, so this should be ok to do.
2. Agreed.

The feedback from #18 was addressed, so back to RTBC.

xjm’s picture

Status: Reviewed & tested by the community » Fixed

Thanks, that works nicely.

This issue is a normal bug fix, and doesn't include any disruptive changes, so it is allowed per https://www.drupal.org/core/beta-changes. Committed and pushed to 8.0.x.

  • xjm committed 8b9dfce on 8.0.x
    Issue #2400143 by geertvd, pcambra, koence, pjonckiere: Bulk form...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.