summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2016-03-07 16:36:05 (GMT)
committerAlex Pott2016-03-07 16:36:05 (GMT)
commita888a694fe9d3d83b8127dc376093e23149ccf32 (patch)
tree1ba663ef65f351bce8fdbc853cca0de4e72a410f
parentc6e1b96008619781a91b6cdd083c6fa0f40093db (diff)
Issue #1836384 by Lendude, pguillard, dawehner, damiankloip, hynnot, tadityar, anil280988, jain_deepak, gaurav_varshney: The views UI should display "All Displays" option only when there are more 1 displays
-rw-r--r--core/modules/views/src/Tests/Plugin/PagerTest.php5
-rw-r--r--core/modules/views_ui/admin.inc6
-rw-r--r--core/modules/views_ui/src/Tests/DisplayTest.php28
3 files changed, 37 insertions, 2 deletions
diff --git a/core/modules/views/src/Tests/Plugin/PagerTest.php b/core/modules/views/src/Tests/Plugin/PagerTest.php
index bdd95ed..a4f2f42 100644
--- a/core/modules/views/src/Tests/Plugin/PagerTest.php
+++ b/core/modules/views/src/Tests/Plugin/PagerTest.php
@@ -47,6 +47,9 @@ class PagerTest extends PluginTestBase {
* @see https://www.drupal.org/node/652712
*/
public function testStorePagerSettings() {
+ // Show the master display so the override selection is shown.
+ \Drupal::configFactory()->getEditable('views.settings')->set('ui.show.master_display', TRUE)->save();
+
$admin_user = $this->drupalCreateUser(array('administer views', 'administer site configuration'));
$this->drupalLogin($admin_user);
// Test behavior described in
@@ -106,7 +109,7 @@ class PagerTest extends PluginTestBase {
'pager[type]' => 'mini',
);
$this->drupalPostForm('admin/structure/views/nojs/display/test_store_pager_settings/page_1/pager', $edit, t('Apply'));
- $this->drupalGet('admin/structure/views/view/test_store_pager_settings/edit');
+ $this->drupalGet('admin/structure/views/view/test_store_pager_settings/edit/page_1');
$this->assertText('Mini', 'Changed pager plugin, should change some text');
$edit = array(
diff --git a/core/modules/views_ui/admin.inc b/core/modules/views_ui/admin.inc
index 01bcf7a..fd031d2 100644
--- a/core/modules/views_ui/admin.inc
+++ b/core/modules/views_ui/admin.inc
@@ -226,7 +226,11 @@ function views_ui_standard_display_dropdown(&$form, FormStateInterface $form_sta
$form['progress']['#weight'] = -1001;
}
- if ($current_display->isDefaultDisplay()) {
+ // The dropdown should not be added when :
+ // - this is the default display.
+ // - there is no master shown and just one additional display (mostly page)
+ // and the current display is defaulted.
+ if ($current_display->isDefaultDisplay() || ($current_display->isDefaulted($section) && !\Drupal::config('views.settings')->get('ui.show.master_display') && count($displays) <= 2)) {
return;
}
diff --git a/core/modules/views_ui/src/Tests/DisplayTest.php b/core/modules/views_ui/src/Tests/DisplayTest.php
index 1948e63..7c3eb7a 100644
--- a/core/modules/views_ui/src/Tests/DisplayTest.php
+++ b/core/modules/views_ui/src/Tests/DisplayTest.php
@@ -305,4 +305,32 @@ class DisplayTest extends UITestBase {
$this->assertNoRaw($display_title);
}
+ /**
+ * Tests that the override option is hidden when it's not needed.
+ */
+ public function testHideDisplayOverride() {
+ // Test that the override option appears with two displays.
+ $this->drupalGet('admin/structure/views/nojs/handler/test_display/page_1/field/title');
+ $this->assertText('All displays');
+
+ // Remove a display and test if the override option is hidden.
+ $this->drupalPostForm('admin/structure/views/view/test_display/edit/block_1', [], t('Delete @display', ['@display' => 'Block']));
+ $this->drupalPostForm(NULL, [], t('Save'));
+
+ $this->drupalGet('admin/structure/views/nojs/handler/test_display/page_1/field/title');
+ $this->assertNoText('All displays');
+
+ // Test that the override option is shown when display master is on.
+ \Drupal::configFactory()->getEditable('views.settings')->set('ui.show.master_display', TRUE)->save();
+ $this->drupalGet('admin/structure/views/nojs/handler/test_display/page_1/field/title');
+ $this->assertText('All displays');
+
+ // Test that the override option is shown if the current display is
+ // overridden so that the option to revert is available.
+ $this->drupalPostForm(NULL, ['override[dropdown]' => 'page_1'], t('Apply'));
+ \Drupal::configFactory()->getEditable('views.settings')->set('ui.show.master_display', FALSE)->save();
+ $this->drupalGet('admin/structure/views/nojs/handler/test_display/page_1/field/title');
+ $this->assertText('Revert to default');
+ }
+
}