Problem/Motivation

Admin paths are defined now in route definitions (see https://www.drupal.org/node/2224207). But in Views UI, the route is build via UI and you'll need to code to mark a view route as admin route. This is very painful.

Use case: As a site moderator, I'm able to use a View, located at /articles/moderate, with VBO to bulk approve/decline articles. I want to access this moderation tool using the admin theme in the same way I'm using the node edit page.

Proposed resolution

Add a new page setting "Use the administration theme" in the page display that allows site builders to make that page an admin one, similar to https://www.drupal.org/project/page_manager.

Remaining tasks

  1. Have the results of the usability review been addressed
  2. Update screenshots, add links to the issue summary
  3. Update the draft CR with the final screenshots and UI text.
  4. Commit.
  5. Publish the CR.
  6. Rejoice.

User interface changes

View edit page: Page settings

Page settings UI on the View edit form.

View edit page: Page settings (with an admin/* path)

Page settings UI on the View edit form when the path starts with admin/

Modal 'Administration theme' form

Modal form to control administration theme checkbox.

Modal 'Administration theme' form (with an admin/* path)

Modal with disabled form explaining paths starting with admin/ always use the administration theme.

API changes

None.

Data model changes

New page display option: use_admin_theme

CommentFileSizeAuthor
#201 2719797-201.patch5.72 KBsaurabh-2k17
#192 2719797-192.modal-form-admin-override.png66.29 KBdww
#192 2719797-192.modal-form.png48.16 KBdww
#192 2719797-192.view-edit-admin-override.png51.79 KBdww
#192 2719797-192.view-edit.png40.43 KBdww
#190 2719797.188_190.interdiff.txt854 bytesdww
#190 2719797-190.patch8.9 KBdww
#188 2719797.187_188.interdiff.txt587 bytesdww
#188 2719797-188.patch8.87 KBdww
#187 2719797.184_187.interdiff.txt1.17 KBdww
#187 2719797-187.patch8.88 KBdww
#184 2719797.181_184.interdiff.txt2.11 KBdww
#184 2719797-184.patch8.88 KBdww
#183 2719797.181_182.interdiff.txt2.36 KBdww
#181 2719797.171_181.interdiff.txt1.21 KBdww
#181 2719797-181.patch8.99 KBdww
#176 interdiff_174-176.txt6.15 KBakram khan
#176 2719797-176.patch14.46 KBakram khan
#174 interdiff_171_174.txt1.8 KBrishabh vishwakarma
#174 2719797-174.patch9.8 KBrishabh vishwakarma
#171 interdiff.txt6.1 KBlauriii
#171 2719797-171.patch9.09 KBlauriii
#169 Admin-Theme.png325.69 KBarunkumark
#169 Admin-theme-1.png244.55 KBarunkumark
#164 view-admin-override.png52.27 KBsmustgrave
#164 view-admin-popup.png74.62 KBsmustgrave
#164 view-admin-page-setting.png47.61 KBsmustgrave
#159 After_patch.jpg74.91 KBgaurav-mathur
#159 before_patch.jpg48.64 KBgaurav-mathur
#158 2719797-158.patch5.56 KBsmustgrave
#158 interdiff-144-158.txt895 bytessmustgrave
#155 2719797-155.patch5.58 KBRatan Priya
#155 interdiff_154-155.txt575 bytesRatan Priya
#154 interdiff-2719797-153_154.txt2.96 KBanchal_gupta
#154 2719797-154.patch5.57 KBanchal_gupta
#153 2719797-153.patch5.61 KBnitin shrivastava
#147 2719797-147.png146.99 KBheni_deepak
#144 2719797-144.patch5.54 KBsmustgrave
#144 2719797-144-tests-only.patch1.92 KBsmustgrave
#144 interdiff-137-144.txt1.59 KBsmustgrave
#142 after-patch-2.png1.83 MBgayatri chahar
#142 after-patch-1.png1.59 MBgayatri chahar
#137 2719797-137-9.3.x.patch5.54 KBpfrenssen
#127 Description changes.png35.15 KBmitthukumawat
#127 Title changes.png15.26 KBmitthukumawat
#126 interdiff-2719797-126.txt1.43 KBswentel
#126 2053399-126.patch5.54 KBswentel
#125 2719797-interdiff-125.txt1.34 KBswentel
#125 2719797-125.patch5.54 KBswentel
#120 2719797-120.patch5.47 KBayushmishra206
#120 interdiff_109-120.txt768 bytesayushmishra206
#113 interdiff_109-113.txt1.5 KBsulfikar_s
#113 afterpatch-113.png17.52 KBsulfikar_s
#113 new_option_views_page-2719797-113.patch5.47 KBsulfikar_s
#113 coding_standard.png26.8 KBsulfikar_s
#113 after_109.png20.78 KBsulfikar_s
#110 afterPatch.png43.11 KBRuchi Joshi
#109 interdiff_106_109.txt945 bytesrajneeshb
#109 2719797-109.patch5.48 KBrajneeshb
#107 afterPatch2.png30.94 KBRuchi Joshi
#107 afterPatch1.png35.13 KBRuchi Joshi
#106 2719797-106.patch5.46 KBsnehalgaikwad
#98 interdiff_95-98.txt1.68 KBsaurabh-2k17
#98 new_option_for_views_page-2719797-98.patch5.75 KBsaurabh-2k17
#95 interdiff_90-95.txt1.47 KBsaurabh-2k17
#95 new_option_for_views_page-2719797-95.patch5.4 KBsaurabh-2k17
#90 interdiff_86-90.txt1.61 KBsaurabh-2k17
#90 new_option_for_views_page-2719797-90.patch5.22 KBsaurabh-2k17
#86 interdiff.2719797.77-86.txt2.35 KBaleevas
#86 2719797-86.patch5.46 KBaleevas
#77 interdiff--2719797-76-77.txt751 bytesesolitos
#77 core-88x--views--admin-path-2719797-77.patch5.06 KBesolitos
#76 interdiff--2719797-69-76.txt7.91 KBesolitos
#76 core-88x--views--admin-path-2719797-76.patch5.06 KBesolitos
#73 Screen Shot 2018-12-06 at 17.33.55.png40.96 KBalexpott
#73 Screen Shot 2018-12-06 at 17.28.15.png32.99 KBalexpott
#69 2719797-69.interdiff.txt3.26 KBclaudiu.cristea
#69 admin_theme2.png172.77 KBclaudiu.cristea
#69 admin_theme1.png129.4 KBclaudiu.cristea
#69 2719797-69.patch7.31 KBclaudiu.cristea
#66 2719797-66.patch7.09 KBdaniel korte
#65 2719797-65.patch7.19 KBclaudiu.cristea
#62 view-display-as-admin-page.png52.47 KByoroy
#60 in_ui.png9.87 KBxjm
#60 always_use_admin_theme.png53.17 KBxjm
#59 2719797-59.interdiff.txt857 bytesclaudiu.cristea
#59 2719797-59.patch7.04 KBclaudiu.cristea
#52 always-use-admin-theme.png155.06 KBclaudiu.cristea
#52 always-use-admin-theme-1.png98.24 KBclaudiu.cristea
#52 2719797-52-8.4.x.patch7.21 KBclaudiu.cristea
#52 2719797-52.patch7.03 KBclaudiu.cristea
#52 2719797-52.interdiff.txt7.96 KBclaudiu.cristea
#50 view_option.png115.09 KBxjm
#49 using_admin_theme.png25.31 KBxjm
#44 2719797-44-8.4.x.patch7.02 KBclaudiu.cristea
#44 2719797-44.patch6.94 KBclaudiu.cristea
#44 2719797-44.interdiff.txt836 bytesclaudiu.cristea
#40 2719797-40-8.4.x.patch7.02 KBclaudiu.cristea
#40 2719797-40.patch6.93 KBclaudiu.cristea
#40 2719797-40.interdiff.txt6.92 KBclaudiu.cristea
#37 2719797-36-8.4.x.patch6.76 KBclaudiu.cristea
#36 2719797-36.interdiff.txt4.51 KBclaudiu.cristea
#36 2719797-36.patch6.68 KBclaudiu.cristea
#33 views-admin-8.5.x.patch6.8 KBfago
#23 interdiff.txt565 bytesclaudiu.cristea
#23 new_option_for_views-2719797-1.patch10.55 KBclaudiu.cristea
#21 interdiff.txt12.04 KBclaudiu.cristea
#21 new_option_for_views-2719797-21.patch10.54 KBclaudiu.cristea
#16 interdiff.txt2.46 KBclaudiu.cristea
#16 new_option_for_views-2719797-16.patch6.63 KBclaudiu.cristea
#13 admin-theme-1.png74.87 KBclaudiu.cristea
#13 admin-theme.png131.13 KBclaudiu.cristea
#12 interdiff.txt3.7 KBclaudiu.cristea
#12 new_option_for_views-2719797-12.patch4.17 KBclaudiu.cristea
#4 admin_theme_12.png87.69 KBclaudiu.cristea
#3 admin_theme_11.png85.15 KBclaudiu.cristea
#2 2719797-2.patch2.62 KBclaudiu.cristea
#2 admin_theme_1.png85.15 KBclaudiu.cristea
#2 admin_theme_2.png55.99 KBclaudiu.cristea

Issue fork drupal-2719797

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

claudiu.cristea created an issue. See original summary.

claudiu.cristea’s picture

Title: Option for Views page displays to use the admin theme » New option for Views page displays to use the admin theme
Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new55.99 KB
new85.15 KB
new2.62 KB

Here's a first patch.

claudiu.cristea’s picture

Issue summary: View changes
StatusFileSize
new85.15 KB
claudiu.cristea’s picture

Issue summary: View changes
StatusFileSize
new87.69 KB
claudiu.cristea’s picture

Issue tags: +Needs backport to D7

Probably this can be back-ported to Views module.

Status: Needs review » Needs work

The last submitted patch, 2: 2719797-2.patch, failed testing.

dawehner’s picture

Ideally we would have an update path to set those default values.

+++ b/core/modules/views/src/Plugin/views/display/Page.php
@@ -217,6 +218,12 @@ public function optionsSummary(&$categories, &$options) {
+    $options['admin_theme'] = [
+      'category' => 'page',
+      'title' => $this->t('Use admin theme'),
+      'value' => $this->getOption('admin_theme') ? 'Yes' : 'No',
+    ];
   }

@@ -429,6 +436,14 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
+      case 'admin_theme':
+        $form['admin_theme'] = [
+          '#type' => 'checkbox',
+          '#title' => $this->t('Use admin theme'),
+          '#description' => $this->t('If checked, the admin theme will be used to display this page.'),
+          '#default_value' => $this->getOption('admin_theme'),
+        ];
+        break;

This is kind of an advanced option so I was wondering whether the option could be part of an existing form. Any thoughts on that?

claudiu.cristea’s picture

@dawehner,

Ideally we would have an update path to set those default values.

Yes I'm thinking on this, but how? Probably the existing views that have page displays with admin routes are set through the code. In this case the only place where this info is stored is the {router} table. Should we:

  1. Scan all the views for page displays
  2. Then, for each, load the corresponding route
  3. Extract the _admin_route value from there
  4. Store it in the view

This is kind of an advanced option so I was wondering whether the option could be part of an existing form. Any thoughts on that?

Initially, I thought that should be together with the path/route. But that one is a simple option, so I didn't want to touch that.

claudiu.cristea’s picture

@dawehner, sorry. You meant to add it as advanced option but ONLY in UI/form. In the storage will remain as simple. That would make sense, yes. So should I add it together with the route/path?

dawehner’s picture

Yes I'm thinking on this, but how? Probably the existing views that have page displays with admin routes are set through the code. In this case the only place where this info is stored is the {router} table. Should we:

Scan all the views for page displays
Then, for each, load the corresponding route
Extract the _admin_route value from there
Store it in the view

Nope. Its totally enough to resave the views ..., but note, there should be some code in \Drupal\views\Plugin\views\display\Page::alterRoutes to copy over previously existing admin route information.

Initially, I thought that should be together with the path/route. But that one is a simple option, so I didn't want to touch that.

I think yeah showing it on the path link is a good idea. Is that advanced that I won't bother to not show anything about it in the summary.

claudiu.cristea’s picture

@dawehner

Its totally enough to resave the views ..., but note, there should be some code in \Drupal\views\Plugin\views\display\Page::alterRoutes to copy over previously existing admin route information.

I don't get it. So, we are implementing :: alterRoutes() in Page just to store the admin_theme value in the View? Why not doing this only once, in the update path? Then alterations are able to alter this stored value if they want.

claudiu.cristea’s picture

Status: Needs work » Needs review
StatusFileSize
new4.17 KB
new3.7 KB

@dawehner, Thinking more on this, I don't think we need an update path. The existing Views pages showed with the admin theme are resolved right now via route subscribers > route alters. They will continue to do so, unless a site builder manually saves that view. In that case the option is stored and the view will go using the option (if no alter decides something else). Please look at the the interdiff, I'm adding now the _admin_route only if TRUE so that \Drupal\system\EventSubscriber\AdminRouteSubscriber::alterRoutes() will continue to work.

claudiu.cristea’s picture

Issue summary: View changes
StatusFileSize
new131.13 KB
new74.87 KB
dawehner’s picture

Issue tags: +Needs usability review

Well its about a 100% complete configuration, rather than relying on the default fallback.

... Adding the needs usability review ...

Bojhan’s picture

Issue tags: -Needs usability review

Interesting feature, I can imagine this be useful if your building operational views for authors who don't have admin access. Could you elaborate on the use case?

A few concerns:

  • What if I enter a path with /admin in it - does it automatically check the box?
  • What if I disable admin theme on a path using /admin?
  • The whole description is useless.
claudiu.cristea’s picture

Issue summary: View changes
StatusFileSize
new6.63 KB
new2.46 KB

@Bojhan,

Could you elaborate on the use case?

Added in the summary.

What if I enter a path with /admin in it - does it automatically check the box?

No. This new option is stored in the view backend. But route event subscribers can later alter this value. If you create a view under /admin you can leave this option unchecked because we already have a route alteration as a route event subscriber (\Drupal\system\EventSubscriber\AdminRouteSubscriber::alterRoutes()) that resolves all /admin routes. If no route subscribe alters the route, then this value will act.

What if I disable admin theme on a path using /admin?

Nothing. \Drupal\system\EventSubscriber\AdminRouteSubscriber::alterRoutes() is overriding your decision.

claudiu.cristea’s picture

Issue summary: View changes
dawehner’s picture

@claudiu.cristea
Well, now its also a bit confusing, because the user might think that they can disable the admin theme via the UI, but well, they can't

claudiu.cristea’s picture

@dawehner, right but happens everywhere in Drupal. You store a node title and then an hook_node_view changes that and shows the user other title. Nothing new here.

dawehner’s picture

Right, but this time we expose this behaviour even within just core.

claudiu.cristea’s picture

Issue tags: +DevDaysMilan
StatusFileSize
new10.54 KB
new12.04 KB

@Bojhan,

@dawehner and me have discussed, here at Milan Drupal DevDays, to provide in this patch only the option without the UI part. In this way, it's still possible to achieve the goal by setting the config value. For the UI/UX part we need to understand what the user expects to find as a default value. Let's do that in a follow-up after this gets committed and, course, we need your input. In the current patch, the admin-theme option can have 3 states: NULL, TRUE, FALSE. If an explicit boolean is stored, that will override the default behaviour. If it's NULL is falling back to what we have now (eg. by /admin path prefix).

dawehner’s picture

+++ b/core/modules/views/views.post_update.php
@@ -203,5 +203,22 @@ function views_post_update_serializer_dependencies() {
+function views_post_update_admin_theme() {
+  $config_factory = \Drupal::configFactory();
+  foreach ($config_factory->listAll('views.view.') as $name) {
+    $view = $config_factory->getEditable($name);
+    foreach ($view->get('display') as $display_id => $display) {
+      // Deal only with page displays.
+      if ($display['display_plugin'] == 'page') {
+        $trail = "display.$display_id.display_options.admin_theme";
+        $view->set($trail, NULL)->save();
+      }
+    }
+  }

Should we respect value potentially set already by something else?

claudiu.cristea’s picture

StatusFileSize
new10.55 KB
new565 bytes

Good catch.

claudiu.cristea’s picture

Issue summary: View changes

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

kristiaanvandeneynde’s picture

I'd like to see a feature like this go in. Not sure why there are two issues for it, though. I mean, I get that you want the option in and then build a UI for it in a follow-up, but the whole package shouldn't be that hard to get right in one go.

The way I see it, there are only four scenarios. Well two, really, but each has an on and off state:

  1. Nothing alters the route, so the checkbox is the only control - good.
  2. Something alters the route, so the checkbox may not represent the real effect - bad.

So the main thing we need to fix is the notion that an 'off' checkbox for an altered route would somehow disable the admin theme, which it won't. There are a few ways to go about this.

1. Turn the checkbox into a radio element with a clear description.

The label being "Admin theme behavior" and the options being "Inherit" and "Enforced". The description could state:

Choose whether this page will always use the admin theme, provided the user has access to see it, or if it will only use the admin theme when flagged as such through code (e.g.: paths starting with /admin).

Choosing "Enforced" would add the text between parentheses as shown in the screenshot in the other issue.

2. Actually make the checkbox trump all other route alterations

Using a route subscriber with a heavy weight, we could make the checkbox the ultimate admin theme defining mechanism. This would "break" core and other modules' views unless we write an update hook that figures out whether or not the admin theme is enabled for every individual view. And then there's still the issue of "default" views shipped by modules (config/install and config/optional) needing to be updated in their YAML files.

My preference goes to option 1 as it's more of a 'soft' flag. Introducing a 'hard' flag (option 2) could be done in D9.

P. S.: Loving the screenshots in the follow-up.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

weekbeforenext’s picture

The last patch, new_option_for_views-2719797-1.patch, isn't working for 8.3.4. I tried re-rolling it, but it still doesn't seem to be working. Is there any chance someone can provide an updated patch for 8.3.4?

Thanks,
April

weekbeforenext’s picture

kristiaanvandeneynde’s picture

I've given this some thought and I feel we should not introduce the three_way data type for this patch. It's currently serving as a placeholder because we're not including a UI in this issue yet. Once you add a UI option, how will you distinguish between NULL and FALSE with a checkbox? You'd need radio buttons where one maps to NULL, which I'd like to avoid.

So why don't we do the following:

  • Keep the patch but change the admin_theme config key to boolean and update all existing views to start as FALSE.
  • Immediately add a UI checkbox as shown in the other patch.
  • If the checkbox is unchecked (FALSE), nothing happens.
  • If the checkbox is checked (TRUE), then the route is flagged as an admin route.

The checkbox does not have to mean "do not show in the admin theme" when left unchecked. Instead, we could phrase it so the option becomes: "Default behavior" vs "Enforce admin path".

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

fago’s picture

As a site-builder I'd expect this option to exist - it being missing is quite unfortunate.

I agree that the usability issue of /admin being always admin routes can be solved by simply phrasing the checkbox like the following:

"Enforce this path to be displayed in the admin theme"
Description: Note that paths starting with /admin/ are always shown in the admin theme.

This should explain everything and even document the so-far undocumented behavior, this it's even an UX improvement! ;)

fago’s picture

StatusFileSize
new6.8 KB

I re-rolled the patch from #16 and improved the labelling as suggested. The patch applies to 8.3.x and 8.4.x as well.

Status: Needs review » Needs work

The last submitted patch, 33: views-admin-8.5.x.patch, failed testing. View results

lendude’s picture

@fago++ I really like where this is going!

\Drupal\views\Plugin\views\display\Page::getRoute got added in #2449143: REST views specify HTML as a possible request format, so if there is a "regular" HTML view on the same path, it will serve JSON, so this fatals when applied.

+++ b/core/modules/views/src/Plugin/views/display/Page.php
--- /dev/null
+++ b/core/modules/views/src/Tests/Update/AdminThemeOptionUpdateTest.php

+++ b/core/modules/views/src/Tests/Update/AdminThemeOptionUpdateTest.php
@@ -0,0 +1,43 @@
+use Drupal\system\Tests\Update\UpdatePathTestBase;
...
+class AdminThemeOptionUpdateTest extends UpdatePathTestBase {

Also, can we update this to extend \Drupal\FunctionalTests\Update\UpdatePathTestBase please (and move it to the right dir)

claudiu.cristea’s picture

Status: Needs work » Needs review
Issue tags: -DevDaysMilan
StatusFileSize
new6.68 KB
new4.51 KB

Glad this is back.

Fixed the method duplication. The ::testAdminTheme() is new, so it should not contain deprecated code. Move the update test.

claudiu.cristea’s picture

StatusFileSize
new6.76 KB

A 8.4.x version of #36 for those who need it.

dawehner’s picture

+++ b/core/modules/views/src/Plugin/views/display/Page.php
@@ -430,6 +435,14 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
+        $form['admin_theme'] = [

Can we rename the key as well, so it clear setting it to false might cause it to in the admin theme as well?

claudiu.cristea’s picture

Assigned: Unassigned » claudiu.cristea
Status: Needs review » Needs work

Can we rename the key as well, so it clear setting it to false might cause it to in the admin theme as well?

yes, makes sense. enforce_admin_theme?

claudiu.cristea’s picture

Assigned: claudiu.cristea » Unassigned
Status: Needs work » Needs review
StatusFileSize
new6.92 KB
new6.93 KB
new7.02 KB

Fixed the key.

lendude’s picture

Status: Needs review » Reviewed & tested by the community

Really nice feature, and RTBC now in my book.

claudiu.cristea’s picture

Issue tags: +8.5.0 release notes

This deserves a change notice and probably should go in release notes as a new feature. Here's the CR https://www.drupal.org/node/2917575

kristiaanvandeneynde’s picture

Great patch, loving it!

Minor nitpick:

+    // Check that enforce_admin_theme option is TRUE.
+    $this->assertFalse($options['enforce_admin_theme']);

That should read FALSE instead of TRUE, as indicated by the actual update hook.

claudiu.cristea’s picture

StatusFileSize
new836 bytes
new6.94 KB
new7.02 KB

Oh, yes. In fact only the comment is wrong. Thank you for catching.

kristiaanvandeneynde’s picture

No worries, thank you for working on it :)

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 44: 2719797-44-8.4.x.patch, failed testing. View results

claudiu.cristea’s picture

Status: Needs work » Reviewed & tested by the community

Unrelated failure.

dawehner’s picture

+++ b/core/modules/views/views.post_update.php
@@ -213,3 +213,20 @@ function views_post_update_revision_metadata_fields() {
+    foreach ($view->get('display') as $display_id => $display) {
+      // Deal only with page displays.
+      if ($display['display_plugin'] == 'page') {
+        $trail = "display.$display_id.display_options.enforce_admin_theme";
+        $view->set($trail, FALSE)->save();
+      }
+    }

Can we ensure to not save the view multiple times when there are multiple page displays?

xjm’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs usability review
StatusFileSize
new25.31 KB

This is a cool idea for a feature! Looks like it has signoff from a(nother) Views maintainer already.

Here's what this looks like in the user interface (edit -- having some issues with file attachments; I'll try again shortly...)

  1. +++ b/core/modules/views/config/schema/views.display.schema.yml
    @@ -68,6 +68,9 @@ views.display.page:
    +    enforce_admin_theme:
    +      type: boolean
    +      label: 'Enforce admin theme'
    

    I think "enforce admin theme" has undesirable connotations. A better choice might be "Always use admin theme".

  2. +++ b/core/modules/views/src/Plugin/views/display/Page.php
    @@ -218,6 +219,10 @@ public function optionsSummary(&$categories, &$options) {
    +      $options['path']['value'] .= ' ' . $this->t('(using admin theme)');
    

    In our UI text standard, "Using" should be capitalized here.

  3. +++ b/core/modules/views/src/Plugin/views/display/Page.php
    @@ -430,6 +435,14 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    +          '#title' => $this->t('Enforce this page to be displayed in the admin theme'),
    

    This is a lot of words for the checkbox value. I think we could just change this title to "Always use admin theme" for better readability.

  4. +++ b/core/modules/views/src/Plugin/views/display/Page.php
    @@ -430,6 +435,14 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    +          '#description' => $this->t('Paths starting with /admin/ are always shown in the admin theme. If checked, pages on other paths are shown in the admin theme as well.'),
    

    I would reduce this text to "Paths starting with /admin/ use the admin theme even when this is not set."

xjm’s picture

Issue summary: View changes
StatusFileSize
new115.09 KB

claudiu.cristea’s picture

Assigned: Unassigned » claudiu.cristea
claudiu.cristea’s picture

Assigned: claudiu.cristea » Unassigned
Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new7.96 KB
new7.03 KB
new7.21 KB
new98.24 KB
new155.06 KB

Implemented #48, #49. The usability review was done already in #15 but let's see a new review based on the last changes.

Change notice adapted.

claudiu.cristea’s picture

Issue summary: View changes

Updated IS to reflect latest changes.

claudiu.cristea’s picture

Assigned: Unassigned » lendude

@Lendude, could you, please, review again? Thank you.

lendude’s picture

Assigned: lendude » Unassigned

@claudiu.cristea sure!

All feedback from #48/#49 has been addressed. From a code standpoint this is RTBC again.

But I agree we need the usability review for the current proposed changed before moving forward. So leaving at 'needs review' for that.

pfrenssen’s picture

Issue summary: View changes
Status: Needs review » Needs work
Issue tags: -Needs usability review

I did a usability review wearing my site builder hat.

  1. ✓ The UI is placed in a location which makes sense. I immediately found it where I expected it to be.
  2. ✓ I find it user friendly that the overview shows that my path is going to be shown in the admin theme. I can easily see this at a glance without having to open the UI. I noticed that the path is shortened with an ellipsis to make room for the "Using admin theme" text, but this doesn't bother me at all. I can still see the start of the path and this gives me enough confidence that the page is actually using a path, and that I can open it to verify the full path in case I need to verify the path or change it. The path is not something that changes often so I trust it.
  3. ✖ I am confused by the wording "Always use admin theme". Does this mean that when this is checked that the admin theme is "always" used, but when it is unchecked it is "sometimes" used? I interpret this as "maybe it is used, maybe not?". It would be clearer to me if this said "Display page using admin theme" or "Use the admin theme" instead.
  4. ✖ The description helps to clarify it but, depending on my experience level, the example path might be a source of confusion. It currently is "/admin/" (without quotes) which starts with a slash. However the other examples do not start with a slash. Am I supposed to prefix the paths with a slash or not? It would be clearer if this did not start with a slash and was enclosed in quotes.
  5. ✖ Lastly, I think the description would be even clearer if the ending "even when this is not set." was replaced with "even when this option is not checked."
kristiaanvandeneynde’s picture

Fair points Pieter, thanks for the review.

Re .3: The checkbox used to say "Enforce this page to be displayed in the admin theme", but that was changed to the current label following #49.3. A final version that everyone can agree upon would be nice :)

claudiu.cristea’s picture

Status: Needs work » Reviewed & tested by the community

Thank you, @pfrenssen, for review.

As the code has been reviewed in #55, let's discuss #56.3, 4 and 5:

  • #56.3: I see Pieter's concerns but, as he admits, this point is clarified in #56.4. As a recap of all the options, before "Always use admin theme" these labels were used:
    1. "Use admin theme" was proposed in the original patch. This was dropped because, as @dawehner pointed out: (quoting) its (...) a bit confusing, because the user might think that they can disable the admin theme via the UI, but well, they can't. The alternatives proposed by @pfrenssen, in #56.3 ("Display page using admin theme" or "Use the admin theme") have exactly the same meaning.
    2. "Enforce this page to be displayed in the admin theme" was proposed by @fago in #32 in order to solve the point raised by @dawehner.
    3. "Always use admin theme" (current patch) is a softer version, proposed by @xjm in #49 because the word "enforce" (quoting) has undesirable connotations.

    So, we are at "Always use admin theme" as result of a process. Anyway, as the description gives details, I think we can keep it as it is.

  • #56.4: I removed the slash prefixing and surrounded with double quotes. However, looking to other examples, I see that usage of quotes is not so consistent.
  • #56.5: Agree and fixed.

Now as we already have the RTBC for the technical solution and code in #55 and because we have already the usability review made two times, I'm switching this to RTBC (as per #55).

claudiu.cristea’s picture

StatusFileSize
new7.04 KB
new857 bytes

Sorry, forgot the patch :)

xjm’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Needs review
Issue tags: +Needs usability review
StatusFileSize
new53.17 KB
new9.87 KB

Thanks everyone. The usability review in #15 wasn't based on the latest version of the patch. Since @pfrenssen had other suggestions about the strings, let's get another usability review now.

The other screenshots were kind of small, so I added these:

benjifisher’s picture

Status: Needs review » Needs work

We reviewed this on the weekly UX meeting.

We had several questions. As usual, we did not have time to review all the comments, so some of these may already have been discussed.

Discoverability

If a site administrator does not know where to look for it, then this checkbox is hard to find. Often, the administrator sets the path when first creating the view. Then there is no reason to edit it later, exposing this option.

It would be easier to find this option if it were added as one of the Page settings: Path, Menu, Access, and ... Admin? Clicking on the new option would bring up a page or modal with a more complete explanation.

Other effects

The path works by setting the _admin_route option on the route. This is checked by AdminContext::isAdminRoute(), which has effects other than setting the theme. For example, quickedit_page_attachments() will not enable in-place editing for an admin page.

So, is this issue about creating "admin pages" or is it about using the admin theme? If it is about "admin pages", then we need to be clearer about the effect of selecting the option. If it is about using a different theme, then why not present a choice of all enabled themes (as well as "site default" and "admin theme")? Either way, you can make good use of the extra space you get by making this a separate option under Page settings.

yoroy’s picture

Status: Needs work » Needs review
StatusFileSize
new52.47 KB

Something like this:

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

xjm’s picture

Issue tags: -8.5.0 release notes
claudiu.cristea’s picture

StatusFileSize
new7.19 KB

Simple reroll of #59 for 8.5.x.

#61 and #62 still not addressed.

daniel korte’s picture

StatusFileSize
new7.09 KB

Reroll

Status: Needs review » Needs work

The last submitted patch, 66: 2719797-66.patch, failed testing. View results

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

claudiu.cristea’s picture

Issue summary: View changes
Status: Needs work » Needs review
Issue tags: -Needs usability review
StatusFileSize
new7.31 KB
new129.4 KB
new172.77 KB
new3.26 KB

I've implemented the usability team review recommendations from #62.

Others:

  • Rerolled for Drupal 8.7.x.
  • Updated the CR to reflect the changes.
  • Updated the IS screenshots.
jidrone’s picture

Hi everyone,

I don't know if I am the only one with the following error when running db updates:
[error] Placeholders must have a trailing [] if they are to be expanded with an array of values.
[error] Update failed: views_post_update_enforce_admin_theme

grayle’s picture

Patch no longer applies to 8.6.4. Assuming that means it also won't apply to 8.7 anymore either.

grayle’s picture

Status: Needs review » Reviewed & tested by the community

Nope, it does still apply. Just some composer weirdness. Nvm.

Also, we've been using it since September and everything works fine.

alexpott’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Needs work
StatusFileSize
new32.99 KB
new40.96 KB
+++ b/core/modules/views/views.post_update.php
@@ -366,3 +366,25 @@ function views_post_update_table_display_cache_max_age(&$sandbox = NULL) {
+  $config_factory = \Drupal::configFactory();
+  foreach ($config_factory->listAll('views.view.') as $name) {
+    $view = $config_factory->getEditable($name);
+    $changed = FALSE;
+    foreach ($view->get('display') as $display_id => $display) {
+      // Deal only with page displays.
+      if ($display['display_plugin'] === 'page') {
+        $trail = "display.$display_id.display_options.always_use_admin_theme";
+        $view->set($trail, FALSE)->save();
+        $changed = TRUE;
+      }
+    }
+    if ($changed) {
+      $view->save();
+    }
+  }

This should use the config entity updater. Does it it need to set the value or can it just do a save and the default value (hopefully FALSE) be completed?

Also manual testing shows me that I'm not sure that the update path is necessary. If I:

  1. Install standard
  2. Apply the patch
  3. Go to a view that has a page display - for example admin/content and change the title of the view and press save
  4. The always_use_admin_theme setting is not set.

It is only set if I invoke the dialogue to make the change. Therefore I think we can skip the update path and rely on the default value. This is also true for new views created via the wizard.

Also we already have a place in core where we can switch between admin and other themes so I think we should use that as inspiration. See the /admin/appearance page - all the way at the bottom:

I think we need to have a checkbox that says "Use administration theme" we also need to add similar text that this will impact who can see the view due to the permission to use the admin theme. Also if the path is set to something like admin/blah this option should be disabled and checked because it will be using the admin theme.

Also the summary label of Admin page: no makes no sense when the page is admin/content because this is clearly an admin page. See screenshot:

I think this page needs a bit more UI work to make it consistent. Also if we do this I think the setting should be use_admin_theme

kristiaanvandeneynde’s picture

This should use the config entity updater. Does it it need to set the value or can it just do a save and the default value (hopefully FALSE) be completed?

If you're simply updating the config,which seems to be the case, I'd say a hook_update_N is in order. If you want to actually use the entity API to save the views, then it should be a post-update hook that saves the entities, like Alex said.

Also manual testing shows me that I'm not sure that the update path is necessary. If I:

  1. Install standard
  2. Apply the patch
  3. Go to a view that has a page display - for example admin/content and change the title of the view and press save
  4. The always_use_admin_theme setting is not set.

It is only set if I invoke the dialogue to make the change. Therefore I think we can skip the update path and rely on the default value. This is also true for new views created via the wizard.

If this is intended, then yeah: You can skip the update path altogether.

On a sidenote: Wouldn't it be cleaner for the key to always be present in the config export, though? Or is that already the case? From your comment above, it seems to be missing when set to FALSE as the default (i.e. UI was not saved).

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

esolitos’s picture

Status: Needs work » Needs review
Issue tags: -Needs backport to D7
StatusFileSize
new5.06 KB
new7.91 KB

Patch rerolled for 8.8.x.

As suggested on #73 I updated the patch to
- use the config name use_admin_theme instead of always_use_admin_theme,
- improved (I hope) some texts to be more consistent with pre-existing options in Drupal
- mark the summary label to "Yes (Forced)" when the display path starts with /admin/...

esolitos’s picture

StatusFileSize
new5.06 KB
new751 bytes

Herg, uploaded a patch with a typo, ignore patch from #76!

fenstrat’s picture

Status: Needs review » Reviewed & tested by the community

#77 is good to go and addresses the feedback from #73. Have manually tested it, and agree that there's no need for an upgrade path.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 77: core-88x--views--admin-path-2719797-77.patch, failed testing. View results

aiphes’s picture

Suscribe to this option, because actually I can't set admin theme for a Views Page (Manage Content page display) for users, the original page is served with admin theme...

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

esolitos’s picture

Status: Needs work » Reviewed & tested by the community
martijn de wit’s picture

Why are you changing the status, if the test failed on the patch.
I think no maintainer wil commit it, if he/she sees a failed test without any explanation.

jungle’s picture

Status: Reviewed & tested by the community » Needs work

Agree with #84

aleevas’s picture

Status: Needs work » Needs review
StatusFileSize
new5.46 KB
new2.35 KB

Fixed failed test and re-rolled onto 9.1 branch

jungle’s picture

Thanks @aleevas!

  1. +++ b/core/modules/views/src/Plugin/views/display/Page.php
    @@ -230,6 +238,30 @@ public function optionsSummary(&$categories, &$options) {
    +    /*
    +     * If the views' dispaly path starts with 'admin/' the page will be
    +     * rendered with the Administration theme regardless of the
    +     * 'use_admin_theme' option.
    +     * Therefore we need to set the summary message to reflect this.
    +     */
    +    $display_path = $this->getOption('path');
    +    if (!empty($display_path) && 0 === stripos($display_path, 'admin/')) {
    

    Should we add a global option to views.settings.yml (/admin/structure/views/settings accordingly) for the 'admin/' thing?, for example:

    [✅] Force using the admin theme if the path starts with [admin/].
    

    Furthermore, what if users want an alternative path to be forced. Such as administration/, guan-li-yuan/ (Guan li yuan in Chinese pinyin means admin), or drupal/admin/

     [✅] Force using the admin theme if the path starts with [drupal/admin/].
    

    So, two config keys might be considered, for example:

    1. force_admin_theme_by_path: (default to TRUE)
    2. force_admin_theme_path: (default to /admin)
  2. +++ b/core/modules/views/src/Plugin/views/display/Page.php
    @@ -230,6 +238,30 @@ public function optionsSummary(&$categories, &$options) {
    +    $display_path = $this->getOption('path');
    +    if (!empty($display_path) && 0 === stripos($display_path, 'admin/')) {
    
    @@ -442,6 +474,14 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    +      case 'use_admin_theme':
    +        $form['use_admin_theme'] = [
    +          '#type' => 'checkbox',
    +          '#title' => $this->t('Use the administration theme'),
    

    Moreover:

    // Pseudocode.
    if (force_admin_theme_by_path === TRUE && $display_path matches $force_admin_theme_path ) {
      THEN, $form['use_admin_theme'] should be DISABLED, instead of telling people that you can check this or not, but whatever you do here won't take any effects.
    }
    
  3. The last, should a hook or event be considered to allow contributed module(s) altering the default start with logic of matching the display path. e.g. what if they want the matching logic be contains string foobar etc.

lendude’s picture

Status: Needs review » Needs work

Thanks everybody for working on this!

#87.1 the forced use for the admin theme on a /admin path doesn't come from Views, so we shouldn't add an option to Views to do that. Even if we want to do that, I'd say this is out of scope for this issue. Same goes for the second option, nice idea, but out of scope here, we can look at that in a follow up.
#87.2 Good idea, lets disable the checkbox on forced paths
#87.3 Also out of scope, we can look at that in a follow up

  1. +++ b/core/modules/views/src/Plugin/views/display/Page.php
    @@ -93,6 +93,13 @@ protected function getRoute($view_id, $display_id) {
    +    // Add the _admin_route option only if use_admin_theme display option
    +    // is TRUE. Otherwise, let other modules or alters to make a decision.
    +    // @see \Drupal\system\EventSubscriber\AdminRouteSubscriber::alterRoutes()
    

    This comment doesn't really add much value, do we need this? Seems pretty obvious that you only set this option when the right setting was set in the View

  2. +++ b/core/modules/views/src/Plugin/views/display/Page.php
    @@ -230,6 +238,30 @@ public function optionsSummary(&$categories, &$options) {
    +    /*
    +     * If the views' dispaly path starts with 'admin/' the page will be
    +     * rendered with the Administration theme regardless of the
    +     * 'use_admin_theme' option.
    +     * Therefore we need to set the summary message to reflect this.
    +     */
    

    "the views' dispaly" can just be "the display".
    I don't think these need to be two sentences, but one.
    For all inline comments (even multi line) we use // not /* */

  3. +++ b/core/modules/views/src/Plugin/views/display/Page.php
    @@ -230,6 +238,30 @@ public function optionsSummary(&$categories, &$options) {
    +    if (!empty($display_path) && 0 === stripos($display_path, 'admin/')) {
    

    0 === stripos is a yoda statement, we try to avoid those for readability

+++ b/core/modules/views/src/Plugin/views/display/Page.php
@@ -230,6 +238,30 @@ public function optionsSummary(&$categories, &$options) {
+    if (!empty($display_path) && 0 === stripos($display_path, 'admin/')) {
+      $admin_theme_text = $this->t("Yes (Forced by path)");
+    }
+    elseif ($this->getOption('use_admin_theme')) {
+      $admin_theme_text = $this->t("Yes");
+    }
+    else {
+      $admin_theme_text = $this->t("No");
+    }

This logic needs test coverage

saurabh-2k17’s picture

Assigned: Unassigned » saurabh-2k17
saurabh-2k17’s picture

Assigned: saurabh-2k17 » Unassigned
Status: Needs work » Needs review
StatusFileSize
new5.22 KB
new1.61 KB

Hi @Lendude,

I have tried fixing your points.

Thanks

jungle’s picture

Status: Needs review » Needs work

Thanks, @Lendude! agreed with your reply to #87.

  1. +++ b/core/modules/views/src/Plugin/views/display/Page.php
    @@ -230,6 +235,28 @@ public function optionsSummary(&$categories, &$options) {
    +    // If the display path starts with 'admin/' the page will be
    +    // rendered with the Administration theme regardless of the
    +    // 'use_admin_theme' option therefore, we need to set the summary message ¶
    +    // to reflect this.    ¶
    

    Thanks @Saurabh_sgh! No exceed 80 chars, great! But wrapped too early, and unexpected tail whitespaces.

  2. #87.2 Good idea, lets disable the checkbox on forced paths

    #87.2 has not been addressed yet.

pavnish’s picture

Assigned: Unassigned » pavnish
pavnish’s picture

Assigned: pavnish » Unassigned
saurabh-2k17’s picture

Assigned: Unassigned » saurabh-2k17
saurabh-2k17’s picture

Assigned: saurabh-2k17 » Unassigned
Status: Needs work » Needs review
StatusFileSize
new5.4 KB
new1.47 KB

Hi @jungle,

I have addressed all your points in this patch.

Thanks

jungle’s picture

Status: Needs review » Needs work

Thank you, @Saurabh_sgh!

  1. +++ b/core/modules/views/src/Plugin/views/display/Page.php
    @@ -230,6 +235,28 @@ public function optionsSummary(&$categories, &$options) {
    +    // If the display path starts with 'admin/' the page will be
    +    // rendered with the Administration theme regardless of the
    

    Should be adjusted further. "rendered with" wrapped too early as well.

  2. +++ b/core/modules/views/config/schema/views.display.schema.yml
    index 3816ee179f..0c2e3a7762 100644
    --- a/core/modules/views/src/Plugin/views/display/Page.php
    
    +++ b/core/modules/views/src/Plugin/views/display/Page.php
    @@ -442,6 +469,18 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    +          '#type' => 'checkbox',
    ...
    +          $form['use_admin_theme']['#attributes'] = array('disabled' => 'disabled');
    

    Meanwhile, it should be auto-checked if the display path starts with admin/

  3. +++ b/core/modules/views/tests/src/Functional/Plugin/DisplayPageWebTest.php
    @@ -152,6 +152,37 @@ public function testPagePaths() {
    +  public function testAdminTheme() {
    

    Needs updating the test to cover the new change.

saurabh-2k17’s picture

Assigned: Unassigned » saurabh-2k17
saurabh-2k17’s picture

Assigned: saurabh-2k17 » Unassigned
Status: Needs work » Needs review
StatusFileSize
new5.75 KB
new1.68 KB

Hi @jungle

I have addressed your point except 96.3, I don't think there is change required in that part. If you still feel change is required, please guide me so that i could change it as per your suggestions.

Thanks

jungle’s picture

Thanks, @Saurabh_sgh! Perhaps, the official doc might help, see PHPUnit in Drupal.

lendude’s picture

  1. +++ b/core/modules/views/src/Plugin/views/display/Page.php
    @@ -224,12 +229,33 @@ public function optionsSummary(&$categories, &$options) {
    +    // This adds a 'Settings' link to the style_options setting if the style has
    +    //  options.
    

    We shouldn't be updating this comment, since it is unrelated to the patch.

  2. +++ b/core/modules/views/src/Plugin/views/display/Page.php
    @@ -224,12 +229,33 @@ public function optionsSummary(&$categories, &$options) {
    +    if (!empty($display_path) && stripos($display_path, 'admin/') === 0) {
    ...
    +    elseif ($this->getOption('use_admin_theme')) {
    ...
    +    else {
    

    And the change we are referring to, is that we need to update the test coverage to cover this if/else piece of logic

jungle’s picture

Thanks @Lendude, +1 to #100.1, did not realize it.

saurabh-2k17’s picture

Assigned: Unassigned » saurabh-2k17
saurabh-2k17’s picture

Assigned: saurabh-2k17 » Unassigned
Ruchi Joshi’s picture

@saurabh-2k17 : Patch#98 is failing on applying it for drupal 9.1. Needs re-roll of the patch.

Ruchi Joshi’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

Moving it to "Needs Work" for patch reroll

snehalgaikwad’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new5.46 KB

Re-rolled the patch and as per #100.1 kept comment as it was before.

Ruchi Joshi’s picture

StatusFileSize
new35.13 KB
new30.94 KB

Patch#106 is not working on drupal 9 as per expectation:
1. Check box should be labelled as "Always use admin theme"
2. Helper text for check box should be "Paths starting with "admin/" use the admin theme even this option is not checked"
3. On checking the box "Use the administration theme", Default theme is not appearing on the page.

Screenshots are attached.

Steps:
1. Visit /admin/structure/views
2. Open view page of any content
3. Click on "Admin page | No" under Page Settings.
4. A dialog box will appear with a checkbox
5. Click on checkbox and then on apply

Ruchi Joshi’s picture

Status: Needs review » Needs work

Moving it to "Needs work" for fixing of issues on comment #107

rajneeshb’s picture

Status: Needs work » Needs review
StatusFileSize
new5.48 KB
new945 bytes

Updated the patch as per #107

Ruchi Joshi’s picture

StatusFileSize
new43.11 KB

Tested patch #109 for the issues mentioned in comment #107. All the issues are covered in this updated patch and working fine. @claudiu.cristea- +1 for RTBC.
Screenshots are attached.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

tanubansal’s picture

#109 working for me as well
RTBC + 1

sulfikar_s’s picture

StatusFileSize
new20.78 KB
new26.8 KB
new5.47 KB
new17.52 KB
new1.5 KB

I've tested the patch in #109. It applied cleanly but I found it would be more meaningful when we change the text "even this option is not checked" in,

after-patch-109

to "even when this option is not checked" as said in #56. i.e,

after-patch-109

Also, there are some coding standard issues,

coding-standard-issues

So, I've corrected all of this in my patch. Hereby attaching the patch and interdiff.

Please review. Thanks!

jonathanshaw’s picture

I think we should be cautious about disabling this option on paths that start with /admin. Yes these use the admin theme by default, but modules and sites could customise that behavior.

I'd suggest simply having the description saying something like "By default paths beginning with /admin/ will use the admin theme without regard to this setting.".

le72’s picture

I did try #113 and it is OK.
RTBC + 1

bserem’s picture

RTBC+1 here too. We have it under testing for about a week, we will be deploying to production very very soon.

akalam’s picture

The patch #113 applies and works as expected on a Drupal 9.0.11 site. Great improvement. +1 to RTBC

bserem’s picture

Status: Needs review » Reviewed & tested by the community
catch’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs usability review

The patch no longer applies.

This seems potentially useful, but some of the wording could use some help IMO, tagging for usability review.

+++ b/core/modules/views/src/Plugin/views/display/Page.php
@@ -232,6 +237,27 @@ public function optionsSummary(&$categories, &$options) {
+    $display_path = $this->getOption('path');
+    if (!empty($display_path) && stripos($display_path, 'admin/') === 0) {
+      $admin_theme_text = $this->t("Yes (Forced by path)");
+    }

Can we use something like 'Yes (admin path)' or something instead of 'forced by path'? Definitely adds some complexity having to deal with both cases.

ayushmishra206’s picture

Status: Needs work » Needs review
StatusFileSize
new768 bytes
new5.47 KB

Rerolled for 9.2.x and made the suggested change in #120. Please review.

keopx’s picture

Status: Needs review » Reviewed & tested by the community

Patch #120 works for me (9.1.5)

Thanks!!

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

benjifisher’s picture

Version: 9.3.x-dev » 10.0.x-dev
Status: Reviewed & tested by the community » Needs work

Usability Review

We discussed this issue at #3210553: Drupal Usability Meeting 2021-04-30.

  1. @keopx, an issue should be marked "Reviewed & tested by the community" (RTBC) only when it has been both reviewed and tested. From your comment, it seems that you tested, but you did not say anything about review. In fact, the patch in #120 did not pass automated tests, so we have to set the status back to "Needs work" (NW).

    The message "Custom Commands Failed" usually means that there are problems found in static analysis: spelling errors, coding standards problems, etc. Look at the test results for a full report.

  2. The modal window has the message

    Paths starting with "admin/" use the admin theme even this option is not checked.

    That should be "… even when this option is not checked." The screenshot in the issue summary shows the correct text.

  3. The consensus at the usability meeting was that "Admin page" is misleading. It suggests access restrictions as well as a theme. (As I said in #61, there are some effects other than changing the theme, but access restriction is not one of them.) I have browsed the comments (not read all of them) and I am not sure when the text changes from "Always use admin theme" (as in #49, for example) to "Admin page". Was there a full discussion? I do see discussion in #56-#58, settling on "Always use admin theme".

  4. If a user does not have permission to use the admin theme, then the page will be shown in the site’s default theme. Perhaps the description in the modal window should mention this.

benjifisher’s picture

Version: 10.0.x-dev » 9.3.x-dev

The change to 10.0.x was a gllitch. Back to 9.3.x. See #3211455: Bulk updates for the 9.2.x release cycle.

swentel’s picture

Status: Needs work » Needs review
StatusFileSize
new5.54 KB
new1.34 KB

New patch with subtle changes:

  • Added 'Administration theme' to the title of the popup - it otherwise just said 'Page:'
  • Change 'Admin page' to 'Admin theme', that makes more sense indeed.
  • Fix the description adding 'when'

I don't have any other strong opinions, so if someone decides on the working, let's go ahead :)

swentel’s picture

StatusFileSize
new5.54 KB
new1.43 KB

Fix errors

mitthukumawat’s picture

StatusFileSize
new15.26 KB
new35.15 KB

I have applied and tested the patch #126. it is showing the following changes done as per #125.

  • Added 'Administration theme' to the title of the popup - it otherwise just said 'Page:'
  • Change 'Admin page' to 'Admin theme', that makes more sense indeed.
  • Fix the description adding 'when'
  • Adding screenshots for reference.

    camslice’s picture

    Nice work folks. Patch #126 working well for me.

    heni_deepak’s picture

    This is such a useful and great patch #126. I have applied at my job it is really useful I think I was waiting for it.

    z.stolar’s picture

    Status: Needs review » Reviewed & tested by the community

    FWIW, the patch at #126 is working as expected and does a great service.
    Marking as RTBC to help push this issue forward.

    Version: 9.3.x-dev » 9.4.x-dev

    Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

    Status: Reviewed & tested by the community » Needs work

    The last submitted patch, 126: 2053399-126.patch, failed testing. View results

    jeroent’s picture

    Status: Needs work » Reviewed & tested by the community

    Status: Reviewed & tested by the community » Needs work

    The last submitted patch, 126: 2053399-126.patch, failed testing. View results

    claudiu.cristea’s picture

    Status: Needs work » Reviewed & tested by the community

    Same as #133

    alexpott’s picture

    Status: Reviewed & tested by the community » Needs work

    We need to do a little bit of work to not save the setting if the views path starts with admin/

    Currently if I do this:

    1. Install standard
    2. Export configuration
    3. Visit admin/structure/views/view/user_admin_people
    4. Click on link Admin theme: Yes (admin path)
    5. Press the apply button
    6. Press the save button
    7. Visit http://drupal8alt.test/admin/config/development/configuration

    I'll see that the view has been updated to set use_admin_theme: false which is odd because it will use the admin theme. I think it shouldn't be saving the setting in this case.

    Also if do this:

    1. Install standard
    2. Export configuration
    3. Visit admin/structure/views/view/frontpage
    4. Click on link Admin theme: No
    5. Press the apply button
    6. Press the save button
    7. Visit http://drupal8alt.test/admin/config/development/configuration

    I'll see a new use_admin_theme: false even though I've not really changed anything.

    This brings into question whether we need an update path to add this to all views which leverage a page display. I think it might be best to not set this configuration when it is FALSE. it's not as if we're ever going to change the default behaviour. Not sure.

    pfrenssen’s picture

    StatusFileSize
    new5.54 KB

    Rebased against 9.4.x and opened MR.

    Uploading a patch against 9.3.x. The patch from #126 still applies to 9.2.x.

    Version: 9.4.x-dev » 9.5.x-dev

    Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

    cedewey’s picture

    Status: Needs work » Needs review

    I tested this patch and it worked for me in Drupal 9.2.12

    heni_deepak’s picture

    need to be update with drupal dev version
    ->set('admin', 'seven')
    Drupal >= 9.4 admin theme is Claro

    gayatri chahar’s picture

    StatusFileSize
    new1.59 MB
    new1.83 MB

    I have successfully applied patch #137 on drupal 9.2.22-dev and its working for me
    Thanks @pfrenssen. Adding screenshots for the refrence

    smustgrave’s picture

    Status: Needs review » Needs work

    Moving to NW for
    Can we get a tests-only patch with the full path also please to verify the tests work.
    #141 needs to be addressed
    And Bug found in last bullet of testing.

    Manually tested

    • Patch applies
    • Cloned the content view.
    • Changed URL to /test
    • Verified page rendered with front end theme
    • Updated view with checking new setting to use admin theme
    • Verified page rendered with admin theme.
    • Changed URL to /admin/test
    • Verified checkbox is auto checked.
    • Verified page rendered with admin theme.
    • BUG: The URL of the page is now just /admin vs /admin/test

    No more screenshots are needed.

    smustgrave’s picture

    Status: Needs work » Needs review
    StatusFileSize
    new1.59 KB
    new1.92 KB
    new5.54 KB

    Updated for #141.
    Uploaded tests only patch

    The bug mentioned above "BUG: The URL of the page is now just /admin vs /admin/test" may not actually be an issue it seems.

    The last submitted patch, 144: 2719797-144-tests-only.patch, failed testing. View results

    heni_deepak’s picture

    looks like working for me. :D

    heni_deepak’s picture

    StatusFileSize
    new146.99 KB

    I have added a Test page view

    The admin theme working on both URL

    admin/test and test

    can restrict if don't change URL with admin/?

    heni_deepak’s picture

    Status: Needs review » Reviewed & tested by the community
    adam_y’s picture

    alexpott’s picture

    Status: Reviewed & tested by the community » Needs work

    #136 is still not addressed.

    Version: 9.5.x-dev » 10.1.x-dev

    Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

    scotwith1t’s picture

    #144 no longer applies to Drupal 9.4.8, needs a re-roll

    nitin shrivastava’s picture

    Category: Feature request » Bug report
    Status: Needs work » Needs review
    StatusFileSize
    new5.61 KB

    Created patch for 9.4.x by considering the comment of #152. Please review this patch and move it

    anchal_gupta’s picture

    StatusFileSize
    new5.57 KB
    new2.96 KB

    Fixed CS error.

    Ratan Priya’s picture

    StatusFileSize
    new575 bytes
    new5.58 KB

    Fixed failed custom command for comment #154.

    Status: Needs review » Needs work

    The last submitted patch, 155: 2719797-155.patch, failed testing. View results

    smustgrave’s picture

    Removing credit for #153, #154, #155.

    Patch #144 still applies cleanly to 9.5.x and 10.1.x so the follow up was not needed.

    Will look into #136

    smustgrave’s picture

    Status: Needs work » Needs review
    StatusFileSize
    new895 bytes
    new5.56 KB

    @alexpott regarding #136 this something like you meant?

    gaurav-mathur’s picture

    StatusFileSize
    new48.64 KB
    new74.91 KB

    Applied patch #158 on drupal version 10.1.x-dev successfully and working fine.
    Refer to screenshot.
    Thank you

    hitchshock’s picture

    Great patch to avoid custom hacking, now we can easily apply admin theme.
    +1 RTBC

    mlncn’s picture

    Status: Needs review » Reviewed & tested by the community

    Works beautifully and addresses concern in #136 of unneeded noise in config files while still keeping code pretty straightforward.

    quietone’s picture

    Category: Bug report » Feature request
    Issue summary: View changes
    Status: Reviewed & tested by the community » Needs work
    Issue tags: +Needs screenshots

    @mlncn, thanks for checking that #136 is addressed (I have not confirmed that) but this is tagged for a usability review which means this is not ready for RTBC.

    I found the latest review was done in May 2021 (#123). Have all those points been addressed? The screenshots in the Issue Summary are from 2018, so they need to be updated.

    In #153, this was changed from a Feature Request to a Bug without explanation. I do not see any reference to this change in earlier comments. I am restoring the category of Feature Request.

    quietone’s picture

    The change records also has out of date screenshots. I did not read the text of the change record.

    smustgrave’s picture

    Issue summary: View changes
    Status: Needs work » Needs review
    Issue tags: -Needs screenshots, -Needs change record updates
    StatusFileSize
    new47.61 KB
    new74.62 KB
    new52.27 KB

    Updated screenshots here and on CR.

    rtdean93’s picture

    2719797-158.patch worked perfectly for me on 9.4.8. Thanks.

    nicolas bouteille’s picture

    Same for me thanks!

    smustgrave’s picture

    Status: Needs review » Reviewed & tested by the community

    Putting back to RTBC from #161 as there was no code change.

    Status: Reviewed & tested by the community » Needs work

    The last submitted patch, 158: 2719797-158.patch, failed testing. View results

    arunkumark’s picture

    Status: Needs work » Reviewed & tested by the community
    StatusFileSize
    new244.55 KB
    new325.69 KB

    Tested the patch manually with Drupal core 10.1.x. The patch was applied cleanly and was able to use the option of the Admin theme. Attached screenshot for reference.

    Admin theme

    Admin theme

    Moving the status to RTBC.

    lauriii’s picture

    Status: Reviewed & tested by the community » Needs work
    Issue tags: -Needs usability review

    This has received multiple iterations of Usability review. All of the feedback has been addressed except explaining what other consequences there are from marking a page as admin page. The example provided there was Quickedit, which has been removed from core. I believe this might be outdated and therefore I'm not opening a follow-up issue for this.

    1. +++ b/core/modules/views/config/schema/views.display.schema.yml
      @@ -68,6 +68,9 @@ views.display.page:
      +    use_admin_theme:
      +      type: boolean
      +      label: 'Use the administration theme when rendering the view page'
      

      Since this is no longer a required property, it should be marked as nullable.

    2. +++ b/core/modules/views/src/Plugin/views/display/Page.php
      @@ -244,6 +248,27 @@ public function optionsSummary(&$categories, &$options) {
      +      $admin_theme_text = $this->t("Yes (admin path)");
      ...
      +      $admin_theme_text = $this->t("Yes");
      ...
      +      $admin_theme_text = $this->t("No");
      

      Super nit: s/"/'

    3. +++ b/core/modules/views/src/Plugin/views/display/Page.php
      @@ -244,6 +248,27 @@ public function optionsSummary(&$categories, &$options) {
      +      'title' => $this->t('Admin theme'),
      ...
      +      'desc' => $this->t('Use the administration theme when rendering this display.'),
      
      @@ -445,6 +470,21 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
      +          '#description' => $this->t('Paths starting with "admin/" use the admin theme even when this option is not checked.'),
      

      We should use the term "administration theme" consistently across all of these strings instead of "admin theme"

    4. +++ b/core/modules/views/src/Plugin/views/display/Page.php
      @@ -445,6 +470,21 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
      +          '#title' => $this->t('Always use admin theme'),
      

      We are missing the before admin theme.

    lauriii’s picture

    Status: Needs work » Needs review
    StatusFileSize
    new9.09 KB
    new6.1 KB

    Addressed my feedback and added some more test coverage for the UI.

    smustgrave’s picture

    Status: Needs review » Reviewed & tested by the community
    Issue tags: +Needs Review Queue Initiative

    New changes look good.

    I ran the new test locally too to make sure it failed

    Behat\Mink\Exception\ResponseTextException : The text "Administration theme: No" was not found anywhere in the text of the current page.

    Excited for this new feature.

    alexpott’s picture

    Status: Reviewed & tested by the community » Needs work
    +++ b/core/modules/views/src/Plugin/views/display/Page.php
    @@ -445,6 +470,21 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    +        $form['use_admin_theme'] = [
    +          '#type' => 'checkbox',
    +          '#title' => $this->t('Always use the administration theme'),
    +          '#description' => $this->t('Paths starting with "admin/" use the administration theme even when this option is not checked.'),
    +          '#default_value' => $this->getOption('use_admin_theme'),
    +        ];
    +        $display_path = $this->getOption('path');
    +        if (!empty($display_path) && stripos($display_path, 'admin/') === 0) {
    +          $form['use_admin_theme']['#default_value'] = TRUE;
    +          $form['use_admin_theme']['#attributes'] = ['disabled' => 'disabled'];
    +        }
    +        break;
    

    The use of "Always" here was question by @pfrenssen in #56 and sent back for usability review but the UX review in #61 did not actually address this - it made other recommendations. I think the "always" perhaps was more relevant when this was in the path setting dialog.

    Furthermore the description is odd because it says Paths starting with "admin/" use the administration theme even when this option is not checked but we have code below disabling and setting the field to TRUE when the path starts with admin so it will never be not set.

    I think we should change this code element to:

            $form['use_admin_theme'] = [
              '#type' => 'checkbox',
              '#title' => $this->t('Use the administration theme'),
              '#default_value' => $this->getOption('use_admin_theme'),
            ];
            if (str_starts_with($this->getOption('path') ?? '', 'admin/')) {
              $form['use_admin_theme']['#description'] = $this->t('Paths starting with "admin/" always use the administration theme.');
              $form['use_admin_theme']['#default_value'] = TRUE;
              $form['use_admin_theme']['#attributes'] = ['disabled' => 'disabled'];
            }
    
    rishabh vishwakarma’s picture

    Status: Needs work » Needs review
    StatusFileSize
    new9.8 KB
    new1.8 KB

    Updated as described in #173

    smustgrave’s picture

    Status: Needs review » Needs work
    akram khan’s picture

    StatusFileSize
    new14.46 KB
    new6.15 KB

    added updated patch fixed CCF #174

    akram khan’s picture

    Status: Needs work » Needs review
    smustgrave’s picture

    Status: Needs review » Reviewed & tested by the community

    @catch think your points have been addressed.

    jungle’s picture

    Status: Reviewed & tested by the community » Needs review
    +++ b/core/modules/views/src/Plugin/views/display/Page.php
    @@ -244,6 +251,27 @@ public function optionsSummary(&$categories, &$options) {
    +    if (!empty($display_path) && stripos($display_path, 'admin/') === 0) {
    
    @@ -445,6 +482,24 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    +        if (str_starts_with($this->getOption('path') ?? '', 'admin/')) {
    

    I think the path should be case-insensitive. eg, admin/, Admin/ or ADMIN/ etc. should use the administration theme automatically. So str_starts_with should be replaced with stripos above. And we need to add a test for this.

    NR for agreement.

    dww’s picture

    Status: Needs review » Needs work

    So excited this is so close to being done! Thanks to everyone who has moved it forward.

    Alas #176 introduced a ton of irrelevant whitespace changes, and undesirable capitalization changes. Un-saving "credit" for the anti-contribution.

    And #174 did some things to #171 that were not requested in #173 (like removing the #title of the form itself).

    I think we need to go back to the patch in #171, and carefully re-address #173 only.

    I'm a bit torn on #179, but yeah, we should probably fix that, too. 😅

    dww’s picture

    Status: Needs work » Needs review
    StatusFileSize
    new8.99 KB
    new1.21 KB

    Here's exactly #171 with only the suggested changes in #173. I'm leaving #179 out of it for now.

    lauriii’s picture

    Status: Needs review » Needs work
    +++ b/core/modules/views/src/Plugin/views/display/Page.php
    @@ -244,6 +248,27 @@ public function optionsSummary(&$categories, &$options) {
    +    if (!empty($display_path) && stripos($display_path, 'admin/') === 0) {
    

    I think str_starts_with is better because it's consistent with \Drupal\system\EventSubscriber\AdminRouteSubscriber::alterRoutes. Can we change this too to use str_starts_with?

    dww’s picture

    Assigned: Unassigned » dww
    StatusFileSize
    new2.36 KB

    Okay, thanks for clarifying. I was about to post test-only and full to address #179 but d.o flagged it as a x-post that you had already changed the status. 😅 I'll remove the remaining stripos().

    dww’s picture

    Assigned: dww » Unassigned
    Status: Needs work » Needs review
    StatusFileSize
    new8.88 KB
    new2.11 KB

    Fixes #182 (and the ?? improvement suggested for a similar code block in #173) and now core/scripts/dev/commit-code-check.sh --cached is passing. 😅

    dww’s picture

    (Side note: Did something with d.o CI change in the last 3 days, or does the bot not run the same checks for core committer patches as it does for the rest of us? 😂 @lauriii's patch in #171 has all the same CS bugs as #181, but the testbot flagged mine and wouldn't even test it, but ran the whole test suite for 171... weird)

    dww’s picture

    Assigned: Unassigned » dww
    Status: Needs review » Needs work
    1. +++ b/core/modules/views/src/Plugin/views/display/Page.php
      @@ -445,6 +469,20 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
      +          $form['use_admin_theme']['#description'] = $this->t('Paths starting with "admin/" always use the administration theme.');
      

      Just noticed a possible minor nit:

      The code here is totally hard-coded. Do we want to let translators potentially change this? In some other UI strings, I've seen placeholders used to ensure that the path output is always what core wants. Do we care?

    2. +++ b/core/modules/views/tests/src/Functional/Plugin/DisplayPageWebTest.php
      @@ -148,6 +148,37 @@ public function testPagePaths() {
      +  public function testAdminTheme() {
      

      Oh, and more uber-nit, doesn't this want : void?

    3. +++ b/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php
      @@ -286,4 +288,56 @@ public function testDefaultMenuTabRegression() {
      +   * Tests the "Always use the administration theme" configuration.
      

      That's not what the UI label is, anymore... 😅

    I'll clean up 2 and 3 while waiting for feedback on 1.

    dww’s picture

    Assigned: dww » Unassigned
    Status: Needs work » Needs review
    StatusFileSize
    new8.88 KB
    new1.17 KB

    Fixes #186 points 2 and 3 for now. Maybe point 1 isn't real.

    dww’s picture

    StatusFileSize
    new8.87 KB
    new587 bytes

    Argh, sorry for the noise! I spotted one more "Always" we don't want.

    lauriii’s picture

    @dww IMO providing a placeholder for the "admin/" part would be great! 👍

    dww’s picture

    StatusFileSize
    new8.9 KB
    new854 bytes

    Cool, then this fixes #186.1. Anything else? Thanks! 🙏

    lauriii’s picture

    Status: Needs review » Reviewed & tested by the community

    Looks great! Thank you @dww!

    dww’s picture

    Great, thanks! Fixed the summary and screenshots to reflect the current patch.

    However, I noticed the draft CR is stale, with stale screenshots, "Always", etc. But it's almost 1am here now, so I'm just going to add the tag and hope someone else can handle that. ;)

    Thanks again, excited to see this almost in core! 🎉🙏
    -Derek

    dww’s picture

    Issue summary: View changes

    Hiding obsolete files and updating remaining tasks.

    alexpott’s picture

    Status: Reviewed & tested by the community » Fixed

    Committed 4dbf3f4 and pushed to 10.1.x. Thanks!

    Hopefully got the issue credit correct. I credited everyone who provided screenshots of the feature because it was hard to decide whose screenshots where useful and whose where not.

    • alexpott committed 4dbf3f46 on 10.1.x
      Issue #2719797 by claudiu.cristea, dww, pfrenssen, smustgrave, saurabh-...
    longwave’s picture

    z.stolar’s picture

    Sing Halleluyah!!!!

    quietone’s picture

    Status: Fixed » Needs review

    This is tagged for change record improvements. I have updated the CR and setting to NR for someone to check that changes.

    lauriii’s picture

    Status: Needs review » Fixed
    Issue tags: -Needs change record updates

    The updated change record looks good! I removed the paragraph about the location of the config since that didn't seem critical to most users.

    Status: Fixed » Closed (fixed)

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

    saurabh-2k17’s picture

    Version: 10.1.x-dev » 9.5.x-dev
    StatusFileSize
    new5.72 KB

    I am attaching a working patch for this issue.