Skip to content
Snippets Groups Projects
Commit 741f38a0 authored by Justin Toupin's avatar Justin Toupin
Browse files

Merge branch '2.0.x' of https://git.drupalcode.org/project/layout_paragraphs into 2.0.x

parents 14990659 8158f2d8
No related branches found
No related tags found
1 merge request!103Issue #3295875: Add a new dedicated permission for Layout paragraphs configurations
......@@ -3,16 +3,19 @@
namespace Drupal\layout_paragraphs\Controller;
use Drupal\Core\Url;
use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Template\Attribute;
use Drupal\Core\Ajax\AjaxHelperTrait;
use Drupal\Core\Ajax\OpenDialogCommand;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
use Drupal\layout_paragraphs\LayoutParagraphsLayout;
use Drupal\layout_paragraphs\LayoutParagraphsLayoutRefreshTrait;
use Drupal\layout_paragraphs\Event\LayoutParagraphsAllowedTypesEvent;
use Drupal\layout_paragraphs\Utility\Dialog;
use Symfony\Component\HttpFoundation\Request;
use Drupal\layout_paragraphs\LayoutParagraphsLayout;
use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Drupal\layout_paragraphs\LayoutParagraphsLayoutRefreshTrait;
use Drupal\layout_paragraphs\Event\LayoutParagraphsAllowedTypesEvent;
/**
* ChooseComponentController controller class.
......@@ -91,7 +94,7 @@ class ChooseComponentController extends ControllerBase {
if (count($types) === 1) {
$type_name = key($types);
$type = $this->entityTypeManager()->getStorage('paragraphs_type')->load($type_name);
$response = $this->formBuilder()->getForm(
$form = $this->formBuilder()->getForm(
'\Drupal\layout_paragraphs\Form\InsertComponentForm',
$layout_paragraphs_layout,
$type,
......@@ -100,7 +103,13 @@ class ChooseComponentController extends ControllerBase {
$query_params['sibling_uuid'],
$query_params['placement']
);
return $response;
if ($this->isAjax()) {
$response = new AjaxResponse();
$selector = Dialog::dialogSelector($layout_paragraphs_layout);
$response->addCommand(new OpenDialogCommand($selector, $form['#title'], $form, Dialog::dialogSettings()));
return $response;
}
return $form;
}
foreach ($types as &$type) {
......
......@@ -123,6 +123,12 @@ abstract class BuilderTestBase extends WebDriverTestBase {
$this->assertSession()->assertWaitOnAjaxRequest();
}
$dialog = $page->find('css', '.lpb-dialog');
$style = $dialog->getAttribute('style');
if (strpos($style, 'width: 90%;') === FALSE || strpos($style, 'height: auto;') === FALSE) {
throw new ExpectationException('Incorrect dialog width or height settings', $this->getSession()->getDriver());
}
$this->assertSession()->pageTextContains('field_text');
$page->fillField('field_text[0][value]', $text);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment