set the admin route option on entity tabs if the entity canonical route has it too

Created on 7 March 2019, over 5 years ago
Updated 23 April 2024, 2 months ago

All Entity UI tabs use the main site theme, but if an entity type uses AdminHtmlRouteProvider, then switching between an entity UI tab and a built-in tab is jarring.

The logical thing to do is to check whether the entity type's canonical route has the _admin_route option.

However, within an entity type's route provider handler, we don't have access to the route collection that's been built so far, and we can't use the route provider service as if Entity UI is enabled at the same time as the target entity's module, then the target entity's routes don't exist.

It would be nice if EntityRouteProviderSubscriber passed the route collection in to the handler, but it doesn't:

          $routes = $route_provider->getRoutes($entity_type);

So I think the thing here is to stop using a route handler for entity tab routes, and so stop making use of EntityRouteProviderSubscriber's code. Instead, provide our own route subscriber.

So:

- remove setting of our entity route provider in entity_ui_entity_type_build()
- add custom route subscriber, which iterates over target entity types and calls TabRouteProvider directly for each one.

πŸ› Bug report
Status

Needs work

Version

1.0

Component

User interface

Created by

πŸ‡¬πŸ‡§United Kingdom joachim

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States DamienMcKenna NH, USA

    The current merge request does work as intended, and is a nice addition to the module.

    Maybe it should default to "on" for entity forms and off for others? Then site builders could have a reasonable default but be able to control it as needed.

  • Status changed to Needs work 2 months ago
  • πŸ‡¬πŸ‡§United Kingdom joachim

    > Maybe it should default to "on" for entity forms and off for others? Then site builders could have a reasonable default but be able to control it as needed.

    It's expanding the scope, but it would make sense for each EntityTabContent plugin to declare whether it wants to define its route as an admin route.

Production build 0.69.0 2024