Loading core/modules/layout_builder/src/Form/RemoveSectionForm.php +3 −1 Changes for core/modules/layout_builder/src/Form/RemoveSectionForm.php: 3 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -25,7 +25,9 @@ public function getFormId() { */ public function getQuestion() { $configuration = $this->sectionStorage->getSection($this->delta)->getLayoutSettings(); if ($configuration['label']) { // Layouts may choose to use a class that might not have a label // configuration. if (!empty($configuration['label'])) { return $this->t('Are you sure you want to remove @section?', ['@section' => $configuration['label']]); } return $this->t('Are you sure you want to remove section @section?', ['@section' => $this->delta + 1]); Loading core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/Layout/LayoutWithoutLabel.php 0 → 100644 +42 −0 Changes for core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/Layout/LayoutWithoutLabel.php: 42 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace Drupal\layout_builder_test\Plugin\Layout; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Layout\LayoutDefault; /** * Layout plugin without a label configuration. * * @Layout( * id = "layout_without_label", * label = @Translation("Layout Without Label"), * regions = { * "main" = { * "label" = @Translation("Main Region") * } * }, * ) */ class LayoutWithoutLabel extends LayoutDefault { /** * {@inheritdoc} */ public function defaultConfiguration() { return []; } /** * {@inheritdoc} */ public function buildConfigurationForm(array $form, FormStateInterface $form_state) { return $form; } /** * {@inheritdoc} */ public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {} } core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php +34 −0 Changes for core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php: 34 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -1320,6 +1320,40 @@ public function testRemovingAllSections() { $assert_session->pageTextNotContains('The first node body'); } /** * Tests removing section without layout label configuration. */ public function testRemovingSectionWithoutLayoutLabel() { $assert_session = $this->assertSession(); $page = $this->getSession()->getPage(); $this->drupalLogin($this->drupalCreateUser([ 'configure any layout', 'administer node display', ])); // Enable overrides. $field_ui_prefix = 'admin/structure/types/manage/bundle_with_section_field'; $this->drupalGet("$field_ui_prefix/display/default"); $this->submitForm(['layout[enabled]' => TRUE], 'Save'); $this->submitForm(['layout[allow_custom]' => TRUE], 'Save'); $this->drupalGet("$field_ui_prefix/display/default/layout"); $page->clickLink('Add section'); $assert_session->linkExists('Layout Without Label'); $page->clickLink('Layout Without Label'); $page->pressButton('Add section'); $assert_session->elementsCount('css', '.layout', 2); $assert_session->linkExists('Remove Section 1'); $this->clickLink('Remove Section 1'); $page->pressButton('Remove'); $assert_session->statusCodeEquals(200); $assert_session->elementsCount('css', '.layout', 1); } /** * Asserts that the correct layouts are available. */ Loading Loading
core/modules/layout_builder/src/Form/RemoveSectionForm.php +3 −1 Changes for core/modules/layout_builder/src/Form/RemoveSectionForm.php: 3 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -25,7 +25,9 @@ public function getFormId() { */ public function getQuestion() { $configuration = $this->sectionStorage->getSection($this->delta)->getLayoutSettings(); if ($configuration['label']) { // Layouts may choose to use a class that might not have a label // configuration. if (!empty($configuration['label'])) { return $this->t('Are you sure you want to remove @section?', ['@section' => $configuration['label']]); } return $this->t('Are you sure you want to remove section @section?', ['@section' => $this->delta + 1]); Loading
core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/Layout/LayoutWithoutLabel.php 0 → 100644 +42 −0 Changes for core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/Layout/LayoutWithoutLabel.php: 42 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace Drupal\layout_builder_test\Plugin\Layout; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Layout\LayoutDefault; /** * Layout plugin without a label configuration. * * @Layout( * id = "layout_without_label", * label = @Translation("Layout Without Label"), * regions = { * "main" = { * "label" = @Translation("Main Region") * } * }, * ) */ class LayoutWithoutLabel extends LayoutDefault { /** * {@inheritdoc} */ public function defaultConfiguration() { return []; } /** * {@inheritdoc} */ public function buildConfigurationForm(array $form, FormStateInterface $form_state) { return $form; } /** * {@inheritdoc} */ public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {} }
core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php +34 −0 Changes for core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php: 34 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -1320,6 +1320,40 @@ public function testRemovingAllSections() { $assert_session->pageTextNotContains('The first node body'); } /** * Tests removing section without layout label configuration. */ public function testRemovingSectionWithoutLayoutLabel() { $assert_session = $this->assertSession(); $page = $this->getSession()->getPage(); $this->drupalLogin($this->drupalCreateUser([ 'configure any layout', 'administer node display', ])); // Enable overrides. $field_ui_prefix = 'admin/structure/types/manage/bundle_with_section_field'; $this->drupalGet("$field_ui_prefix/display/default"); $this->submitForm(['layout[enabled]' => TRUE], 'Save'); $this->submitForm(['layout[allow_custom]' => TRUE], 'Save'); $this->drupalGet("$field_ui_prefix/display/default/layout"); $page->clickLink('Add section'); $assert_session->linkExists('Layout Without Label'); $page->clickLink('Layout Without Label'); $page->pressButton('Add section'); $assert_session->elementsCount('css', '.layout', 2); $assert_session->linkExists('Remove Section 1'); $this->clickLink('Remove Section 1'); $page->pressButton('Remove'); $assert_session->statusCodeEquals(200); $assert_session->elementsCount('css', '.layout', 1); } /** * Asserts that the correct layouts are available. */ Loading