--- 2946333-224.patch 2021-11-02 09:09:13.000000000 +0100 +++ 2946333-9.3.x-258.patch 2021-11-03 13:03:49.000000000 +0100 @@ -27,7 +27,7 @@ + data-dialog-type: dialog + data-dialog-renderer: off_canvas diff --git a/core/modules/layout_builder/layout_builder.module b/core/modules/layout_builder/layout_builder.module -index cf1fcc9be6..f002fdc2d7 100644 +index cc849733e3..c42f31a61c 100644 --- a/core/modules/layout_builder/layout_builder.module +++ b/core/modules/layout_builder/layout_builder.module @@ -17,6 +17,7 @@ @@ -50,25 +50,24 @@ /** diff --git a/core/modules/layout_builder/layout_builder.post_update.php b/core/modules/layout_builder/layout_builder.post_update.php -index 47d94aa52c..764480c193 100644 +index 04d2139cf7..e5e869fac3 100644 --- a/core/modules/layout_builder/layout_builder.post_update.php +++ b/core/modules/layout_builder/layout_builder.post_update.php -@@ -5,6 +5,10 @@ - * Post update functions for Layout Builder. - */ +@@ -7,7 +7,10 @@ -+use Drupal\field\Entity\FieldStorageConfig; + use Drupal\Core\Config\Entity\ConfigEntityUpdater; + use Drupal\Core\Entity\Display\EntityViewDisplayInterface; +use Drupal\field\Entity\FieldConfig; ++use Drupal\field\Entity\FieldStorageConfig; + use Drupal\layout_builder\Entity\LayoutEntityDisplayInterface; +use Drupal\layout_builder\Plugin\SectionStorage\OverridesSectionStorage; -+ + /** * Implements hook_removed_post_updates(). - */ -@@ -34,3 +38,62 @@ function layout_builder_removed_post_updates() { - function layout_builder_post_update_override_entity_form_controller() { +@@ -39,6 +42,65 @@ function layout_builder_post_update_override_entity_form_controller() { // Empty post-update hook. } -+ + +/** + * Adds the layout translation settings field. + */ @@ -127,6 +126,10 @@ + $field->save(); + } +} ++ + /** + * Update view displays that use Layout Builder to add empty context mappings. + */ diff --git a/core/modules/layout_builder/layout_builder.routing.yml b/core/modules/layout_builder/layout_builder.routing.yml index 6dcf0c9f05..4f561b8e97 100644 --- a/core/modules/layout_builder/layout_builder.routing.yml @@ -240,7 +243,7 @@ _admin_route: TRUE parameters: diff --git a/core/modules/layout_builder/layout_builder.services.yml b/core/modules/layout_builder/layout_builder.services.yml -index bce1734e71..e767703a3c 100644 +index e67a3b4d1a..8296df3758 100644 --- a/core/modules/layout_builder/layout_builder.services.yml +++ b/core/modules/layout_builder/layout_builder.services.yml @@ -6,6 +6,10 @@ services: @@ -254,7 +257,7 @@ plugin.manager.layout_builder.section_storage: class: Drupal\layout_builder\SectionStorage\SectionStorageManager parent: default_plugin_manager -@@ -38,6 +42,11 @@ services: +@@ -43,6 +47,11 @@ services: arguments: ['@current_user'] tags: - { name: event_subscriber } @@ -385,7 +388,7 @@ + +} diff --git a/core/modules/layout_builder/src/Element/LayoutBuilder.php b/core/modules/layout_builder/src/Element/LayoutBuilder.php -index 0814604bbc..dd65f05aa1 100644 +index 8bf656475b..b905906b3f 100644 --- a/core/modules/layout_builder/src/Element/LayoutBuilder.php +++ b/core/modules/layout_builder/src/Element/LayoutBuilder.php @@ -2,7 +2,10 @@ @@ -406,7 +409,7 @@ +use Drupal\layout_builder\LayoutEntityHelperTrait; use Drupal\layout_builder\SectionStorageInterface; use Symfony\Component\DependencyInjection\ContainerInterface; - use Symfony\Component\EventDispatcher\EventDispatcherInterface; + use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; @@ -29,6 +33,7 @@ class LayoutBuilder extends RenderElement implements ContainerFactoryPluginInter use AjaxHelperTrait; use LayoutBuilderContextTrait; @@ -431,7 +434,7 @@ * @@ -48,11 +60,14 @@ class LayoutBuilder extends RenderElement implements ContainerFactoryPluginInter * The plugin implementation definition. - * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher + * @param \Symfony\Contracts\EventDispatcher\EventDispatcherInterface $event_dispatcher * The event dispatcher service. - * @param \Drupal\Core\Messenger\MessengerInterface|null $messenger - * The messenger service. This is no longer used and will be removed in @@ -509,15 +512,16 @@ return $output; } -@@ -233,6 +261,7 @@ protected function buildAdministrativeSection(SectionStorageInterface $section_s - $storage_id = $section_storage->getStorageId(); +@@ -234,6 +262,8 @@ protected function buildAdministrativeSection(SectionStorageInterface $section_s $section = $section_storage->getSection($delta); + $layout = $section->getLayout($this->getPopulatedContexts($section_storage)); + $sections_editable = !static::isTranslation($section_storage); - $layout = $section->getLayout(); ++ $layout = $section->getLayout(); $layout_settings = $section->getLayoutSettings(); $section_label = !empty($layout_settings['label']) ? $layout_settings['label'] : $this->t('Section @section', ['@section' => $delta + 1]); -@@ -244,33 +273,19 @@ protected function buildAdministrativeSection(SectionStorageInterface $section_s + +@@ -244,33 +274,19 @@ protected function buildAdministrativeSection(SectionStorageInterface $section_s foreach ($layout_definition->getRegions() as $region => $info) { if (!empty($build[$region])) { foreach (Element::children($build[$region]) as $uuid) { @@ -556,7 +560,7 @@ // Add one to the current delta since it is zero-indexed. '#title' => $this->t('Add block in @section, @region region', ['@section' => $section_label, '@region' => $region_labels[$region]]), '#url' => Url::fromRoute('layout_builder.choose_block', -@@ -346,6 +361,7 @@ protected function buildAdministrativeSection(SectionStorageInterface $section_s +@@ -346,6 +362,7 @@ protected function buildAdministrativeSection(SectionStorageInterface $section_s ], 'remove' => [ '#type' => 'link', @@ -564,7 +568,7 @@ '#title' => $this->t('Remove @section', ['@section' => $section_label]), '#url' => Url::fromRoute('layout_builder.remove_section', [ 'section_storage_type' => $storage_type, -@@ -370,8 +386,8 @@ protected function buildAdministrativeSection(SectionStorageInterface $section_s +@@ -370,8 +387,8 @@ protected function buildAdministrativeSection(SectionStorageInterface $section_s ], 'configure' => [ '#type' => 'link', @@ -574,7 +578,7 @@ '#url' => Url::fromRoute('layout_builder.configure_section', [ 'section_storage_type' => $storage_type, 'section_storage' => $storage_id, -@@ -391,4 +407,67 @@ protected function buildAdministrativeSection(SectionStorageInterface $section_s +@@ -391,4 +408,67 @@ protected function buildAdministrativeSection(SectionStorageInterface $section_s ]; } @@ -643,7 +647,7 @@ + } diff --git a/core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php b/core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php -index c0288297f6..42ed20f47d 100644 +index 6094889664..dcb9fbd38c 100644 --- a/core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php +++ b/core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php @@ -217,6 +217,41 @@ protected function addSectionField($entity_type_id, $bundle, $field_name) { @@ -690,7 +694,7 @@ /** diff --git a/core/modules/layout_builder/src/EventSubscriber/ComponentPluginTranslate.php b/core/modules/layout_builder/src/EventSubscriber/ComponentPluginTranslate.php new file mode 100644 -index 0000000000..ab1c38efe5 +index 0000000000..5434fada26 --- /dev/null +++ b/core/modules/layout_builder/src/EventSubscriber/ComponentPluginTranslate.php @@ -0,0 +1,93 @@ @@ -1029,7 +1033,7 @@ } diff --git a/core/modules/layout_builder/src/Form/TranslateBlockForm.php b/core/modules/layout_builder/src/Form/TranslateBlockForm.php new file mode 100644 -index 0000000000..4fef961876 +index 0000000000..9812a40e68 --- /dev/null +++ b/core/modules/layout_builder/src/Form/TranslateBlockForm.php @@ -0,0 +1,218 @@ @@ -1129,7 +1133,7 @@ + * An associative array containing the structure of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. -+ * @param \Drupal\layout_builder\SectionStorageInterface $section_storage ++ * @param \Drupal\layout_builder\TranslatableSectionStorageInterface $section_storage + * The section storage being configured. + * @param int $delta + * The delta of the section. @@ -1252,7 +1256,7 @@ + +} diff --git a/core/modules/layout_builder/src/InlineBlockEntityOperations.php b/core/modules/layout_builder/src/InlineBlockEntityOperations.php -index 9760243bf3..291baaf7d3 100644 +index ad255cd6fe..92189b07d9 100644 --- a/core/modules/layout_builder/src/InlineBlockEntityOperations.php +++ b/core/modules/layout_builder/src/InlineBlockEntityOperations.php @@ -2,6 +2,7 @@ @@ -1276,7 +1280,7 @@ - * general policy for constructor backwards compatibility is determined in - * https://www.drupal.org/node/3030640. + * @var \Drupal\Core\Block\BlockManagerInterface -+ */ ++ */ + protected $blockManager; + + /** @@ -1839,7 +1843,7 @@ 'enabled' => TRUE, 'allow_custom' => TRUE, diff --git a/core/modules/layout_builder/tests/src/Functional/LayoutBuilderTranslationTest.php b/core/modules/layout_builder/tests/src/Functional/LayoutBuilderTranslationTest.php -index 16c15993e6..37ee428db7 100644 +index a4873d5d7b..eb7e2dc238 100644 --- a/core/modules/layout_builder/tests/src/Functional/LayoutBuilderTranslationTest.php +++ b/core/modules/layout_builder/tests/src/Functional/LayoutBuilderTranslationTest.php @@ -2,16 +2,20 @@ @@ -2062,7 +2066,7 @@ } /** -@@ -165,25 +272,8 @@ protected function setUpEntities() { +@@ -168,25 +275,8 @@ protected function setUpEntities() { ->getStorage($this->entityTypeId); $storage->resetCache([$id]); $this->entity = $storage->load($id); @@ -2089,10 +2093,10 @@ $this->drupalLogin($this->translator); $add_translation_url = Url::fromRoute("entity.$this->entityTypeId.content_translation_add", [ $this->entityTypeId => $this->entity->id(), -@@ -193,31 +283,18 @@ protected function addEntityTranslation() { - $this->drupalPostForm($add_translation_url, [ - "{$this->fieldName}[0][value]" => 'The translated field value', - ], 'Save'); +@@ -195,31 +285,18 @@ protected function addEntityTranslation() { + ]); + $this->drupalGet($add_translation_url); + $this->submitForm(["{$this->fieldName}[0][value]" => 'The translated field value'], 'Save'); - $this->drupalLogin($user); } @@ -2264,10 +2268,10 @@ +} diff --git a/core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockTranslationTest.php b/core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockTranslationTest.php new file mode 100644 -index 0000000000..30c804e33d +index 0000000000..02d030dcf7 --- /dev/null +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockTranslationTest.php -@@ -0,0 +1,244 @@ +@@ -0,0 +1,243 @@ +drupalPostForm( -+ static::FIELD_UI_PREFIX . '/display/default', -+ ['layout[enabled]' => TRUE], ++ $this->drupalGet(static::FIELD_UI_PREFIX . '/display/default'); ++ $this->submitForm(['layout[enabled]' => TRUE], + 'Save' + ); -+ $this->drupalPostForm( -+ static::FIELD_UI_PREFIX . '/display/default', -+ ['layout[allow_custom]' => TRUE], ++ $this->drupalGet(static::FIELD_UI_PREFIX . '/display/default'); ++ $this->submitForm(['layout[allow_custom]' => TRUE], + 'Save' + ); + @@ -2355,7 +2357,8 @@ + 'source' => 'en', + 'target' => 'it', + ]); -+ $this->drupalPostForm($add_translation_url, [ ++ $this->drupalGet($add_translation_url); ++ $this->submitForm([ + 'title[0][value]' => 'The translated node title', + 'body[0][value]' => 'The translated node body', + ], 'Save'); @@ -2571,7 +2574,7 @@ + +} diff --git a/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php -index 16e7640143..c674884b9c 100644 +index 773715c932..0eaf9f9969 100644 --- a/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php @@ -17,6 +17,7 @@ @@ -2582,7 +2585,7 @@ /** * {@inheritdoc} -@@ -136,36 +137,6 @@ public function testFormsLinksDisabled() { +@@ -138,36 +139,6 @@ public function testFormsLinksDisabled() { $this->assertContextualLinksClickable(); } @@ -2699,7 +2702,7 @@ +} diff --git a/core/modules/layout_builder/tests/src/FunctionalJavascript/ModeratedTranslationTest.php b/core/modules/layout_builder/tests/src/FunctionalJavascript/ModeratedTranslationTest.php new file mode 100644 -index 0000000000..4e88f3c415 +index 0000000000..e920a3a722 --- /dev/null +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/ModeratedTranslationTest.php @@ -0,0 +1,250 @@ @@ -2810,19 +2813,19 @@ + 'target' => 'it', + ]); + $this->drupalGet($add_translation_url); -+ $this->drupalPostForm($add_translation_url, [ ++ $this->submitForm([ + 'title[0][value]' => 'The translated node title', + 'body[0][value]' => 'The translated node body', + ], 'Save'); + + // Allow layout overrides. -+ $this->drupalPostForm( -+ static::FIELD_UI_PREFIX . '/display/default', ++ $this->drupalGet(static::FIELD_UI_PREFIX . '/display/default'); ++ $this->submitForm( + ['layout[enabled]' => TRUE], + 'Save' + ); -+ $this->drupalPostForm( -+ static::FIELD_UI_PREFIX . '/display/default', ++ $this->drupalGet(static::FIELD_UI_PREFIX . '/display/default'); ++ $this->submitForm( + ['layout[allow_custom]' => TRUE], + 'Save' + ); @@ -2955,10 +2958,10 @@ +} diff --git a/core/modules/layout_builder/tests/src/FunctionalJavascript/TranslationTest.php b/core/modules/layout_builder/tests/src/FunctionalJavascript/TranslationTest.php new file mode 100644 -index 0000000000..becc19b919 +index 0000000000..5978e1aa17 --- /dev/null +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/TranslationTest.php -@@ -0,0 +1,177 @@ +@@ -0,0 +1,176 @@ + 'en', + 'target' => 'it', + ]); -+ $this->drupalPostForm($add_translation_url, [ ++ $this->drupalGet($add_translation_url); ++ $this->submitForm([ + 'title[0][value]' => 'The translated node title', + 'body[0][value]' => 'The translated node body', + ], 'Save'); + + // Allow layout overrides. -+ $this->drupalPostForm( -+ static::FIELD_UI_PREFIX . '/display/default', -+ ['layout[enabled]' => TRUE], ++ $this->drupalGet(static::FIELD_UI_PREFIX . '/display/default'); ++ $this->submitForm(['layout[enabled]' => TRUE], + 'Save' + ); -+ $this->drupalPostForm( -+ static::FIELD_UI_PREFIX . '/display/default', -+ ['layout[allow_custom]' => TRUE], ++ $this->drupalGet(static::FIELD_UI_PREFIX . '/display/default'); ++ $this->submitForm(['layout[allow_custom]' => TRUE], + 'Save' + ); + }