Skip to content

Commit

Permalink
Merge pull request #792 from yalesites-org/v1100
Browse files Browse the repository at this point in the history
Release v1.10.0
  • Loading branch information
vinmassaro authored Nov 19, 2024
2 parents ea71043 + d5003ec commit dbc1942
Show file tree
Hide file tree
Showing 172 changed files with 5,300 additions and 354 deletions.
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.8",
"drupal/core-project-message": "10.3.8",
"drupal/core-recommended": "10.3.8",
"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
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
"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",
"eslint-plugin-yml": "^0.14.0",
"semantic-release": "^23.0.0",
"semantic-release": "^24.0.0",
"semantic-release-replace-plugin": "^1.2.7",
"shelljs": "^0.8.5"
},
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
1 change: 1 addition & 0 deletions pantheon.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
api_version: 1
# Downstream sites should not change the workflow.

# Specifying Quicksilver workflows in pantheon.upstream.yml is not supported.
workflows:
clone_database:
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 @@ -99,26 +103,23 @@ index 9331cae..376d953 100644
+ if ($config->get('group_reusable_blocks_together')) {
+
+ 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>
+ $changed = date('m/d/Y - H:i', $block_link['link']['#changed']);
+ $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

0 comments on commit dbc1942

Please sign in to comment.