Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
229
Merge Requests
229
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
73d179af
Commit
73d179af
authored
Jan 08, 2021
by
catch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#3167901
by raman.b, johnwebdev, Spokje: RemoveSectionForm assumes there is a label
parent
33c3de6f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
79 additions
and
1 deletion
+79
-1
core/modules/layout_builder/src/Form/RemoveSectionForm.php
core/modules/layout_builder/src/Form/RemoveSectionForm.php
+3
-1
core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/Layout/LayoutWithoutLabel.php
...out_builder_test/src/Plugin/Layout/LayoutWithoutLabel.php
+42
-0
core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php
...layout_builder/tests/src/Functional/LayoutBuilderTest.php
+34
-0
No files found.
core/modules/layout_builder/src/Form/RemoveSectionForm.php
View file @
73d179af
...
...
@@ -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
]);
...
...
core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/Layout/LayoutWithoutLabel.php
0 → 100644
View file @
73d179af
<?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
View file @
73d179af
...
...
@@ -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.
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment