Skip to content

Commit

Permalink
SHS-5905: Rework social media footer (#1662)
Browse files Browse the repository at this point in the history
* feat(SHS-5905): Recreate social media block as a custom block plugin

* feat(SHS-5905): Add composer.lock

* feat(SHS-5905): Enable multivalue form element module

* feat(SHS-5905): Add update hook for permissions change

* fix(SHS-5905): Fix error for default config and add cache context for user

* fix(SHS-5905): Contextual menu still not rendering on Tugboat for non-admins

* fix(SHS-5905): Fix attached library for contextual menu

* fix(SHS-5909): Strict checking of the array seemed to fix the contextual links on local

* fix(SHS-5905): Remove strict checking

* fix(SHS-5905): Remove old permissions before adding social media block permissions

* fix(SHS-5905): Linting fixes

* chore(SHS-5905): WIP TEST ONLY - see if removing the code block in the profile works on tugboat

* fix(SHS-5905): Fix contextual menu for non-admins

* feat(SHS-5905): Remove permission update hook and add dependency on one in profile

* feat(shs-5906): icon logic, templates and styles for social media footer block (#1673)

* chore(SHS-5905): Temp remove code to test other contextual menus

* feat(SHS-5905): Add custom contextual link

* fix(SHS-5905): Get contextual links working (finally) for Social Media block

* fix(shs-5905): fixes in social media block

* fix(shs-5905): replace multivalue_form_element with custom version in social media block

* fix(shs-5905): remove multivalue_form_element module

* fix(shs-5905): update social media block links help text

* fix(shs-5905): social media footer block fixes

---------

Co-authored-by: Andrés Díaz Soto <[email protected]>
  • Loading branch information
codechefmarc and cienvaras authored Dec 13, 2024
1 parent e59df54 commit 3d9ef65
Show file tree
Hide file tree
Showing 12 changed files with 584 additions and 2 deletions.
1 change: 1 addition & 0 deletions config/default/user.role.site_manager.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ permissions:
- 'edit own hs_research content'
- 'edit own image media'
- 'edit own video media'
- 'edit social media block'
- 'edit terms in hs_course_component'
- 'edit terms in hs_course_tags'
- 'edit terms in hs_event_audience'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
block.settings.hs_blocks_social_media_block:
type: block_settings
label: 'Social Media Block Configuration'
mapping:
icon_size:
type: string
label: 'Icon Size'
layout:
type: string
label: String
links:
type: sequence
label: Links
sequence:
link_url:
type: uri
label: URL
link_title:
type: string
label: Title
_weight:
type: integer
label: Weight
7 changes: 7 additions & 0 deletions docroot/modules/humsci/hs_blocks/hs_blocks.install
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,10 @@ function _hs_blocks_fix_sections(array $sections) {
}
return $was_changed;
}

/**
* Update user permissions for new social media block.
*/
function hs_blocks_update_10201() {
user_role_grant_permissions('site_manager', ['edit social media block']);
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,8 @@ hs_blocks.block_move_down:
class: ['use-ajax']
# data-dialog-type: dialog
# data-dialog-renderer: off_canvas

hs_blocks.social_media_block:
title: 'Edit Social Media block'
route_name: 'entity.block.edit_form'
group: 'social_media_block'
28 changes: 28 additions & 0 deletions docroot/modules/humsci/hs_blocks/hs_blocks.module
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
* Contains hs_blocks.module.
*/

use Drupal\block\Entity\Block;
use Drupal\Component\Utility\Html;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Session\AccountInterface;

/**
* Implements hook_help().
Expand All @@ -34,6 +37,14 @@ function hs_blocks_theme($existing, $type, $theme, $path) {
'template' => 'block--hs-login',
'variables' => ['preface' => NULL, 'link' => NULL, 'postface' => NULL],
],
'hs_blocks_social_media' => [
'template' => 'block--social-media',
'variables' => [
'icon_size' => NULL,
'layout' => NULL,
'links' => [],
],
],
];
}

Expand Down Expand Up @@ -128,3 +139,20 @@ function hs_blocks_preprocess_block__views_exposed_filter_block(&$variables) {
$variables['content']['#id'] .= '-' . $build_id;
}
}

/**
* Implements hook_block_access().
*/
function hs_blocks_block_access(Block $block, $operation, AccountInterface $account) {
// Allows roles with "Edit social media block" to edit the custom block.
if (
$block->getPluginId() === 'hs_blocks_social_media_block' &&
$operation === 'update' &&
$account->hasPermission('edit social media block')
) {
return AccessResult::allowed();
}

// No change, return neutral result.
return AccessResult::neutral();
}
3 changes: 3 additions & 0 deletions docroot/modules/humsci/hs_blocks/hs_blocks.permissions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
edit social media block:
title: 'Edit social media block'
description: 'Allows users to configure the social media block'
Loading

0 comments on commit 3d9ef65

Please sign in to comment.