Problem/Motivation
When we redesigned the place block UI, we changed where blocks live before they are placed in a region. On a standard install, the disabled region is now empty.
In the usability study we observed some users looking for blocks in this region, likely due to previous experience with the Drupal 7 UI.
Proposed resolution
Remove the 'disabled' region
Replace with a 'disabled' block state, so the blocks stay in the region they are, but are visually styled to be disabled.
Add either a new "Enable" or "Disable" link to the "Operations" links on the Blocks Layout page depending on the state of the individual block.
Remaining tasks
None
User interface changes
Remove the 'disabled' region
Replace with a 'disabled' block state, so the blocks stay in the region they are, but are visually styled to be disabled.
API changes
None
Data model changes
None
| Comment | File | Size | Author |
|---|---|---|---|
| #117 | interdiff.txt | 899 bytes | tim.plunkett |
| #117 | 2513534-block-117.patch | 43.76 KB | tim.plunkett |
| #113 | 2513534-block-113.patch | 43.11 KB | tim.plunkett |
| #113 | interdiff-2513534.patch | 2.31 KB | tim.plunkett |
| #108 | 2513534-108.patch | 43.11 KB | alexpott |
Comments
Comment #1
darol100 commentedI like the disable region, but I can see how this can make new user confuse.
I think is the way to go, in order to fix this issue. However, what I did not see in this issue is a enable/disable button. We would have to provide an easy way (button) to enable the or disable from this page.
Comment #2
tim.plunkettWe need some guidance on what the visual representation of a disabled block would be (when left in its region).
The API for disabling a block is already in place.
Comment #3
tim.plunkettWell here is some shoddy CSS just to demonstrate what needs to be done.
I've also appended
(disabled)to the label just for now.Comment #4
tim.plunkettHere is a picture showing the working enable/disable links.
Comment #6
tim.plunkettHere are some test fixes.
Comment #7
darol100 commented@tim.plunkett,
Great work, this patch makes the block page looks way better than the current block page. This patch looks good to me.
Comment #8
tim.plunkett#2508547: Placing a block with same machine name of region causes region to disappear in admin UI fixes a bug with regions in the Block UI and refactors some code, so postponing on that.
Also while this patch is functionally sound, I just made up the actual UI changes and I'm sure @bojhan or @LewisNyman will want to have their say.
Comment #9
lewisnyman@tim.plunkett Nice one, thanks. I'll have a chat with Bojhan and post a patch.
Comment #10
tim.plunkettThis is essentially blocked on #2514998: Reduce fragility in the monolithic BlockListBuilder, but if @LewisNyman comes back with a patch sooner, we can try to work around it.
Comment #11
darol100 commentedComment #12
Bojhan commentedThis is amazing, the visual styling is a little bit off - but I like that we can just use text for the state.
@Lewis lets experiment a bit with the table style.
Comment #13
tim.plunkettReroll, still needs better CSS than #999/#eee :)
Comment #14
gábor hojtsyI agree the new concept makes a lot of sense and it looks sane. Given this is a normal task, committers will very likely request a beta evaluation (https://www.drupal.org/core/beta-changes).
Comment #15
tim.plunkettAs far as update hooks are concerned, into which region will we put all of the blocks that are in "Disabled"?
Comment #16
lokapujyaWouldn't this make the UI hard to use because the disabled blocks would clutter up the list? Imagine that you have 100 disabled blocks. Now you want to drag one block to a different region. The disabled blocks may make it so you need to scroll the screen to drag the block.
Edit: We could always add a hide disabled blocks feature later.
Comment #17
tim.plunkettIn IRC we discussed preventing the user from updating if there are any blocks left in the disabled region.
However, once they update the code, it's too late, the blocks are gone from the UI.
Secondly, once they fix that, there is *nothing left to update*, so the update hook is pointless.
This patch tries a different, less ideal, approach.
It simply disables each block, and places them into the system_default_region()
However, it uses the Entity API directly, aren't we not supposed to do that? I know I saw another issue discussing this recently.
Comment #18
gábor hojtsy@tim.plunkett: Yeah update hooks are supposed to use as little of the API as possible, **especially** where hooks may be invoked, events may be fired, etc. Because those will run the new code assuming the new structures of things, while the data is not yet updated. While for this change itself that looks like does not make sense to consider, people will run several updates at once and may run multiple version updates in one batch (if not keeping updated with each version independently). So other updates may introduce changes to data structure, etc. that this code will be problematic to run with.
Comment #19
tim.plunkettHere's an version using configFactory directly, but still using entity.query
Comment #21
lewisnymanI've tweaked the colors to align with the Seven styleguide. The entire row has opacity set so all the UI elements fade into the background a little.

None of this styling applies on hover, because the UI element can still be interacted with (contrast with a disabled form element, which can't)

And yes, this passes AA contrast requirements ;-)

Comment #22
Bojhan commentedIf it passes WCAG AA, then this looks good to me :)
Comment #23
tim.plunkettLooks great, thanks @LewisNyman!
Now we just need update tests and a beta eval.
Comment #24
manjit.singhComment #25
manjit.singhrerolling a patch
Comment #30
legolasboThe radical solution in #2514150: Advertise the block region demonstration in a more prominent way would effectively solve this issue.
Comment #31
tim.plunkettYes, except this is an incremental fix, that is much much more.
Also we'd need to solve the upgrade path anyway.
Let's keep working on this.
Comment #32
legolasbo@tim.plunkett,
I agree we should continue working on this aswel. Just wanted to explain why I added the relationship.
Comment #33
tim.plunkettFixed the reroll.
Comment #34
Bojhan commentedAwesome, does this need anything else?
Comment #35
bill richardson commentedWorks as expected ( Only issue i had was that it was not immediately obvious how to disable block -- i just clicked the configure button and found no way to disable block ) . Maybe the expand part of the configure button could be highlighted more.
Comment #36
lewisnyman@bill richardson That's a good point. We should be offering a disable option on each individual block config form as well. I guess a checkbox would be consistent with with menu items?
Comment #37
legolasboAnother option would be to add a checkbox to the vertical tabs at the bottom. Which would be in line with node's published checkbox and keep the form clean and simple.
Comment #38
tim.plunkettNo, this belongs on the listing page. People will get used to it. Menu links and nodes are not config, they don't treat "disabled" the same way, and are not analogous.
This is blocked on an upgrade path.
Comment #39
lewisnyman@tim.plunkett Maybe not in code, but I don't know if a user perceives any difference between the two? Every other action you can perform on a block in a block listing you can also perform on the config form.
Comment #40
tim.plunkettSearch pages, filter formats, and views all have their disable functionality solely on the listing page. Blocks are to be the 4th.
I would say that menu links are wrong, and should be changed.
And nodes cannot be disabled, only unpublished, completely unrelated.
Comment #41
lewisnymanOk cool, as long as we aren't introducing inconsistency, I wasn't sure. I've added the remaining tasks to the issue summary.
Comment #42
tim.plunkettStill needs tests.
Comment #43
tim.plunkettStill needs tests.
Comment #44
wim leersThis is looking great! Zero nits :)
Comment #45
tim.plunkettWe need test coverage for double escaping, it's currently broken and possibly fixed by #2568045: Make it impossible to double escape with #plain_text
Comment #48
lokapujyaIncremented the update hook. Created the updateTest (nothing in it); Ran out of time.
Comment #51
tim.plunkettComment #52
lokapujyafix one of the failing tests by rerolling the tests for some changes in head, possibly from the disabled block issue.
Comment #55
catchThis looks more rc deadline/minor version target to me.
Comment #56
joelpittetAssigning to @webchick as this is Drupal product facing to see if it can be "rc eligible" or target.
Comment #57
lokapujyaFix failures.
Comment #58
lokapujyaComment #59
lokapujyaComment #60
lokapujyaFound a small bug. Not sure if we need to fix it. Needs work anyway for the upgrade test.
A block that is enabled before running the upgrade can become disabled.
condition: A block is placed more than once. It is enabled in a region and the second is disabled.
Comment #61
webchickWhile I definitely still think we should do this, I can't see how we could possibly do this now, during RC vs. in a minor release. It breaks UI, strings, documentation, adds an update hook, all kinds of things.
Moving to 8.1.x unless I'm missing something.
Comment #62
webchickComment #63
lokapujyaAdded some progress on an upgrade path test.
Comment #64
lokapujyaComment #65
lokapujyaMinimal update path tests.
Comment #66
lokapujyaTests are not running for this issue.
Comment #67
tim.plunkettThe issue is marked for 8.1.x, which has 2+ year old code, so tests don't run.
If you'd like, feel free to upload patches to an issue like #2374115: IGNORE: Patch testing issue just to get test results.
Comment #68
almaudoh commentedComment #69
almaudoh commentedWill testbot pickup the patches...?
Comment #72
imrancluster commentedHello everyone,
I found 'disabled' section in "Manage form display" and "Manage display". For some content types we may have to create more fields. Can we build something this new feature for those area?
Comment #73
tim.plunkett@imrancluster that is unrelated to the Block UI
Comment #75
tedbowRe-rolled against 8.2.x to start work on remaining tasks
Comment #76
manjit.singhI can still found the regions that had not block assigned. Please check the screenshot.
correct me if i am wrong.
Comment #77
tim.plunkett@Manjit.Singh I don't understand, that is 100% supposed to happen.
We're only removing the "Disabled" section of this page.
Comment #78
tedbow@Manjit.Singh I am new to this issue but from reading of the issue summary and looking at the code this issue is not to remove regions from the Block Layout page that currently don't have any blocks assigned to them but rather to remove Disabled region from the block layouts page.
Here is an unpatched 8.1.x sight layout page

Regions with no blocks should still show up. That way you still have the "Place Block" button.
Comment #79
tedbowRemoving non-relevant task and tags.
There already is an upgrade path block_update_8004 and tests for the upgrade path, BlockRemoveDisabledRegionUpdateTest
I am looking over the code but looks like there no remaining tasks and this code be RTBC.
Comment #80
tedbowThis looks good. Changing to RTBC!
I really like this change!
Comment #82
tim.plunkettOkay one more thing to discuss.
Are we allowed to remove this constant in 8.y.x?
Also this obsoletes #2724283: BlockInterface::BLOCK_REGION_NONE is integer, Block::$region is string
Comment #83
wim leers#82: I wonder if we should keep that and then move this:
into
Block::save(), which would then effectively retain BC?Comment #84
tim.plunkettRestoring the constant, deprecating it, and merging in the test coverage from #2724283: BlockInterface::BLOCK_REGION_NONE is integer, Block::$region is string.
Comment #85
tedbowI think #83 makes sense because there could be custom that is trying to disable blocks currently by moving them to the disabled region.
Comment #86
tim.plunkett#83 I disagree, I don't think we should change Block::save that way.
We can just rely on the existing functionality of block_rebuild.
Comment #87
manjit.singhSeems like it should be "Disable blocks" rather than "Disables blocks".
Comment #88
tim.plunkettLeaving at needs review for a substantive review.
Comment #89
lokapujyaWhile in review, any thought regarding comment #16: The disabled blocks could clutter the UI? I don't want to delay progress, but it's something to consider.
Comment #90
tim.plunkettHonestly, I consider disabling a block to extremely temporary. Creating new blocks is simple, so I would generally delete any block I left disabled for a significant period of time.
Comment #91
maninders commentedJust review the #86 patch and it's working fine. 'Disabled' regions is no more available. Now enable, disable link is coming with every configure dropdown. Screenshot is attached for your reference.
Comment #92
maninders commentedComment #93
yoroy commentedThanks for testing the patch @Maninders, but @tim.plunkett in #90 set it to "needs review" for a thorough review of the actual code changes. Setting back to needs review for that.
Comment #94
tedbowReviewing from #86
@Manjit.Singh nice catch! I thought you were wrong but checked: https://www.drupal.org/coding-standards/docs#updateN
And says
No trailing comma for annotations
In my patch I am changing this to not display this message if the BlockInterface::BLOCK_REGION_NONE was used to disable the block. It seems if this is just deprecated we should not show an error message.
Looks Great!
Here is patch with those small changes. It these are ok I think RTBC
Comment #95
tim.plunkettAnnotations can have trailing commas as of late 2013: https://github.com/doctrine/annotations/pull/11
That change related to the message needs test coverage. I'll fix that shortly.
Comment #96
tim.plunkettI did more thinking on the change to block_rebuild in #94. I don't think we should add new usages of the constant. -1 is now an invalid region, I don't think it's wrong to display that. The functionality is the same as in HEAD regardless of the message.
Also restoring the trailing comma.
Comment #97
tedbow@tim.plunkett ok I see the point about the message. Looks good
I also have updated the annotations doc page to reflect the changes to trailing spaces https://www.drupal.org/node/1882526
RTBC!
Comment #98
alexpottI don't think we should use the entity API in hook_update_N(). I think this fix could be done in a post update and using the config entity API.
Also should we detect and handle blocks saved with REGION_NONE in the config entity - since nothing is supposed to have REGION_NONE anymore but once the update is run it is perfectly possible to save such a block through the API and then on a hook_rebuild it'll be moved to the default region.
Comment #99
tim.plunkettOn hook_rebuild it will be moved to the default region but also disabled.
I'll look into the post_update change.
Comment #100
andypostAlso
\Drupal::entityManager()is *deprecated*Comment #101
tim.plunkettWorking on this.
Comment #102
tim.plunkett@alexpott pointed out that due to block_rebuild(), we don't actually need an update path, just to trigger a cache flush by putting in an empty post_update hook. Additionally, block_rebuild was not handling disabled blocks in the wrong regions. Fixed that and the test coverage. Finally, added a Block::preSave() to address concerns about contrib/custom modules expecting
$block->setRegion(-1)->save()to work even without a cache rebuild.Comment #104
Bojhan commentedSuper excited if we can get this into 8.2 :)
Comment #105
tim.plunkettSo we have a major problem with that addition of Block::preSave().
Migrate has a simple mapping of region names, but those differ for each theme. For example, Bartik no longer has a region named "footer".
Migrate has no ability to provide different mappings per theme.
Furthermore, it tries to migrate things for themes like Bluemarine, which no longer exists. system_region_list() will always fail for that in tests unless we ship with a fake theme named
bluemarine, so not sure what to do there.So either we're blocked on Migrate being fixed, or we go without the Block::preSave() fix.
Comment #107
tim.plunkettOption 1 is blocked on #2753939: BlockRegion process plugin should be source theme-aware and also another issue that @phenaproxima hasn't opened yet either.
Option 2 is just reverting the one Block::preSave() hunk introduced in #102.
Comment #108
alexpottI think that block migrations are fundamentally broken see #2753939-2: BlockRegion process plugin should be source theme-aware
We could just add @todo's to fix the migration tests because migrations don't make make sense when block_rebuild() is going to come along and change what you've just migrated.
Comment #109
tim.plunkettThat's a reasonable workaround for me.
The second line should be indented.
That can be fixed on commit.
Comment #110
alexpottWe need a CR because as the recent patches show some tests for contrib might break.
Comment #111
alexpottFor #110
Comment #112
tim.plunkettPosted CR and restored RTBC status: https://www.drupal.org/node/2778489
Comment #113
tim.plunkettFixed those nits just to make it easier to get this in.
Comment #117
tim.plunkettUpdating test coverage added recently.
Comment #119
catchCommitted/pushed to 8.3.x, thanks!
I'm not seeing anything that makes this time-sensitive for the 8.2.x beta (i.e. the issue summary does not mention anything), so leaving it fixed against 8.3.x for now.
Comment #120
gábor hojtsyPublished change record at https://www.drupal.org/node/2778489
Comment #121
chx commentedhttp://i.imgur.com/n34QWnF.gifv
Comment #123
xjmThis is a longstanding UX issue, maybe worth a release notes mention?
Comment #124
lokapujyaDisabled blocks go to the end of the list; They don't stay in order by weight. However, when you enable the block it goes back in order using the previous weight. Is that how it should be?
Comment #125
tim.plunkettIt is by design, \Drupal\block\Entity\Block::sort() does three things:
Changing that would need a new issue.
Comment #126
lewisnymanComment #127
groovedork commentedSome feedback on the new design:
+ I like the "place block" button right where I need it.
+ The search function is great, but also quite necessary:
- The list of available block can get a little long.
+ I like how you can see what type of block it is. I currently have two "contact us" blocks, and this helps differentiate them.
Something I have more trouble with:
- I've accidentally deleted a custom block (and the view that generated it) because I didn't realize that "remove" now means "remove the entire block form existence" instead of "remove it form this spot in the layout".
- I have no idea how I actually remove disabled items from the block layout page. It's getting a bit cluttered.
I would propose a simplification:
> Remove the "disable" option from the interface. After all, if I want to re-add a block, I now have the nice 'place block' buttons. But maybe I'm missing a use-case?
> The "Remove" button should then just remove the block for the layout page.
Comment #128
dkre commentedI'm really lost about this change unless I'm not seeing the correct behaviour.
After upgrading 8.2 > 8.3 I have 60 disabled blocks in the first page region ('Nav Header') rather than is the 'Disabled' region at the bottom of the page.
Is what should be happening?
Comment #129
lokapujyaNo, they should not all be in the 'Nav Header'. That sounds like a bug.
Comment #130
lokapujyaYou might have blocks that are disabled. You want to be able to quickly enable them without having to re-add them.
Comment #131
groovedork commented@lokapujya I understand the functionality. But how often does this happen in the real world? When do you temporarily need to disable a block?
For me personally this never happens. And if it would, I wouldn't have a problem with removing the block and re-adding it, especially if it would fix the issues with the interface I mentioned above.
Comment #132
lokapujyaSuppose you have a block that is experimental, or you are doing AB testing. You might have multiple alternative blocks that you want to demo. The block has a lot of configuration. You don't want to add the block and retype everything and possibly misconfigure something. Then you may need to disable and then enable the block.
Comment #133
lewisnymanComment #134
thomasmurphy commentedChanging such a key part of Drupal admin UI for an issue only followed by 39 people seems an odd decision making process.