Problem/Motivation
The instances list (/admin/structure/display-builder/instances) and the Views list (/admin/structure/views/display-builder) are hand-built tables of the same display_builder_instance entities:
- Both call
collectInstances(), which loads every display on each page view and creates missing instances as a side effect. - Filtering, sorting and paging happen in PHP, after everything is loaded.
- The entity has SQL storage but no
views_datahandler, so site builders cannot customize either list.
Proposed resolution
- Add a
views_datahandler (InstanceViewsDataextendingEntityViewsData):- show the buildable plugin ID as a plain field, with a select filter listing the buildable labels;
- hide the serialized buildable configuration.
- Add labels to the base fields
id,buildable,hashandpublished. - Add Views field plugins for the instance label, the profile and the publication status (reusing
DisplayBuilderHelpers::publicationBadge()). - Ship a default View in
display_builder_uiwith two displays: the global list at the current path, and the Views list filtered toview_display. Keepcontextas the filter identifier so the Instances panel links keep working. - Remove the custom load, filter, sort and pager code in
InstanceListBuilder, andViewsManagementController::pageViewsIndex().
Prototype check: ID, Updated, Last log and Operations work with core Views as is (operations added by other modules included). The buildable plugin, label, profile and publication columns need the work above.
Out of scope
The page layout list stays a list builder: PageLayout is a config entity, and its row order is the matching priority (drag-to-reorder).
Remaining tasks
- Decide what replaces the side effect. A View only lists existing instances, so a display never opened in the builder will not appear.
- Decide how to show orphaned instances (display deleted). A View lists them; the current lists hide them.
- Implement, with kernel tests.
User interface changes
Both lists become customizable Views, with exposed filters and table sorting.
API changes
New views_data handler. ViewsManagementController::pageViewsIndex() is removed.
Data model changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #27 | 3623275 after.png | 888.1 KB | csakiistvan |
| #27 | 3623275 before.png | 895.97 KB | csakiistvan |
Issue fork display_builder-3623275
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
Comment #2
mogtofu33 commentedComment #3
mogtofu33 commentedComment #4
mogtofu33 commentedComment #7
andres alvarez commentedContinuing work on replacing the instances admin list with a View. The MR adds:
InstanceViewsDatato exposedisplay_builder_instancefields to ViewsThe old
InstanceListBuilderandViewsManagementControllerare removed. Remaining work is fixing the PHPUnit test failures before this is ready for review.MR to follow.
Comment #8
andres alvarez commentedComment #9
mogtofu33 commentedComment #10
andres alvarez commentedThe branch was behind 1.0.x and the default View failed config schema validation, which broke every test that installs display_builder_ui. Both are fixed: the View config validates and the branch is rebased on the current 1.0.x.
The instances list renders from the View with the Context, Instance, Profile, Publication and Updated columns plus the exposed Context and Instance filters. The Views index at
/admin/structure/views/display-builderstays onViewsManagementController::pageViewsIndex, because it creates the missing view display instances and the Playwright views test depends on its build links. Pipeline is green.Two open points: the View has no Reset button (
reset_button: false), and a site that already imported the earlier version of the View keeps a staleviewsdisplay, which would need a post update to remove. MR updated.Comment #11
andres alvarez commentedComment #12
mogtofu33 commentedComment #13
pdureau commentedHi Andres,
Thanks for your proposal. However, the MR need a rebase and some changes because the goal was to reduce PHP code and complexity but here we have the addition of:
Instances are proper content entities using proper field types (except the "Plugin" one). So, can we do without all that?
Comment #14
andres alvarez commentedI built on top of 1.0.x and streamlined the code as requested in #13. With
EntityViewsDatafrom the core and the tags in the base fields, the standard handlers cover almost everything, so I removedInstanceViewsData,InstanceViewsHooks,BuildablePluginId,InstanceContext, andInstanceOperationsHook. OnlyInstanceDerivedremains for the label, profile, and publication badge, because they come from the display and not from a column. There are 2 new PHP files instead of 10. I kept Jean’s upgrade path, andpageViewsIndexremains in its controller. The Kernel tests pass, and fail without the change. In the global list, view displays only have “Build” and “Edit,” and orphaned views appear with a “-” and no operations. Should we also move the list of views to the view?Comment #15
andres alvarez commentedComment #16
pdureau commentedI will have a look (php-cs-fixer job on pipeline is red, but this is not preventing the review)
Comment #17
pdureau commentedbeta9 has been released. Changing the tag.
Comment #18
pdureau commentedCode review
It is way better, thanks.
It is nice to see
InstanceListFilterFormremoved.InstanceListBuilderhas been simplified, but can't be remove becauseEntityListBuilderis not rendering any field, computed or not, even the ones listed asentity_keys.⚠️ I still have some doubts about:
views_data_alter: could move into the entity's own Views data class:views_pre_buildmay be avoidable once #3629063: Instances list: load instances from storage, not from each buildable landsInstanceDerived: maybe avoidable if::label(),::getProfile()and::getPublicationStatus()become computed fields (whcih will be the opportunity to "drupalize"PublicationStatus)⚠️ Why a 345 kernel test for the view (
modules/display_builder_views/tests/src/Kernel/InstancesViewTest.php) ? I am not sure it is a thing to kernel testing a config entity. What do you think?Feature review
After switching branch, I had to do this to activate the view:
⚠️ Do we need an update hook to activate the view ?
1.0.x:

MR:

Review:
Comment #19
andres alvarez commentedThanks for the review, pdureau.
- Update hook: I think we need one. The View lives in the install config of display_builder_ui, which is only imported when the module is installed, so sites that already have it won't get it. What you saw when switching branches is the same thing. I'll add a post_update that creates it if missing, plus the cleanup of the stale views display from the earlier version that I mentioned in #10.
- Kernel test: good point, 345 lines is a lot. I'll trim it to what protects behavior (filters, sorting and operations) and drop what only tests the View's own config.
- InstanceDerived and computed fields: I'll look into it. If label, profile and publication status can be exposed as computed fields on the entity, the class goes away. I'll report what I find before changing it.
- views_data_alter and views_pre_build: I'll move views_data_alter into the Views data class if it doesn't complicate things. views_pre_build stays until #3629063 lands.
- "Context" filter: I don't have a better name yet. If you have one in mind, tell me.
- Pager: I didn't test it either, I'll check it.
Comment #20
pdureau commentedNo need to hook something under our control. So, I have added a commit with
src/Entity/InstanceViewsData.phpIt was also the opportunity to remove the unused
ContextFieldItemList.It was moved in a dedicated ticket for later: #3633653: Refine instances admin list view
Andres, can you:
InstancesViewTestComment #21
csakiistvanIs this issue ready to review or @andresalvarez is working on it?
Comment #22
andres alvarez commentedHi, it's ready for review.
Comment #23
pdureau commentedThanks to #3633766: List filter form has no inner padding outside the Default Admin theme, I am discovering
modules/display_builder_ui/css/instance-list.css😲Do we still need this file now we are using Views? It is still loaded by
PatternPresetListBuilderusingFilteredListBuilderTrait.display_builder_uihaving alreadydrupal:viewsdependency, we may be able to load its library.It is nice, I am the one who suggested this ;)
But since then, I saw "Context" unfortunately used in other admin listings with this meaning, so let's revert this specific commit.
Comment #24
pdureau commentedI will have a quick look.
Comment #25
pdureau commentedfix: #3623275 by andres-alvarez: Rename the Context column removed (with a rebase, so the revert is not visible in log)
Remove display_builder_ui/instance_list library added.
Ready for review.
Comment #26
csakiistvanComment #27
csakiistvan✅ Tested and works — applied MR !404 on top of 1.0.x, ran
drush updb(the post update created the View) and rebuilt caches: /admin/structure/display-builder/instances now renders from thedisplay_builder_instancesView with its columns, exposed filters and pager, and /admin/structure/views/display-builder still works. The View shipped withreset_button: false, dropping the Reset button the old filter form had, so I pushed73a29ee0setting it totrue; the button now shows on the filtered list.Comment #28
pdureau commentedgreat
Comment #29
mogtofu33 commentedBecause of #3629063: Instances list: load instances from storage, not from each buildable we lost here the 'Entity view override' on the list if not created (For example from config import and never opened for build).
Will add a follow-up as it would influence the rtbc and work here is good.
Thanks all!
Comment #31
mogtofu33 commentedComment #33
pdureau commentedShipped in beta10 release.