diff --git a/core/lib/Drupal/Core/Entity/EntityListBuilder.php b/core/lib/Drupal/Core/Entity/EntityListBuilder.php index b9c8db3..8a81f92 100644 --- a/core/lib/Drupal/Core/Entity/EntityListBuilder.php +++ b/core/lib/Drupal/Core/Entity/EntityListBuilder.php @@ -2,6 +2,7 @@ namespace Drupal\Core\Entity; +use Drupal\Component\Serialization\Json; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -150,6 +151,13 @@ protected function getDefaultOperations(EntityInterface $entity) { $operations['delete'] = array( 'title' => $this->t('Delete'), 'weight' => 100, + 'attributes' => array( + 'class' => array('use-ajax'), + 'data-dialog-type' => 'modal', + 'data-dialog-options' => Json::encode(array( + 'width' => 'auto', + )), + ), 'url' => $entity->urlInfo('delete-form'), ); } @@ -201,6 +209,10 @@ public function buildOperations(EntityInterface $entity) { $build = array( '#type' => 'operations', '#links' => $this->getOperations($entity), + // Allow links to use modals. + '#attached' => array( + 'library' => array('core/drupal.ajax'), + ), ); return $build; diff --git a/core/lib/Drupal/Core/Form/ConfirmFormHelper.php b/core/lib/Drupal/Core/Form/ConfirmFormHelper.php index fc92ff9..8bf3957 100644 --- a/core/lib/Drupal/Core/Form/ConfirmFormHelper.php +++ b/core/lib/Drupal/Core/Form/ConfirmFormHelper.php @@ -45,7 +45,7 @@ public static function buildCancelLink(ConfirmFormInterface $form, Request $requ return [ '#type' => 'link', '#title' => $form->getCancelText(), - '#attributes' => ['class' => ['button']], + '#attributes' => ['class' => ['button', 'dialog-cancel']], '#url' => $url, '#cache' => [ 'contexts' => [ diff --git a/core/modules/config/src/Tests/ConfigEntityListTest.php b/core/modules/config/src/Tests/ConfigEntityListTest.php index 9d31de0..9cf9bc8 100644 --- a/core/modules/config/src/Tests/ConfigEntityListTest.php +++ b/core/modules/config/src/Tests/ConfigEntityListTest.php @@ -2,6 +2,7 @@ namespace Drupal\config\Tests; +use Drupal\Component\Serialization\Json; use Drupal\simpletest\WebTestBase; use Drupal\config_test\Entity\ConfigTest; use Drupal\Core\Entity\EntityStorageInterface; @@ -64,6 +65,13 @@ function testList() { 'delete' => array ( 'title' => t('Delete'), 'weight' => 100, + 'attributes' => array( + 'class' => array('use-ajax'), + 'data-dialog-type' => 'modal', + 'data-dialog-options' => Json::encode(array( + 'width' => 'auto', + )), + ), 'url' => $entity->urlInfo('delete-form'), ), ); @@ -134,6 +142,13 @@ function testList() { 'delete' => array( 'title' => t('Delete'), 'weight' => 100, + 'attributes' => array( + 'class' => array('use-ajax'), + 'data-dialog-type' => 'modal', + 'data-dialog-options' => Json::encode(array( + 'width' => 'auto', + )), + ), 'url' => $entity->urlInfo('delete-form'), ), ); diff --git a/core/modules/views/tests/src/Kernel/Plugin/RowRenderCacheTest.php b/core/modules/views/tests/src/Kernel/Plugin/RowRenderCacheTest.php index ac85c77..3a59e68 100644 --- a/core/modules/views/tests/src/Kernel/Plugin/RowRenderCacheTest.php +++ b/core/modules/views/tests/src/Kernel/Plugin/RowRenderCacheTest.php @@ -2,6 +2,8 @@ namespace Drupal\Tests\views\Kernel\Plugin; +use Drupal\Component\Serialization\Json; +use Drupal\Component\Utility\Html; use Drupal\Core\Session\AccountInterface; use Drupal\node\Entity\Node; use Drupal\node\Entity\NodeType; @@ -181,7 +183,7 @@ protected function doTestRenderedOutput(AccountInterface $account, $check_cache $this->assertEqual($output, $expected); $expected = $access ? '
' : ''; $output = $view->style_plugin->getField($index, 'operations'); $this->assertEqual($output, $expected);