Problem/Motivation

The content translation module now adds routes without designating them as admin paths. This results in this confusing setup with the default Standard profile:

So although Edit/Delete would lead to Seven, Translate leads to Bartik. Then for any existing translation, Edit leads again to Seven but for adding translations or removing them, you keep being in Bartik. Its a confusing mess of theme application.

Proposed resolution

Inherit admin page state from the edit screen. Nodes have a setting which means they may or may not be admin. Comments don't have such setting and are always frontend edited. Custom blocks are always backend edited, even though they don't have an admin/ path either. The admin status needs to be inherited from the parent route.

Remaining tasks

Commit.

User interface changes

Translate path will follow the same setup for admin theme that the edit path has. Instead of always being frontend themed.

API changes

None.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Gábor Hojtsy’s picture

Title: Translate tab should be properly admin path or not » Translate routes should properly inherit admin path use from edit route

Better title.

Gábor Hojtsy’s picture

Adding test.

Gábor Hojtsy’s picture

Issue tags: +Usability

The last submitted patch, inherit-content-translation-admin-route.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 2: inherit-content-translation-admin-route-2.patch, failed testing.

vijaycs85’s picture

Status: Needs work » Needs review
FileSize
4.22 KB
1.88 KB

Fixed 3/4 fails. For some reason, the 'use_admin_theme' doesn't effect translation tab.

Status: Needs review » Needs work

The last submitted patch, 6: 2276387-tranlate-path-theme-6.patch, failed testing.

Gábor Hojtsy’s picture

Well, I manually tested the fix while working on it and it manually worked :) So I'm wondering how this is not good :/ I'll see to add some more asserts for the edit page too to make sure alignment is happening.

Gábor Hojtsy’s picture

Status: Needs work » Needs review
FileSize
4.48 KB
1.05 KB

I thought that routes need to be rebuilt when the theme settings are set, but that seems to be already happening:

function node_form_system_themes_admin_form_submit($form, &$form_state) {
  \Drupal::config('node.settings')
    ->set('use_admin_theme', $form_state['values']['use_admin_theme'])
    ->save();
  \Drupal::service('router.builder')->setRebuildNeeded();
}

So it is a possibility that the JS snippet I use to test for the applied theme does not appear in the test system for some reason. Hum. Anyway, adding a condition for the edit page as well to see if that at least follows the setting or not in the test.

Status: Needs review » Needs work

The last submitted patch, 9: 2276387-tranlate-path-theme-9.patch, failed testing.

Gábor Hojtsy’s picture

Status: Needs work » Needs review
FileSize
4.65 KB
1.6 KB

So this proves my rebuilding theory. While the submit function I quoted above does have rebuild, our test uses the config API directly and therefore does not test how Drupal would normally react when this change is flipped. We should test through the UI and set the mode there so the route rebuild is going to happen.

Status: Needs review » Needs work

The last submitted patch, 11: 2276387-tranlate-path-theme-11.patch, failed testing.

Gábor Hojtsy’s picture

Status: Needs work » Needs review
FileSize
4.43 KB
1.93 KB

So the final problem was the test did not allow admins to see the admin theme. Doh. That took a bit too much time... Removed testing the edit page because that is already tested in ThemeTest.php in system module. I looked into extending that to test for translate, but there are several things that need to be set up, translatability, etc. for the tab to show up, so better not merged this into system's ThemeTest.php.

I think this is ready now :)

vijaycs85’s picture

Status: Needs review » Reviewed & tested by the community

Fine by me.

tstoeckler’s picture

+++ b/core/modules/content_translation/src/Routing/ContentTranslationRouteSubscriber.php
@@ -46,8 +46,14 @@ protected function alterRoutes(RouteCollection $collection) {
+        $is_admin = (bool) $edit_route->getOption('_admin_route');

I think it would have been slightly cleaner to use AdminContext::isAdminRoute() here, but since this is very route bound I think it's also fine to use the route option directly.

RTBC++

Gábor Hojtsy’s picture

Yeah the assumption that that option makes it an admin route is already encoded in the other parts of this route provider, so while we can make it look a tiny bit nicer here, we are directly fiddling with routes here.

tstoeckler’s picture

Yeah the assumption that that option makes it an admin route is already encoded in the other parts of this route provider

Really? Can't find anything like that. Still not against RTBC, just wanted to check for clarity.

Gábor Hojtsy’s picture

+++ b/core/modules/content_translation/src/Routing/ContentTranslationRouteSubscriber.php
@@ -63,6 +69,7 @@ protected function alterRoutes(RouteCollection $collection) {
+          '_admin_route' => $is_admin,

This. In multiple copies.

Gábor Hojtsy’s picture

Gábor Hojtsy’s picture

#1987882: Convert content_translation routes to a new style controller just attempted to hardcode translate routes as admin routes. Would be good to let this land sooner than later. :)

Gábor Hojtsy’s picture

Issue summary: View changes

Updated remaining tasks.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 5a06f7b and pushed to 8.x. Thanks!

  • Commit 5a06f7b on 8.x by alexpott:
    Issue #2276387 by Gábor Hojtsy, vijaycs85: Fixed Translate routes should...
Gábor Hojtsy’s picture

Issue tags: -sprint

Woot, superb, thanks.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.