Skip to content

Commit

Permalink
Merge pull request #632 from City-of-Helsinki/dev
Browse files Browse the repository at this point in the history
Dev to main
  • Loading branch information
khalima authored May 4, 2023
2 parents 9c910af + 191ae78 commit cdf991d
Show file tree
Hide file tree
Showing 59 changed files with 4,112 additions and 215 deletions.
371 changes: 183 additions & 188 deletions composer.lock

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions conf/cmi/system.action.user_add_role_action.debug_api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
uuid: f8733b1d-34c1-4d4d-976e-3e14fdbbe024
langcode: en
status: true
dependencies:
config:
- user.role.debug_api
module:
- user
id: user_add_role_action.debug_api
label: 'Add the Debug API role to the selected user(s)'
type: user
plugin: user_add_role_action
configuration:
rid: debug_api
14 changes: 14 additions & 0 deletions conf/cmi/system.action.user_remove_role_action.debug_api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
uuid: dda12743-f31d-4ad0-ad81-82426a494de0
langcode: en
status: true
dependencies:
config:
- user.role.debug_api
module:
- user
id: user_remove_role_action.debug_api
label: 'Remove the Debug API role from the selected user(s)'
type: user
plugin: user_remove_role_action
configuration:
rid: debug_api
14 changes: 14 additions & 0 deletions conf/cmi/user.role.debug_api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
uuid: 47322bdd-3ae1-410a-86ef-14c0b8fc1661
langcode: en
status: true
dependencies:
config:
- rest.resource.helfi_debug_data
module:
- rest
id: debug_api
label: 'Debug API'
weight: 6
is_admin: null
permissions:
- 'restful get helfi_debug_data'
100 changes: 100 additions & 0 deletions public/modules/custom/helfi_custom_test_content/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Helfi custom test content

Helfi custom test content module holds test content for this instance specific layouts, components and menu links.

**Note!** This module should not be enabled in production environment as it uses [default content](https://www.drupal.org/project/default_content) module to produce the test content. The test content is created with normal content entities, like nodes and menu links, and it will be automatically visible for anonymous users!

## Dependencies
- [helfi_test_content module from the helfi_platform_config module](https://github.com/City-of-Helsinki/drupal-helfi-platform-config)

## How to import the test content

The content is imported when the module is enabled.

The module can be enabled from admin UI (/admin/modules) or by running the following drush command.

```
drush en -y helfi_custom_test_content
```

When the module is already enabled and the content should be re-imported, it can be done with following drush command.

```
drush dcim helfi_custom_test_content
```

## How to export the test content

Modify the nodes / menu links / etc. from the admin UI. Once the changes are saved, run the following drush command to export the data to this module.
```
drush dcem helfi_custom_test_content
```

All content what is listed in [helfi_custom_test_content.info.yml](helfi_custom_test_content.info.yml) will be exported.

**Note!** As always with exported configurations and/or content, go through the exported changes in the .yml files and remove the unwanted ones before committing the code. For example in TPR Services and TPR Units the IDs will be removed when exporting content - this should not be committed.

## How to generate new test content

Create the preferred content in admin UI as you would normally do. Make a note of the content ID and export the created content via drush to this module. Possible references to other entities (like paragraphs, media entities, etc.) will be created and if the referenced entity is missing from the test content, it will be created as well.

Add the test content UUIDs to [helfi_custom_test_content.info.yml](helfi_custom_test_content.info.yml) under appropriate entity to automatically install the content when helfi test content module is being installed.

### Examples

#### Nodes
1. Create a node of any type, fill in the desired content and save it.
2. Retrieve the ID of the content.
1. Either check from the `/admin/content` list by hovering the edit link or go and edit the node and get the ID from the URL `/node/##/edit`
3. Run the following drush command. The `1` is the ID of the node.
```
drush dcer node 1 --folder=/app/public/modules/custom/helfi_custom_test_content/content
```
4. Add the new content UUID to [helfi_custom_test_content.info.yml](helfi_custom_test_content.info.yml) under appropriate entity.

#### Menu links
1. Create a menu link.
2. Retrieve the ID of the menu link.
1. Either check from the `/admin/structure/menu/manage/main` list by hovering the edit link or go and edit the menu link and get the ID from the URL `/admin/structure/menu/item/##/edit`
3. Run the following drush command. The `22` is the ID of the node.
```
drush dcer menu_link_content 22 --folder=/app/public/modules/custom/helfi_custom_test_content/content
```
4. Add the new content UUID to [helfi_custom_test_content.info.yml](helfi_custom_test_content.info.yml) under appropriate entity.

#### Other content

Content can be exported with the drush command like so:
```
drush dcer [entity type] [id] --folder=/app/public/modules/custom/helfi_custom_test_content/content
```

## How to delete the test content

The test content can be deleted manually. [There is a fix on the way](https://www.drupal.org/project/default_content/issues/3282547).

## Known bugs

### Path aliases
There seems to be a problem of nodes losing their paths if pathauto is enabled for the node. To fix this problem, make sure the paths are not auto generated. For example in a node.yml file check that the pathauto variable is set to 0.
```
path:
-
alias: /dc-helfi-platform-test-content/dc-components/dc-component-list-of-plans
langcode: en
pathauto: 0
```

### Exporting nodes with drush dcer won't create the menu item

This is actually not a bug, because the reference is from menu item --> node.

To fix the problem, the menu item should be imported instead of the node.
For example:
- The node is called `DC: Navigation` and it's added to menu with the same name.
- We need to retrieve the menu link ID to export it and it's references.
- Either check from the /admin/structure/menu/manage/main list by hovering the edit link or go and edit the menu link and get the ID from the URL `/admin/structure/menu/item/##/edit`. In our example it's `/admin/structure/menu/item/10/edit`
- Then it's as simple as exporting the menu item with references
```
drush dcer menu_link_content 10 --folder=/app/public/modules/custom/helfi_custom_test_content/content
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
_meta:
version: '1.0'
entity_type: menu_link_content
uuid: 08591473-4036-4137-9e8e-d0a3ea6c9bad
bundle: menu_link_content
default_langcode: en
depends:
b58878d7-e165-48b5-b9ca-858061764b19: menu_link_content
935bcf05-9346-4cb1-ba2d-beddc301ba1e: node
default:
enabled:
-
value: true
title:
-
value: 'DC: layout district - no-hero - subnav - no-sidebar - toc'
menu_name:
-
value: main
link:
-
target_uuid: 935bcf05-9346-4cb1-ba2d-beddc301ba1e
title: ''
options: { }
external:
-
value: false
rediscover:
-
value: false
weight:
-
value: 0
expanded:
-
value: false
parent:
-
value: 'menu_link_content:b58878d7-e165-48b5-b9ca-858061764b19'
revision_translation_affected:
-
value: true
content_translation_source:
-
value: und
content_translation_outdated:
-
value: false
content_translation_uid:
-
target_id: 1
content_translation_status:
-
value: true
content_translation_created:
-
value: 1678438655
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
_meta:
version: '1.0'
entity_type: menu_link_content
uuid: 0a0bc030-12ee-40a2-a6c4-a750e7ca114f
bundle: menu_link_content
default_langcode: en
depends:
b58878d7-e165-48b5-b9ca-858061764b19: menu_link_content
41a73f09-2b63-4cbb-b4af-924b771b8c86: node
default:
enabled:
-
value: true
title:
-
value: 'DC: layout district - hero - subnav - no-sidebar - no-toc'
menu_name:
-
value: main
link:
-
target_uuid: 41a73f09-2b63-4cbb-b4af-924b771b8c86
title: ''
options: { }
external:
-
value: false
rediscover:
-
value: false
weight:
-
value: 0
expanded:
-
value: false
parent:
-
value: 'menu_link_content:b58878d7-e165-48b5-b9ca-858061764b19'
revision_translation_affected:
-
value: true
content_translation_source:
-
value: und
content_translation_outdated:
-
value: false
content_translation_uid:
-
target_id: 1
content_translation_status:
-
value: true
content_translation_created:
-
value: 1678437686
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
_meta:
version: '1.0'
entity_type: menu_link_content
uuid: 0f1e306e-7940-42f1-a924-ff14e1af3983
bundle: menu_link_content
default_langcode: en
depends:
3b4a4c02-bbca-45dc-b647-107e9d9d5978: menu_link_content
a1a7c479-cb1b-4661-98c1-a9d59a11bc0f: node
default:
enabled:
-
value: true
title:
-
value: 'DC: components custom'
menu_name:
-
value: main
link:
-
target_uuid: a1a7c479-cb1b-4661-98c1-a9d59a11bc0f
title: ''
options: { }
external:
-
value: false
rediscover:
-
value: false
weight:
-
value: 0
expanded:
-
value: false
parent:
-
value: 'menu_link_content:3b4a4c02-bbca-45dc-b647-107e9d9d5978'
revision_translation_affected:
-
value: true
content_translation_source:
-
value: und
content_translation_outdated:
-
value: false
content_translation_uid:
-
target_id: 1
content_translation_status:
-
value: true
content_translation_created:
-
value: 1678371558
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
_meta:
version: '1.0'
entity_type: menu_link_content
uuid: 16be7c3d-dfbf-4ea1-8775-c4db5b6d3666
bundle: menu_link_content
default_langcode: en
depends:
b58878d7-e165-48b5-b9ca-858061764b19: menu_link_content
5c3777f5-7486-43cb-ada3-8c863440ee84: node
default:
enabled:
-
value: true
title:
-
value: 'DC: layout district - hero - subnav - sidebar - no-toc'
menu_name:
-
value: main
link:
-
target_uuid: 5c3777f5-7486-43cb-ada3-8c863440ee84
title: ''
options: { }
external:
-
value: false
rediscover:
-
value: false
weight:
-
value: 0
expanded:
-
value: false
parent:
-
value: 'menu_link_content:b58878d7-e165-48b5-b9ca-858061764b19'
revision_translation_affected:
-
value: true
content_translation_source:
-
value: und
content_translation_outdated:
-
value: false
content_translation_uid:
-
target_id: 1
content_translation_status:
-
value: true
content_translation_created:
-
value: 1678435352
Loading

0 comments on commit cdf991d

Please sign in to comment.