From 95c1f92556520a0f4c0fb2d92930518dbe5e992d Mon Sep 17 00:00:00 2001 From: Tero Elonen Date: Mon, 10 Jun 2024 16:49:32 +0300 Subject: [PATCH 1/8] UHF-9708: Grant defined ad role the drupal role survey_editor --- public/sites/default/all.settings.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/public/sites/default/all.settings.php b/public/sites/default/all.settings.php index f33707b03..1e9a1f502 100644 --- a/public/sites/default/all.settings.php +++ b/public/sites/default/all.settings.php @@ -35,6 +35,10 @@ 'ad_role' => 'Drupal_Helfi_Etusivu_uutistuottajat', 'roles' => ['news_producer'], ], + [ + 'ad_role' => 'Drupal_Helfi_Etusivu_kayttajakyselyt', + 'roles' => ['survey_editor'], + ], [ 'ad_role' => '947058f4-697e-41bb-baf5-f69b49e5579a', 'roles' => ['super_administrator'], From b4af7fe48970d6eb763e03bc5533ce4e771e452d Mon Sep 17 00:00:00 2001 From: Santeri Hurnanen Date: Fri, 14 Jun 2024 09:40:33 +0300 Subject: [PATCH 2/8] UHF-9708: Enable survey type on jsonapi --- ...s.jsonapi_resource_config.node--survey.yml | 215 ++++++++++++++++++ 1 file changed, 215 insertions(+) create mode 100644 conf/cmi/jsonapi_extras.jsonapi_resource_config.node--survey.yml diff --git a/conf/cmi/jsonapi_extras.jsonapi_resource_config.node--survey.yml b/conf/cmi/jsonapi_extras.jsonapi_resource_config.node--survey.yml new file mode 100644 index 000000000..e4cd20081 --- /dev/null +++ b/conf/cmi/jsonapi_extras.jsonapi_resource_config.node--survey.yml @@ -0,0 +1,215 @@ +uuid: 1d49642a-fab8-4c74-ac95-ab4a509893db +langcode: en +status: true +dependencies: + config: + - node.type.survey +id: node--survey +disabled: false +path: node/survey +resourceType: node--survey +resourceFields: + nid: + disabled: false + fieldName: nid + publicName: nid + enhancer: + id: '' + uuid: + disabled: false + fieldName: uuid + publicName: uuid + enhancer: + id: '' + vid: + disabled: false + fieldName: vid + publicName: vid + enhancer: + id: '' + langcode: + disabled: false + fieldName: langcode + publicName: langcode + enhancer: + id: '' + type: + disabled: false + fieldName: type + publicName: type + enhancer: + id: '' + revision_timestamp: + disabled: false + fieldName: revision_timestamp + publicName: revision_timestamp + enhancer: + id: '' + revision_uid: + disabled: false + fieldName: revision_uid + publicName: revision_uid + enhancer: + id: '' + revision_log: + disabled: false + fieldName: revision_log + publicName: revision_log + enhancer: + id: '' + status: + disabled: false + fieldName: status + publicName: status + enhancer: + id: '' + uid: + disabled: false + fieldName: uid + publicName: uid + enhancer: + id: '' + title: + disabled: false + fieldName: title + publicName: title + enhancer: + id: '' + created: + disabled: false + fieldName: created + publicName: created + enhancer: + id: '' + changed: + disabled: false + fieldName: changed + publicName: changed + enhancer: + id: '' + promote: + disabled: false + fieldName: promote + publicName: promote + enhancer: + id: '' + sticky: + disabled: false + fieldName: sticky + publicName: sticky + enhancer: + id: '' + default_langcode: + disabled: false + fieldName: default_langcode + publicName: default_langcode + enhancer: + id: '' + revision_default: + disabled: false + fieldName: revision_default + publicName: revision_default + enhancer: + id: '' + revision_translation_affected: + disabled: false + fieldName: revision_translation_affected + publicName: revision_translation_affected + enhancer: + id: '' + color_palette: + disabled: false + fieldName: color_palette + publicName: color_palette + enhancer: + id: '' + hide_sidebar_navigation: + disabled: false + fieldName: hide_sidebar_navigation + publicName: hide_sidebar_navigation + enhancer: + id: '' + toc_enabled: + disabled: false + fieldName: toc_enabled + publicName: toc_enabled + enhancer: + id: '' + toc_title: + disabled: false + fieldName: toc_title + publicName: toc_title + enhancer: + id: '' + metatag: + disabled: false + fieldName: metatag + publicName: metatag + enhancer: + id: '' + path: + disabled: false + fieldName: path + publicName: path + enhancer: + id: '' + publish_on: + disabled: false + fieldName: publish_on + publicName: publish_on + enhancer: + id: '' + unpublish_on: + disabled: false + fieldName: unpublish_on + publicName: unpublish_on + enhancer: + id: '' + menu_link: + disabled: false + fieldName: menu_link + publicName: menu_link + enhancer: + id: '' + content_translation_source: + disabled: false + fieldName: content_translation_source + publicName: content_translation_source + enhancer: + id: '' + content_translation_outdated: + disabled: false + fieldName: content_translation_outdated + publicName: content_translation_outdated + enhancer: + id: '' + published_at: + disabled: false + fieldName: published_at + publicName: published_at + enhancer: + id: '' + body: + disabled: false + fieldName: body + publicName: body + enhancer: + id: '' + field_survey_all_pages: + disabled: false + fieldName: field_survey_all_pages + publicName: field_survey_all_pages + enhancer: + id: '' + field_survey_content_pages: + disabled: false + fieldName: field_survey_content_pages + publicName: field_survey_content_pages + enhancer: + id: '' + field_survey_link: + disabled: false + fieldName: field_survey_link + publicName: field_survey_link + enhancer: + id: '' From ffc9e318a98b5501331aa49e648a79deec4fa242 Mon Sep 17 00:00:00 2001 From: Juho Lehmonen Date: Tue, 18 Jun 2024 14:08:40 +0300 Subject: [PATCH 3/8] UHF-9708: Handle external entity cache invalidation for survey nodes. --- .../custom/helfi_etusivu/helfi_etusivu.module | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/public/modules/custom/helfi_etusivu/helfi_etusivu.module b/public/modules/custom/helfi_etusivu/helfi_etusivu.module index df8d7caa9..239ead394 100644 --- a/public/modules/custom/helfi_etusivu/helfi_etusivu.module +++ b/public/modules/custom/helfi_etusivu/helfi_etusivu.module @@ -155,8 +155,8 @@ function helfi_etusivu_block_alter(&$definitions) : void { * 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. + * an 'announcement' or 'survey' 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 @@ -170,17 +170,32 @@ function helfi_etusivu_invalidate_external_caches(EntityInterface $entity) : voi if (!$entity instanceof ContentEntityInterface) { return; } - // Only flush caches when we're saving announcement node with + + // Only act on nodes. + if ($entity->getEntityTypeId() !== 'node') { + return; + } + + // Only flush caches when we're saving announcement or survey 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 ($entity->bundle() === 'announcement') { + $invalidateTag = 'helfi_external_entity_announcement'; + } + elseif ($entity->bundle() === 'survey') { + $invalidateTag = 'helfi_external_entity_survey'; + } + else { + return; + } - if (!$isAnnouncementNode || !$publishExternally) { + $publishExternally = $entity->hasField('field_publish_externally') && (bool) $entity->get('field_publish_externally')->value === TRUE; + if (!$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']); + $service->invalidateTags([$invalidateTag]); } /** From 495cfb161ed335a50cf7ee6eddcd0242eb504a57 Mon Sep 17 00:00:00 2001 From: Santeri Hurnanen Date: Thu, 20 Jun 2024 08:09:40 +0300 Subject: [PATCH 4/8] UHF-9708: Rewrite survey node form --- ...re.entity_form_display.node.survey.default.yml | 15 +++++++++++++++ .../helfi_etusivu_config.module | 1 + 2 files changed, 16 insertions(+) create mode 100644 public/modules/custom/helfi_etusivu_config/config/rewrite/core.entity_form_display.node.survey.default.yml diff --git a/public/modules/custom/helfi_etusivu_config/config/rewrite/core.entity_form_display.node.survey.default.yml b/public/modules/custom/helfi_etusivu_config/config/rewrite/core.entity_form_display.node.survey.default.yml new file mode 100644 index 000000000..b5cd5e531 --- /dev/null +++ b/public/modules/custom/helfi_etusivu_config/config/rewrite/core.entity_form_display.node.survey.default.yml @@ -0,0 +1,15 @@ +config_rewrite: + replace: ['hidden'] +content: + field_publish_externally: + type: boolean_checkbox + weight: 14 + region: content + settings: + display_label: true + third_party_settings: { } +hidden: + hide_sidebar_navigation: true + promote: true + sticky: true + url_redirects: true diff --git a/public/modules/custom/helfi_etusivu_config/helfi_etusivu_config.module b/public/modules/custom/helfi_etusivu_config/helfi_etusivu_config.module index 4a37476eb..c45473dc6 100644 --- a/public/modules/custom/helfi_etusivu_config/helfi_etusivu_config.module +++ b/public/modules/custom/helfi_etusivu_config/helfi_etusivu_config.module @@ -15,6 +15,7 @@ use Drupal\config_rewrite\ConfigRewriterInterface; function helfi_etusivu_config_rewrite_config_update(string $module, ConfigRewriterInterface $configRewriter): void { $modules = [ 'helfi_node_announcement', + 'helfi_node_survey', 'helfi_node_news_item', 'helfi_paragraphs_accordion', 'helfi_paragraphs_banner', From 56c4e568151678da85bde990edd07eb33d95829f Mon Sep 17 00:00:00 2001 From: Santeri Hurnanen Date: Tue, 30 Jul 2024 14:42:37 +0300 Subject: [PATCH 5/8] UHF-9708: Install helfi_etusivu_entities and config overrides --- .../helfi_etusivu_config.install | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 public/modules/custom/helfi_etusivu_config/helfi_etusivu_config.install diff --git a/public/modules/custom/helfi_etusivu_config/helfi_etusivu_config.install b/public/modules/custom/helfi_etusivu_config/helfi_etusivu_config.install new file mode 100644 index 000000000..951f75f07 --- /dev/null +++ b/public/modules/custom/helfi_etusivu_config/helfi_etusivu_config.install @@ -0,0 +1,24 @@ +moduleExists('helfi_etusivu_entities')) { + $module_installer->install(['helfi_etusivu_entities']); + } + + // Ensure config overrides are installed. + \Drupal::service("helfi_platform_config.config_update_helper") + ->update("helfi_node_survey"); +} From 8733e4c45321f47800a985c3fa161d04c3e209a9 Mon Sep 17 00:00:00 2001 From: Santeri Hurnanen Date: Mon, 12 Aug 2024 14:11:31 +0300 Subject: [PATCH 6/8] UHF-9708: Fix phpcs --- .../custom/helfi_etusivu_config/helfi_etusivu_config.install | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/modules/custom/helfi_etusivu_config/helfi_etusivu_config.install b/public/modules/custom/helfi_etusivu_config/helfi_etusivu_config.install index 951f75f07..acc459c87 100644 --- a/public/modules/custom/helfi_etusivu_config/helfi_etusivu_config.install +++ b/public/modules/custom/helfi_etusivu_config/helfi_etusivu_config.install @@ -1,12 +1,12 @@ Date: Mon, 12 Aug 2024 14:11:50 +0300 Subject: [PATCH 7/8] UHF-9708: Get cache tag names from class property --- public/modules/custom/helfi_etusivu/helfi_etusivu.module | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/public/modules/custom/helfi_etusivu/helfi_etusivu.module b/public/modules/custom/helfi_etusivu/helfi_etusivu.module index 239ead394..401123b88 100644 --- a/public/modules/custom/helfi_etusivu/helfi_etusivu.module +++ b/public/modules/custom/helfi_etusivu/helfi_etusivu.module @@ -15,6 +15,8 @@ use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageInterface; use Drupal\helfi_annif\TextConverter\Document; use Drupal\helfi_etusivu\Entity\Node\NewsItem; +use Drupal\helfi_etusivu_entities\Plugin\ExternalEntities\StorageClient\Announcements; +use Drupal\helfi_etusivu_entities\Plugin\ExternalEntities\StorageClient\Surveys; use Drupal\helfi_platform_config\DTO\ParagraphTypeCollection; use Drupal\node\NodeInterface; use Drupal\paragraphs\ParagraphInterface; @@ -179,10 +181,10 @@ function helfi_etusivu_invalidate_external_caches(EntityInterface $entity) : voi // Only flush caches when we're saving announcement or survey node with // 'field_publish_externally' option checked. if ($entity->bundle() === 'announcement') { - $invalidateTag = 'helfi_external_entity_announcement'; + $invalidateTag = Announcements::$customCacheTag; } elseif ($entity->bundle() === 'survey') { - $invalidateTag = 'helfi_external_entity_survey'; + $invalidateTag = Surveys::$customCacheTag; } else { return; From 8c735847a311b691467ff612a5f8a9bdda73e15f Mon Sep 17 00:00:00 2001 From: Santeri Hurnanen Date: Mon, 12 Aug 2024 15:27:28 +0300 Subject: [PATCH 8/8] UHF-9708: Export config --- conf/cmi/block.block.surveys.yml | 21 ++++++++ ...ntity_form_display.node.survey.default.yml | 8 +++- conf/cmi/core.extension.yml | 1 + ...ternal_entity_type.helfi_announcements.yml | 48 +++++++++++++++++++ ...ies.external_entity_type.helfi_surveys.yml | 42 ++++++++++++++++ conf/cmi/user.role.anonymous.yml | 3 ++ conf/cmi/user.role.authenticated.yml | 3 ++ 7 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 conf/cmi/block.block.surveys.yml create mode 100644 conf/cmi/external_entities.external_entity_type.helfi_announcements.yml create mode 100644 conf/cmi/external_entities.external_entity_type.helfi_surveys.yml diff --git a/conf/cmi/block.block.surveys.yml b/conf/cmi/block.block.surveys.yml new file mode 100644 index 000000000..417c693e2 --- /dev/null +++ b/conf/cmi/block.block.surveys.yml @@ -0,0 +1,21 @@ +uuid: e44c3b61-6b9e-4731-9674-413f230e1710 +langcode: en +status: true +dependencies: + module: + - helfi_etusivu_entities + theme: + - hdbt_subtheme +id: surveys +theme: hdbt_subtheme +region: before_content +weight: -15 +provider: helfi_node_survey +plugin: surveys +settings: + id: surveys + label: Surveys + label_display: '' + provider: helfi_node_survey + use_remote_entities: true +visibility: { } diff --git a/conf/cmi/core.entity_form_display.node.survey.default.yml b/conf/cmi/core.entity_form_display.node.survey.default.yml index 71779fabc..7d3ff31d0 100644 --- a/conf/cmi/core.entity_form_display.node.survey.default.yml +++ b/conf/cmi/core.entity_form_display.node.survey.default.yml @@ -128,8 +128,14 @@ content: region: content settings: { } third_party_settings: { } + field_publish_externally: + type: boolean_checkbox + weight: 14 + region: content + settings: + display_label: true + third_party_settings: { } hidden: - field_publish_externally: true hide_sidebar_navigation: true promote: true sticky: true diff --git a/conf/cmi/core.extension.yml b/conf/cmi/core.extension.yml index 4487a3a63..f56bdf7a7 100644 --- a/conf/cmi/core.extension.yml +++ b/conf/cmi/core.extension.yml @@ -52,6 +52,7 @@ module: helfi_ckeditor: 0 helfi_etusivu: 0 helfi_etusivu_config: 0 + helfi_etusivu_entities: 0 helfi_eu_cookie_compliance: 0 helfi_global_navigation: 0 helfi_image_styles: 0 diff --git a/conf/cmi/external_entities.external_entity_type.helfi_announcements.yml b/conf/cmi/external_entities.external_entity_type.helfi_announcements.yml new file mode 100644 index 000000000..8bd8bfb7c --- /dev/null +++ b/conf/cmi/external_entities.external_entity_type.helfi_announcements.yml @@ -0,0 +1,48 @@ +uuid: 072df4c4-3de5-44f9-bd4f-c1d09006ce88 +langcode: en +status: true +dependencies: { } +_core: + default_config_hash: klULx3zqlYgz7OOfeGsjBYHQmFp8V6_aMlFUYaOQRmA +id: helfi_announcements +label: 'Helfi: Announcements' +label_plural: 'Helfi: Announcements' +description: '' +generate_aliases: null +read_only: true +field_mapper_id: jsonpath +field_mapper_config: + field_mappings: + id: + value: $.id + uuid: + value: $.id + title: + value: '$.attributes["title"]' + published_at: + value: '$.attributes["published_at"]' + unpublish_on: + value: '$.attributes["unpublish_on"]' + notification: + value: '$.attributes["notification"]' + langcode: + value: '$.attributes["langcode"]' + body: + value: '$.attributes["body"]["value"]' + status: + value: '$.attributes["status"]' + announcement_type: + value: '$.attributes["field_announcement_type"]' + announcement_link_text: + value: '$.attributes["field_announcement_link"]["title"]' + announcement_link_url: + value: '$.attributes["field_announcement_link"]["uri"]' + announcement_assistive_technology_close_button_title: + value: '$.attributes["field_announcement_title"]' +storage_client_id: helfi_announcements +storage_client_config: { } +persistent_cache_max_age: -1 +annotation_entity_type_id: null +annotation_bundle_id: null +annotation_field_name: null +inherits_annotation_fields: false diff --git a/conf/cmi/external_entities.external_entity_type.helfi_surveys.yml b/conf/cmi/external_entities.external_entity_type.helfi_surveys.yml new file mode 100644 index 000000000..2a9fc5698 --- /dev/null +++ b/conf/cmi/external_entities.external_entity_type.helfi_surveys.yml @@ -0,0 +1,42 @@ +uuid: be631905-d77b-418a-890e-b04fa3ed3e22 +langcode: en +status: true +dependencies: { } +_core: + default_config_hash: _EBh68cyUNEhZdqfsN5IEH5ieC-ND8JOMk5t_uhXdJc +id: helfi_surveys +label: 'Helfi: Survey' +label_plural: 'Helfi: Surveys' +description: '' +generate_aliases: null +read_only: true +field_mapper_id: jsonpath +field_mapper_config: + field_mappings: + id: + value: $.id + uuid: + value: $.id + title: + value: '$.attributes["title"]' + published_at: + value: '$.attributes["published_at"]' + unpublish_on: + value: '$.attributes["unpublish_on"]' + langcode: + value: '$.attributes["langcode"]' + body: + value: '$.attributes["body"]["value"]' + status: + value: '$.attributes["status"]' + survey_link_text: + value: '$.attributes["field_survey_link"]["title"]' + survey_link_url: + value: '$.attributes["field_survey_link"]["uri"]' +storage_client_id: helfi_surveys +storage_client_config: { } +persistent_cache_max_age: -1 +annotation_entity_type_id: null +annotation_bundle_id: null +annotation_field_name: null +inherits_annotation_fields: false diff --git a/conf/cmi/user.role.anonymous.yml b/conf/cmi/user.role.anonymous.yml index cc6bcb50a..6296a0045 100644 --- a/conf/cmi/user.role.anonymous.yml +++ b/conf/cmi/user.role.anonymous.yml @@ -8,6 +8,7 @@ dependencies: - rest.resource.helfi_menu_link_collection module: - eu_cookie_compliance + - external_entities - helfi_api_base - helfi_global_navigation - media @@ -28,5 +29,7 @@ permissions: - 'restful get helfi_global_mobile_menu' - 'restful get helfi_menu_link_collection' - 'view global_menu' + - 'view helfi_announcements external entity' + - 'view helfi_surveys external entity' - 'view media' - 'view remote entities' diff --git a/conf/cmi/user.role.authenticated.yml b/conf/cmi/user.role.authenticated.yml index b7237a416..b083ab844 100644 --- a/conf/cmi/user.role.authenticated.yml +++ b/conf/cmi/user.role.authenticated.yml @@ -9,6 +9,7 @@ dependencies: module: - draggableviews - eu_cookie_compliance + - external_entities - file - helfi_api_base - helfi_global_navigation @@ -38,6 +39,8 @@ permissions: - 'restful get helfi_menu_link_collection' - 'setup own tfa' - 'view global_menu' + - 'view helfi_announcements external entity' + - 'view helfi_surveys external entity' - 'view media' - 'view remote entities' - 'view unpublished paragraphs'