diff --git a/core/modules/views/lib/Drupal/views/Tests/UI/DefaultViewsTest.php b/core/modules/views/lib/Drupal/views/Tests/UI/DefaultViewsTest.php index a274311f1bf..590bc6ef937 100644 --- a/core/modules/views/lib/Drupal/views/Tests/UI/DefaultViewsTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/UI/DefaultViewsTest.php @@ -115,6 +115,37 @@ class DefaultViewsTest extends UITestBase { $this->assertNoLinkByHref($edit_href); } + /** + * Tests that enabling views moves them to the correct table. + */ + function testSplitListing() { + // Build a re-usable xpath query. + $xpath = '//div[@id="views-entity-list"]/div[@class = :status]/table//tr[@title = :title]'; + $arguments = array( + ':status' => 'views-list-section enabled', + ':title' => t('Machine name: test_view_status'), + ); + + $this->drupalGet('admin/structure/views'); + + $elements = $this->xpath($xpath, $arguments); + $this->assertIdentical(count($elements), 0, 'A disabled view is not found in the enabled views table.'); + + $arguments[':status'] = 'views-list-section disabled'; + $elements = $this->xpath($xpath, $arguments); + $this->assertIdentical(count($elements), 1, 'A disabled view is found in the disabled views table.'); + + // Enable the view. + $this->clickViewsOperationLink(t('Enable'), '/test_view_status/'); + + $elements = $this->xpath($xpath, $arguments); + $this->assertIdentical(count($elements), 0, 'After enabling a view, it is not found in the disabled views table.'); + + $arguments[':status'] = 'views-list-section enabled'; + $elements = $this->xpath($xpath, $arguments); + $this->assertIdentical(count($elements), 1, 'After enabling a view, it is found in the enabled views table.'); + } + /** * Click a link to perform an operation on a view. * diff --git a/core/modules/views/views_ui/css/views-admin.theme.css b/core/modules/views/views_ui/css/views-admin.theme.css index d309edc489b..a565b473ca6 100644 --- a/core/modules/views/views_ui/css/views-admin.theme.css +++ b/core/modules/views/views_ui/css/views-admin.theme.css @@ -1158,3 +1158,7 @@ div.messages { } /* @end */ + +.views-list-section { + margin-bottom: 2em; +} diff --git a/core/modules/views/views_ui/lib/Drupal/views_ui/ViewListController.php b/core/modules/views/views_ui/lib/Drupal/views_ui/ViewListController.php index a3e2bea4c22..46c139b8a3d 100644 --- a/core/modules/views/views_ui/lib/Drupal/views_ui/ViewListController.php +++ b/core/modules/views/views_ui/lib/Drupal/views_ui/ViewListController.php @@ -19,15 +19,18 @@ class ViewListController extends EntityListController { * Overrides Drupal\Core\Entity\EntityListController::load(); */ public function load() { - $entities = parent::load(); - uasort($entities, function ($a, $b) { - $a_enabled = $a->isEnabled(); - $b_enabled = $b->isEnabled(); - if ($a_enabled != $b_enabled) { - return $a_enabled < $b_enabled; + $entities = array( + 'enabled' => array(), + 'disabled' => array(), + ); + foreach (parent::load() as $entity) { + if ($entity->isEnabled()) { + $entities['enabled'][] = $entity; } - return $a->id() > $b->id(); - }); + else { + $entities['disabled'][] = $entity; + } + } return $entities; } @@ -156,10 +159,30 @@ class ViewListController extends EntityListController { * Overrides Drupal\Core\Entity\EntityListController::render(); */ public function render() { - $list = parent::render(); + $entities = $this->load(); + $list['#type'] = 'container'; $list['#attached']['css'] = ViewFormControllerBase::getAdminCSS(); $list['#attached']['library'][] = array('system', 'drupal.ajax'); $list['#attributes']['id'] = 'views-entity-list'; + $list['enabled']['heading']['#markup'] = '