Skip to content
This repository has been archived by the owner on Jul 27, 2022. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into EPIC-5614
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiu-cristea committed Jun 10, 2020
2 parents 0fcf61c + f4b4054 commit 2fdb06b
Show file tree
Hide file tree
Showing 27 changed files with 313 additions and 15 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"drupal/search_api_solr": "2.2",
"drupal/simple_sitemap": "~3.6",
"drupal/simplenews": "^1.0-beta1",
"drupal/site_alert": "~1.1",
"drupal/smart_trim": "~1.2",
"drupal/social_media_links": "^2.6",
"drupal/spdx": "^1.0.0-alpha5",
Expand Down
57 changes: 56 additions & 1 deletion composer.lock

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

2 changes: 1 addition & 1 deletion config/sync/block.block.eiradeprecatedtermmessage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dependencies:
id: eiradeprecatedtermmessage
theme: joinup_theme
region: content_top
weight: 0
weight: -19
provider: null
plugin: eira_derprecated_term_block
settings:
Expand Down
2 changes: 1 addition & 1 deletion config/sync/block.block.joinup_theme_messages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ _core:
id: joinup_theme_messages
theme: joinup_theme
region: content_top
weight: -18
weight: -20
provider: null
plugin: system_messages_block
settings:
Expand Down
3 changes: 2 additions & 1 deletion config/sync/block.block.licencedeprecatedmessage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ langcode: en
status: true
dependencies:
module:
- joinup_core
- joinup_licence
theme:
- joinup_theme
id: licencedeprecatedmessage
theme: joinup_theme
region: content_top
weight: 0
weight: -18
provider: null
plugin: licence_deprecated_message_block
settings:
Expand Down
3 changes: 1 addition & 2 deletions config/sync/block.block.navigation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ dependencies:
config:
- og_menu.ogmenu.navigation
module:
- collection
- solution
- joinup_group
- og
theme:
- joinup_theme
Expand Down
1 change: 1 addition & 0 deletions config/sync/block.block.rdf_entities_in_proposed_state.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ status: true
dependencies:
module:
- joinup_core
- joinup_group
- user
theme:
- joinup_theme
Expand Down
21 changes: 21 additions & 0 deletions config/sync/block.block.site_alerts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
uuid: 3204b36b-f978-4f1b-bd6d-b2d3fe0660c4
langcode: en
status: true
dependencies:
module:
- site_alert
theme:
- joinup_theme
id: site_alerts
theme: joinup_theme
region: content_top
weight: -21
provider: null
plugin: site_alert_block
settings:
id: site_alert_block
label: 'Site alerts'
provider: site_alert
label_display: '0'
timeout: 0
visibility: { }
1 change: 1 addition & 0 deletions config/sync/block.block.unpublished_content_of_group.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ dependencies:
module:
- ctools
- joinup_core
- joinup_group
theme:
- joinup_theme
_core:
Expand Down
1 change: 1 addition & 0 deletions config/sync/core.extension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ module:
serialization: 0
simple_sitemap: 0
simplenews: 0
site_alert: 0
smart_trim: 0
social_media_links: 0
social_media_links_field: 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,4 +245,7 @@ settings:
paragraphs_type:
handler: 'default:paragraphs_type'
handler_settings: { }
site_alert:
handler: 'default:site_alert'
handler_settings: { }
field_type: dynamic_entity_reference
10 changes: 7 additions & 3 deletions config/sync/user.role.moderator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ permissions:
- 'access release create field'
- 'access toolbar'
- 'access uri converter'
- 'add site alerts'
- 'administer collection ownership'
- 'administer comments'
- 'administer entity legal'
Expand All @@ -26,6 +27,7 @@ permissions:
- 'administer nodes'
- 'administer search fields'
- 'administer shared entities'
- 'administer site alert'
- 'administer solution ownership'
- 'administer support menu items'
- 'administer tallinn settings'
Expand All @@ -35,16 +37,17 @@ permissions:
- 'create custom collection page'
- 'create discussion content'
- 'create licence rdf entity'
- 'create paragraph content simple_paragraph'
- 'create paragraph content json_map'
- 'create paragraph content simple_paragraph'
- 'create rdf entity news'
- 'create solution releases'
- 'delete any document content'
- 'delete contact_information rdf entity'
- 'delete licence rdf entity'
- 'delete owner rdf entity'
- 'delete paragraph content simple_paragraph'
- 'delete paragraph content json_map'
- 'delete paragraph content simple_paragraph'
- 'delete site alerts'
- 'edit any custom_page content'
- 'edit any discussion content'
- 'edit contact_information rdf entity'
Expand All @@ -68,8 +71,9 @@ permissions:
- 'unfeature entity'
- 'unpin entity'
- 'update any simple_block block content'
- 'update paragraph content simple_paragraph'
- 'update paragraph content json_map'
- 'update paragraph content simple_paragraph'
- 'update site alerts'
- 'view any unpublished content'
- 'view licence overview page'
- 'view rdf entity overview'
Expand Down
57 changes: 57 additions & 0 deletions tests/features/moderator/site_alerts.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
@api @group-b
Feature: Site alerts
In order to announce scheduled downtime
As a moderator
I want to be able to display a site wide alert

Scenario: Show a site wide alert and hide it again
# Create a site wide alert as a moderator.
Given I am logged in as a moderator
When I click "Site alerts" in the "Administration toolbar" region
Then I should see the text "There are no site alerts yet."

When I click "Add Site Alert"
And I fill in "Label" with "Site maintenance 18:00-20:00"
And I select "Medium" from "Severity"
And I enter "Between 18:00 and 20:00 the site will be temporarily unavailable due to scheduled maintenance" in the "Message" wysiwyg editor
And I press "Save"

# Anonymous users should see the alert.
Given I am not logged in
And I am on the homepage
Then I should see the text "Between 18:00 and 20:00 the site will be temporarily unavailable due to scheduled maintenance"

# Deactivate the alert without deleting it, so it can be used again later.
Given I am logged in as a moderator
When I click "Site alerts" in the "Administration toolbar" region
And I click "Edit"
And I uncheck "Active"
And I press "Save"
Then I should see the text "Not Active"

# The alert should no longer be shown.
Given I am not logged in
And I am on the homepage
Then I should not see the text "Between 18:00 and 20:00 the site will be temporarily unavailable due to scheduled maintenance"

# Re-enable the alert, it should appear again.
Given I am logged in as a moderator
When I click "Site alerts" in the "Administration toolbar" region
And I click "Edit"
And I check "Active"
And I press "Save"

Given I am not logged in
And I am on the homepage
Then I should see the text "Between 18:00 and 20:00 the site will be temporarily unavailable due to scheduled maintenance"

# An alert can also be removed entirely, if it does not need to be reused.
Given I am logged in as a moderator
When I click "Site alerts" in the "Administration toolbar" region
And I click "Delete"
And I press "Delete"
Then I should see the message " The Site Alert Site maintenance 18:00-20:00 has been deleted."

Given I am not logged in
And I am on the homepage
Then I should not see the text "Between 18:00 and 20:00 the site will be temporarily unavailable due to scheduled maintenance"
1 change: 1 addition & 0 deletions web/modules/custom/joinup_core/joinup_core.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ dependencies:
- 'redirect:redirect'
- 'search_api:search_api'
- 'search_api_solr:search_api_solr'
- 'site_alert:site_alert'
- 'state_machine:state_machine'

config_devel:
Expand Down
9 changes: 8 additions & 1 deletion web/modules/custom/joinup_core/joinup_core.links.menu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,17 @@ joinup_core.edit_support_menu:
route_name: entity.menu.edit_form
route_parameters:
menu: support
description: 'Allows to manage of the user support menu.'
description: 'Allows to manage the user support menu.'
parent: system.admin
weight: 0

joinup_core.site_alerts:
title: 'Site alerts'
route_name: entity.site_alert.collection
description: 'Manage site wide alerts.'
parent: system.admin
weight: 3

joinup_core.support.tour:
title: 'Take a tour'
menu_name: support
Expand Down
21 changes: 21 additions & 0 deletions web/modules/custom/joinup_core/joinup_core.module
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use Drupal\Core\Link;
use Drupal\Core\StreamWrapper\StreamWrapperManager;
use Drupal\Core\Template\Attribute;
use Drupal\joinup_core\Element\Datetime;
use Drupal\joinup_core\JoinupSiteAlertListBuilder;
use Drupal\node\NodeInterface;
use Drupal\search_api\IndexInterface;
use Drupal\search_api\Utility\Utility;
Expand Down Expand Up @@ -127,6 +128,18 @@ function joinup_core_form_rdf_entity_form_alter(&$form, FormStateInterface $form
}
}

/**
* Implements hook_form_BASE_FORM_ID_alter().
*
* Alters the Site Alert entity form to hide the scheduling of the alerts. Due
* to a bug in the core page cache module the scheduling can only work using an
* additional AJAX call which is undesirable in our case. By disabling the
* scheduling the alerts are managed manually and the page cache works normally.
*/
function joinup_core_form_site_alert_form_alter(&$form, FormStateInterface $form_state, $form_id) {
$form['scheduling']['#access'] = FALSE;
}

/**
* Implements hook_entity_base_field_info().
*
Expand Down Expand Up @@ -174,6 +187,14 @@ function joinup_core_entity_base_field_info(EntityTypeInterface $entity_type) {
* Implements hook_entity_type_alter().
*/
function joinup_core_entity_type_alter(array &$entity_types) {
// Check that the Site Alert entity type is defined, so we can avoid depending
// on the Site Alert module.
if (isset($entity_types['site_alert'])) {
// Override the list builder with a version which omits the unused 'Start
// time' and 'End time' columns.
$entity_types['site_alert']->setListBuilderClass(JoinupSiteAlertListBuilder::class);
}

if (!isset($entity_types['rdf_entity'])) {
return;
}
Expand Down
Loading

0 comments on commit 2fdb06b

Please sign in to comment.