Skip to content

Commit

Permalink
Merge pull request #437 from City-of-Helsinki/dev
Browse files Browse the repository at this point in the history
Dev to main
  • Loading branch information
khalima authored Sep 27, 2023
2 parents 3406a2d + 393ba1d commit 2dc0c49
Show file tree
Hide file tree
Showing 19 changed files with 248 additions and 261 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ jobs:
- name: Run PHPUnit tests
run: |
composer test-php public/modules/custom
[ -d "tests/" ] && composer test-php tests/ || echo "No DTT tests found. Ignoring..."
if [ -d "tests/" ]; then composer test-php tests/; else echo "No DTT tests found. Ignoring..."; fi
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"drupal/helfi_navigation": "^2.0",
"drupal/helfi_platform_config": "^3.0",
"drupal/helfi_proxy": "^3.0",
"drupal/helfi_tunnistamo": "^2.0",
"drupal/helfi_tunnistamo": "^3.0",
"drupal/json_field": "^1.0@RC",
"drupal/jsonapi_extras": "^3.20",
"drupal/jsonapi_menu_items": "^1.2",
Expand Down
136 changes: 68 additions & 68 deletions composer.lock

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions conf/cmi/core.base_field_override.node.announcement.title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
uuid: 049b3dd7-afc2-481f-b648-3869d01e681e
langcode: en
status: true
dependencies:
config:
- node.type.announcement
_core:
default_config_hash: v0rg9ztfYRnKz2PXAcGD_Q52rTcPbwqaZLw3tXWd4rM
id: node.announcement.title
field_name: title
entity_type: node
bundle: announcement
label: 'Administrative title'
description: ''
required: true
translatable: true
default_value: { }
default_value_callback: ''
settings: { }
field_type: string
35 changes: 25 additions & 10 deletions conf/cmi/core.entity_form_display.node.announcement.default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ dependencies:
- field.field.node.announcement.field_announcement_all_pages
- field.field.node.announcement.field_announcement_content_pages
- field.field.node.announcement.field_announcement_link
- field.field.node.announcement.field_announcement_title
- field.field.node.announcement.field_announcement_type
- field.field.node.announcement.field_publish_externally
- node.type.announcement
Expand All @@ -19,15 +20,15 @@ dependencies:
- select2
- text
_core:
default_config_hash: le2Wzlas0qZ9Bj-o6WlJbHDeisFrucs9F4B3VOK8t_w
default_config_hash: 0ewsu2ZhpNhAo4t7wkUgEa9ABQAkcsF7IXtR-kFeDUg
id: node.announcement.default
targetEntityType: node
bundle: announcement
mode: default
content:
body:
type: text_textarea_with_summary
weight: 15
weight: 17
region: content
settings:
rows: 9
Expand All @@ -43,14 +44,14 @@ content:
third_party_settings: { }
field_announcement_all_pages:
type: boolean_checkbox
weight: 11
weight: 13
region: content
settings:
display_label: true
third_party_settings: { }
field_announcement_content_pages:
type: select2_entity_reference
weight: 12
weight: 15
region: content
settings:
width: 100%
Expand All @@ -60,39 +61,54 @@ content:
third_party_settings: { }
field_announcement_link:
type: link_default
weight: 16
weight: 18
region: content
settings:
placeholder_url: ''
placeholder_title: ''
third_party_settings: { }
field_announcement_service_pages:
type: select2_entity_reference
weight: 14
weight: 16
region: content
settings:
width: 100%
autocomplete: true
match_operator: CONTAINS
match_limit: 20
third_party_settings: { }
field_announcement_title:
type: string_textfield
weight: 16
region: content
settings:
size: 60
placeholder: ''
third_party_settings: { }
field_announcement_type:
type: select2
weight: 10
weight: 11
region: content
settings:
width: 100%
third_party_settings: { }
field_announcement_unit_pages:
type: select2_entity_reference
weight: 13
weight: 15
region: content
settings:
width: 100%
autocomplete: true
match_operator: CONTAINS
match_limit: 20
third_party_settings: { }
field_publish_externally:
type: boolean_checkbox
weight: 14
region: content
settings:
display_label: true
third_party_settings: { }
langcode:
type: language_select
weight: 1
Expand Down Expand Up @@ -124,7 +140,7 @@ content:
settings: { }
third_party_settings: { }
simple_sitemap:
weight: 10
weight: 12
region: content
settings: { }
third_party_settings: { }
Expand Down Expand Up @@ -165,7 +181,6 @@ content:
settings: { }
third_party_settings: { }
hidden:
field_publish_externally: true
hide_sidebar_navigation: true
promote: true
sticky: true
Expand Down
11 changes: 10 additions & 1 deletion conf/cmi/core.entity_view_display.node.announcement.default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ dependencies:
- field.field.node.announcement.field_announcement_all_pages
- field.field.node.announcement.field_announcement_content_pages
- field.field.node.announcement.field_announcement_link
- field.field.node.announcement.field_announcement_title
- field.field.node.announcement.field_announcement_type
- field.field.node.announcement.field_publish_externally
- node.type.announcement
Expand All @@ -16,7 +17,7 @@ dependencies:
- text
- user
_core:
default_config_hash: IHF-sP4Gq6tdTyWDxQDDEdLbHz3-QzklMNE1QA2mQU0
default_config_hash: LQ9K_wCbd758UCcNEORQvFUQ7gNJddkukiwwYHrZv4c
id: node.announcement.default
targetEntityType: node
bundle: announcement
Expand All @@ -41,6 +42,14 @@ content:
third_party_settings: { }
weight: 3
region: content
field_announcement_title:
type: string
label: hidden
settings:
link_to_entity: false
third_party_settings: { }
weight: 4
region: content
field_announcement_type:
type: list_default
label: hidden
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ dependencies:
- field.field.node.announcement.field_announcement_all_pages
- field.field.node.announcement.field_announcement_content_pages
- field.field.node.announcement.field_announcement_link
- field.field.node.announcement.field_announcement_title
- field.field.node.announcement.field_announcement_type
- field.field.node.announcement.field_publish_externally
- node.type.announcement
module:
- text
- user
_core:
default_config_hash: FhIJpRvY90w782EYtR2V2Yfppyglwp191xkVdXEEbbM
default_config_hash: OwH532HYBVjDOUW0iJnoDWc2yFGZwwGJnAZEmZPjLCA
id: node.announcement.teaser
targetEntityType: node
bundle: announcement
Expand All @@ -39,6 +40,7 @@ hidden:
field_announcement_content_pages: true
field_announcement_link: true
field_announcement_service_pages: true
field_announcement_title: true
field_announcement_type: true
field_announcement_unit_pages: true
field_publish_externally: true
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
uuid: ed800b6e-cbe6-473b-a8af-cb545a8a4481
langcode: en
status: true
dependencies:
config:
- field.storage.node.field_announcement_title
- node.type.announcement
_core:
default_config_hash: f0piVjyoLRnZfc5fbRP6BdQ6_iMw7az35Req0V6Z4mg
id: node.announcement.field_announcement_title
field_name: field_announcement_title
entity_type: node
bundle: announcement
label: 'Announcement title'
description: 'This title is only available to users of assistive technology. '
required: true
translatable: false
default_value: { }
default_value_callback: ''
settings: { }
field_type: string
23 changes: 23 additions & 0 deletions conf/cmi/field.storage.node.field_announcement_title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
uuid: f3e37f50-b1d1-4861-b867-065f9b5e66ad
langcode: en
status: true
dependencies:
module:
- node
_core:
default_config_hash: dDVMTZxf5aD5P9HjLJX_6ThWFSclPORpZMThR3dd_XY
id: node.field_announcement_title
field_name: field_announcement_title
entity_type: node
type: string
settings:
max_length: 255
case_sensitive: false
is_ascii: false
module: core
locked: false
cardinality: 1
translatable: true
indexes: { }
persist_with_no_fields: false
custom_storage: false
6 changes: 6 additions & 0 deletions conf/cmi/helfi_api_base.delete_revisions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
entity_types:
- node
- paragraph
- tpr_unit
- tpr_service
- tpr_errand_service
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
label: 'Poikkeusilmoituksen otsikko'
description: 'Tämä otsikko on avustavan teknologian käyttäjiä varten.'
16 changes: 0 additions & 16 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,22 +82,6 @@ services:
- "traefik.http.routers.${COMPOSE_PROJECT_NAME}-varnish.tls=true"
- "traefik.http.services.${COMPOSE_PROJECT_NAME}-varnish.loadbalancer.server.port=6081"
- "traefik.docker.network=stonehenge-network"
robo:
image: ghcr.io/city-of-helsinki/drupal-robo:latest
shm_size: '2gb'
tty: true
volumes:
- .:/app:delegated
networks:
- internal
- stonehenge-network
depends_on:
- app
profiles:
- testing
extra_hosts:
- "${DRUPAL_HOSTNAME}:host-gateway"
- "varnish-${DRUPAL_HOSTNAME}:host-gateway"
networks:
internal:
external: false
Expand Down
1 change: 1 addition & 0 deletions docker/openshift/crons/base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ exec "/crons/purge-queue.sh" &
exec "/crons/update-translations.sh" &
# Uncomment this to enable content scheduler
exec "/crons/content-scheduler.sh" &
exec "/crons/pubsub.sh" &

while true
do
Expand Down
6 changes: 5 additions & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<env name="DTT_MINK_DRIVER_ARGS" value='["chrome", {"chromeOptions":{"w3c": false }}, "http://127.0.0.1:4444"]'/>
<env name="DTT_API_OPTIONS" value='{"socketTimeout": 360, "domWaitTimeout": 3600000}' />
<env name="DTT_API_URL" value="http://127.0.0.1:9222"/>
<env name="DTT_BASE_URL" value="http://127.0.0.1:8080"/>
<env name="DTT_BASE_URL" value="http://127.0.0.1:8888"/>
</php>
<testsuites>
<testsuite name="unit">
Expand All @@ -41,9 +41,13 @@
</testsuite>
<testsuite name="existing-site">
<directory>./tests/dtt/src/ExistingSite</directory>
<directory>./public/modules/custom/*/tests/src/ExistingSite</directory>
<directory>./public/modules/contrib/*/tests/src/ExistingSite</directory>
</testsuite>
<testsuite name="existing-site-javascript">
<directory>./tests/dtt/src/ExistingSiteJavascript</directory>
<directory>./public/modules/custom/*/tests/src/ExistingSiteJavascript</directory>
<directory>./public/modules/contrib/*/tests/src/ExistingSiteJavascript</directory>
</testsuite>
</testsuites>
<listeners>
Expand Down
57 changes: 56 additions & 1 deletion public/modules/custom/helfi_etusivu/helfi_etusivu.module
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

declare(strict_types = 1);

use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Render\BubbleableMetadata;
Expand Down Expand Up @@ -178,14 +180,67 @@ function helfi_etusivu_preprocess_toolbar(&$variables): void {
/**
* Implements hook_block_alter().
*/
function helfi_etusivu_block_alter(&$definitions) {
function helfi_etusivu_block_alter(&$definitions) : void {
foreach ($definitions as $id => $definition) {
if ($id === 'local_tasks_block') {
$definitions[$id]['class'] = 'Drupal\helfi_etusivu\Plugin\Block\EtusivuLocalTasksBlock';
}
}
}

/**
* Invalidate external caches.
*
* This is used to automatically flush caches on all external sites when
* an 'announcement' node marked as 'publish externally' is created/modified
* or deleted.
*
* @todo Decouple this from node save. Establishing connection to Azure PubSub
* service seems to take pretty long time
*
* @see https://helsinkisolutionoffice.atlassian.net/browse/UHF-8533
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity to flush cache tags for.
*/
function helfi_etusivu_invalidate_external_caches(EntityInterface $entity) : void {
if (!$entity instanceof ContentEntityInterface) {
return;
}
// Only flush caches when we're saving announcement node with
// 'field_publish_externally' option checked.
$isAnnouncementNode = $entity->getEntityTypeId() === 'node' && $entity->bundle() === 'announcement';
$publishExternally = $entity->hasField('field_publish_externally') && (bool) $entity->get('field_publish_externally')->value === TRUE;

if (!$isAnnouncementNode || !$publishExternally) {
return;
}
/** @var \Drupal\helfi_api_base\Cache\CacheTagInvalidator $service */
$service = \Drupal::service('helfi_api_base.cache_tag_invalidator');
$service->invalidateTags(['helfi_external_entity_announcement']);
}

/**
* Implements hook_entity_update().
*/
function helfi_etusivu_entity_update(EntityInterface $entity) : void {
helfi_etusivu_invalidate_external_caches($entity);
}

/**
* Implements hook_entity_delete().
*/
function helfi_etusivu_entity_delete(EntityInterface $entity) : void {
helfi_etusivu_invalidate_external_caches($entity);
}

/**
* Implements hook_entity_insert().
*/
function helfi_etusivu_entity_insert(EntityInterface $entity) : void {
helfi_etusivu_invalidate_external_caches($entity);
}

/**
* Implements hook_helfi_hero_design_alter().
*/
Expand Down
Loading

0 comments on commit 2dc0c49

Please sign in to comment.