Skip to content

Commit

Permalink
SHS-5958: Bug: Inconsistent "Add Above" feature (#1692)
Browse files Browse the repository at this point in the history
* fix(SHS-5958): Fix issue with paragraphs features to allow add buttons on non gin/claro themes

* feat(SHS-5958): Add config and update hook to allow add paragraphs in between

* refactor(SHS-5958): Change how we are updating the add in between to config

* test(SHS-5958): Update test to refelect new buttons

* test(SHS-5958): Update testPostCard test for new add in between buttons

* test(SHS-5958): Update other tests for new add in between buttons

* test(SHS-5958): Add a wait in test to make sure JS add in between buttons load

* test(SHS-5958): Fix photo album test - photo album can come before or after text component, making tests work sometimes but not all the time

* fix(shs-5958): fix video embed test

* fix(shs-5958): fix private page tests

* fix(shs-5958): fix video embed test

* fix(shs-5958): fix private page tests

* fix(shs-5958): fixes in tests

* fix(shs-5958): fix private page tests

* fix(shs-5958): fix private page tests

* chore(SHS-5958): Remove unnecessary layout builder config

* chore(SHS-5958): Revert hidden layout builder layout

* chore(SHS-5958): Revert composer.lock to 11.6.1 version

---------

Co-authored-by: Andrés Díaz Soto <[email protected]>
  • Loading branch information
codechefmarc and cienvaras authored Dec 17, 2024
1 parent 0ed1984 commit 28633c9
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 22 deletions.
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,9 @@
"https://www.drupal.org/project/paragraphs_browser/issues/3381981": "https://www.drupal.org/files/issues/2023-08-22/3381981-sort-by-weight-4.patch",
"https://www.drupal.org/project/paragraphs_browser/issues/3064852": "https://www.drupal.org/files/issues/2023-11-07/3064852-allow-hiding-browser-12.patch"
},
"drupal/paragraphs_features": {
"Add-in only works if active theme is claro or gin https://www.drupal.org/project/paragraphs_features/issues/3353704": "https://www.drupal.org/files/issues/2024-03-22/3353704-mr12-18.patch"
},
"drupal/redirect": {
"https://www.drupal.org/project/redirect/issues/3057250": "https://www.drupal.org/files/issues/2024-08-11/redirect--2024-08-11--3057250-79.patch",
"https://www.drupal.org/project/redirect/issues/3018897": "https://www.drupal.org/files/issues/2024-08-12/redirect-3018897-28.patch"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dependencies:
- field.field.node.hs_basic_page.layout_builder__layout
- node.type.hs_basic_page
module:
- field_formatter_class
- menu_link
- paragraphs
- paragraphs_ee
Expand Down Expand Up @@ -48,16 +49,19 @@ content:
duplicate: duplicate
expose_drag_drop: '1'
third_party_settings:
field_formatter_class:
class: ''
paragraphs_features:
add_in_between: false
add_in_between_link_count: 3
add_in_between: true
add_in_between_link_count: 0
delete_confirmation: false
show_drag_and_drop: true
show_collapse_all: true
paragraphs_ee:
paragraphs_ee:
dialog_off_canvas: false
dialog_style: tiles
drag_drop: false
field_hs_page_hero:
type: paragraphs
weight: 1
Expand All @@ -79,16 +83,19 @@ content:
duplicate: duplicate
expose_drag_drop: '1'
third_party_settings:
field_formatter_class:
class: ''
paragraphs_features:
add_in_between: false
add_in_between_link_count: 3
add_in_between: true
add_in_between_link_count: 0
delete_confirmation: false
show_drag_and_drop: true
show_collapse_all: true
paragraphs_ee:
paragraphs_ee:
dialog_off_canvas: false
dialog_style: tiles
drag_drop: false
field_menulink:
type: menu_link_default
weight: 26
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dependencies:
- field.field.node.hs_private_page.layout_builder__layout
- node.type.hs_private_page
module:
- field_formatter_class
- file
- insert
- menu_link
Expand Down Expand Up @@ -46,17 +47,21 @@ content:
collapse_edit_all: collapse_edit_all
convert: '0'
duplicate: duplicate
expose_drag_drop: '1'
third_party_settings:
field_formatter_class:
class: ''
paragraphs_features:
add_in_between: false
add_in_between_link_count: 3
add_in_between: true
add_in_between_link_count: 0
delete_confirmation: false
show_drag_and_drop: true
show_collapse_all: true
paragraphs_ee:
paragraphs_ee:
dialog_off_canvas: false
dialog_style: tiles
drag_drop: false
field_menulink:
type: menu_link_default
weight: 26
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,3 +376,32 @@ function hs_paragraph_types_update_10010() {
$hs_priv_collection_style->delete();
}
}

/**
* Adds add between buttons to existing paragraphs.
*/
function hs_paragraph_types_update_10011() {
$fields = [
'field_hs_page_components' => 'node.hs_basic_page.default',
'field_hs_page_hero' => 'node.hs_basic_page.default',
'field_hs_priv_page_components' => 'node.hs_private_page.default',
];
$form_display_storage = \Drupal::entityTypeManager()->getStorage('entity_form_display');
foreach ($fields as $field => $form_display_id) {
/** @var \Drupal\Core\Entity\Display\EntityFormDisplayInterface $form_display */
$form_display = $form_display_storage->load($form_display_id);
if (empty($form_display)) {
continue;
}

$component = $form_display->getComponent($field);

if (empty($component)) {
continue;
}
$component['third_party_settings']['paragraphs_features']['add_in_between'] = 'true';
$component['third_party_settings']['paragraphs_features']['add_in_between_link_count'] = 0;
$form_display->setComponent($field, $component)
->save();
}
}
24 changes: 12 additions & 12 deletions tests/codeception/functional/Install/Content/FlexiblePageCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public function testDuplicateScroll(FunctionalTester $I) {
'type' => 'hs_basic_page',
]);
$I->amOnPage($node->toUrl('edit-form')->toString());
$I->scrollTo('#edit-field-hs-page-components-add-more-add-modal-form-area-add-more');
$I->click('#edit-field-hs-page-components-add-more-add-modal-form-area-add-more');
$I->scrollTo('#field-hs-page-components-values tr:last-child .paragraphs-features__add-in-between__button');
$I->click('#field-hs-page-components-values tr:last-child .paragraphs-features__add-in-between__button');
$I->waitForText('Add Component');
$I->fillField('.paragraphs-ee-add-dialog input[type="search"]', 'Collection');
$I->click('Collection', '.paragraphs-ee-add-dialog');
Expand Down Expand Up @@ -91,7 +91,7 @@ public function testHeroParagraph(FunctionalTester $I) {
// Prevent JS alerts from firing before loading a new page.
$I->executeJS('window.onbeforeunload = undefined;');
$I->fillField('Title', 'Demo Basic Page');
$I->click('#edit-field-hs-page-components-add-more-add-modal-form-area-add-more');
$I->click('#field-hs-page-components-values tr:last-child .paragraphs-features__add-in-between__button');
$I->waitForText('Add Component');
$I->fillField('.paragraphs-ee-add-dialog input[type="search"]', 'Banner');
$I->click('Banner image with full overlay and text', '.paragraphs-ee-add-dialog');
Expand Down Expand Up @@ -132,7 +132,7 @@ public function testPhotoAlbum(FunctionalTester $I) {
// Prevent JS alerts from firing before loading a new page.
$I->executeJS('window.onbeforeunload = undefined;');
$I->fillField('Title', 'Demo Basic Page');
$I->click('#edit-field-hs-page-components-add-more-add-modal-form-area-add-more');
$I->click('#field-hs-page-components-values tr:last-child .paragraphs-features__add-in-between__button');
$I->waitForText('Add Component');
$I->fillField('.paragraphs-ee-add-dialog input[type="search"]', 'Photo Album');
$I->click('Photo Album', '.paragraphs-ee-add-dialog');
Expand All @@ -158,7 +158,7 @@ public function testPhotoAlbum(FunctionalTester $I) {
$I->canSeeNumberOfElements('#cboxContent img', 0);
$I->waitForText('Edit');
$I->click('Edit', '.tabs');
$I->click('field_hs_page_components_1_edit');
$I->click('//input[@data-paragraphs-split-text-type="stanford_gallery"]/preceding::input[contains(@class, "paragraphs-icon-button-edit")][1]');
$I->waitForText('Content');
$I->scrollTo('Style');
$I->selectOption('Style', 'Slideshow');
Expand Down Expand Up @@ -236,7 +236,7 @@ public function testSpotlightSlider(FunctionalTester $I) {
'type' => 'hs_basic_page',
]);
$I->amOnPage($node->toUrl('edit-form')->toString());
$I->click('#edit-field-hs-page-components-add-more-add-modal-form-area-add-more');
$I->click('#field-hs-page-components-values tr:last-child .paragraphs-features__add-in-between__button');
$I->waitForText('Add Component');
$I->fillField('.paragraphs-ee-add-dialog input[type="search"]', 'Spotlight');
$I->click('Spotlight(s)', '.paragraphs-ee-add-dialog');
Expand Down Expand Up @@ -308,7 +308,7 @@ public function testVerticalTimeline(FunctionalTester $I) {
$I->logInWithRole('administrator');
$I->amOnPage('node/add/hs_basic_page');
$I->fillField('Title', $this->faker->words(3, TRUE));
$I->click('#edit-field-hs-page-components-add-more-add-modal-form-area-add-more');
$I->click('#field-hs-page-components-values tr:last-child .paragraphs-features__add-in-between__button');
$I->waitForText('Add Component');
$I->fillField('.paragraphs-ee-add-dialog input[type="search"]', 'Vertical Timeline');
$I->click('Vertical Timeline', '.paragraphs-ee-add-dialog');
Expand Down Expand Up @@ -352,7 +352,7 @@ public function testPostCard(FunctionalTester $I) {
$I->logInWithRole('contributor');
$I->amOnPage('/node/add/hs_basic_page');
$I->fillField('Title', 'Demo Basic Page');
$I->click('#edit-field-hs-page-components-add-more-add-modal-form-area-add-more');
$I->click('#field-hs-page-components-values tr:last-child .paragraphs-features__add-in-between__button');
$I->waitForText('Add Component');
$I->fillField('.paragraphs-ee-add-dialog input[type="search"]', 'Postcard');
$I->click('Postcard', '.paragraphs-ee-add-dialog');
Expand All @@ -376,7 +376,7 @@ public function testAccordion(FunctionalTester $I) {
$I->logInWithRole('contributor');
$I->amOnPage('/node/add/hs_basic_page');
$I->fillField('Title', 'Demo Basic Page');
$I->click('#edit-field-hs-page-components-add-more-add-modal-form-area-add-more');
$I->click('#field-hs-page-components-values tr:last-child .paragraphs-features__add-in-between__button');
$I->waitForText('Add Component');
$I->fillField('.paragraphs-ee-add-dialog input[type="search"]', 'accordion');
$I->click('Accordion', '.paragraphs-ee-add-dialog');
Expand Down Expand Up @@ -405,7 +405,7 @@ public function testBackToTopExists(FunctionalTester $I) {
}
catch (\Exception $e) {
// Add component if does not already exist.
$I->click('#edit-field-hs-page-components-add-more-add-modal-form-area-add-more');
$I->click('#field-hs-page-components-values tr:last-child .paragraphs-features__add-in-between__button');
$I->waitForText('Add Component');
$I->fillField('.paragraphs-ee-add-dialog input[type="search"]', 'text area');
$I->click('Text Area', '.paragraphs-ee-add-dialog');
Expand Down Expand Up @@ -446,7 +446,7 @@ public function testTextArea(FunctionalTester $I) {
}
catch (\Exception $e) {
// Add component if does not already exist.
$I->click('#edit-field-hs-page-components-add-more-add-modal-form-area-add-more');
$I->click('#field-hs-page-components-values tr:last-child .paragraphs-features__add-in-between__button');
$I->waitForText('Add Component');
$I->fillField('.paragraphs-ee-add-dialog input[type="search"]', 'text area');
$I->click('Text Area', '.paragraphs-ee-add-dialog');
Expand Down Expand Up @@ -477,7 +477,7 @@ public function testCollections(FunctionalTester $I) {
$I->amOnPage('/node/add/hs_basic_page');
$I->fillField('Title', 'Demo Basic Page');
// Add a Collection component to the page.
$I->click('#edit-field-hs-page-components-add-more-add-modal-form-area-add-more');
$I->click('#field-hs-page-components-values tr:last-child .paragraphs-features__add-in-between__button');
$I->waitForText('Add Component');
$I->fillField('.paragraphs-ee-add-dialog input[type="search"]', 'Collection');
$I->click('Collection', '.paragraphs-ee-add-dialog');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ public function testPrivatePageContent(FunctionalTester $I) {
$I->amOnPage('/node/add/hs_private_page');
$I->fillField('Title', 'Test Private Page');
foreach ($this->fieldsToCheck as $component => $component_info) {
$I->scrollTo('.field--name-field-priv-wysiwyg-files');
$I->click('Add Component');
$I->scrollTo('table[id^="field-hs-priv-page-components-values"] tr:last-child .paragraphs-features__add-in-between__button');
$I->click('table[id^="field-hs-priv-page-components-values"] tr:last-child .paragraphs-features__add-in-between__button');
$I->waitForText('Add Component');
$I->fillField('.paragraphs-ee-add-dialog input[type="search"]', $component);
$I->click($component_info['component_button_name'], '.paragraphs-ee-add-dialog');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ public function testVideoEmbed(FunctionalTester $I) {
$I->fillField('Title', $this->faker->words(3, TRUE));

// Add text field.
$I->scrollTo('#edit-field-hs-page-components-add-more-add-modal-form-area-add-more');
$I->click('Add Component');
$I->click('#field-hs-page-components-values tr:last-child .paragraphs-features__add-in-between__button');
$I->waitForText('Add Component');
$I->fillField('.paragraphs-ee-add-dialog input[type="search"]', 'Text Area');
$I->click('Text Area', '.paragraphs-ee-add-dialog');
Expand Down

0 comments on commit 28633c9

Please sign in to comment.