@eeacms/volto-slate-metadata-mentions 7.0.2 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.env ADDED
@@ -0,0 +1,3 @@
1
+ # Jest configuration variables
2
+ # - possible values: ON, OFF
3
+ JEST_USE_SETUP=OFF
package/CHANGELOG.md CHANGED
@@ -4,7 +4,32 @@ All notable changes to this project will be documented in this file. Dates are d
4
4
 
5
5
  Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
6
6
 
7
- ### [7.0.2](https://github.com/eea/volto-slate-metadata-mentions/compare/7.0.1...7.0.2) - 19 October 2023
7
+ ### [8.0.0](https://github.com/eea/volto-slate-metadata-mentions/compare/7.0.3...8.0.0) - 22 April 2024
8
+
9
+ #### :rocket: New Features
10
+
11
+ - feat: Release 8.0.0 - Volto 17 support [alin - [`83565c7`](https://github.com/eea/volto-slate-metadata-mentions/commit/83565c76d4893d5f8130bc3af9d96f2ba855a349)]
12
+ - feat: Volto 17 support - refs #264527 [EEA Jenkins - [`ca86e11`](https://github.com/eea/volto-slate-metadata-mentions/commit/ca86e11fdd4806588d59a0bba8b35e9cbf9fb33a)]
13
+
14
+ #### :bug: Bug Fixes
15
+
16
+ - fix(tests): removed waitForResourcesToLoad no longer needed in volto 17 [David Ichim - [`8bc76d1`](https://github.com/eea/volto-slate-metadata-mentions/commit/8bc76d1e4df78d5bd7152791672a4cc5c32563f0)]
17
+
18
+ #### :hammer_and_wrench: Others
19
+
20
+ ### [7.0.3](https://github.com/eea/volto-slate-metadata-mentions/compare/7.0.2...7.0.3) - 18 January 2024
21
+
22
+ #### :house: Internal changes
23
+
24
+
25
+ #### :house: Documentation changes
26
+
27
+ - docs: Add screenshots [Crețu Mihaela - [`aa43092`](https://github.com/eea/volto-slate-metadata-mentions/commit/aa4309228d4fdd5c60289e4b7ade88c98c48882d)]
28
+
29
+ #### :hammer_and_wrench: Others
30
+
31
+ - test: modify cypress test - refs #254313 [ana-oprea - [`df1cff1`](https://github.com/eea/volto-slate-metadata-mentions/commit/df1cff18cc90b327d9cd480af79d62911603e743)]
32
+ ### [7.0.2](https://github.com/eea/volto-slate-metadata-mentions/compare/7.0.1...7.0.2) - 22 October 2023
8
33
 
9
34
  #### :house: Internal changes
10
35
 
@@ -29,7 +54,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
29
54
  #### :hammer_and_wrench: Others
30
55
 
31
56
  - test: EN locales, pre-commit fix, feature PRs checks Refs #257193 [valentinab25 - [`e13b9b6`](https://github.com/eea/volto-slate-metadata-mentions/commit/e13b9b6c36e4d61905807179459929aabf44f56c)]
32
- - test: Fix eslint and yarn i18n [Alin Voinea - [`e085c11`](https://github.com/eea/volto-slate-metadata-mentions/commit/e085c1189c0aa92b984440b51b4534261560c175)]
33
57
  - i18n: Add en [Alin Voinea - [`9e7360d`](https://github.com/eea/volto-slate-metadata-mentions/commit/9e7360da54440957842726bae19e093bb1937a49)]
34
58
  - test: Update Makefile and docker-compose to align it with Jenkinsfile [valentinab25 - [`b873d00`](https://github.com/eea/volto-slate-metadata-mentions/commit/b873d00ba45dbe569512b54740ab54fa9dd296ce)]
35
59
  ## [7.0.0](https://github.com/eea/volto-slate-metadata-mentions/compare/6.1.2...7.0.0) - 25 July 2023
@@ -51,24 +75,16 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
51
75
 
52
76
  #### :house: Internal changes
53
77
 
54
- - chore: [JENKINS] Deprecate circularity website [valentinab25 - [`bea37a4`](https://github.com/eea/volto-slate-metadata-mentions/commit/bea37a4cd51c087a67dbb23f8ac778e201f06596)]
55
78
 
56
79
  #### :hammer_and_wrench: Others
57
80
 
58
81
  - test: jest should look for addons in node_modules Refs #253277 [valentinab25 - [`98fa009`](https://github.com/eea/volto-slate-metadata-mentions/commit/98fa00918b613bdbf079300e4683f300ba77c575)]
59
82
  - test: Fix test config, coverage Refs #253277 [valentinab25 - [`e87dda2`](https://github.com/eea/volto-slate-metadata-mentions/commit/e87dda2b7ec6f8d39383ee4024265628e562be8f)]
60
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`d941f6b`](https://github.com/eea/volto-slate-metadata-mentions/commit/d941f6bcdf7154c8fac1a6e8c9436f2a0af1dfef)]
61
83
  ### [6.1.0](https://github.com/eea/volto-slate-metadata-mentions/compare/6.0.1...6.1.0) - 27 March 2023
62
84
 
63
85
  #### :hammer_and_wrench: Others
64
86
 
65
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`eb5cef6`](https://github.com/eea/volto-slate-metadata-mentions/commit/eb5cef62bf50f5f100e4348f5642166168f7db3b)]
66
- - Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`11d00a7`](https://github.com/eea/volto-slate-metadata-mentions/commit/11d00a7994b7ad7efaeb1d23582052be43abac1b)]
67
- - Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`5293413`](https://github.com/eea/volto-slate-metadata-mentions/commit/5293413f9bbf28d304c3a26c5df9c6bca935ca04)]
68
87
  - test(Jenkins): Run tests and cypress with latest canary @plone/volto [Alin Voinea - [`fc0a308`](https://github.com/eea/volto-slate-metadata-mentions/commit/fc0a30840ee5cc4c3d00683800c510080b13cb09)]
69
- - Add Sonarqube tag using cca-frontend addons list [EEA Jenkins - [`abb75cd`](https://github.com/eea/volto-slate-metadata-mentions/commit/abb75cd923d258edd89cee3b5ef52e6232cf0a03)]
70
- - yarn 3 [Alin Voinea - [`ae13d7b`](https://github.com/eea/volto-slate-metadata-mentions/commit/ae13d7b7e029da5765c8e85aede5f08c01131152)]
71
- - Add Sonarqube tag using demo-kitkat-frontend addons list [EEA Jenkins - [`561f504`](https://github.com/eea/volto-slate-metadata-mentions/commit/561f5043e35499b2208d81358f3289a9199ce8dd)]
72
88
  ### [6.0.1](https://github.com/eea/volto-slate-metadata-mentions/compare/6.0.0...6.0.1) - 16 November 2022
73
89
 
74
90
  #### :hammer_and_wrench: Others
@@ -83,47 +99,35 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
83
99
 
84
100
  #### :hammer_and_wrench: Others
85
101
 
86
- - Add Sonarqube tag using marine-frontend addons list [EEA Jenkins - [`a684cac`](https://github.com/eea/volto-slate-metadata-mentions/commit/a684cac03f47b8d89bbf4b14ede23143e4b774a5)]
87
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`a30ae17`](https://github.com/eea/volto-slate-metadata-mentions/commit/a30ae17a70d891d20f6b73ea4a5c6576316894a2)]
88
102
  ### [5.0.1](https://github.com/eea/volto-slate-metadata-mentions/compare/5.0.0...5.0.1) - 30 June 2022
89
103
 
90
104
  #### :hammer_and_wrench: Others
91
105
 
92
- - Add Sonarqube tag using circularity-frontend addons list [EEA Jenkins - [`6d5c31f`](https://github.com/eea/volto-slate-metadata-mentions/commit/6d5c31f8217c9f5a52fc2447c5d89fafa717932d)]
93
106
  ## [5.0.0](https://github.com/eea/volto-slate-metadata-mentions/compare/4.0.3...5.0.0) - 6 April 2022
94
107
 
95
108
  #### :hammer_and_wrench: Others
96
109
 
97
110
  - Breaking 5.0.0 [Alin Voinea - [`9daf888`](https://github.com/eea/volto-slate-metadata-mentions/commit/9daf88800e0f375b9e7927540827c64c8f03c00e)]
98
- - Add Sonarqube tag using clms-frontend addons list [EEA Jenkins - [`c77d975`](https://github.com/eea/volto-slate-metadata-mentions/commit/c77d975b57d3982b360b8d0bc2d3aa4d64a41254)]
99
111
  ### [4.0.3](https://github.com/eea/volto-slate-metadata-mentions/compare/4.0.2...4.0.3) - 16 March 2022
100
112
 
101
113
  #### :hammer_and_wrench: Others
102
114
 
103
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`80d1b4e`](https://github.com/eea/volto-slate-metadata-mentions/commit/80d1b4eafce60c03c5fb3698ef2375ee903c05d6)]
104
115
  ### [4.0.2](https://github.com/eea/volto-slate-metadata-mentions/compare/4.0.1...4.0.2) - 3 January 2022
105
116
 
106
117
  ### [4.0.1](https://github.com/eea/volto-slate-metadata-mentions/compare/4.0.0...4.0.1) - 18 December 2021
107
118
 
108
119
  #### :hammer_and_wrench: Others
109
120
 
110
- - Add Sonarqube tag using freshwater-frontend addons list [EEA Jenkins - [`2de3bf6`](https://github.com/eea/volto-slate-metadata-mentions/commit/2de3bf624ff35504add94f5daf37484a8f459df7)]
111
121
  - Refs #142010 - Optimize Volto-addons gitflow pipelines [valentinab25 - [`3a6a696`](https://github.com/eea/volto-slate-metadata-mentions/commit/3a6a69612652cd947d54f77c430bdca21b82a0df)]
112
- - Add Sonarqube tag using industry-frontend addons list [EEA Jenkins - [`6e8fb49`](https://github.com/eea/volto-slate-metadata-mentions/commit/6e8fb492411d12c570ae75f00ee710818e5027f8)]
113
- - Add Sonarqube tag using clms-frontend addons list [EEA Jenkins - [`fc8fcc3`](https://github.com/eea/volto-slate-metadata-mentions/commit/fc8fcc35bf20e4a1c3b3bbc099e67045e3feea15)]
114
- - Add Sonarqube tag using forests-frontend addons list [EEA Jenkins - [`9e0c360`](https://github.com/eea/volto-slate-metadata-mentions/commit/9e0c360b5e842d30f4cc09efe3e3f8f7d3bd351c)]
115
- - Add Sonarqube tag using sustainability-frontend addons list [EEA Jenkins - [`e7404b9`](https://github.com/eea/volto-slate-metadata-mentions/commit/e7404b9f21415e894c149e5c8275bf74d0540c2c)]
116
122
  ## [4.0.0](https://github.com/eea/volto-slate-metadata-mentions/compare/3.0.2...4.0.0) - 24 September 2021
117
123
 
118
124
  #### :hammer_and_wrench: Others
119
125
 
120
126
  - Allow also dict fields: temporal, geolocation [Alin Voinea - [`49be384`](https://github.com/eea/volto-slate-metadata-mentions/commit/49be3845a5fed9957139ebe88d24adc44b2521d5)]
121
- - Add Sonarqube tag using climate-energy-frontend addons list [EEA Jenkins - [`53de974`](https://github.com/eea/volto-slate-metadata-mentions/commit/53de9745893b04f14f4688c81e52a857a5fbe7b9)]
122
127
  ### [3.0.2](https://github.com/eea/volto-slate-metadata-mentions/compare/3.0.1...3.0.2) - 10 September 2021
123
128
 
124
129
  #### :hammer_and_wrench: Others
125
130
 
126
- - Add Sonarqube tag using ims-frontend addons list [EEA Jenkins - [`cc67fec`](https://github.com/eea/volto-slate-metadata-mentions/commit/cc67fec41698b99c1382b8be4a9aec4d14806d15)]
127
131
  ### [3.0.1](https://github.com/eea/volto-slate-metadata-mentions/compare/3.0.0...3.0.1) - 9 September 2021
128
132
 
129
133
  ## [3.0.0](https://github.com/eea/volto-slate-metadata-mentions/compare/2.4.0...3.0.0) - 3 September 2021
@@ -133,7 +137,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
133
137
  - Update package metadata [Alin Voinea - [`af8c5b3`](https://github.com/eea/volto-slate-metadata-mentions/commit/af8c5b3bf2ce6d9520b3d9378c648a37d8d519d3)]
134
138
  - Add ErrorBoundary to Widgets [Alin Voinea - [`f9c7e0d`](https://github.com/eea/volto-slate-metadata-mentions/commit/f9c7e0de20c13305e9dfe09a968753f44e3224ce)]
135
139
  - Make sure it doesn't crash if used with SlateJSONField [Alin Voinea - [`60dbd38`](https://github.com/eea/volto-slate-metadata-mentions/commit/60dbd389f217b7341eb0c369abd044424357ab05)]
136
- - Add Sonarqube tag using frontend addons list [EEA Jenkins - [`7c7f219`](https://github.com/eea/volto-slate-metadata-mentions/commit/7c7f2196bafde9bbb3ecead19d65ff109080e1f1)]
137
140
  ### [2.4.0](https://github.com/eea/volto-slate-metadata-mentions/compare/2.3.1...2.4.0) - 1 July 2021
138
141
 
139
142
  ### [2.3.1](https://github.com/eea/volto-slate-metadata-mentions/compare/2.3.0...2.3.1) - 1 July 2021
@@ -253,7 +256,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
253
256
  - Cleanup [Alin Voinea - [`4edb16c`](https://github.com/eea/volto-slate-metadata-mentions/commit/4edb16c39bd1632a285aae1dc4b23bc3121b30af)]
254
257
  - Remove unused uid normalizer [Alin Voinea - [`6006d90`](https://github.com/eea/volto-slate-metadata-mentions/commit/6006d9070ca8418c508f002032eca087c851b489)]
255
258
  - Cosmetics [Alin Voinea - [`15424a4`](https://github.com/eea/volto-slate-metadata-mentions/commit/15424a48b14117a19c00167966a8fa15bcff8504)]
256
- - yarn lint [Alin Voinea - [`45403b3`](https://github.com/eea/volto-slate-metadata-mentions/commit/45403b3962c2c995e22c8c40535098948f6f8d2b)]
257
259
  - lint [Alin Voinea - [`9eedfe6`](https://github.com/eea/volto-slate-metadata-mentions/commit/9eedfe614e9202a2fd3d97c5d8cf53a52a43a3a4)]
258
260
  - Update widgets to use children; lint [Alin Voinea - [`17b5eec`](https://github.com/eea/volto-slate-metadata-mentions/commit/17b5eecc0ce445c123fd57abbc14e045f4920370)]
259
261
  - Style token widget [Alin Voinea - [`4fa52f5`](https://github.com/eea/volto-slate-metadata-mentions/commit/4fa52f5cc7cfde140e482048792c6f1782b4ee4e)]
package/Dockerfile CHANGED
@@ -1,6 +1,6 @@
1
1
  # syntax=docker/dockerfile:1
2
2
  ARG VOLTO_VERSION
3
- FROM plone/frontend-builder:${VOLTO_VERSION}
3
+ FROM eeacms/frontend-builder:${VOLTO_VERSION}
4
4
 
5
5
  ARG ADDON_NAME
6
6
  ARG ADDON_PATH
package/Jenkinsfile CHANGED
@@ -1,16 +1,24 @@
1
1
  pipeline {
2
- agent any
2
+ tools {
3
+ jdk 'Java17'
4
+ }
5
+ agent {
6
+ node { label 'docker-host' }
7
+ }
3
8
 
4
9
  environment {
5
- GIT_NAME = "volto-slate-metadata-mentions"
6
- NAMESPACE = "@eeacms"
7
- SONARQUBE_TAGS = "volto.eea.europa.eu,biodiversity.europa.eu,www.eea.europa.eu-ims,climate-energy.eea.europa.eu,sustainability.eionet.europa.eu,forest.eea.europa.eu,clms.land.copernicus.eu,industry.eea.europa.eu,water.europa.eu-freshwater,demo-www.eea.europa.eu,clmsdemo.devel6cph.eea.europa.eu,water.europa.eu-marine,climate-adapt.eea.europa.eu,climate-advisory-board.devel4cph.eea.europa.eu,climate-advisory-board.europa.eu,www.eea.europa.eu-en"
8
- DEPENDENCIES = ""
9
- VOLTO = "16"
10
- }
10
+ GIT_NAME = "volto-slate-metadata-mentions"
11
+ NAMESPACE = "@eeacms"
12
+ SONARQUBE_TAGS = "volto.eea.europa.eu,biodiversity.europa.eu,www.eea.europa.eu-ims,climate-energy.eea.europa.eu,forest.eea.europa.eu,clms.land.copernicus.eu,industry.eea.europa.eu,water.europa.eu-freshwater,demo-www.eea.europa.eu,clmsdemo.devel6cph.eea.europa.eu,water.europa.eu-marine,climate-adapt.eea.europa.eu,climate-advisory-board.devel4cph.eea.europa.eu,climate-advisory-board.europa.eu,www.eea.europa.eu-en,insitu-frontend.eionet.europa.eu,insitu.copernicus.eu"
13
+ DEPENDENCIES = ""
14
+ BACKEND_PROFILES = "eea.kitkat:testing"
15
+ BACKEND_ADDONS = ""
16
+ VOLTO = "17"
17
+ VOLTO16_BREAKING_CHANGES = "no"
18
+ IMAGE_NAME = BUILD_TAG.toLowerCase()
19
+ }
11
20
 
12
21
  stages {
13
-
14
22
  stage('Release') {
15
23
  when {
16
24
  allOf {
@@ -20,47 +28,36 @@ pipeline {
20
28
  }
21
29
  steps {
22
30
  node(label: 'docker') {
23
- withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN'),string(credentialsId: 'eea-jenkins-npm-token', variable: 'NPM_TOKEN')]) {
24
- sh '''docker pull eeacms/gitflow'''
25
- sh '''docker run -i --rm --name="$BUILD_TAG-gitflow-master" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_NAME="$GIT_NAME" -e GIT_TOKEN="$GITHUB_TOKEN" -e NPM_TOKEN="$NPM_TOKEN" -e LANGUAGE=javascript eeacms/gitflow'''
31
+ withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN'), string(credentialsId: 'eea-jenkins-npm-token', variable: 'NPM_TOKEN')]) {
32
+ sh '''docker run -i --rm --pull always --name="$IMAGE_NAME-gitflow-master" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_NAME="$GIT_NAME" -e GIT_TOKEN="$GITHUB_TOKEN" -e NPM_TOKEN="$NPM_TOKEN" -e LANGUAGE=javascript eeacms/gitflow'''
26
33
  }
27
34
  }
28
35
  }
29
36
  }
30
37
 
31
- stage('Code') {
38
+ stage('Check if testing needed') {
32
39
  when {
33
40
  allOf {
34
- environment name: 'CHANGE_ID', value: ''
35
- not { changelog '.*^Automated release [0-9\\.]+$' }
36
41
  not { branch 'master' }
42
+ not { branch 'develop' }
43
+ environment name: 'CHANGE_ID', value: ''
37
44
  }
38
45
  }
39
46
  steps {
40
- parallel(
41
-
42
- "ES lint": {
43
- node(label: 'docker') {
44
- sh '''docker run -i --rm --name="$BUILD_TAG-eslint" -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e VOLTO=$VOLTO plone/volto-addon-ci eslint'''
45
- }
46
- },
47
-
48
- "Style lint": {
49
- node(label: 'docker') {
50
- sh '''docker run -i --rm --name="$BUILD_TAG-stylelint" -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e VOLTO=$VOLTO plone/volto-addon-ci stylelint'''
51
- }
52
- },
47
+ script {
48
+ checkout scm
49
+ withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN')]) {
50
+ check_result = sh script: '''docker run --pull always -i --rm --name="$IMAGE_NAME-gitflow-check" -e GIT_TOKEN="$GITHUB_TOKEN" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_ORG="$GIT_ORG" -e GIT_NAME="$GIT_NAME" eeacms/gitflow /check_if_testing_needed.sh''', returnStatus: true
53
51
 
54
- "Prettier": {
55
- node(label: 'docker') {
56
- sh '''docker run -i --rm --name="$BUILD_TAG-prettier" -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e VOLTO=$VOLTO plone/volto-addon-ci prettier'''
52
+ if (check_result == 0) {
53
+ env.SKIP_TESTS = 'yes'
54
+ }
57
55
  }
58
- }
59
- )
56
+ }
60
57
  }
61
58
  }
62
59
 
63
- stage('Tests') {
60
+ stage('Testing') {
64
61
  when {
65
62
  anyOf {
66
63
  allOf {
@@ -76,23 +73,75 @@ pipeline {
76
73
  }
77
74
  }
78
75
  }
79
- steps {
80
- parallel(
76
+ parallel {
77
+
78
+ stage('Volto 17') {
79
+ agent { node { label 'docker-1.13'} }
80
+ stages {
81
+ stage('Build test image') {
82
+ steps {
83
+ sh '''docker build --pull --build-arg="VOLTO_VERSION=$VOLTO" --build-arg="ADDON_NAME=$NAMESPACE/$GIT_NAME" --build-arg="ADDON_PATH=$GIT_NAME" . -t $IMAGE_NAME-frontend'''
84
+ }
85
+ }
81
86
 
82
- "Volto": {
83
- node(label: 'docker') {
87
+ stage('Fix code') {
88
+ when {
89
+ environment name: 'CHANGE_ID', value: ''
90
+ not { branch 'master' }
91
+ }
92
+ steps {
84
93
  script {
85
- try {
86
- sh '''docker pull plone/volto-addon-ci'''
87
- sh '''docker run -i --name="$BUILD_TAG-volto" -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e VOLTO=$VOLTO plone/volto-addon-ci'''
88
- sh '''rm -rf xunit-reports'''
89
- sh '''mkdir -p xunit-reports'''
90
- sh '''docker cp $BUILD_TAG-volto:/opt/frontend/my-volto-project/coverage xunit-reports/'''
91
- sh '''docker cp $BUILD_TAG-volto:/opt/frontend/my-volto-project/junit.xml xunit-reports/'''
92
- sh '''docker cp $BUILD_TAG-volto:/opt/frontend/my-volto-project/unit_tests_log.txt xunit-reports/'''
93
- stash name: "xunit-reports", includes: "xunit-reports/**"
94
- archiveArtifacts artifacts: "xunit-reports/unit_tests_log.txt", fingerprint: true
95
- publishHTML (target : [
94
+ fix_result = sh(script: '''docker run --name="$IMAGE_NAME-fix" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend ci-fix''', returnStatus: true)
95
+ sh '''docker cp $IMAGE_NAME-fix:/app/src/addons/$GIT_NAME/src .'''
96
+ sh '''docker rm -v $IMAGE_NAME-fix'''
97
+ FOUND_FIX = sh(script: '''git diff | wc -l''', returnStdout: true).trim()
98
+
99
+ if (FOUND_FIX != '0') {
100
+ withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN')]) {
101
+ sh '''sed -i "s|url = .*|url = https://eea-jenkins:$GITHUB_TOKEN@github.com/eea/$GIT_NAME.git|" .git/config'''
102
+ }
103
+ sh '''git fetch origin $GIT_BRANCH:$GIT_BRANCH'''
104
+ sh '''git checkout $GIT_BRANCH'''
105
+ sh '''git add src/'''
106
+ sh '''git commit -m "style: Automated code fix" '''
107
+ sh '''git push --set-upstream origin $GIT_BRANCH'''
108
+ sh '''exit 1'''
109
+ }
110
+ }
111
+ }
112
+ }
113
+
114
+ stage('ES lint') {
115
+ when { environment name: 'SKIP_TESTS', value: '' }
116
+ steps {
117
+ sh '''docker run --rm --name="$IMAGE_NAME-eslint" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend lint'''
118
+ }
119
+ }
120
+
121
+ stage('Style lint') {
122
+ when { environment name: 'SKIP_TESTS', value: '' }
123
+ steps {
124
+ sh '''docker run --rm --name="$IMAGE_NAME-stylelint" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend stylelint'''
125
+ }
126
+ }
127
+
128
+ stage('Prettier') {
129
+ when { environment name: 'SKIP_TESTS', value: '' }
130
+ steps {
131
+ sh '''docker run --rm --name="$IMAGE_NAME-prettier" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend prettier'''
132
+ }
133
+ }
134
+ stage('Unit tests') {
135
+ when { environment name: 'SKIP_TESTS', value: '' }
136
+ steps {
137
+ script {
138
+ try {
139
+ sh '''docker run --name="$IMAGE_NAME-volto" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend test-ci'''
140
+ sh '''rm -rf xunit-reports'''
141
+ sh '''mkdir -p xunit-reports'''
142
+ sh '''docker cp $IMAGE_NAME-volto:/app/coverage xunit-reports/'''
143
+ sh '''docker cp $IMAGE_NAME-volto:/app/junit.xml xunit-reports/'''
144
+ publishHTML(target : [
96
145
  allowMissing: false,
97
146
  alwaysLinkToLastBuild: true,
98
147
  keepAll: true,
@@ -105,87 +154,81 @@ pipeline {
105
154
  catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') {
106
155
  junit testResults: 'xunit-reports/junit.xml', allowEmptyResults: true
107
156
  }
108
- sh script: '''docker rm -v $BUILD_TAG-volto''', returnStatus: true
157
+ sh script: '''docker rm -v $IMAGE_NAME-volto''', returnStatus: true
158
+ }
109
159
  }
110
160
  }
111
- }
112
161
  }
113
- )
114
- }
115
- }
162
+
163
+ stage('Integration tests') {
164
+ when { environment name: 'SKIP_TESTS', value: '' }
165
+ steps {
166
+ script {
167
+ try {
168
+ sh '''docker run --pull always --rm -d --name="$IMAGE_NAME-plone" -e SITE="Plone" -e PROFILES="$BACKEND_PROFILES" -e ADDONS="$BACKEND_ADDONS" eeacms/plone-backend'''
169
+ sh '''docker run -d --shm-size=6g --link $IMAGE_NAME-plone:plone --name="$IMAGE_NAME-cypress" -e "RAZZLE_INTERNAL_API_PATH=http://plone:8080/Plone" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend start-ci'''
170
+ sleep 30
171
+ frontend = sh script:'''docker exec --workdir=/app/src/addons/${GIT_NAME} $IMAGE_NAME-cypress make check-ci''', returnStatus: true
172
+ if ( frontend != 0 ) {
173
+ sh '''docker logs $IMAGE_NAME-cypress; exit 1'''
174
+ }
116
175
 
117
- stage('Integration tests') {
118
- when {
119
- anyOf {
120
- allOf {
121
- not { environment name: 'CHANGE_ID', value: '' }
122
- environment name: 'CHANGE_TARGET', value: 'develop'
123
- }
124
- allOf {
125
- environment name: 'CHANGE_ID', value: ''
126
- anyOf {
127
- not { changelog '.*^Automated release [0-9\\.]+$' }
128
- branch 'master'
129
- }
130
- }
131
- }
132
- }
133
- steps {
134
- parallel(
176
+ sh '''timeout -s 9 1800 docker exec --workdir=/app/src/addons/${GIT_NAME} $IMAGE_NAME-cypress make cypress-ci'''
177
+ } finally {
178
+ try {
179
+ if ( frontend == 0 ) {
180
+ sh '''rm -rf cypress-videos cypress-results cypress-coverage cypress-screenshots'''
181
+ sh '''mkdir -p cypress-videos cypress-results cypress-coverage cypress-screenshots'''
182
+ videos = sh script: '''docker cp $IMAGE_NAME-cypress:/app/src/addons/$GIT_NAME/cypress/videos cypress-videos/''', returnStatus: true
183
+ sh '''docker cp $IMAGE_NAME-cypress:/app/src/addons/$GIT_NAME/cypress/reports cypress-results/'''
184
+ screenshots = sh script: '''docker cp $IMAGE_NAME-cypress:/app/src/addons/$GIT_NAME/cypress/screenshots cypress-screenshots''', returnStatus: true
135
185
 
136
- "Cypress": {
137
- node(label: 'docker') {
138
- script {
139
- try {
140
- sh '''docker pull eeacms/plone-backend; docker run --rm -d --name="$BUILD_TAG-plone" -e SITE="Plone" -e PROFILES="eea.kitkat:testing" eeacms/plone-backend'''
141
- sh '''docker pull plone/volto-addon-ci; docker run -i --name="$BUILD_TAG-cypress" --link $BUILD_TAG-plone:plone -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e DEPENDENCIES="$DEPENDENCIES" -e NODE_ENV=development -e VOLTO="$VOLTO" plone/volto-addon-ci cypress'''
142
- } finally {
143
- try {
144
- sh '''rm -rf cypress-reports cypress-results cypress-coverage'''
145
- sh '''mkdir -p cypress-reports cypress-results cypress-coverage'''
146
- sh '''docker cp $BUILD_TAG-cypress:/opt/frontend/my-volto-project/src/addons/$GIT_NAME/cypress/videos cypress-reports/'''
147
- sh '''docker cp $BUILD_TAG-cypress:/opt/frontend/my-volto-project/src/addons/$GIT_NAME/cypress/reports cypress-results/'''
148
- coverage = sh script: '''docker cp $BUILD_TAG-cypress:/opt/frontend/my-volto-project/src/addons/$GIT_NAME/coverage cypress-coverage/''', returnStatus: true
149
- if ( coverage == 0 ) {
150
- publishHTML (target : [allowMissing: false,
186
+ archiveArtifacts artifacts: 'cypress-screenshots/**', fingerprint: true, allowEmptyArchive: true
187
+
188
+ coverage = sh script: '''docker cp $IMAGE_NAME-cypress:/app/src/addons/$GIT_NAME/coverage cypress-coverage''', returnStatus: true
189
+
190
+ if ( coverage == 0 ) {
191
+ publishHTML(target : [allowMissing: false,
151
192
  alwaysLinkToLastBuild: true,
152
193
  keepAll: true,
153
194
  reportDir: 'cypress-coverage/coverage/lcov-report',
154
195
  reportFiles: 'index.html',
155
196
  reportName: 'CypressCoverage',
156
197
  reportTitles: 'Integration Tests Code Coverage'])
157
- }
158
- sh '''touch empty_file; for ok_test in $(grep -E 'file=.*failures="0"' $(grep 'testsuites .*failures="0"' $(find cypress-results -name *.xml) empty_file | awk -F: '{print $1}') empty_file | sed 's/.* file="\\(.*\\)" time.*/\\1/' | sed 's#^cypress/integration/##g' | sed 's#^../../../node_modules/@eeacms/##g'); do rm -f cypress-reports/videos/$ok_test.mp4; rm -f cypress-reports/$ok_test.mp4; done'''
159
- archiveArtifacts artifacts: 'cypress-reports/**/*.mp4', fingerprint: true, allowEmptyArchive: true
160
- stash name: "cypress-coverage", includes: "cypress-coverage/**", allowEmpty: true
161
- }
162
- finally {
163
- catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') {
198
+ }
199
+ if ( videos == 0 ) {
200
+ sh '''for file in $(find cypress-results -name *.xml); do if [ $(grep -E 'failures="[1-9].*"' $file | wc -l) -eq 0 ]; then testname=$(grep -E 'file=.*failures="0"' $file | sed 's#.* file=".*\\/\\(.*\\.[jsxt]\\+\\)" time.*#\\1#' ); rm -f cypress-videos/videos/$testname.mp4; fi; done'''
201
+ archiveArtifacts artifacts: 'cypress-videos/**/*.mp4', fingerprint: true, allowEmptyArchive: true
202
+ }
203
+ }
204
+ } finally {
205
+ catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') {
164
206
  junit testResults: 'cypress-results/**/*.xml', allowEmptyResults: true
207
+ }
208
+ catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') {
209
+ sh '''docker logs $IMAGE_NAME-cypress'''
210
+ }
211
+ sh script: "docker stop $IMAGE_NAME-cypress", returnStatus: true
212
+ sh script: "docker stop $IMAGE_NAME-plone", returnStatus: true
213
+ sh script: "docker rm -v $IMAGE_NAME-plone", returnStatus: true
214
+ sh script: "docker rm -v $IMAGE_NAME-cypress", returnStatus: true
165
215
  }
166
- sh script: "docker stop $BUILD_TAG-plone", returnStatus: true
167
- sh script: "docker rm -v $BUILD_TAG-plone", returnStatus: true
168
- sh script: "docker rm -v $BUILD_TAG-cypress", returnStatus: true
169
-
170
216
  }
171
217
  }
172
218
  }
173
- }
174
219
  }
175
220
 
176
- )
177
- }
178
- }
179
-
180
221
  stage('Report to SonarQube') {
181
222
  when {
182
223
  anyOf {
183
224
  allOf {
184
225
  not { environment name: 'CHANGE_ID', value: '' }
185
226
  environment name: 'CHANGE_TARGET', value: 'develop'
227
+ environment name: 'SKIP_TESTS', value: ''
186
228
  }
187
229
  allOf {
188
230
  environment name: 'CHANGE_ID', value: ''
231
+ environment name: 'SKIP_TESTS', value: ''
189
232
  anyOf {
190
233
  allOf {
191
234
  branch 'develop'
@@ -197,32 +240,120 @@ pipeline {
197
240
  }
198
241
  }
199
242
  steps {
200
- node(label: 'swarm') {
201
- script{
202
- checkout scm
203
- unstash "xunit-reports"
204
- unstash "cypress-coverage"
205
- def scannerHome = tool 'SonarQubeScanner';
206
- def nodeJS = tool 'NodeJS';
207
- withSonarQubeEnv('Sonarqube') {
208
- sh '''sed -i "s#/opt/frontend/my-volto-project/src/addons/${GIT_NAME}/##g" xunit-reports/coverage/lcov.info'''
209
- sh '''sed -i "s#src/addons/${GIT_NAME}/##g" xunit-reports/coverage/lcov.info'''
210
- sh "export PATH=${scannerHome}/bin:${nodeJS}/bin:$PATH; sonar-scanner -Dsonar.javascript.lcov.reportPaths=./xunit-reports/coverage/lcov.info,./cypress-coverage/coverage/lcov.info -Dsonar.sources=./src -Dsonar.projectKey=$GIT_NAME-$BRANCH_NAME -Dsonar.projectVersion=$BRANCH_NAME-$BUILD_NUMBER"
211
- sh '''try=2; while [ \$try -gt 0 ]; do curl -s -XPOST -u "${SONAR_AUTH_TOKEN}:" "${SONAR_HOST_URL}api/project_tags/set?project=${GIT_NAME}-${BRANCH_NAME}&tags=${SONARQUBE_TAGS},${BRANCH_NAME}" > set_tags_result; if [ \$(grep -ic error set_tags_result ) -eq 0 ]; then try=0; else cat set_tags_result; echo "... Will retry"; sleep 60; try=\$(( \$try - 1 )); fi; done'''
243
+ script {
244
+ def scannerHome = tool 'SonarQubeScanner'
245
+ def nodeJS = tool 'NodeJS'
246
+ withSonarQubeEnv('Sonarqube') {
247
+ sh '''sed -i "s#/app/src/addons/${GIT_NAME}/##g" xunit-reports/coverage/lcov.info'''
248
+ sh '''sed -i "s#src/addons/${GIT_NAME}/##g" xunit-reports/coverage/lcov.info'''
249
+ sh "export PATH=${scannerHome}/bin:${nodeJS}/bin:$PATH; sonar-scanner -Dsonar.javascript.lcov.reportPaths=./xunit-reports/coverage/lcov.info,./cypress-coverage/coverage/lcov.info -Dsonar.sources=./src -Dsonar.projectKey=$GIT_NAME-$BRANCH_NAME -Dsonar.projectVersion=$BRANCH_NAME-$BUILD_NUMBER"
250
+ sh '''try=5; while [ \$try -gt 0 ]; do curl -s -XPOST -u "${SONAR_AUTH_TOKEN}:" "${SONAR_HOST_URL}api/project_tags/set?project=${GIT_NAME}-${BRANCH_NAME}&tags=${SONARQUBE_TAGS},${BRANCH_NAME}" > set_tags_result; if [ \$(grep -ic error set_tags_result ) -eq 0 ]; then try=0; else cat set_tags_result; echo "... Will retry"; sleep 15; try=\$(( \$try - 1 )); fi; done'''
251
+ }
252
+ }
253
+ }
254
+ }
255
+
256
+
257
+ }
258
+ }
259
+
260
+ stage('Volto 16') {
261
+ agent { node { label 'integration'} }
262
+ when {
263
+ environment name: 'SKIP_TESTS', value: ''
264
+ not { environment name: 'VOLTO16_BREAKING_CHANGES', value: 'yes' }
265
+ }
266
+ stages {
267
+ stage('Build test image') {
268
+ steps {
269
+ sh '''docker build --pull --build-arg="VOLTO_VERSION=16" --build-arg="ADDON_NAME=$NAMESPACE/$GIT_NAME" --build-arg="ADDON_PATH=$GIT_NAME" . -t $IMAGE_NAME-frontend16'''
212
270
  }
213
271
  }
272
+
273
+ stage('Unit tests Volto 16') {
274
+ steps {
275
+ script {
276
+ try {
277
+ sh '''docker run --name="$IMAGE_NAME-volto16" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend16 test-ci'''
278
+ sh '''rm -rf xunit-reports16'''
279
+ sh '''mkdir -p xunit-reports16'''
280
+ sh '''docker cp $IMAGE_NAME-volto16:/app/junit.xml xunit-reports16/'''
281
+ } finally {
282
+ catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') {
283
+ junit testResults: 'xunit-reports16/junit.xml', allowEmptyResults: true
284
+ }
285
+ sh script: '''docker rm -v $IMAGE_NAME-volto16''', returnStatus: true
286
+ }
287
+ }
288
+ }
289
+ }
290
+
291
+ stage('Integration tests Volto 16') {
292
+ steps {
293
+ script {
294
+ try {
295
+ sh '''docker run --pull always --rm -d --name="$IMAGE_NAME-plone16" -e SITE="Plone" -e PROFILES="$BACKEND_PROFILES" -e ADDONS="$BACKEND_ADDONS" eeacms/plone-backend'''
296
+ sh '''docker run -d --shm-size=4g --link $IMAGE_NAME-plone16:plone --name="$IMAGE_NAME-cypress16" -e "RAZZLE_INTERNAL_API_PATH=http://plone:8080/Plone" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend16 start-ci'''
297
+ frontend = sh script:'''docker exec --workdir=/app/src/addons/${GIT_NAME} $IMAGE_NAME-cypress16 make check-ci''', returnStatus: true
298
+ if ( frontend != 0 ) {
299
+ sh '''docker logs $IMAGE_NAME-cypress16; exit 1'''
300
+ }
301
+ sh '''timeout -s 9 1800 docker exec --workdir=/app/src/addons/${GIT_NAME} $IMAGE_NAME-cypress16 make cypress-ci'''
302
+ } finally {
303
+ try {
304
+ if ( frontend == 0 ) {
305
+ sh '''rm -rf cypress-videos16 cypress-results16 cypress-coverage16 cypress-screenshots16'''
306
+ sh '''mkdir -p cypress-videos16 cypress-results16 cypress-coverage16 cypress-screenshots16'''
307
+ videos = sh script: '''docker cp $IMAGE_NAME-cypress16:/app/src/addons/$GIT_NAME/cypress/videos cypress-videos16/''', returnStatus: true
308
+ sh '''docker cp $IMAGE_NAME-cypress16:/app/src/addons/$GIT_NAME/cypress/reports cypress-results16/'''
309
+ screenshots = sh script: '''docker cp $IMAGE_NAME-cypress16:/app/src/addons/$GIT_NAME/cypress/screenshots cypress-screenshots16''', returnStatus: true
310
+
311
+ archiveArtifacts artifacts: 'cypress-screenshots16/**', fingerprint: true, allowEmptyArchive: true
312
+
313
+ if ( videos == 0 ) {
314
+ sh '''for file in $(find cypress-results16 -name *.xml); do if [ $(grep -E 'failures="[1-9].*"' $file | wc -l) -eq 0 ]; then testname=$(grep -E 'file=.*failures="0"' $file | sed 's#.* file=".*\\/\\(.*\\.[jsxt]\\+\\)" time.*#\\1#' ); rm -f cypress-videos16/videos/$testname.mp4; fi; done'''
315
+ archiveArtifacts artifacts: 'cypress-videos16/**/*.mp4', fingerprint: true, allowEmptyArchive: true
316
+ }
317
+ }
318
+ } finally {
319
+ catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') {
320
+ junit testResults: 'cypress-results16/**/*.xml', allowEmptyResults: true
321
+ }
322
+ catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') {
323
+ sh '''docker logs $IMAGE_NAME-cypress16'''
324
+ }
325
+ sh script: "docker stop $IMAGE_NAME-cypress16", returnStatus: true
326
+ sh script: "docker stop $IMAGE_NAME-plone16", returnStatus: true
327
+ sh script: "docker rm -v $IMAGE_NAME-plone16", returnStatus: true
328
+ sh script: "docker rm -v $IMAGE_NAME-cypress16", returnStatus: true
329
+ }
330
+ }
331
+ }
332
+ }
333
+ }
334
+
335
+ }
336
+ }
337
+ }
338
+ post {
339
+ always {
340
+ sh script: "docker rmi $IMAGE_NAME-frontend", returnStatus: true
341
+ sh script: "docker rmi $IMAGE_NAME-frontend16", returnStatus: true
214
342
  }
215
343
  }
216
344
  }
217
345
 
346
+
218
347
  stage('SonarQube compare to master') {
219
348
  when {
220
349
  anyOf {
221
350
  allOf {
222
351
  not { environment name: 'CHANGE_ID', value: '' }
223
352
  environment name: 'CHANGE_TARGET', value: 'develop'
353
+ environment name: 'SKIP_TESTS', value: ''
224
354
  }
225
355
  allOf {
356
+ environment name: 'SKIP_TESTS', value: ''
226
357
  environment name: 'CHANGE_ID', value: ''
227
358
  branch 'develop'
228
359
  not { changelog '.*^Automated release [0-9\\.]+$' }
@@ -230,18 +361,15 @@ pipeline {
230
361
  }
231
362
  }
232
363
  steps {
233
- node(label: 'docker') {
234
- script {
235
- sh '''docker pull eeacms/gitflow'''
236
- sh '''echo "Error" > checkresult.txt'''
237
- catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
238
- sh '''set -o pipefail; docker run -i --rm --name="$BUILD_TAG-gitflow-sn" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_NAME="$GIT_NAME" eeacms/gitflow /checkSonarqubemaster.sh | grep -v "Found script" | tee checkresult.txt'''
239
- }
240
-
241
- publishChecks name: 'SonarQube', title: 'Sonarqube Code Quality Check', summary: "Quality check on the SonarQube metrics from branch develop, comparing it with the ones from master branch. No bugs are allowed",
242
- text: readFile(file: 'checkresult.txt'), conclusion: "${currentBuild.currentResult}",
243
- detailsURL: "${env.BUILD_URL}display/redirect"
364
+ script {
365
+ sh '''echo "Error" > checkresult.txt'''
366
+ catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
367
+ sh '''set -o pipefail; docker run -i --rm --pull always --name="$IMAGE_NAME-gitflow-sn" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_NAME="$GIT_NAME" eeacms/gitflow /checkSonarqubemaster.sh | grep -v "Found script" | tee checkresult.txt'''
244
368
  }
369
+
370
+ publishChecks name: 'SonarQube', title: 'Sonarqube Code Quality Check', summary: 'Quality check on the SonarQube metrics from branch develop, comparing it with the ones from master branch. No bugs are allowed',
371
+ text: readFile(file: 'checkresult.txt'), conclusion: "${currentBuild.currentResult}",
372
+ detailsURL: "${env.BUILD_URL}display/redirect"
245
373
  }
246
374
  }
247
375
  }
@@ -254,20 +382,16 @@ pipeline {
254
382
  environment name: 'CHANGE_TARGET', value: 'master'
255
383
  }
256
384
  steps {
257
- node(label: 'docker') {
258
- script {
259
- if ( env.CHANGE_BRANCH != "develop" ) {
260
- error "Pipeline aborted due to PR not made from develop branch"
261
- }
262
- withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN')]) {
263
- sh '''docker pull eeacms/gitflow'''
264
- sh '''docker run -i --rm --name="$BUILD_TAG-gitflow-pr" -e GIT_CHANGE_TARGET="$CHANGE_TARGET" -e GIT_CHANGE_BRANCH="$CHANGE_BRANCH" -e GIT_CHANGE_AUTHOR="$CHANGE_AUTHOR" -e GIT_CHANGE_TITLE="$CHANGE_TITLE" -e GIT_TOKEN="$GITHUB_TOKEN" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e GIT_ORG="$GIT_ORG" -e GIT_NAME="$GIT_NAME" -e LANGUAGE=javascript eeacms/gitflow'''
265
- }
385
+ script {
386
+ if (env.CHANGE_BRANCH != 'develop') {
387
+ error 'Pipeline aborted due to PR not made from develop branch'
388
+ }
389
+ withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN')]) {
390
+ sh '''docker run --pull always -i --rm --name="$IMAGE_NAME-gitflow-pr" -e GIT_CHANGE_TARGET="$CHANGE_TARGET" -e GIT_CHANGE_BRANCH="$CHANGE_BRANCH" -e GIT_CHANGE_AUTHOR="$CHANGE_AUTHOR" -e GIT_CHANGE_TITLE="$CHANGE_TITLE" -e GIT_TOKEN="$GITHUB_TOKEN" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e GIT_ORG="$GIT_ORG" -e GIT_NAME="$GIT_NAME" -e LANGUAGE=javascript eeacms/gitflow'''
266
391
  }
267
392
  }
268
393
  }
269
394
  }
270
-
271
395
  }
272
396
 
273
397
  post {
@@ -290,3 +414,4 @@ pipeline {
290
414
  }
291
415
  }
292
416
  }
417
+
package/Makefile CHANGED
@@ -46,10 +46,15 @@ endif
46
46
  DIR=$(shell basename $$(pwd))
47
47
  NODE_MODULES?="../../../node_modules"
48
48
  PLONE_VERSION?=6
49
- VOLTO_VERSION?=16
49
+ VOLTO_VERSION?=17
50
50
  ADDON_PATH="${DIR}"
51
51
  ADDON_NAME="@eeacms/${ADDON_PATH}"
52
52
  DOCKER_COMPOSE=PLONE_VERSION=${PLONE_VERSION} VOLTO_VERSION=${VOLTO_VERSION} ADDON_NAME=${ADDON_NAME} ADDON_PATH=${ADDON_PATH} docker compose
53
+ RAZZLE_INTERNAL_API_PATH?="http://localhost:8080/Plone"
54
+ RAZZLE_DEV_PROXY_API_PATH?="${RAZZLE_INTERNAL_API_PATH}"
55
+ CYPRESS_API_PATH="${RAZZLE_DEV_PROXY_API_PATH}"
56
+
57
+
53
58
 
54
59
  # Top-level targets
55
60
  .PHONY: all
@@ -77,11 +82,11 @@ shell: ## Start a shell in the frontend container
77
82
 
78
83
  .PHONY: cypress-open
79
84
  cypress-open: ## Open cypress integration tests
80
- NODE_ENV=development $(NODE_MODULES)/cypress/bin/cypress open
85
+ CYPRESS_API_PATH="${RAZZLE_DEV_PROXY_API_PATH}" NODE_ENV=development $(NODE_MODULES)/cypress/bin/cypress open
81
86
 
82
87
  .PHONY: cypress-run
83
88
  cypress-run: ## Run cypress integration tests
84
- NODE_ENV=development $(NODE_MODULES)/cypress/bin/cypress run
89
+ CYPRESS_API_PATH="${RAZZLE_DEV_PROXY_API_PATH}" NODE_ENV=development $(NODE_MODULES)/cypress/bin/cypress run
85
90
 
86
91
  .PHONY: test
87
92
  test: ## Run jest tests
@@ -93,7 +98,7 @@ test-update: ## Update jest tests snapshots
93
98
 
94
99
  .PHONY: stylelint
95
100
  stylelint: ## Stylelint
96
- $(NODE_MODULES)/stylelint/bin/stylelint.js --allow-empty-input 'src/**/*.{css,less}'
101
+ $(NODE_MODULES)/.bin/stylelint --allow-empty-input 'src/**/*.{css,less}'
97
102
 
98
103
  .PHONY: stylelint-overrides
99
104
  stylelint-overrides:
@@ -101,7 +106,7 @@ stylelint-overrides:
101
106
 
102
107
  .PHONY: stylelint-fix
103
108
  stylelint-fix: ## Fix stylelint
104
- $(NODE_MODULES)/stylelint/bin/stylelint.js --allow-empty-input 'src/**/*.{css,less}' --fix
109
+ $(NODE_MODULES)/.bin/stylelint --allow-empty-input 'src/**/*.{css,less}' --fix
105
110
  $(NODE_MODULES)/.bin/stylelint --custom-syntax less --allow-empty-input 'theme/**/*.overrides' 'src/**/*.overrides' --fix
106
111
 
107
112
  .PHONY: prettier
@@ -114,11 +119,11 @@ prettier-fix: ## Fix prettier
114
119
 
115
120
  .PHONY: lint
116
121
  lint: ## ES Lint
117
- $(NODE_MODULES)/eslint/bin/eslint.js --max-warnings=0 'src/**/*.{js,jsx}'
122
+ $(NODE_MODULES)/.bin/eslint --max-warnings=0 'src/**/*.{js,jsx}'
118
123
 
119
124
  .PHONY: lint-fix
120
125
  lint-fix: ## Fix ES Lint
121
- $(NODE_MODULES)/eslint/bin/eslint.js --fix 'src/**/*.{js,jsx}'
126
+ $(NODE_MODULES)/.bin/eslint --fix 'src/**/*.{js,jsx}'
122
127
 
123
128
  .PHONY: i18n
124
129
  i18n: ## i18n
@@ -129,3 +134,32 @@ i18n: ## i18n
129
134
  help: ## Show this help.
130
135
  @echo -e "$$(grep -hE '^\S+:.*##' $(MAKEFILE_LIST) | sed -e 's/:.*##\s*/:/' -e 's/^\(.\+\):\(.*\)/\\x1b[36m\1\\x1b[m:\2/' | column -c2 -t -s :)"
131
136
  head -n 14 Makefile
137
+
138
+ .PHONY: ci-fix
139
+ ci-fix:
140
+ echo "Running lint-fix"
141
+ make lint-fix
142
+ echo "Running prettier-fix"
143
+ make prettier-fix
144
+ echo "Running stylelint-fix"
145
+ make stylelint-fix
146
+
147
+ .PHONY: test-ci
148
+ test-ci:
149
+ cd /app
150
+ RAZZLE_JEST_CONFIG=src/addons/${ADDON_PATH}/jest-addon.config.js CI=true yarn test src/addons/${ADDON_PATH}/src --watchAll=false --reporters=default --reporters=jest-junit --collectCoverage --coverageReporters lcov cobertura text
151
+
152
+ .PHONY: start-ci
153
+ start-ci:
154
+ cp .coverage.babel.config.js /app/babel.config.js
155
+ cd ../..
156
+ yarn start
157
+
158
+ .PHONY: check-ci
159
+ check-ci:
160
+ $(NODE_MODULES)/.bin/wait-on -t 240000 http://localhost:3000
161
+
162
+ .PHONY: cypress-ci
163
+ cypress-ci:
164
+ $(NODE_MODULES)/.bin/wait-on -t 240000 http://localhost:3000
165
+ CYPRESS_API_PATH="${RAZZLE_DEV_PROXY_API_PATH}" NODE_ENV=development $(NODE_MODULES)/cypress/bin/cypress run --browser chromium
@@ -6,29 +6,35 @@ describe('Block Tests: Metadata', () => {
6
6
 
7
7
  it('As editor I can add metadata mentions', function () {
8
8
  // Complete chained commands
9
- cy.getSlateEditorAndType('Colorless green ideas sleep furiously.');
9
+ cy.getSlateEditorAndType('Colorless green ideas sleep furiously.')
10
+ .type('{selectAll}')
11
+ .dblclick();
10
12
 
11
13
  // Metadata mention
14
+ cy.setSlateCursor('Colorless').dblclick();
12
15
  cy.setSlateSelection('Colorless', 'green');
13
16
  cy.clickSlateButton('Metadata');
14
17
 
15
- cy.get('.sidebar-container div[id="field-metadata"]')
16
- .type('Publishing Date{enter}');
18
+ cy.get('.sidebar-container div[id="field-metadata"]').type(
19
+ 'Publishing Date{enter}',
20
+ );
17
21
  cy.get('.sidebar-container .form .header button:first-of-type').click();
18
22
 
19
23
  // Remove link
20
- cy.setSlateSelection('Colorless')
21
- .setSlateSelection('green');
24
+ cy.setSlateSelection('Colorless').setSlateSelection('green');
22
25
  cy.clickSlateButton('Remove metadata');
23
26
 
24
27
  // Re-add link
28
+ cy.setSlateCursor('Colorless').dblclick();
25
29
  cy.setSlateSelection('green', 'sleep');
26
30
  cy.clickSlateButton('Metadata');
27
31
 
28
- cy.get('.sidebar-container div[id="field-metadata"]')
29
- .type('Summary{enter}');
30
- cy.get('.sidebar-container [id="blockform-fieldset-metadata"] [id="field-description"]')
31
- .type('blue cats sleep');
32
+ cy.get('.sidebar-container div[id="field-metadata"]').type(
33
+ 'Summary{enter}',
34
+ );
35
+ cy.get(
36
+ '.sidebar-container [id="blockform-fieldset-metadata"] [id="field-description"]',
37
+ ).type('blue cats sleep');
32
38
  cy.get('.sidebar-container .form .header button:first-of-type').click();
33
39
 
34
40
  // Save
@@ -68,8 +68,7 @@ Cypress.Commands.add(
68
68
  id: contentId,
69
69
  title: contentTitle,
70
70
  image: {
71
- data:
72
- 'iVBORw0KGgoAAAANSUhEUgAAANcAAAA4CAMAAABZsZ3QAAAAM1BMVEX29fK42OU+oMvn7u9drtIPisHI4OhstdWZyt4fkcXX5+sAg74umMhNp86p0eJ7vNiKw9v/UV4wAAAAAXRSTlMAQObYZgAABBxJREFUeF7tmuty4yAMhZG4X2zn/Z92J5tsBJwWXG/i3XR6frW2Y/SBLIRAfaQUDNt8E5tLUt9BycfcKfq3R6Mlfyimtx4rzp+K3dtibXkor99zsEqLYZltblTecciogoh+TXfY1Ve4dn07rCDGG9dHSEEOg/GmXl0U1XDxTKxNK5De7BxsyyBr6gGm2/vPxKJ8F6f7BXKfRMp1xIWK9A+5ks25alSb353dWnDJN1k35EL5f8dVGifTf/4tjUuuFq7u4srmXC60yAmldLXIWbg65RKU87lcGxJCFqUPv0IacW0PmSivOZFLE908inPToMmii/roG+MRV/O8FU88i8tFsxV3a06MFUw0Qu7RmAtdV5/HVVaOVMTWNOWSwMljLhzhcB6XIS7OK5V6AvRDNN7t5VJWQs1J40UmalbK56usBG/CuCHSYuc+rkUGeMCViNRARPrzW52N3oQLe6WifNliSuuGaH3czbVNudI9s7ZLUCLHVwWlyES522o1t14uvmbblmVTKqFjaZYJFSTPP4dLL1kU1z7p0lzdbRulmEWLxoQX+z9ce7A8GqEEucllLxePuZwdJl1Lezu0hoswvTPt61DrFcRuujV/2cmlxaGBC7Aw6cpovGANwRiSdOAWJ5AGy4gLL64dl0QhUEAuEUNws+XxV+OKGPdw/hESGYF9XEGaFC7sNLMSXWJjHsnanYi87VK428N2uxpOjOFANcagLM5l+7mSycM8KknZpKLcGi6jmzWGr/vLurZ/0g4u9AZuAoeb5r1ceQhyiTPY1E4wUR6u/F3H2ojSpXMMriBPT9cezTto8Cx+MsglHL4fv1Rxrb1LVw9yvyQpJ3AhFnLZfuRLH2QsOG3FGGD20X/th/u5bFAt16Bt308KjF+MNOXgl/SquIEySX3GhaZvc67KZbDxcCDORz2N8yCWPaY5lyQZO7lQ29fnZbt3Xu6qoge4+DjXl/MocySPOp9rlvdyznahRyHEYd77v3LhugOXDv4J65QXfl803BDAdaWBEDhfVx7nKofjoVCgxnUAqw/UAUDPn788BDvQuG4TDtdtUPvzjSlXAB8DvaDOhhrmhwbywylXAm8CvaouikJTL93gs3y7Yy4VYbIxOHrcMizPqWOjqO9l3Uz52kibQy4xxOgqhJvD+w5rvokOcAlGvNCfeqCv1ste1stzLm0f71Iq3ZfTrPfuE5nhPtF+LvQE2lffQC7pYtQy3tdzdrKvd5TLVVzDetScS3nEKmmwDyt1Cev1kX3YfbvzNK4fzrlw+cB6vm+uiUgf2zdXI62241LawCb7Pi5FXFPF8KpzDoF/Sw2lg+GrHNbno1mhPu+VCF/vfMnw06PnUl6j48dVHD3jHNHPua+fc3o/5yp/zsGi0vYtzi3Pz5mHd4T6BWMIlewacd63AAAAAElFTkSuQmCC',
71
+ data: 'iVBORw0KGgoAAAANSUhEUgAAANcAAAA4CAMAAABZsZ3QAAAAM1BMVEX29fK42OU+oMvn7u9drtIPisHI4OhstdWZyt4fkcXX5+sAg74umMhNp86p0eJ7vNiKw9v/UV4wAAAAAXRSTlMAQObYZgAABBxJREFUeF7tmuty4yAMhZG4X2zn/Z92J5tsBJwWXG/i3XR6frW2Y/SBLIRAfaQUDNt8E5tLUt9BycfcKfq3R6Mlfyimtx4rzp+K3dtibXkor99zsEqLYZltblTecciogoh+TXfY1Ve4dn07rCDGG9dHSEEOg/GmXl0U1XDxTKxNK5De7BxsyyBr6gGm2/vPxKJ8F6f7BXKfRMp1xIWK9A+5ks25alSb353dWnDJN1k35EL5f8dVGifTf/4tjUuuFq7u4srmXC60yAmldLXIWbg65RKU87lcGxJCFqUPv0IacW0PmSivOZFLE908inPToMmii/roG+MRV/O8FU88i8tFsxV3a06MFUw0Qu7RmAtdV5/HVVaOVMTWNOWSwMljLhzhcB6XIS7OK5V6AvRDNN7t5VJWQs1J40UmalbK56usBG/CuCHSYuc+rkUGeMCViNRARPrzW52N3oQLe6WifNliSuuGaH3czbVNudI9s7ZLUCLHVwWlyES522o1t14uvmbblmVTKqFjaZYJFSTPP4dLL1kU1z7p0lzdbRulmEWLxoQX+z9ce7A8GqEEucllLxePuZwdJl1Lezu0hoswvTPt61DrFcRuujV/2cmlxaGBC7Aw6cpovGANwRiSdOAWJ5AGy4gLL64dl0QhUEAuEUNws+XxV+OKGPdw/hESGYF9XEGaFC7sNLMSXWJjHsnanYi87VK428N2uxpOjOFANcagLM5l+7mSycM8KknZpKLcGi6jmzWGr/vLurZ/0g4u9AZuAoeb5r1ceQhyiTPY1E4wUR6u/F3H2ojSpXMMriBPT9cezTto8Cx+MsglHL4fv1Rxrb1LVw9yvyQpJ3AhFnLZfuRLH2QsOG3FGGD20X/th/u5bFAt16Bt308KjF+MNOXgl/SquIEySX3GhaZvc67KZbDxcCDORz2N8yCWPaY5lyQZO7lQ29fnZbt3Xu6qoge4+DjXl/MocySPOp9rlvdyznahRyHEYd77v3LhugOXDv4J65QXfl803BDAdaWBEDhfVx7nKofjoVCgxnUAqw/UAUDPn788BDvQuG4TDtdtUPvzjSlXAB8DvaDOhhrmhwbywylXAm8CvaouikJTL93gs3y7Yy4VYbIxOHrcMizPqWOjqO9l3Uz52kibQy4xxOgqhJvD+w5rvokOcAlGvNCfeqCv1ste1stzLm0f71Iq3ZfTrPfuE5nhPtF+LvQE2lffQC7pYtQy3tdzdrKvd5TLVVzDetScS3nEKmmwDyt1Cev1kX3YfbvzNK4fzrlw+cB6vm+uiUgf2zdXI62241LawCb7Pi5FXFPF8KpzDoF/Sw2lg+GrHNbno1mhPu+VCF/vfMnw06PnUl6j48dVHD3jHNHPua+fc3o/5yp/zsGi0vYtzi3Pz5mHd4T6BWMIlewacd63AAAAAElFTkSuQmCC',
73
72
  encoding: 'base64',
74
73
  filename: 'image.png',
75
74
  'content-type': 'image/png',
@@ -409,10 +408,6 @@ Cypress.Commands.add('toolbarSave', () => {
409
408
 
410
409
  // Save
411
410
  cy.get('#toolbar-save').click();
412
- cy.waitForResourceToLoad('@navigation');
413
- cy.waitForResourceToLoad('@breadcrumbs');
414
- cy.waitForResourceToLoad('@actions');
415
- cy.waitForResourceToLoad('@types');
416
411
  cy.waitForResourceToLoad('my-page');
417
412
  cy.url().should('eq', Cypress.config().baseUrl + '/cypress/my-page');
418
413
  });
@@ -35,10 +35,6 @@ export const slateBeforeEach = (contentType = 'Document') => {
35
35
  path: 'cypress',
36
36
  });
37
37
  cy.visit('/cypress/my-page');
38
- cy.waitForResourceToLoad('@navigation');
39
- cy.waitForResourceToLoad('@breadcrumbs');
40
- cy.waitForResourceToLoad('@actions');
41
- cy.waitForResourceToLoad('@types');
42
38
  cy.waitForResourceToLoad('my-page');
43
39
  cy.navigate('/cypress/my-page/edit');
44
40
  };
package/cypress.config.js CHANGED
@@ -2,12 +2,12 @@ const { defineConfig } = require('cypress');
2
2
 
3
3
  module.exports = defineConfig({
4
4
  viewportWidth: 1280,
5
- defaultCommandTimeout: 5000,
5
+ defaultCommandTimeout: 8888,
6
6
  chromeWebSecurity: false,
7
7
  reporter: 'junit',
8
- video: true,
8
+ video: false,
9
9
  retries: {
10
- runMode: 1,
10
+ runMode: 2,
11
11
  openMode: 0,
12
12
  },
13
13
  reporterOptions: {
@@ -1,3 +1,5 @@
1
+ require('dotenv').config({ path: __dirname + '/.env' })
2
+
1
3
  module.exports = {
2
4
  testMatch: ['**/src/addons/**/?(*.)+(spec|test).[jt]s?(x)'],
3
5
  collectCoverageFrom: [
@@ -9,18 +11,26 @@ module.exports = {
9
11
  '@plone/volto/cypress': '<rootDir>/node_modules/@plone/volto/cypress',
10
12
  '@plone/volto/babel': '<rootDir>/node_modules/@plone/volto/babel',
11
13
  '@plone/volto/(.*)$': '<rootDir>/node_modules/@plone/volto/src/$1',
12
- '@package/(.*)$': '<rootDir>/src/$1',
13
- '@root/(.*)$': '<rootDir>/src/$1',
14
+ '@package/(.*)$': '<rootDir>/node_modules/@plone/volto/src/$1',
15
+ '@root/(.*)$': '<rootDir>/node_modules/@plone/volto/src/$1',
14
16
  '@plone/volto-quanta/(.*)$': '<rootDir>/src/addons/volto-quanta/src/$1',
17
+ '@eeacms/search/(.*)$': '<rootDir>/src/addons/volto-searchlib/searchlib/$1',
18
+ '@eeacms/search': '<rootDir>/src/addons/volto-searchlib/searchlib',
15
19
  '@eeacms/(.*?)/(.*)$': '<rootDir>/node_modules/@eeacms/$1/src/$2',
16
- '@plone/volto-slate':
20
+ '@plone/volto-slate$':
17
21
  '<rootDir>/node_modules/@plone/volto/packages/volto-slate/src',
22
+ '@plone/volto-slate/(.*)$':
23
+ '<rootDir>/node_modules/@plone/volto/packages/volto-slate/src/$1',
18
24
  '~/(.*)$': '<rootDir>/src/$1',
19
25
  'load-volto-addons':
20
26
  '<rootDir>/node_modules/@plone/volto/jest-addons-loader.js',
21
27
  },
28
+ transformIgnorePatterns: [
29
+ '/node_modules/(?!(@plone|@root|@package|@eeacms)/).*/',
30
+ ],
22
31
  transform: {
23
32
  '^.+\\.js(x)?$': 'babel-jest',
33
+ '^.+\\.ts(x)?$': 'babel-jest',
24
34
  '^.+\\.(png)$': 'jest-file',
25
35
  '^.+\\.(jpg)$': 'jest-file',
26
36
  '^.+\\.(svg)$': './node_modules/@plone/volto/jest-svgsystem-transform.js',
@@ -33,4 +43,9 @@ module.exports = {
33
43
  statements: 5,
34
44
  },
35
45
  },
36
- };
46
+ ...(process.env.JEST_USE_SETUP === 'ON' && {
47
+ setupFilesAfterEnv: [
48
+ '<rootDir>/node_modules/@eeacms/volto-slate-metadata-mentions/jest.setup.js',
49
+ ],
50
+ }),
51
+ }
package/jest.setup.js ADDED
@@ -0,0 +1,65 @@
1
+ import { jest } from '@jest/globals';
2
+ import configureStore from 'redux-mock-store';
3
+ import thunk from 'redux-thunk';
4
+ import { blocksConfig } from '@plone/volto/config/Blocks';
5
+ import installSlate from '@plone/volto-slate/index';
6
+
7
+ var mockSemanticComponents = jest.requireActual('semantic-ui-react');
8
+ var mockComponents = jest.requireActual('@plone/volto/components');
9
+ var config = jest.requireActual('@plone/volto/registry').default;
10
+
11
+ config.blocks.blocksConfig = {
12
+ ...blocksConfig,
13
+ ...config.blocks.blocksConfig,
14
+ };
15
+
16
+ jest.doMock('semantic-ui-react', () => ({
17
+ __esModule: true,
18
+ ...mockSemanticComponents,
19
+ Popup: ({ content, trigger }) => {
20
+ return (
21
+ <div className="popup">
22
+ <div className="trigger">{trigger}</div>
23
+ <div className="content">{content}</div>
24
+ </div>
25
+ );
26
+ },
27
+ }));
28
+
29
+ jest.doMock('@plone/volto/components', () => {
30
+ return {
31
+ __esModule: true,
32
+ ...mockComponents,
33
+ SidebarPortal: ({ children }) => <div id="sidebar">{children}</div>,
34
+ };
35
+ });
36
+
37
+ jest.doMock('@plone/volto/registry', () =>
38
+ [installSlate].reduce((acc, apply) => apply(acc), config),
39
+ );
40
+
41
+ const mockStore = configureStore([thunk]);
42
+
43
+ global.fetch = jest.fn(() =>
44
+ Promise.resolve({
45
+ json: () => Promise.resolve({}),
46
+ }),
47
+ );
48
+
49
+ global.store = mockStore({
50
+ intl: {
51
+ locale: 'en',
52
+ messages: {},
53
+ formatMessage: jest.fn(),
54
+ },
55
+ content: {
56
+ create: {},
57
+ subrequests: [],
58
+ },
59
+ connected_data_parameters: {},
60
+ screen: {
61
+ page: {
62
+ width: 768,
63
+ },
64
+ },
65
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-slate-metadata-mentions",
3
- "version": "7.0.2",
3
+ "version": "8.0.0",
4
4
  "description": "Volto Slate Metadata Mentions Plugin",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -22,6 +22,7 @@
22
22
  "@cypress/code-coverage": "^3.10.0",
23
23
  "@plone/scripts": "*",
24
24
  "babel-plugin-transform-class-properties": "^6.24.1",
25
+ "dotenv": "^16.3.2",
25
26
  "husky": "^8.0.3",
26
27
  "lint-staged": "^14.0.1",
27
28
  "md5": "^2.3.0"
@@ -10,7 +10,7 @@ import { setPluginOptions } from '@plone/volto-slate/actions';
10
10
  import { MentionSchema } from './schema';
11
11
  import { getMentionWidget } from './utils';
12
12
 
13
- export default (props) => {
13
+ const MentionEditor = (props) => {
14
14
  const {
15
15
  editor,
16
16
  pluginId,
@@ -193,3 +193,5 @@ export default (props) => {
193
193
  />
194
194
  );
195
195
  };
196
+
197
+ export default MentionEditor;
@@ -4,7 +4,7 @@ export const withMention = (editor) => {
4
4
  const { isInline } = editor;
5
5
 
6
6
  editor.isInline = (element) => {
7
- return element.type === MENTION ? true : isInline(element);
7
+ return element && element.type === MENTION ? true : isInline(element);
8
8
  };
9
9
 
10
10
  return editor;
@@ -40,7 +40,7 @@ const btnFactory = (options) => (props) => (
40
40
  <ToolbarButton {...props} {...options} title="Metadata" />
41
41
  );
42
42
 
43
- export default (config) => {
43
+ const createMentionsPlugin = (config) => {
44
44
  const opts = {
45
45
  title: 'Metadata',
46
46
  pluginId: MENTION,
@@ -54,9 +54,8 @@ export default (config) => {
54
54
  toolbarButtonIcon: mentionsSVG,
55
55
  messages,
56
56
  };
57
- const [installMentionsEditor, , , pluginOptions] = makeInlineElementPlugin(
58
- opts,
59
- );
57
+ const [installMentionsEditor, , , pluginOptions] =
58
+ makeInlineElementPlugin(opts);
60
59
  config = installMentionsEditor(config);
61
60
 
62
61
  const { slate } = config.settings;
@@ -71,3 +70,5 @@ export default (config) => {
71
70
 
72
71
  return config;
73
72
  };
73
+
74
+ export default createMentionsPlugin;
@@ -1,48 +0,0 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
-
4
- const projectRootPath = fs.existsSync('./project')
5
- ? fs.realpathSync('./project')
6
- : fs.realpathSync('./../../../');
7
- const packageJson = require(path.join(projectRootPath, 'package.json'));
8
- const jsConfig = require(path.join(projectRootPath, 'jsconfig.json')).compilerOptions;
9
-
10
- const pathsConfig = jsConfig.paths;
11
-
12
- let voltoPath = path.join(projectRootPath, 'node_modules/@plone/volto');
13
-
14
- Object.keys(pathsConfig).forEach(pkg => {
15
- if (pkg === '@plone/volto') {
16
- voltoPath = `./${jsConfig.baseUrl}/${pathsConfig[pkg][0]}`;
17
- }
18
- });
19
- const AddonConfigurationRegistry = require(`${voltoPath}/addon-registry.js`);
20
- const reg = new AddonConfigurationRegistry(projectRootPath);
21
-
22
- // Extends ESlint configuration for adding the aliases to `src` directories in Volto addons
23
- const addonAliases = Object.keys(reg.packages).map(o => [
24
- o,
25
- reg.packages[o].modulePath,
26
- ]);
27
-
28
-
29
- module.exports = {
30
- extends: `${projectRootPath}/node_modules/@plone/volto/.eslintrc`,
31
- settings: {
32
- 'import/resolver': {
33
- alias: {
34
- map: [
35
- ['@plone/volto', '@plone/volto/src'],
36
- ...addonAliases,
37
- ['@package', `${__dirname}/src`],
38
- ['~', `${__dirname}/src`],
39
- ],
40
- extensions: ['.js', '.jsx', '.json'],
41
- },
42
- 'babel-plugin-root-import': {
43
- rootPathSuffix: 'src',
44
- },
45
- },
46
- },
47
- };
48
-