Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
fac611f
[EPAD8-2653] Adding user_not_role module to the project to hide block…
carsoncho Nov 11, 2024
8fdd608
[EPAD8-2653] Adding back edit link to content info box template.
carsoncho Nov 11, 2024
d70c667
[EPAD8-2653] Adding back old content moderation info box to be displa…
carsoncho Nov 11, 2024
345c488
[EPAD8-2653] Enabling user_not_role module.
carsoncho Nov 11, 2024
1e17a4f
[EPAD8-2653] Adding additional user_not_role logic to default tabs bl…
carsoncho Nov 11, 2024
1fc7833
[EPAD8-2653] Removing use_epa_node_tabs permission from authenticated…
carsoncho Nov 11, 2024
4ff47b5
[EPAD8-2653] Reverting label and weight back to the original values b…
carsoncho Nov 11, 2024
5471154
[EPAD8-2653] Adding additional access check to check if user has use_…
carsoncho Nov 11, 2024
f3c9530
[EPAD8-2653] Ensuring devel is disabled.
carsoncho Nov 11, 2024
c88aaf9
EPAD8-2653: Add spaced utility classes
dcmouyard Nov 19, 2024
ab86e8d
EPAD8-2653: Update content info box styles
dcmouyard Nov 19, 2024
d19b23a
[EPAD8-2653] Reworking core local tasks to not use user_not_role conf…
carsoncho Nov 21, 2024
819a9a2
[EPAD8-2653] Removing user_not_role contrib module.
carsoncho Nov 21, 2024
33234f3
Merge branch 'EPAD8-2653-beta-test-flag' of github.com:USEPA/webcms i…
carsoncho Nov 21, 2024
f4c883f
[EPAD8-2653] Fixing some form alter logic to ensure that a user who d…
carsoncho Nov 21, 2024
03f4a8f
[EPAD8-2653] Adjusting template logic for content moderation form.
carsoncho Nov 21, 2024
2c0b8d4
[EPAD8-2653] Removing user_not_role.
carsoncho Nov 21, 2024
fda57ba
[EPAD8-2625] Fixing issue with content moderation form displaying whe…
carsoncho Nov 25, 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
3 changes: 2 additions & 1 deletion services/drupal/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,8 @@
"drupal/core-project-message": true,
"mglaman/composer-drupal-lenient": true,
"drupal/core-vendor-hardening": true,
"php-http/discovery": true
"php-http/discovery": true,
"tbachert/spi": true
}
},
"autoload": {
Expand Down
4 changes: 2 additions & 2 deletions services/drupal/composer.lock

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

11 changes: 2 additions & 9 deletions services/drupal/config/sync/block.block.gesso_local_tasks.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
uuid: 1af0c01b-357e-4d33-8897-af6baf9519ff
uuid: e23e91b7-ef43-40d3-b8c3-eaf0b326f0ab
langcode: en
status: true
dependencies:
module:
- block_in_page_403
- system
theme:
- epa_theme
_core:
default_config_hash: c-06bbElRY5sKmglk74ppgTW93Et4-EJFyNiUZMb8JY
id: gesso_local_tasks
theme: epa_theme
region: messages
weight: -21
weight: 0
provider: null
plugin: local_tasks_block
settings:
Expand All @@ -27,7 +24,3 @@ visibility:
id: page_403
negate: false
page_403: 0
request_path:
id: request_path
negate: true
pages: '/node/*'
1 change: 0 additions & 1 deletion services/drupal/config/sync/user.role.authenticated.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ permissions:
- 'use text format restricted_html'
- 'use text format restricted_html_no_links'
- 'use text format webform_default'
- use_epa_node_tabs
- 'view all revisions'
- 'view any unpublished content'
- 'view any webform submission'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ epa_web_areas.my_web_areas:

epa_web_areas.node_group_dashboard:
route_name: page_manager.page_view_group_view_group_view-layout_builder-0
title: 'Back to group dashboard'
title: 'Group dashboard'
base_route: entity.node.canonical
class: '\Drupal\epa_web_areas\Plugin\Menu\NodeGroupTab'
weight: -100
weight: 9

epa_web_areas.group_type_allowed_bulk_change_nodes:
title: 'Allowed Bulk Change Entity Bundles'
Expand Down
69 changes: 56 additions & 13 deletions services/drupal/web/modules/custom/epa_workflow/epa_workflow.module
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
* Contains epa_workflow.module.
*/

use Drupal\block\Entity\Block;
use Drupal\content_moderation\Entity\ContentModerationStateInterface;
use Drupal\content_moderation\Form\EntityModerationForm;
use Drupal\content_moderation_notifications\ContentModerationNotificationInterface;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Entity\EntityInterface;
Expand All @@ -15,6 +18,7 @@ use Drupal\Core\Entity\RevisionLogInterface;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Link;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Site\Settings;
use Drupal\Core\Url;
use Drupal\datetime\Plugin\Field\FieldType\DateTimeItemInterface;
Expand Down Expand Up @@ -378,7 +382,10 @@ function epa_workflow_entity_view(array &$build, EntityInterface $entity, Entity
return;
}

build_content_moderation_info_box($entity, $build);
// Logic to ensure that only non-beta tester role users get to see the 'old' content moderation info box.
if (!in_array('beta_tester', \Drupal::currentUser()->getRoles())) {
build_content_moderation_info_box($entity, $build);
}
}
}

Expand Down Expand Up @@ -525,18 +532,18 @@ function build_content_moderation_info_box(EntityInterface $entity, array &$buil
'#markup' => $renderer->render($flag_link),
];

// $build['epa_content_moderation_info_box'] = [
// '#theme' => 'epa_content_info_box',
// '#node_edit_link' => $node_edit_link,
// '#nid' => $nid,
// '#vid' => $vid,
// '#revision_author' => $revision_author,
// '#review_deadline' => $review_deadline,
// '#current' => $current,
// '#flag_link' => $flag_link_item,
// '#content_moderation_form' => \Drupal::formBuilder()
// ->getForm(EntityModerationForm::class, $entity),
// ];
$build['epa_content_moderation_info_box'] = [
'#theme' => 'epa_content_info_box',
'#node_edit_link' => $node_edit_link,
'#nid' => $nid,
'#vid' => $vid,
'#revision_author' => $revision_author,
'#review_deadline' => $review_deadline,
'#current' => $current,
'#flag_link' => $flag_link_item,
'#content_moderation_form' => \Drupal::formBuilder()
->getForm(EntityModerationForm::class, $entity),
];
}

/**
Expand All @@ -548,6 +555,17 @@ function build_content_moderation_info_box(EntityInterface $entity, array &$buil
* @see \Drupal\epa_workflow\Plugin\Block\EpaNodeTabsBlock
*/
function epa_workflow_menu_local_tasks_alter(array &$data, $route_name) {

// Hide the node edit tab always. This is added back as a separate button in the epa_content_info_box
if (isset($data['tabs'][0]['entity.node.edit_form'])) {
unset($data['tabs'][0]['entity.node.edit_form']);
}

// This should only be altered if the user has the permission to the new node tabs.
if (!\Drupal::currentUser()->hasPermission('use_epa_node_tabs')) {
return;
}

// Order:
// - Back to group dashboard
// - Edit page layout
Expand All @@ -565,6 +583,7 @@ function epa_workflow_menu_local_tasks_alter(array &$data, $route_name) {
'title' => 'Content',
],
'epa_web_areas.node_group_dashboard' => [
'title' => 'Back to group dashboard',
'weight' => -100
],
'layout_builder_ui:layout_builder.overrides.node.view' => [
Expand Down Expand Up @@ -619,6 +638,7 @@ function epa_workflow_menu_local_tasks_alter(array &$data, $route_name) {
}
}
}

}

/**
Expand Down Expand Up @@ -1049,3 +1069,26 @@ function epa_workflow_page_top(array &$page_top) {
}
}
}

/**
* Implements hook_block_access().
*
* @todo: Remove this once the local task redesign work becomes the standard for all.
*/
function epa_workflow_block_access(Block $block, $operation, AccountInterface $account) {
// The core local tasks are special now with the local task redesign work.
// We want to only have the standard local tasks shown if:
// 1. Not on a node page
// 2. If we are on a node page AND the user does not have the "Beta Tester" role
if ($block->id() == 'gesso_local_tasks') {
// First check to see if we're on a node route.
if (!\Drupal::routeMatch()->getParameter('node')) {
return AccessResult::neutral();
}

// Must mean we're on a node route so check if the user is a beta tester
if ($account->hasRole('beta_tester')) {
return AccessResult::forbidden();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,15 @@ private function addPublishDateField(array &$form, NodeInterface $node) {
private function tweakFormClasses(array &$form) {
$form['new_state']['#title'] = t('Change state to');
$form['new_state']['#wrapper_attributes']['class'][] = 'epa-content-moderation__fancy-select';
$form['revision_log']['#wrapper_attributes']['class'][] = 'epa-content-moderation__form-item';

$form['workflow_508_compliant']['#wrapper_attributes']['class'][] = 'epa-content-moderation__form-item';
$form['submit']['#attributes']['class'][] = 'button--primary';
if (isset($form['submit'])) {
$form['submit']['#attributes']['class'][] = 'button--primary';
}

if (isset($form['revision_log'])) {
$form['revision_log']['#wrapper_attributes']['class'][] = 'epa-content-moderation__form-item';
}
}

/**
Expand Down Expand Up @@ -214,9 +220,11 @@ private function adjustStateOptions(array &$form) {
* @return void
*/
private function adjustRevisionLog(array &$form) {
$form['revision_log']['#title'] = t('Revision notes');
$form['revision_log']['#type'] = 'textarea';
unset($form['revision_log']['#size']);
if (isset($form['revision_log'])) {
$form['revision_log']['#title'] = t('Revision notes');
$form['revision_log']['#type'] = 'textarea';
unset($form['revision_log']['#size']);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Drupal\Core\Template\Attribute;
use Drupal\Core\Url;
use Drupal\epa_workflow\ModerationStateToColorMapTrait;
use Drupal\node\Entity\Node;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
Expand Down Expand Up @@ -100,6 +101,10 @@ protected function blockAccess(AccountInterface $account) {
return AccessResultForbidden::forbidden();
}

if (!\Drupal::currentUser()->hasPermission('use_epa_node_tabs')) {
return AccessResultForbidden::forbidden();
}

// This block doesn't make sense on the below routes.
// - Node revisions listing page.
// - Node delete form.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@
<details class="epa-content-moderation__dropdown epa-dropdown js-epa-dropdown">
<summary class="epa-content-moderation__button epa-dropdown__button">
{{ current_state }}
<svg class="epa-content-moderation__button-icon epa-dropdown__icon" aria-hidden="true" role="img">
<use href="/themes/epa_theme/images/drupal-sprite.artifact.svg#chevron-down"></use>
</svg>
{% if content_moderation_form|render|striptags|trim is not empty %}
<svg class="epa-content-moderation__button-icon epa-dropdown__icon" aria-hidden="true" role="img">
<use href="/themes/epa_theme/images/drupal-sprite.artifact.svg#chevron-down"></use>
</svg>
{% endif %}
</summary>
<div class="epa-content-moderation__drawer epa-dropdown__drawer">
{{ content_moderation_form }}
</div>
{% if content_moderation_form|render|striptags|trim is not empty %}
<div class="epa-content-moderation__drawer epa-dropdown__drawer">
{{ content_moderation_form }}
</div>
{% endif %}
</details>
<p class="epa-content-moderation__info">{{ last_modified }}</p>
<p class="epa-content-moderation__help-text">{{ help_text }}</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
@forward 'clearfix';
@forward 'full-width';
@forward 'print';
@forward 'spaced';
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// @file
// Vertical spacing utility classes.

@use '../00-config' as *;

$sizes: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15;

@each $size in $sizes {
.u-spaced-#{$size},
.u-spaced-#{$size}-above {
margin-block-start: #{rem(gesso-spacing($size))} !important;
}

.u-spaced-#{$size},
.u-spaced-#{$size}-below {
margin-block-end: #{rem(gesso-spacing($size))} !important;
}
}

.u-spaced-none,
.u-spaced-none-above {
margin-block-start: 0 !important;
}

.u-spaced-none,
.u-spaced-none-below {
margin-block-end: 0 !important;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{% if node_edit_link %}
{{ node_edit_link }}
{% endif %}

{% set box_content %}
{% if flag_link %}
{{ flag_link }}
<div class="u-align-right">{{ flag_link }}</div>
{% endif %}

{% if nid %}
Expand Down Expand Up @@ -67,7 +71,7 @@
{% endif %}

{% if content_moderation_form %}
{{ content_moderation_form }}
<div class="u-spaced-3-above">{{ content_moderation_form }}</div>
{% endif %}
{% endset %}

Expand Down