Problem/Motivation

The operations for individual blocks on the Block-layout page list are "Edit" and "Delete" (as well as "Disable" in D8.2) so they seem to refer to the actual block, and when clicking on "Delete" they get the message Are you sure you want to delete the block <em>foo</em>?.

However, this does not delete the block, but only removes it from the block-layout. In order to actually delete a custom block, the user needs to do that on the Custom block library page or in the view that creates that block.

Proposed resolution

Replace "Delete" to "Remove".

That way, removing undoes the "Place a block", while "Deleting" undoes the adding of a block on the Custom block library page.

Remaining tasks

User interface changes

API changes

Data model changes

Comments

ifrik created an issue. See original summary.

chishah92’s picture

Assigned: Unassigned » chishah92
ifrik’s picture

Assigned: chishah92 » Unassigned

chisha92,
I unassign you so that somebody else can take this up.

muschpusch’s picture

Issue tags: +Dublin2016

Me and stmh will work on this at dublin2016

yoroy’s picture

Issue tags: +Novice

Maybe something for the sprinters today :)

SenneS’s picture

Assigned: Unassigned » SenneS

I'll do this one!

stmh’s picture

Patch will follow...

stmh’s picture

StatusFileSize
new3.96 KB

Here's a first patch...

muschpusch’s picture

Status: Active » Needs work

We missed one 'delete' action on the edit form. Still working on it

stmh’s picture

Status: Needs work » Needs review
StatusFileSize
new4.55 KB

Here's a new patch with no failing tests :)

jeroent’s picture

.

stmh’s picture

Hi @JeroenT

We met SenneS at the Drupalcon dublin and agreed that he'll review the patch. And as in #4 noted we were first ;-)

tim.plunkett’s picture

Status: Needs review » Needs work
  1. +++ b/core/modules/block/block.module
    @@ -280,3 +280,12 @@ function block_configurable_language_delete(ConfigurableLanguageInterface $langu
    +function block_entity_operation_alter(array &$operations, \Drupal\Core\Entity\EntityInterface $entity) {
    +  if ($entity instanceof \Drupal\block\BlockInterface && isset($operations['delete'])) {
    +    $operations['delete']['title'] = t('Remove');
    +  }
    +}
    

    This can instead be fixed directly in \Drupal\block\BlockListBuilder::getDefaultOperations(), see the switching of "Edit" to "Configure"

  2. +++ b/core/modules/block/src/BlockForm.php
    @@ -292,6 +292,7 @@ protected function buildVisibilityInterface(array $form, FormStateInterface $for
         $actions['submit']['#value'] = $this->t('Save block');
    +    $actions['delete']['#title'] = $this->t('Remove block');
    

    I believe the #title should be #value

  3. +++ b/core/modules/block/src/Form/BlockDeleteForm.php
    @@ -7,6 +7,9 @@
    + * Overrides some functions to supply better wording (replace 'delete' with
    + * 'remove').
    

    Unnecessary, please remove.

Either this patch should fail, or there isn't sufficient coverage for the BlockForm change.

muschpusch’s picture

Status: Needs work » Needs review
StatusFileSize
new4.21 KB

Hey tim.plunkett, regarding

1.) yes
\Drupal\block\BlockListBuilder::getDefaultOperations()
Is a lot nicer. Changed that. Thanks for that.

2.) It's not a button but a link. The current value is in #title and not in #value, so i assume it's correct the way we did it.

3.) Removed the additional comment

Why do you think the last patch should let the tests fail?

Thanks for reviewing!

msti’s picture

Status: Needs review » Needs work

@muschpusch The coding tests fail, maybe this is the reason why the test failed testing.

➜  drupalcon git:(8.3.x) ✗ phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md core/modules/block/src/Form/BlockDeleteForm.php

FILE: .../Sites/drupalcon/core/modules/block/src/Form/BlockDeleteForm.php
----------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------
 49 | ERROR | [x] Expected 1 blank line after function; 0 found
 50 | ERROR | [x] The closing brace for the class must have an empty
    |       |     line before it
----------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

Time: 46ms; Memory: 6.25Mb

muschpusch’s picture

Status: Needs work » Needs review
StatusFileSize
new4.22 KB
new4.22 KB

Thanks msti. Fixed the coding standard warnings.

ifrik’s picture

StatusFileSize
new18.46 KB
new18.53 KB

I reviewed the UI and the patch works as expected.

On the Block layout page, the operation is labelled "Remove", and on the confirmation page the title and the button both say "Remove" as well.

See screenshots as well.

msti’s picture

I tested the patch and it looks good.

tim.plunkett’s picture

  1. +++ b/core/modules/block/src/Form/BlockDeleteForm.php
    @@ -17,4 +17,34 @@ public function getCancelUrl() {
    +  /**
    +   * Gets the message to display to the user after removing the block.
    +   *
    +   * @return string
    +   *   The translated string of the deletion message.
    +   */
    

    This should be {@inheritdoc}

  2. +++ b/core/modules/block/src/Form/BlockDeleteForm.php
    @@ -17,4 +17,34 @@ public function getCancelUrl() {
    +  }
     }
    

    There should be a blank line before the end of the class.

ifrik’s picture

muschpusch,
thanks a lot for continuing on your patch.

In future, can you make an interdiff? That way the reviewers can easily see what has been changed since your last patch.

There's a detailed description how to do this on https://www.drupal.org/documentation/git/interdiff

ifrik’s picture

Status: Needs review » Needs work
stmh’s picture

thanks for the feedback, will provide a new patch.

stmh’s picture

Status: Needs work » Needs review
StatusFileSize
new4.08 KB
new575 bytes

Attached is a new patch (and an interdiff) fixing the doc-issue. I can't fix the missing blank line before class-end, looks good at my end and code sniffer is also happy.

tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community
+++ b/core/modules/block/src/Form/BlockDeleteForm.php
@@ -17,4 +17,32 @@ public function getCancelUrl() {
+  }
+
 }

Seems to be there now!

Thanks

The last submitted patch, 8: replace-delete-by-remove_2806651_8.patch, failed testing.

webchick’s picture

Nice! It's lovely to have a better label for what's actually happening here. :)

Committed and pushed to 8.3.x. Thanks!

  • webchick committed d561e62 on 8.3.x
    Issue #2806651 by stmh, muschpusch, ifrik, tim.plunkett, msti, SenneS:...
webchick’s picture

Status: Reviewed & tested by the community » Fixed

Oops. :P

ifrik’s picture

Status: Fixed » Reviewed & tested by the community

Thanks - this improves sitebuilder usability!

ifrik’s picture

Status: Reviewed & tested by the community » Fixed

sorry, now I messed up the status

Status: Fixed » Closed (fixed)

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