Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YSP-446: Reusable Block Sort Verification #786

Merged
merged 60 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
b37588f
chore(deps): bump the drupal-core group with 3 updates
dependabot[bot] Apr 1, 2024
28195eb
chore(deps): bump the yalesites-profile group
dependabot[bot] Apr 2, 2024
e6cf4fa
chore(YSP-446): update composer.json for drupal 10.2 compatibility
vinmassaro Apr 9, 2024
3dd74b6
chore(YSP-446): update patch for #2999491 for 10.2
vinmassaro Apr 11, 2024
6c981da
chore(YSP-446): update patch for #3100117 for 10.2
vinmassaro Apr 11, 2024
6eceb7e
chore(YSP-446): remove gin_lb patch for #3387157 since it no longer a…
vinmassaro Apr 11, 2024
6427d97
chore(YSP-446): update config for Drupal 10.2
vinmassaro May 13, 2024
be33a0c
chore(YSP-446): update config and dependencies for Drupal 10.2
vinmassaro May 13, 2024
792073f
feat(YSP-446): update PHP to 8.3, MariaDB to 10.6
vinmassaro May 13, 2024
f6a4eda
feat(YSP-446): update core to 10.2.6, remove core patch
vinmassaro May 13, 2024
3cf481f
feat(YSP-446): update core to 10.3.1 and re-export config
vinmassaro Jul 5, 2024
4529e02
feat(YSP-446): update/remove dependencies and patches for Drupal 10.3
vinmassaro Jul 5, 2024
6ad0cf6
chore(YSP-446): update config
vinmassaro Jul 9, 2024
2680ab3
fix(YSP-446): reroll combo patch
dblanken-yale Jul 22, 2024
0da9e5c
fix(YSP-446): bump focal_point to work with patch
dblanken-yale Jul 22, 2024
3a083bc
fix(YSP-446): use 10.3 reusable patch
dblanken-yale Jul 22, 2024
aa9b471
Merge pull request #700 from yalesites-org/YSP-446-drupal-10.3-fixes
vinmassaro Sep 11, 2024
0cb259e
chore(YSP-446): resolve conflicts from develop
vinmassaro Sep 11, 2024
c280738
feat(YSP-446): update core to 10.3.4
vinmassaro Sep 11, 2024
1db679d
fix(YSP-446): fix runtime exception error from search_api
vinmassaro Sep 11, 2024
a68b956
fix(YSP-446): update patch for drupal.org/node/2888320 for 10.3.x
vinmassaro Sep 11, 2024
f848e0b
chore(YSP-446): patch for drupal.org/node/3340159 no longer needed
vinmassaro Sep 11, 2024
c651f6f
chore(YSP-446): patch for drupal.org/node/2999491 updated for 10.3.x
vinmassaro Sep 11, 2024
a44425e
chore(YSP-446): update modules to latest versions
vinmassaro Sep 11, 2024
7c3639c
chore(YSP-446): update redirect patch
vinmassaro Sep 11, 2024
90e66ff
chore(YSP-446): export updated config
vinmassaro Sep 11, 2024
e6dee11
chore(YSP-446): downgrade honeypot due to drupal.org/node/3468450
vinmassaro Sep 11, 2024
51f6300
Merge remote-tracking branch 'origin/develop' into YSP-446-drupal-10.2
vinmassaro Sep 24, 2024
a86a14d
fix(YSP-446): update typogrify version and patch
vinmassaro Sep 24, 2024
511f6d9
Merge branch 'develop' into YSP-446-drupal-10.2
vinmassaro Oct 10, 2024
d7c62c4
feat(YSP-446): update core to 10.3.6
vinmassaro Oct 18, 2024
bc672e0
chore(YSP-446): update config for Drupal 10.2
vinmassaro May 13, 2024
b91f961
feat(YSP-446): update core to 10.2.6, remove core patch
vinmassaro May 13, 2024
8f651ca
feat(YSP-446): update core to 10.3.1 and re-export config
vinmassaro Jul 5, 2024
d616b86
chore(YSP-446): update modules to latest versions
vinmassaro Sep 11, 2024
079009c
chore(YSP-446): export updated config
vinmassaro Sep 11, 2024
775885a
fix(YSP-559): update packages
joetower Jun 17, 2024
a303540
fix(YSP-559): update to node 20
joetower Jun 18, 2024
4feffd0
fix(YSP-559): add eslint and other formatting repository
joetower Jun 18, 2024
f0c8480
chore(YSP-689): fix null error on views
dblanken-yale Sep 30, 2024
d333871
fix(YSP-559): add jquery_ui
dblanken-yale Oct 1, 2024
2686c59
feat(YSP-559): allow spi plugin
dblanken-yale Oct 17, 2024
4a55330
fix(YSP-559): add role_delegation as dependency
dblanken-yale Oct 22, 2024
23f0628
fix(YSP-559): add maxlength dependency on ys_alert
dblanken-yale Oct 22, 2024
f5bc3e5
fix(YSP-559): revert honeypot to 2.1.4
dblanken-yale Oct 22, 2024
14fea02
Revert "fix(YSP-559): add jquery_ui"
dblanken-yale Oct 22, 2024
e366e22
Merge pull request #772 from yalesites-org/YSP-559-update-npm-package…
dblanken-yale Oct 22, 2024
2e3eb14
Reapply "fix(YSP-559): add jquery_ui"
dblanken-yale Oct 23, 2024
fb645ae
fix(YSP-446): downgrade better_exposed_filters to 6.0.5
dblanken-yale Oct 23, 2024
f24d26d
feat(YSP-446): bump ai_engine to 1.2.5
dblanken-yale Oct 25, 2024
58955cd
fix(YSP-446): re-roll combined patch
dblanken-yale Oct 28, 2024
3653219
fix(YSP-446): add sort to patch
dblanken-yale Oct 28, 2024
d50034e
fix(YSP-446): fix patch sorting
dblanken-yale Oct 29, 2024
afe6148
fix(YSP-446): hide "Blocks" from Content menu
dblanken-yale Oct 30, 2024
2eeecb3
chore(YSP-446): Updated config exports due to upgrade
dblanken-yale Oct 30, 2024
db0f5c5
fix(YSP-446): hide single content sync
dblanken-yale Oct 30, 2024
dbac9cc
chore(YSP-446): bump editoria11y to 2.1.19
dblanken-yale Oct 31, 2024
6d85aa4
fix(YSP-446): guard against no tabs
dblanken-yale Oct 31, 2024
f267417
fix(YSP-446): guard against invalid endpoint URLs
dblanken-yale Oct 31, 2024
bbed5b0
fix(YSP-446): rename "Status" to "Published" on Content
dblanken-yale Oct 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/build_deploy_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ defaults:
run:
shell: bash
env:
TZ: "/usr/share/zoneinfo/America/Los_Angeles"
TZ: '/usr/share/zoneinfo/America/Los_Angeles'
TERM: dumb
ADMIN_EMAIL: ${{ secrets.ADMIN_EMAIL }}
ADMIN_PASSWORD: ${{ secrets.ADMIN_PASSWORD }}
Expand Down Expand Up @@ -86,7 +86,7 @@ jobs:
options: --user root
runs-on: ubuntu-latest
env:
YALESITES_BUILD_TOKEN: ${{ secrets.YALESITES_BUILD_TOKEN }}
YALESITES_BUILD_TOKEN: ${{ secrets.YALESITES_BUILD_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -145,7 +145,7 @@ jobs:
# Workaround for https://github.com/actions/runner/issues/2033
- name: Set git safe.directory
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
git config --global --add safe.directory "$GITHUB_WORKSPACE"

- name: Set bash_env env var
run: echo BASH_ENV=${RUNNER_TEMP}/bash_env.txt >> $GITHUB_ENV
Expand Down Expand Up @@ -194,11 +194,11 @@ jobs:
# https://github.com/pantheon-systems/docker-build-tools-ci/blob/6.x/scripts/set-environment
- name: setup-environment-vars
run: /build-tools-ci/scripts/set-environment

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '16.13'
node-version: '20'

- name: build frontend components
env:
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16.13
20.14.0
26 changes: 15 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
"require": {
"composer/installers": "^1.9",
"cweagans/composer-patches": "^1.7",
"drupal/core-composer-scaffold": "10.1.7",
"drupal/core-project-message": "10.1.7",
"drupal/core-recommended": "10.1.7",
"drupal/core-composer-scaffold": "10.3.6",
"drupal/core-project-message": "10.3.6",
"drupal/core-recommended": "10.3.6",
"drush/drush": "^11 || ^12",
"oomphinc/composer-installers-extender": "^2.0",
"pantheon-systems/drupal-integrations": "^10",
Expand Down Expand Up @@ -70,7 +70,9 @@
"[project-root]/.gitattributes": false
}
},
"installer-types": ["npm-asset"],
"installer-types": [
"npm-asset"
],
"installer-paths": {
"web/core": [
"type:drupal-core"
Expand Down Expand Up @@ -116,7 +118,7 @@
"preferred-install": "dist",
"sort-packages": true,
"platform": {
"php": "8.2"
"php": "8.3"
},
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
Expand All @@ -126,7 +128,9 @@
"oomphinc/composer-installers-extender": true,
"drupal/core-project-message": true,
"phpstan/extension-installer": true,
"drupal/console-extend-plugin": true
"drupal/console-extend-plugin": true,
"php-http/discovery": true,
"tbachert/spi": true
}
},
"scripts": {
Expand All @@ -137,14 +141,14 @@
"prepare-for-pantheon": "DrupalProject\\composer\\ScriptHandler::prepareForPantheon",
"unit-test": "echo 'No unit test step defined.'",
"code-sniff": [
".\/vendor\/bin\/phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,info,txt --colors --ignore=node_modules,bower_components,vendor .\/web\/modules\/custom .\/web\/themes\/custom .\/web\/profiles\/custom",
".\/vendor\/bin\/phpcs --standard=DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt --colors --ignore=node_modules,bower_components,vendor .\/web\/modules\/custom .\/web\/themes\/custom .\/web\/profiles\/custom"
"./vendor/bin/phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,info,txt --colors --ignore=node_modules,bower_components,vendor ./web/modules/custom ./web/themes/custom ./web/profiles/custom",
"./vendor/bin/phpcs --standard=DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt --colors --ignore=node_modules,bower_components,vendor ./web/modules/custom ./web/themes/custom ./web/profiles/custom"
],
"code-fix": [
".\/vendor\/bin\/phpcbf --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,info,txt --colors --ignore=node_modules,bower_components,vendor .\/web\/modules\/custom .\/web\/themes\/custom .\/web\/profiles\/custom",
".\/vendor\/bin\/phpcbf --standard=DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt --colors --ignore=node_modules,bower_components,vendor .\/web\/modules\/custom .\/web\/themes\/custom .\/web\/profiles\/custom"
"./vendor/bin/phpcbf --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,info,txt --colors --ignore=node_modules,bower_components,vendor ./web/modules/custom ./web/themes/custom ./web/profiles/custom",
"./vendor/bin/phpcbf --standard=DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt --colors --ignore=node_modules,bower_components,vendor ./web/modules/custom ./web/themes/custom ./web/profiles/custom"
],
"lint:php": ".\/.ci/test/static/lint_php",
"lint:php": "./.ci/test/static/lint_php",
"post-install-cmd": [
"DrupalProject\\composer\\ScriptHandler::createRequiredFiles"
],
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"devDependencies": {
"@saithodev/semantic-release-backmerge": "^4.0.1",
"@semantic-release/git": "^10.0.1",
"@yalesites-org/eslint-config-and-other-formatting": "^1.5.0",
"@yalesites-org/eslint-config-and-other-formatting": "^1.20.0",
"eslint-config-drupal": "^5.0.2",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-react": "^7.29.4",
Expand Down Expand Up @@ -92,7 +92,9 @@
[
"@saithodev/semantic-release-backmerge",
{
"backmergeBranches": ["develop"],
"backmergeBranches": [
"develop"
],
"backmergeStrategy": "merge"
}
],
Expand Down
4 changes: 2 additions & 2 deletions pantheon.upstream.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
api_version: 1
php_version: 8.2
php_version: 8.3
database:
version: 10.4
version: 10.6
drush_version: 10
web_docroot: true
enforce_https: transitional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,39 @@ index b05fa2f..4b5c9b8 100644
+ type: string
+ label: 'Fallback image alt'
diff --git a/src/Controller/BrowserController.php b/src/Controller/BrowserController.php
index 9331cae..376d953 100644
index 34310e2..fa855a6 100644
--- a/src/Controller/BrowserController.php
+++ b/src/Controller/BrowserController.php
@@ -146,6 +146,9 @@ class BrowserController extends ControllerBase {
->loadByProperties(['status' => TRUE]);
uasort($blockcats, ['Drupal\Core\Config\Entity\ConfigEntityBase', 'sort']);

+ // For use with reusable images.
+ // For use with reusable images; this will reuse original images for blocks that are now reusable.
+ $allBlockImages = [];
+
/** @var \Drupal\layout_builder_browser\Entity\LayoutBuilderBrowserBlockCategory $blockcat */
foreach ($blockcats as $blockcat) {
$blocks = [];
@@ -168,6 +171,27 @@ class BrowserController extends ControllerBase {
@@ -169,6 +172,34 @@ class BrowserController extends ControllerBase {
}

$block_categories[$blockcat->id()]['links'] = $this->getBlocks($section_storage, $delta, $region, $blocks);
+
+ // Sets the images for each block into an array for reusable blocks.
+ foreach ($block_categories[$blockcat->id()] as $lbbCategories) {
+ foreach ($lbbCategories as $blockLinks) {
+ $plugin_id = str_replace('inline_block:', '', $blockLinks['#url']->getRouteParameters()['plugin_id']);
+ if (isset($blockLinks['#title']['image'])) {
+ $link_reference = NULL;
+ if (array_key_exists('#url', $blockLinks)) {
+ $link_reference = $blockLinks;
+ }
+ else {
+ $link_reference = $blockLinks['link'];
+ }
+ $plugin_id = str_replace('inline_block:', '', $link_reference['#url']->getRouteParameters()['plugin_id']);
+ if (isset($link_reference['#title']['image'])) {
+ $allBlockImages[$plugin_id] = [
+ 'uri' => $blockLinks['#title']['image']['#uri'],
+ 'alt' => $blockLinks['#title']['image']['#alt'],
+ 'uri' => $link_reference['#title']['image']['#uri'],
+ 'alt' => $link_reference['#title']['image']['#alt'],
+ ];
+ }
+ else {
Expand All @@ -57,7 +64,7 @@ index 9331cae..376d953 100644
if ($block_categories[$blockcat->id()]['links']) {
// Only add the information if the category has links.
$block_categories[$blockcat->id()]['#type'] = 'details';
@@ -187,6 +211,12 @@ class BrowserController extends ControllerBase {
@@ -188,6 +219,11 @@ class BrowserController extends ControllerBase {
$existing_blocks = $this->entityTypeManager->getStorage('layout_builder_browser_block')
->loadMultiple();
$existing_blocks_ids = array_column($existing_blocks, 'block_id');
Expand All @@ -66,22 +73,19 @@ index 9331cae..376d953 100644
+ if ($config->get('group_reusable_blocks_together')) {
+ $block_categories['reusable_blocks']['links'] = [];
+ }
+
foreach ($auto_added_reusable_bundles as $machine_name) {
$blocks = [];
$content_blocks = $this->entityTypeManager->getStorage('block_content')
@@ -203,19 +233,62 @@ class BrowserController extends ControllerBase {
@@ -207,19 +243,57 @@ class BrowserController extends ControllerBase {
}
}
if ($blocks) {
+
+ // For reusable blocks, get the machine name to attach images to.
+ foreach ($blocks as $key => $reusableBlock) {
+ $blockParts = explode(":", $reusableBlock['config_dependencies']['content'][0]);
+ if (!empty($blockParts)) {
+ $entity = $this->entityTypeManager()->getStorage('block_content')->loadByProperties(['uuid' => $blockParts[2]]);
+ $blocks[$key]['reusable_image'] = $allBlockImages[$blockParts[1]];
+ $blocks[$key]['#changed'] = $entity[array_key_first($entity)]->get('changed')->getString();
+ preg_match('/(?<=\:)(.*?)(?=\:)/', $reusableBlock['config_dependencies']['content'][0], $matches);
+ if (isset($matches[0])) {
+ $blocks[$key]['reusable_image'] = $allBlockImages[$matches[0]];
+ $blocks[$key]['#changed'] = $block->get('changed')->getString();
+ }
+ }
+
Expand All @@ -100,25 +104,22 @@ index 9331cae..376d953 100644
+
+ foreach ($block_links as $key => $block_link) {
+ $changed = date('m/d/Y - H:i', $block_link['#changed']);
+ $block_links[$key]['#title']['label']['#markup'] = "
+ <span class='underlined-title'>{$block_link['#title']['label']['#markup']}</span>
+ $block_links[$key]['link']['#title']['label']['#markup'] = "
+ <span class='underlined-title'>{$block_link['link']['#title']['label']['#markup']}</span>
+ <br>
+ Type: {$bundle_label}
+ <br>
+ Changed: {$changed}
+ ";
+ $block_links[$key]['#attributes']['class'][] = 'layout-builder-browser-reusable-block';
+ $block_links[$key]['link']['#attributes']['class'][] = 'layout-builder-browser-reusable-block';
+ }
+
+ // Only add the information if the category has links.
+ foreach ($block_links as $link) {
+ $block_categories['reusable_blocks']['links'][] = $link;
+ }
+
+ array_push($block_categories['reusable_blocks']['links'], $block_links);
+ $block_categories['reusable_blocks']['#type'] = 'details';
+ $block_categories['reusable_blocks']['#attributes']['class'][] = 'js-layout-builder-category';
+ $block_categories['reusable_blocks']['#open'] = $blockcat->getOpened();
+ $block_categories['reusable_blocks']['#title'] = $this->t('Reusable Blocks');
+ $block_categories['reusable_blocks']['#title'] = $this->t('Reusable blocks');
+ }
+ else {
+ // Only add the information if the category has links.
Expand All @@ -131,19 +132,18 @@ index 9331cae..376d953 100644
}
}
}

+ usort($block_categories['reusable_blocks']['links'], function($a, $b) {
+ return $b['#changed'] <=> $a['#changed'];
+ return $b[0]['link']['#changed'] <=> $a[0]['link']['#changed'];
+ });
+
$build['block_categories'] = $block_categories;
$build['#attached']['library'][] = 'layout_builder_browser/browser';

@@ -266,6 +339,16 @@ class BrowserController extends ControllerBase {
'#alt' => $block['layout_builder_browser_data']->image_alt,
@@ -278,6 +352,14 @@ class BrowserController extends ControllerBase {
'#alt' => $block['layout_builder_browser_category_data']->image_alt,
];
}
+
+ // For reusable blocks, attach image.
+ elseif ($block['reusable_image']['uri']) {
+ $block_render_array['image'] = [
Expand All @@ -152,26 +152,25 @@ index 9331cae..376d953 100644
+ '#alt' => $block['reusable_image']['alt'],
+ ];
+ }
+
$block_render_array['label'] = ['#markup' => (empty($block["layout_builder_browser_data"])) ? $block['admin_label'] : $block["layout_builder_browser_data"]->label()];
$link = [
'#type' => 'link',
@@ -280,6 +363,7 @@ class BrowserController extends ControllerBase {
@@ -292,6 +374,7 @@ class BrowserController extends ControllerBase {
]
),
'#attributes' => $attributes,
+ '#changed' => $block['#changed'],
];

$links[] = $link;
$links[] = [
diff --git a/src/Form/SettingsForm.php b/src/Form/SettingsForm.php
index 90253f0..b1c5ff2 100644
index 90253f0..1ac6883 100644
--- a/src/Form/SettingsForm.php
+++ b/src/Form/SettingsForm.php
@@ -83,6 +83,27 @@ class SettingsForm extends ConfigFormBase {
@@ -83,6 +83,28 @@ class SettingsForm extends ConfigFormBase {
'#default_value' => $config->get('auto_added_reusable_block_content_bundles') ?? [],
];

+ $form['group_reusable_blocks_together'] = [
+ '#title' => $this->t('Group reusable blocks together'),
+ '#description' => $this->t('By default, reusable blocks are grouped according to their bundle type. Checking this box will group all reusable blocks together in one group.'),
Expand All @@ -192,17 +191,18 @@ index 90253f0..b1c5ff2 100644
+ '#type' => 'textfield',
+ '#default_value' => $config->get('reusable_image_fallback_alt') ?? NULL,
+ ];
+
+
return parent::buildForm($form, $form_state);
}

@@ -95,6 +116,9 @@ class SettingsForm extends ConfigFormBase {
@@ -95,6 +117,9 @@ class SettingsForm extends ConfigFormBase {
$config->set('enabled_section_storages', array_filter($form_state->getValue('enabled_section_storages')));
$config->set('use_modal', $form_state->getValue('use_modal'));
$config->set('auto_added_reusable_block_content_bundles', array_filter($form_state->getValue('auto_added_reusable_block_content_bundles')));
+ $config->set('group_reusable_blocks_together', $form_state->getValue('group_reusable_blocks_together'));
+ $config->set('reusable_image_fallback', $form_state->getValue('reusable_image_fallback'));
+ $config->set('reusable_image_fallback_alt', $form_state->getValue('reusable_image_fallback_alt'));
$config->save();

parent::submitForm($form, $form_state);
Loading