Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / web / core / modules / views_ui / src / ViewListBuilder.php
index 42166be1a5a9573614c971c602d98ed339b063e8..c690aee99bf98341a098d1c58497c06b71d44799 100644 (file)
@@ -9,6 +9,7 @@ use Drupal\Core\Entity\EntityStorageInterface;
 use Drupal\Core\Entity\EntityTypeInterface;
 use Drupal\Core\Url;
 use Symfony\Component\DependencyInjection\ContainerInterface;
+use Symfony\Component\HttpKernel\Exception\NotAcceptableHttpException;
 
 /**
  * Defines a class to build a listing of view entities.
@@ -177,6 +178,14 @@ class ViewListBuilder extends ConfigEntityListBuilder {
       }
     }
 
+    // ajax.js focuses automatically on the data-drupal-selector element. When
+    // enabling the view again, focusing on the disable link doesn't work, as it
+    // is hidden. We assign data-drupal-selector to every link, so it focuses
+    // on the edit link.
+    foreach ($operations as &$operation) {
+      $operation['attributes']['data-drupal-selector'] = 'views-listing-' . $entity->id();
+    }
+
     return $operations;
   }
 
@@ -255,9 +264,17 @@ class ViewListBuilder extends ConfigEntityListBuilder {
         if ($display->hasPath()) {
           $path = $display->getPath();
           if ($view->status() && strpos($path, '%') === FALSE) {
-            // @todo Views should expect and store a leading /. See:
-            //   https://www.drupal.org/node/2423913
-            $rendered_path = \Drupal::l('/' . $path, Url::fromUserInput('/' . $path));
+            // Wrap this in a try/catch as trying to generate links to some
+            // routes may throw a NotAcceptableHttpException if they do not
+            // respond to HTML, such as RESTExports.
+            try {
+              // @todo Views should expect and store a leading /. See:
+              //   https://www.drupal.org/node/2423913
+              $rendered_path = \Drupal::l('/' . $path, Url::fromUserInput('/' . $path));
+            }
+            catch (NotAcceptableHttpException $e) {
+              $rendered_path = '/' . $path;
+            }
           }
           else {
             $rendered_path = '/' . $path;