Problem/Motivation
#1535868: Convert all blocks into plugins introduced an abstracted API for creating user interface lists of any plugins. This API did not undergo technical review because of the unmanageable scope of that patch. It is unnecessarily complex and is not used anywhere other than the blocks UI.
This issue is major because:
- It is part of resolving the critical #2055853: [meta] Improve the place block UX; Separate interaction from the create block UX; Improve the existing blocks-by-theme layout, but does not itself block release.
- The unnecessary complexity and abstraction of the PluginUI subsystem is extremely confusing and makes it difficult to debug the blocks UI.
- The API was not reviewed, documented, or tested, and was only accepted into core with the explicit understanding that those things would be required.
Proposed resolution
Remove the abstracted Plugin UI API, and replace it with a block-specific implementation.
API changes
-
The following classes are removed:
PluginUIManager
BlockPluginUI
and its derivative classSystemPluginUiCheck
(access checker)
The following classes are renamed:
SystemController
toBlockAutocompleteController
(routing controller)
-
The following callbacks are removed:
system_plugin_ui_form()
system_plugin_ui_access()
-
The
system_forms()
hook implementation is removed. -
The
system_plugin_autocomplete
route is removed and is replaced with a block-specific route for the newBlockAutocompleteController
. -
The following services are removed:
access_check.system_plugin_ui
plugin.manager.system.plugin_ui
-
The
BlockListController
no longer extendsEntityListController
, and therefore no longer takes an entity type in its constructor or itslisting()
method.
Additionally, the URLs for block listings and adding blocks per theme are changed.
Old: admin/structure/block/list/block_plugin_ui:bartik
New: admin/structure/block/list/bartik
Old: admin/structure/block/list/block_plugin_ui:bartik/modules:comment
New: admin/structure/block/list/bartik/add/comment
Related issues
- #1875340: Review PluginUI architecture
- #1874840: Add explicit test coverage for the BlockPluginUI
- #1875942: Improve PluginUI documentation
- #1938888: Convert user_admin_permissions to a new-style Form object
- #2056895: Routes with optional placeholders can fatal when placed in a menu
- #1535868: Convert all blocks into plugins
- #2040037: The requested page "/admin/appearance/settings/bartik" could not be found after installation
Comment | File | Size | Author |
---|---|---|---|
#38 | pluginui-2056513-38.patch | 4.69 KB | tim.plunkett |
#30 | block-2056513-30.patch | 47.25 KB | tim.plunkett |
#22 | block-2056513-22.patch | 49.17 KB | tim.plunkett |
#22 | interdiff.txt | 7.63 KB | tim.plunkett |
#14 | block-2056513-14.patch | 49.19 KB | tim.plunkett |
Comments
Comment #1
tim.plunkettComment #3
tim.plunkettThis is the only part that I know is wrong. Will have to find a way to remove the duplicate route.
Comment #4
tim.plunkettActually, we're going to be removing that whole route and URL-based filtering in #2055853: [meta] Improve the place block UX; Separate interaction from the create block UX; Improve the existing blocks-by-theme layout anyway, so just adding this second route is not a problem.
Comment #5
xjmLoving the diffstat.
Manually tested, and there's a slight regression: If no category is selected, the list of block plugins to place starts off empty rather than "all". Of course the whole page will be removed soon enough, but worth investigating.
I also read through the patch; pretty much just inane observations.
Yech. (Out of scope, just... yech.)
block_admin_place()
is kind of a funny name. :) I realized eventually that it refers to "place" blocks, but it's like... the admin place. :) You know, on the internet thing.Also, I think we need to change our form alter doc standards... there is no
block_admin_place()
callback. There is theblock_admin_place
form, orPlaceBlocksForm
.I don't think Request is in the global namespace?
JSON.
Comment or two in here would be good.
I need a docblock (probably just an
{@inheritdoc}
).Comment #6
xjmTechnically.
Comment #7
xjmThe API changes.
Comment #8
xjmOh. This is interesting. Why?
Comment #9
tim.plunkett5.1 Yeah. That will have to be dealt with, but not this issue.
5.2 Reverting to 'block_plugin_ui' for now, since that's still what it is, and we're going to delete it anyway. No sense in changing it.
5.3
5.4 This is just moved code, but if you insist. :)
5.5 Doesn't inherit anything, will add a docblock
8 So the EntityListController is generic, and forces you to specify the entity type in the route definition. But we need a custom list controller since we pass in the current theme. And we override every method in EntityListController and never call parent:: for anything. So we might as well not force stupidity on the route definition.
I tracked down the need for the duplicate route. I had previously written it for #1938888: Convert user_admin_permissions to a new-style Form object, but we ended up justifying the need for two routes anyway. This unfortunately means this issue now needs tests.
Comment #10
tim.plunkettBlocked by #2056895: Routes with optional placeholders can fatal when placed in a menu
Comment #10.0
xjmUpdated issue summary.
Comment #10.1
xjmUpdated issue summary.
Comment #11
xjmI added the API changes to the summary.
Comment #11.0
xjmUpdated issue summary.
Comment #12
xjmThis issue is a child issue of a critical; however, I don't think ripping out the unneeded complexity and abstraction is release-blocking--it's just a really good idea and will make our lives saner. Setting to major.
I closed these issues as dupes:
#1875340: Review PluginUI architecture
#1874840: Add explicit test coverage for the BlockPluginUI
#1875942: Improve PluginUI documentation
Comment #12.0
xjmUpdated issue summary.
Comment #12.1
xjmUpdated issue summary.
Comment #13
xjmThis issue also reduces what we still need to document in #1535868: Convert all blocks into plugins.
Comment #13.0
xjmUpdated issue summary.
Comment #14
tim.plunkettNo more blockers, this is done.
Comment #15
fubhy CreditAttribution: fubhy commentedOh yes, please. I never understood why this went in. Going to give it an in-depth review tomorrow.
Comment #16
tim.plunkettThe needed tests were for #2056895: Routes with optional placeholders can fatal when placed in a menu, which it had.
Comment #17
xjmNice, I didn't realize this had been componentized alredy.
Missing the one-line summary.
Why are these display plugin IDs?
Is
check_plain()
sufficient and correct here? Either the admin label has already been sanitized, or we'll get escaped HTML entities in it. (This might just be moved code?)So, how early will this method be called? I've had some trouble with the results from
list_themes()
not being reliable in #2040037: The requested page "/admin/appearance/settings/bartik" could not be found after installation which is a very similar situation.The indentation here is funky; is this copied from somewhere?
Comment #18
xjm#1535868-294: Convert all blocks into plugins
Comment #19
tim.plunkettThis is straight as written in core, just moved slightly. I'll polish it a bit, but we don't usually hold moved code to this level of scrutiny.
Comment #20
xjmThe route subscriber is not moved code as far as I can tell, which is why I commented on it. And given that the plugin UI went in without review initially, it makes sense to review whatever bits of it we are retaining now.
Comment #21
fubhy CreditAttribution: fubhy commentedI know that you didn't add that here but I always hate this single quote string concatenation for strings with simple variables. Can we use the double-quote version with heredoc syntax? It's so much nicer to read.
Nope. :)
$default_theme is not really the right variable name there. Should simply stay $theme (not added here, I know, but it's misleading).
The active theme? The theme for which to render the form? ;)
Meh, I hate FormInterface :)
Looking good otherwise.
Comment #22
tim.plunkettThanks, most of the things I fixed are moved code, but xjm makes a good point in #20.
I'm not worried about list_themes() right now, this hasn't broken for me yet, and if there is a problem that other issue will handle it.
The RouteSubscriber was weird, switched the indenting to mimic field_ui's RouteSubscriber.
Comment #23
fubhy CreditAttribution: fubhy commentedHmm, actually... I am a little bit concerned about list_themes(). We don't rebuild anything when we enable a new theme or do we?
Comment #24
fubhy CreditAttribution: fubhy commentedHmm, actually... I am a little bit concerned about list_themes(). We don't rebuild anything when we enable a new theme or do we?
Comment #24.0
fubhy CreditAttribution: fubhy commentedUpdated issue summary.
Comment #25
xjmYah #2040037: The requested page "/admin/appearance/settings/bartik" could not be found after installation is the issue for that. Ideally themes need an installation status and to be handled like modules, and then the tentacled procedural mass that is under
list_themes()
needs to be refactored as a module handler method or something. But out of scope here, and the fix in my issue should fix both.Comment #26
xjmAnd this is ready to go, assuming green. I feel like a weight has just been taken off my shoulders. :)
Comment #28
jthorson CreditAttribution: jthorson commentedWe had a community-sponsored bot go AWOL. Re-queued.
Comment #29
tim.plunkettThanks for requeuing. See you all over in #2058321: Move the 'place block' UI into the block listing soon!
Comment #30
tim.plunkettStraight reroll for #2049159: Create a ControllerBase class to stop the boilerplate code madness
Comment #30.0
tim.plunkettUpdated issue summary.
Comment #30.1
xjmUpdated issue summary.
Comment #31
xjmWe reviewed this patch one more time and noted some minor things that can be followups.
We observed it might make sense to have an AutocompleteControllerBase -- scanning the autocomplete() method, the two things that would probably be different are the regex and the list of available definitions. Maybe, maybe not. Followup question either way.
One missing space here after "\b" -- Let's file a followup for that.
Comment #32
webchickOk. @xjm walked me through this issue for a good half hour, and it looks really good.
I think this was a nice idea in theory, but in practice it doesn't really work. When we examine the facilities in core/contrib most likely to benefit from generic UI handling code like this, pretty much all of them are better off with their own custom UI that's better-oriented to the task(s) at hand (e.g. Views, Blocks, Panels...). Maybe if we'd totally knocked block UI out of the park, and it represented a significant UX improvement that could have benefit in other parts of the system (similar to the benefit we've received from entity listings being generalized), but I don't think that's the case here. Tagging as "Approved API change" in response.
There's a lot of pretty ugly stuff removed from system.module, which is great, and lines like:
...and:
...make me happy.
The one thing that would be nice is a generic facility for autocompletion that other modules could use to avoid boilerplate code like Block module has to do, but that can be a follow-up.
In reviewing, I noticed a couple of small details like off concatenation, check_plain() instead of String::check_plain(), but I don't think those need to hold up this patch; most of these will go away in other patches.
Committed and pushed to 8.x. Thanks!
Let's also make sure that the original blocks-as-plugins change notice gets any updates it needs as a result of this patch. (There might not be any, but let's check.)
Comment #33
tim.plunkettI checked the change notices for #1535868: Convert all blocks into plugins and did a pretty thorough search through the list, and found nothing.
Based on #1875942: Improve PluginUI documentation and #1875340: Review PluginUI architecture, I feel pretty safe saying this had no real docs.
Therefore, not adding a notification for something we never documented as existing :)
The follow-up issue is #2058321: Move the 'place block' UI into the block listing
Comment #34
effulgentsia CreditAttribution: effulgentsia commented#2059955: Standardize and simplify autocomplete controllers and services
Comment #35
xjmAlso, we need that followup for adding a single space. ;) Forthcoming.
Comment #36
xjmActually #2058321: Move the 'place block' UI into the block listing already addresses the single space issue by deleting the line. ;) So disregard.
Comment #37
tim.plunkettComment #38
tim.plunkettWhoops. Left the base class and interface in!
Comment #39
BerdirRemove all the (PluginUI) things.
Comment #40
Dries CreditAttribution: Dries commentedLooks like we have to commit both #20 and #30. All in all, this looks like a good win.
Given that #2058321: Move the 'place block' UI into the block listing is marked 'critical', and this patch is marked 'major', I'm inclined to commit #2058321 first. That may require this patch to be re-rolled, not sure yet.
Comment #41
Dries CreditAttribution: Dries commentedCommitted #2058321: Move the 'place block' UI into the block listing. Asking for a re-test to make sure this still applies and works correctly.
Comment #42
Dries CreditAttribution: Dries commented#38: pluginui-2056513-38.patch queued for re-testing.
Comment #43
webchickD'oh. :P Committed and pushed to 8.x. Thanks!
Comment #44.0
(not verified) CreditAttribution: commentedUpdated issue summary.