Problem/Motivation

Follows #3624760: Plan: consistent Display Builder entry points in the Navigation top bar.

That plan gives every page one entry point per layer that built it: the page layout, the main content display or its override, and the Views page display. All of it renders in the Navigation module's top bar.

A site not running Navigation gets none of it. The per-entity override is still reachable through its local tasks, but the page layout, the bundle display and the Views page display have no entry point from the page they render, which is the problem #3624760: Plan: consistent Display Builder entry points in the Navigation top bar set out to fix.

Proposed resolution

The list itself is already UI agnostic: hook_display_builder_page_displays() fills a PageDisplays collector with a title, a scope, a URL and a weight, and the top bar item is only one consumer of it. A second consumer is small.

Options, to decide in this issue:

  • A block plugin listing the entries. Works with any theme and any admin chrome, and site builders place it where they want.
  • A tab for core's Toolbar, for sites that use it instead of Navigation.
  • Neither, and state in the documentation that these entry points need Navigation.

Remaining tasks

  • Pick the option.
  • Access is checked per builder URL by the consumer, so whatever renders the list repeats that.
  • Test: the entries show without Navigation installed.
  • Document what needs Navigation and what does not.
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.

pdureau’s picture

Can we avoid adding a feature request to beta8 scope that close to completion?

mogtofu33’s picture

pdureau’s picture

Sure.

When I proposed avoid adding a feature request so late in beta8, I meant "so late in beta phase". We are so close to 1.0.0 completion than any new feature is a risk.

Anyway, it is not a big deal. beta9 has been released though, so I am changing the tag.

pdureau’s picture

A block plugin listing the entries. Works with any theme and any admin chrome, and site builders place it where they want.

The block will be useful only when being positioned in the front theme, so the discoverability is low. I am afraid we would add afeature which will not be usable.

Neither, and state in the documentation that these entry points need Navigation.

This is my preference, to keep thinks simple on our side.

A tab for core's Toolbar, for sites that use it instead of Navigation.

Worth a little investigation. Maybe inspired from https://git.drupalcode.org/project/devel/-/blob/5.x/src/ToolbarHandler.php

pdureau’s picture

Assigned: mogtofu33 » pdureau
StatusFileSize
new7.88 KB

A tab for core's Toolbar, for sites that use it instead of Navigation.

I will give a try, it may look like that:

pdureau’s picture

Assigned: pdureau » Unassigned
Status: Active » Needs review

To review. I am still not sure it is a good idea, but I am not against it.

Code changes: some logic is extracted from DisplayTopBarItem to PageDisplaysTrait be shared with ToolbarHooks.

To test, you need to do uninstall navigation and to install toolbar.

I have have hesitated to position the display menu at the end of the toolbar, alongside "Edit", because it is also a contextual menu. What do you think?

csakiistvan made their first commit to this issue’s fork.

csakiistvan’s picture

Assigned: Unassigned » csakiistvan
csakiistvan’s picture

StatusFileSize
new565.81 KB
new319.39 KB

✅ Tested and works — with Navigation uninstalled and Toolbar enabled, a node with an overridable display had no Display Builder entry point in the Toolbar; after applying MR !517 and rebuilding caches, a "Display" tab shows in the Toolbar and its tray lists "Customize this content". Sites on the core Toolbar get an entry point too.

I pushed a functional test, ToolbarDisplayTest: the tray lists the page displays in order, and there is no tab on a page without one or for a user without builder access. The first case fails without ToolbarHooks.

Notes
  • The tray shows only the titles; the top bar also shows each display's description ("Only this content, starts an override"), which tells editors the scope of a change.
  • Non-blocking: the item adds the route cache context to core's render-cached toolbar element, so the whole Toolbar is now cached per route instead of per permission set.
  • Non-blocking: the inline <script> in the tray does not run under a CSP without 'unsafe-inline', and relies on the tray being inside .toolbar-tab.
csakiistvan’s picture

Assigned: csakiistvan » Unassigned
Status: Needs review » Reviewed & tested by the community
pdureau’s picture

Assigned: Unassigned » pdureau
Status: Reviewed & tested by the community » Needs work

The tray shows only the titles; the top bar also shows each display's description ("Only this content, starts an override"), which tells editors the scope of a change

It was done like that in purpose. Toolbar items are one-liners.

The item adds the route cache context to core's render-cached toolbar element, so the whole Toolbar is now cached per route instead of per permission set.

It is a bit the reverse situation of https://www.drupal.org/i/3625978#comment-16819927 where a addCacheContexts(['user.permissions']) was considered redundant in a menu_local_tasks_alter hook. Here, it is considered missing. In both case, permission cache context is already added by AccessResult and/or the renderer.

So, i would prefer not messing with anything here.

The inline

in the tray does not run under a CSP without 'unsafe-inline', and relies on the tray being inside .toolbar-tab.
CSP as "Content Security Policy"? Drupal core sends no CSP header, but I will have a look.
pdureau’s picture

Assigned: pdureau » mogtofu33
Status: Needs work » Reviewed & tested by the community

CSP as "Content Security Policy"? Drupal core sends no CSP header, but I will have a look.

If the CSP assumption fails, the only effect is that core's tab-switching bug comes back #3529674: Toolbar tab behavior is inconsistent when clicked.. Let's not mess with our codebase while the risk is not a security one, and the fix is expected in Core.

Back to RTBC.

mogtofu33’s picture

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

Toolbar is deprecated in 11.5 and removed from core in 12.0.0, both due the week of December 7, so I prefer not to add a feature on it right before 1.0.
The tab adds no public API and can land in 1.1 if a Toolbar site asks for it, so !517 stays here until then.

Before it lands, the route cache context needs an answer: it reaches core's toolbar element, so each URL stores a full Toolbar, admin pages included.
#3529674: Toolbar tab behavior is inconsistent when clicked. has also moved to the contrib Toolbar queue, so that fix will not come from core, and ToolbarDisplayTest will need drupal/toolbar on Drupal 12.

For now I offer 3625979-toolbar-support with small change in docs/install.md to recommend Navigation and says what is missing without it.

  • mogtofu33 committed 2a1697ad on 1.0.x
    feat: #3625979 Entry points to the displays that built a page, without...
pdureau’s picture

Toolbar is deprecated in 11.5 and removed from core in 12.0.0, both due the week of December 7, so I prefer not to add a feature on it right before 1.0.

OK. Good to know. I remove from 1.0.0 the scope.

Do we close as won't fixed?

mogtofu33’s picture

I prefer postponed as admin_toolbar usage is still very high, so could be something we want to provide at some point.