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

SHS-5905: Rework social media footer (backend) #1662

Open
wants to merge 19 commits into
base: 11.5.1-release
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
a9075a7
feat(SHS-5905): Recreate social media block as a custom block plugin
codechefmarc Oct 18, 2024
bc77b70
feat(SHS-5905): Add composer.lock
codechefmarc Oct 18, 2024
3f7823a
feat(SHS-5905): Enable multivalue form element module
codechefmarc Oct 18, 2024
3aac4af
feat(SHS-5905): Add update hook for permissions change
codechefmarc Oct 18, 2024
dcd08ed
fix(SHS-5905): Fix error for default config and add cache context for…
codechefmarc Oct 18, 2024
7d42637
fix(SHS-5905): Contextual menu still not rendering on Tugboat for non…
codechefmarc Oct 18, 2024
8df9eed
fix(SHS-5905): Fix attached library for contextual menu
codechefmarc Oct 18, 2024
69960f0
Merge branch '11.4.1-release' into SHS-5905--social-block
codechefmarc Oct 21, 2024
c0822b8
fix(SHS-5909): Strict checking of the array seemed to fix the context…
codechefmarc Oct 21, 2024
3a31d71
Merge branch '11.4.1-release' into SHS-5905--social-block
codechefmarc Oct 30, 2024
ba88271
fix(SHS-5905): Remove strict checking
codechefmarc Oct 30, 2024
e219687
fix(SHS-5905): Remove old permissions before adding social media bloc…
codechefmarc Oct 30, 2024
d2c1c21
fix(SHS-5905): Linting fixes
codechefmarc Oct 30, 2024
ec99c5d
chore(SHS-5905): WIP TEST ONLY - see if removing the code block in th…
codechefmarc Oct 30, 2024
510737e
fix(SHS-5905): Fix contextual menu for non-admins
codechefmarc Oct 30, 2024
69dc3aa
Merge branch '11.5.1-release' into SHS-5905--social-block
codechefmarc Nov 2, 2024
f0374da
feat(SHS-5905): Remove permission update hook and add dependency on o…
codechefmarc Nov 2, 2024
0a94aff
Merge branch '11.5.1-release' of github.com:SU-HSDO/suhumsci into SHS…
cienvaras Nov 5, 2024
fc6d2a9
feat(shs-5906): icon logic, templates and styles for social media foo…
cienvaras Nov 6, 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
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
"drupal/metatag": "^2.0",
"drupal/migrate_plus": "6.0.2",
"drupal/migrate_source_csv": "^3.4",
"drupal/multivalue_form_element": "^1.0@beta",
"drupal/mysql56": "^1.1",
"drupal/nobots": "^1.0",
"drupal/node_revision_delete": "^1.0@RC",
Expand Down
59 changes: 57 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions config/default/core.extension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ module:
migrate_plus: 0
migrate_source_csv: 0
migrate_tools: 0
multivalue_form_element: 0
mysql: 0
nobots: 0
node: 0
Expand Down
8 changes: 3 additions & 5 deletions config/default/user.role.site_manager.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ dependencies:
- filter.format.basic_html
- filter.format.minimal_html
- filter.format.minimal_html_with_styles
- media.type.embeddable
- media.type.file
- media.type.image
- media.type.video
Expand Down Expand Up @@ -43,6 +42,7 @@ dependencies:
- file
- filter
- help
- hs_blocks
- hs_entities
- hs_page_reports
- media
Expand Down Expand Up @@ -76,9 +76,7 @@ permissions:
- 'administer main menu items'
- 'administer nodes'
- 'administer users'
- 'assign author role'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're changing here a lot of permission unrelated to the block itself, please update to include only the necessary permissions.

- 'assign contributor role'
- 'assign intranet_viewer role'
- 'assign site_manager role'
- 'create embeddable media'
- 'create file media'
Expand Down Expand Up @@ -174,6 +172,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 All @@ -187,7 +186,7 @@ permissions:
- 'edit terms in hs_person_staff_type'
- 'edit terms in hs_person_student_type'
- 'edit terms in hs_publication_type'
- 'import hs_capx migration'
- 'import hs_courses migration'
- 'import hs_events_importer migration'
- 'manipulate entityqueues'
- 'mark as hidden in editoria11y'
Expand All @@ -196,7 +195,6 @@ permissions:
- 'publish any content'
- 'publish editable content'
- 'rabbit hole bypass node'
- 'rabbit hole bypass taxonomy_term'
- 'revert hs_basic_page revisions'
- 'revert hs_course revisions'
- 'revert hs_event revisions'
Expand Down
18 changes: 18 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,21 @@ function _hs_blocks_fix_sections(array $sections) {
}
return $was_changed;
}

/**
* Implements hook_update_dependencies().
*/
function hs_blocks_update_dependencies() {
// Permissions for field_paragraph_style need to be removed first.
$dependencies['hs_blocks'][10201] = [
'su_humsci_profile' => 9714,
];
return $dependencies;
}

/**
* Update user permissions for new social media block.
*/
function hs_blocks_update_10201() {
user_role_grant_permissions('site_manager', ['edit social media block']);
}
23 changes: 23 additions & 0 deletions docroot/modules/humsci/hs_blocks/hs_blocks.module
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
*/

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

/**
* Implements hook_help().
Expand All @@ -34,6 +37,10 @@ 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 +135,19 @@ function hs_blocks_preprocess_block__views_exposed_filter_block(&$variables) {
$variables['content']['#id'] .= '-' . $build_id;
}
}

/**
* Implements hook_entity_access().
*/
function hs_blocks_entity_access(EntityInterface $entity, $operation, AccountInterface $account) {
// Allows roles with "Edit social media block" to edit the custom block.
/** @var Drupal\block\Entity\Block $entity */
if ($entity->getEntityTypeId() === 'block' && $entity->getPluginId() === 'hs_blocks_social_media_block') {
if ($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
Loading