diff -u b/core/modules/views/config/schema/views.display.schema.yml b/core/modules/views/config/schema/views.display.schema.yml --- b/core/modules/views/config/schema/views.display.schema.yml +++ b/core/modules/views/config/schema/views.display.schema.yml @@ -70,6 +70,7 @@ label: 'Menu name' use_admin_theme: type: boolean + nullable: true label: 'Use the administration theme when rendering the view page' views.display.block: diff -u b/core/modules/views/src/Plugin/views/display/Page.php b/core/modules/views/src/Plugin/views/display/Page.php --- b/core/modules/views/src/Plugin/views/display/Page.php +++ b/core/modules/views/src/Plugin/views/display/Page.php @@ -254,18 +254,18 @@ // therefore, we need to set the summary message to reflect this. $display_path = $this->getOption('path'); if (!empty($display_path) && stripos($display_path, 'admin/') === 0) { - $admin_theme_text = $this->t("Yes (admin path)"); + $admin_theme_text = $this->t('Yes (admin path)'); } elseif ($this->getOption('use_admin_theme')) { - $admin_theme_text = $this->t("Yes"); + $admin_theme_text = $this->t('Yes'); } else { - $admin_theme_text = $this->t("No"); + $admin_theme_text = $this->t('No'); } $options['use_admin_theme'] = [ 'category' => 'page', - 'title' => $this->t('Admin theme'), + 'title' => $this->t('Administration theme'), 'value' => $admin_theme_text, 'desc' => $this->t('Use the administration theme when rendering this display.'), ]; @@ -475,8 +475,8 @@ $form['#title'] .= $this->t('Administration theme'); $form['use_admin_theme'] = [ '#type' => 'checkbox', - '#title' => $this->t('Always use admin theme'), - '#description' => $this->t('Paths starting with "admin/" use the admin theme even when this option is not checked.'), + '#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'); diff -u b/core/modules/views/tests/src/Functional/Plugin/DisplayPageWebTest.php b/core/modules/views/tests/src/Functional/Plugin/DisplayPageWebTest.php --- b/core/modules/views/tests/src/Functional/Plugin/DisplayPageWebTest.php +++ b/core/modules/views/tests/src/Functional/Plugin/DisplayPageWebTest.php @@ -148,7 +148,7 @@ } /** - * Tests the 'admin_theme' page display option. + * Tests the 'use_admin_theme' page display option. */ public function testAdminTheme() { $account = $this->drupalCreateUser(['view the administration theme']); only in patch2: unchanged: --- a/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php +++ b/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php @@ -4,7 +4,9 @@ use Drupal\Core\Menu\MenuTreeParameters; use Drupal\menu_link_content\Entity\MenuLinkContent; +use Drupal\Tests\SchemaCheckTestTrait; use Drupal\Tests\system\Functional\Cache\AssertPageCacheContextsAndTagsTrait; +use Drupal\views\Entity\View; /** * Tests the UI of generic display path plugin. @@ -15,6 +17,7 @@ class DisplayPathTest extends UITestBase { use AssertPageCacheContextsAndTagsTrait; + use SchemaCheckTestTrait; /** * {@inheritdoc} @@ -286,4 +289,56 @@ public function testDefaultMenuTabRegression() { $this->assertSession()->statusCodeEquals(200); } + /** + * Tests the "Always use the administration theme" configuration. + * + * @see \Drupal\Tests\views\Functional\Plugin\DisplayPageWebTest::testAdminTheme + */ + function testAlwaysAdminTheme() { + $this->drupalGet('admin/structure/views/view/test_view'); + + // Add a new page display. + $this->submitForm([], 'Add Page'); + $this->assertSession()->pageTextContains('No path is set'); + $this->assertSession()->pageTextContains('Administration theme: No'); + + // Test with a path starting with "/admin". + $admin_path = 'admin/test_admin_path'; + $this->drupalGet('admin/structure/views/nojs/display/test_view/page_1/path'); + $this->submitForm(['path' => $admin_path], 'Apply'); + $this->assertSession()->pageTextContains('/' . $admin_path); + $this->assertSession()->pageTextContains('Administration theme: Yes (admin path)'); + $this->submitForm([], 'Save'); + + $this->assertConfigSchemaByName('views.view.test_view'); + $display_options = $this->config('views.view.test_view')->get('display.page_1.display_options'); + $this->assertArrayNotHasKey('use_admin_theme', $display_options); + + $this->drupalGet('admin/structure/views/nojs/display/test_view/page_1/use_admin_theme'); + $this->assertSession()->elementExists('css','input[name="use_admin_theme"][disabled="disabled"][checked="checked"]'); + + // Test with a non-administration path. + $non_admin_path = 'kittens'; + $this->drupalGet('admin/structure/views/nojs/display/test_view/page_1/path'); + $this->submitForm(['path' => $non_admin_path], 'Apply'); + $this->assertSession()->pageTextContains('/' . $non_admin_path); + $this->assertSession()->pageTextContains('Administration theme: No'); + $this->submitForm([], 'Save'); + + $this->assertConfigSchemaByName('views.view.test_view'); + $display_options = $this->config('views.view.test_view')->get('display.page_1.display_options'); + $this->assertArrayNotHasKey('use_admin_theme', $display_options); + + // Enable administration theme. + $this->drupalGet('admin/structure/views/nojs/display/test_view/page_1/use_admin_theme'); + $this->submitForm(['use_admin_theme' => TRUE], 'Apply'); + $this->assertSession()->pageTextContains('Administration theme: Yes'); + $this->submitForm([], 'Save'); + + $this->assertConfigSchemaByName('views.view.test_view'); + $display_options = $this->config('views.view.test_view')->get('display.page_1.display_options'); + $this->assertArrayHasKey('use_admin_theme', $display_options); + $this->assertTrue($display_options['use_admin_theme']); + } + }