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_data handler, so site builders cannot customize either list.

Proposed resolution

  1. Add a views_data handler (InstanceViewsData extending EntityViewsData):
    • show the buildable plugin ID as a plain field, with a select filter listing the buildable labels;
    • hide the serialized buildable configuration.
  2. Add labels to the base fields id, buildable, hash and published.
  3. Add Views field plugins for the instance label, the profile and the publication status (reusing DisplayBuilderHelpers::publicationBadge()).
  4. Ship a default View in display_builder_ui with two displays: the global list at the current path, and the Views list filtered to view_display. Keep context as the filter identifier so the Instances panel links keep working.
  5. Remove the custom load, filter, sort and pager code in InstanceListBuilder, and ViewsManagementController::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.

Command icon 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

mogtofu33 created an issue. See original summary.

mogtofu33’s picture

mogtofu33’s picture

Issue summary: View changes
mogtofu33’s picture

Issue tags: +AI-accelerated

andres alvarez made their first commit to this issue’s fork.

andres alvarez’s picture

Continuing work on replacing the instances admin list with a View. The MR adds:

  • InstanceViewsData to expose display_builder_instance fields to Views
  • Custom field plugins for label, profile, and publication status
  • Exposed filter for buildable plugin ID
  • Default View with two page displays: general instances and views-only

The old InstanceListBuilder and ViewsManagementController are removed. Remaining work is fixing the PHPUnit test failures before this is ready for review.

MR to follow.

andres alvarez’s picture

Status: Active » Needs work
mogtofu33’s picture

andres alvarez’s picture

The 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-builder stays on ViewsManagementController::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 stale views display, which would need a post update to remove. MR updated.

andres alvarez’s picture

Status: Needs work » Needs review
mogtofu33’s picture

Assigned: Unassigned » mogtofu33
pdureau’s picture

Assigned: mogtofu33 » Unassigned
Status: Needs review » Needs work

Hi 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:

  • modules/display_builder_ui/src/Hook/InstanceViewsHooks.php
  • modules/display_builder_ui/src/Plugin/views/field/InstanceContext.php
  • modules/display_builder_ui/src/Plugin/views/field/InstanceLabel.php
  • modules/display_builder_ui/src/Plugin/views/field/InstanceProfile.php
  • modules/display_builder_ui/src/Plugin/views/field/InstancePublicationStatus.php
  • modules/display_builder_ui/src/Plugin/views/filter/BuildablePluginId.php
  • modules/display_builder_ui/src/ViewsData/InstanceViewsData.php

Instances are proper content entities using proper field types (except the "Plugin" one). So, can we do without all that?

andres alvarez’s picture

I built on top of 1.0.x and streamlined the code as requested in #13. With EntityViewsData from the core and the tags in the base fields, the standard handlers cover almost everything, so I removed InstanceViewsData, InstanceViewsHooks, BuildablePluginId, InstanceContext, and InstanceOperationsHook. Only InstanceDerived remains 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, and pageViewsIndex remains 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?

andres alvarez’s picture

Status: Needs work » Needs review
pdureau’s picture

Assigned: Unassigned » pdureau

I will have a look (php-cs-fixer job on pipeline is red, but this is not preventing the review)

pdureau’s picture

beta9 has been released. Changing the tag.

pdureau’s picture

StatusFileSize
new124.6 KB
new126.62 KB

Code review

It is way better, thanks.

It is nice to see InstanceListFilterForm removed.

InstanceListBuilder has been simplified, but can't be remove because EntityListBuilder is not rendering any field, computed or not, even the ones listed as entity_keys.

⚠️ I still have some doubts about:

  1. views_data_alter: could move into the entity's own Views data class:
  2. views_pre_build may be avoidable once #3629063: Instances list: load instances from storage, not from each buildable lands
  3. InstanceDerived: 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:

$ ddev drush pmu display_builder_ui
$ ddev drush en display_builder_ui

⚠️ Do we need an update hook to activate the view ?

1.0.x:

MR:

Review:

  • Filters on Context & Instance: ✅. By the way, Is it the opportunity to challenge "Context" here?
  • Same help message: ✅
  • Same 9 cols in the same order: ✅
  • Instance & Update cols are sortable: ✅
  • Operations: Build & Edit: ✅
  • Pager: ⚠️ not tested
andres alvarez’s picture

Thanks 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.

pdureau’s picture

Assigned: pdureau » Unassigned

views_data_alter replace by entity's own Views data class

No need to hook something under our control. So, I have added a commit with src/Entity/InstanceViewsData.php

It was also the opportunity to remove the unused ContextFieldItemList.

InstanceDerived replace by computed fields

It was moved in a dedicated ticket for later: #3633653: Refine instances admin list view

Andres, can you:

  • Review my change?
  • Add an update hook to activate the view if we need one?
  • Decide if we keep InstancesViewTest
csakiistvan’s picture

Is this issue ready to review or @andresalvarez is working on it?

andres alvarez’s picture

Hi, it's ready for review.

pdureau’s picture

Thanks 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 PatternPresetListBuilder using FilteredListBuilderTrait.

display_builder_ui having already drupal:views dependency, we may be able to load its library.

fix: #3623275 by andres-alvarez: Rename the Context column

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.

pdureau’s picture

Assigned: Unassigned » pdureau

I will have a quick look.

pdureau’s picture

Assigned: pdureau » Unassigned

fix: #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.

csakiistvan’s picture

Assigned: Unassigned » csakiistvan
csakiistvan’s picture

Assigned: csakiistvan » Unassigned
Status: Needs review » Reviewed & tested by the community
StatusFileSize
new895.97 KB
new888.1 KB

✅ 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 the display_builder_instances View with its columns, exposed filters and pager, and /admin/structure/views/display-builder still works. The View shipped with reset_button: false, dropping the Reset button the old filter form had, so I pushed 73a29ee0 setting it to true; the button now shows on the filtered list.

pdureau’s picture

Assigned: Unassigned » mogtofu33

great

mogtofu33’s picture

Assigned: mogtofu33 » Unassigned
Status: Reviewed & tested by the community » Active

Because 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!

mogtofu33’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

pdureau’s picture

Status: Fixed » Closed (fixed)

Shipped in beta10 release.