diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 0000000..9183f9d --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,2 @@ +[ -n "$CI" ] && exit 0 +yarn lint-staged diff --git a/.i18n.babel.config.js b/.i18n.babel.config.js deleted file mode 100644 index a900a75..0000000 --- a/.i18n.babel.config.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('@plone/volto/babel'); diff --git a/CHANGELOG.md b/CHANGELOG.md index 663f345..e08d9bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,36 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +### [2.0.16](https://github.com/eea/volto-industry-theme/compare/2.0.15...2.0.16) - 4 October 2024 + +#### :bug: Bug Fixes + +- fix: sonarqube bug [Claudia Ifrim - [`c1cba78`](https://github.com/eea/volto-industry-theme/commit/c1cba784cb38378ab8e29f5aa38ea030c4100f19)] +- fix: sonarqube bugs [Claudia Ifrim - [`d94c6c7`](https://github.com/eea/volto-industry-theme/commit/d94c6c79367238db5efaf3a9fc0952a1c84a64ef)] + +#### :house: Internal changes + +- style: Automated code fix [eea-jenkins - [`1600588`](https://github.com/eea/volto-industry-theme/commit/16005880c0fc9e2c6afb9c357fed58986ace13e5)] +- chore: [JENKINS] Refactor automated testing [valentinab25 - [`86174da`](https://github.com/eea/volto-industry-theme/commit/86174da55a5e16ca991f259cf2b7030ceff45e36)] +- chore: husky, lint-staged use fixed versions [valentinab25 - [`18ebada`](https://github.com/eea/volto-industry-theme/commit/18ebada4ff42df96ad4f9a6166e83c2128f5d389)] +- chore:volto 16 in tests, update docs, fix stylelint overrides [valentinab25 - [`33fbe24`](https://github.com/eea/volto-industry-theme/commit/33fbe248ba43e5579b9978c196cbdafdbb1e1b92)] + +#### :house: Documentation changes + +- docs: Cleanup Makefile, update DEVELOP documentation, i18n - refs #254894 [valentinab25 - [`3e78401`](https://github.com/eea/volto-industry-theme/commit/3e78401dc2466c803c095e35a7794ac91233b0bf)] + +#### :hammer_and_wrench: Others + +- remove cypress tests [Claudia Ifrim - [`88ff9bd`](https://github.com/eea/volto-industry-theme/commit/88ff9bdd6c41cd4a04c1fede01c45aef787b6e74)] +- update logo and color scheme [Claudia Ifrim - [`26c9173`](https://github.com/eea/volto-industry-theme/commit/26c9173b1ab8d168a17c57839a515119b4e82849)] +- reorder packages [Claudia Ifrim - [`d3b698c`](https://github.com/eea/volto-industry-theme/commit/d3b698c311d232797ecf57efbc767d8b5aa1bdaa)] +- test: [JENKINS] Use java17 for sonarqube scanner [valentinab25 - [`78e172f`](https://github.com/eea/volto-industry-theme/commit/78e172fce2dba466cac2dfeb00818f6b7ced6150)] +- test: [JENKINS] Run cypress in started frontend container [valentinab25 - [`f098c38`](https://github.com/eea/volto-industry-theme/commit/f098c383138e03c10af323d298aed3a2895c9ae0)] +- test: [JENKINS] Add cpu limit on cypress docker [valentinab25 - [`177cbfc`](https://github.com/eea/volto-industry-theme/commit/177cbfc6965d7a8ad2d7f93a268e060dd4f9f11b)] +- test: [JENKINS] Increase shm-size to cypress docker [valentinab25 - [`808e709`](https://github.com/eea/volto-industry-theme/commit/808e70902da7c8bcb30861c776f968ea5baaabe7)] +- test: [JENKINS] Improve cypress time [valentinab25 - [`9d065e9`](https://github.com/eea/volto-industry-theme/commit/9d065e988c2846a24902d90dd26e0e0157cf5b13)] +- test: EN locales, pre-commit fix, feature PRs checks Refs #257193 [valentinab25 - [`ab9367f`](https://github.com/eea/volto-industry-theme/commit/ab9367f5029ade7a35170ff7a77314865020400a)] +- test: Update Makefile and docker-compose to align it with Jenkinsfile [valentinab25 - [`d279712`](https://github.com/eea/volto-industry-theme/commit/d2797120706691d0453ce5cf60dd7503b9092715)] ### [2.0.15](https://github.com/eea/volto-industry-theme/compare/2.0.14...2.0.15) - 4 July 2023 #### :house: Internal changes diff --git a/DEVELOP.md b/DEVELOP.md index 19904d1..359ffc4 100644 --- a/DEVELOP.md +++ b/DEVELOP.md @@ -2,6 +2,30 @@ ## Develop +1. Make sure you have `docker` and `docker compose` installed and running on your machine: + + ```Bash + git clone https://github.com/eea/volto-industry-theme.git + cd volto-industry-theme + git checkout -b bugfix-123456 develop + make + make start + ``` + +1. Wait for `Volto started at 0.0.0.0:3000` meesage + +1. Go to http://localhost:3000 + +1. Initialize git hooks + + ```Bash + yarn prepare + ``` + +1. Happy hacking! + +### Or add @eeacms/volto-industry-theme to your Volto project + Before starting make sure your development environment is properly set. See [Volto Developer Documentation](https://docs.voltocms.com/getting-started/install/) 1. Make sure you have installed `yo`, `@plone/generator-volto` and `mrs-developer` @@ -26,18 +50,15 @@ Before starting make sure your development environment is properly set. See [Vol 1. Install - yarn develop + make develop yarn 1. Start backend - docker pull plone - docker run -d --name plone -p 8080:8080 -e SITE=Plone -e PROFILES="profile-plone.restapi:blocks" plone + docker run --pull always -it --rm --name plone -p 8080:8080 -e SITE=Plone plone/plone-backend ...wait for backend to setup and start - `Ready to handle requests`: - docker logs -f plone - ...you can also check http://localhost:8080/Plone 1. Start frontend @@ -49,3 +70,37 @@ Before starting make sure your development environment is properly set. See [Vol 1. Happy hacking! cd src/addons/volto-industry-theme/ + +## Cypress + +To run cypress locally, first make sure you don't have any Volto/Plone running on ports `8080` and `3000`. + +You don't have to be in a `clean-volto-project`, you can be in any Volto Frontend +project where you added `volto-industry-theme` to `mrs.developer.json` + +Go to: + + ```BASH + cd src/addons/volto-industry-theme/ + ``` + +Start: + + ```Bash + make + make start + ``` + +This will build and start with Docker a clean `Plone backend` and `Volto Frontend` with `volto-industry-theme` block installed. + +Open Cypress Interface: + + ```Bash + make cypress-open + ``` + +Or run it: + + ```Bash + make cypress-run + ``` diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b1ce603 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +# syntax=docker/dockerfile:1 +ARG VOLTO_VERSION +FROM eeacms/frontend-builder:${VOLTO_VERSION} + +ARG ADDON_NAME +ARG ADDON_PATH + +COPY --chown=node:node ./ /app/src/addons/${ADDON_PATH}/ + +RUN /setupAddon +RUN yarn install + +ENTRYPOINT ["yarn"] +CMD ["start"] diff --git a/Jenkinsfile b/Jenkinsfile index dd6dbae..0efaafb 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,16 +1,23 @@ pipeline { - agent any + tools { + jdk 'Java17' + } + agent { + node { label 'docker-host' } + } environment { - GIT_NAME = "volto-industry-theme" - NAMESPACE = "@eeacms" - SONARQUBE_TAGS = "volto.eea.europa.eu,industry.eea.europa.eu" - DEPENDENCIES = "" - VOLTO = "" - } + GIT_NAME = "volto-industry-theme" + NAMESPACE = "@eeacms" + SONARQUBE_TAGS = "volto.eea.europa.eu,industry.eea.europa.eu" + DEPENDENCIES = "" + BACKEND_PROFILES = "eea.kitkat:testing" + BACKEND_ADDONS = "" + VOLTO = "16" + IMAGE_NAME = BUILD_TAG.toLowerCase() + } stages { - stage('Release') { when { allOf { @@ -20,73 +27,118 @@ pipeline { } steps { node(label: 'docker') { - withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN'),string(credentialsId: 'eea-jenkins-npm-token', variable: 'NPM_TOKEN')]) { - sh '''docker pull eeacms/gitflow''' - 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''' + withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN'), string(credentialsId: 'eea-jenkins-npm-token', variable: 'NPM_TOKEN')]) { + 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''' } } } } - stage('Code') { + stage('Check if testing needed') { when { allOf { - environment name: 'CHANGE_ID', value: '' - not { changelog '.*^Automated release [0-9\\.]+$' } not { branch 'master' } + not { branch 'develop' } + environment name: 'CHANGE_ID', value: '' } } steps { - parallel( + script { + withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN')]) { + 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 - "ES lint": { - node(label: 'docker') { - sh '''docker pull plone/volto-addon-ci; 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''' + if (check_result == 0) { + env.SKIP_TESTS = 'yes' + } } - }, + } + } + } - "Style lint": { - node(label: 'docker') { - sh '''docker pull plone/volto-addon-ci; 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''' + stage('Testing') { + when { + anyOf { + allOf { + not { environment name: 'CHANGE_ID', value: '' } + environment name: 'CHANGE_TARGET', value: 'develop' + environment name: 'SKIP_TESTS', value: '' + } + allOf { + environment name: 'CHANGE_ID', value: '' + anyOf { + not { changelog '.*^Automated release [0-9\\.]+$' } + branch 'master' } - }, + environment name: 'SKIP_TESTS', value: '' + } + } + } + stages { + stage('Build test image') { + steps { + checkout scm + 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''' + } + } + + stage('Fix code') { + when { + environment name: 'CHANGE_ID', value: '' + not { branch 'master' } + } + steps { + script { + 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) + sh '''docker cp $IMAGE_NAME-fix:/app/src/addons/$GIT_NAME/src .''' + sh '''docker rm -v $IMAGE_NAME-fix''' + FOUND_FIX = sh(script: '''git diff | wc -l''', returnStdout: true).trim() - "Prettier": { - node(label: 'docker') { - sh '''docker pull plone/volto-addon-ci; 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''' + if (FOUND_FIX != '0') { + withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN')]) { + sh '''sed -i "s|url = .*|url = https://eea-jenkins:$GITHUB_TOKEN@github.com/eea/$GIT_NAME.git|" .git/config''' + } + sh '''git fetch origin $GIT_BRANCH:$GIT_BRANCH''' + sh '''git checkout $GIT_BRANCH''' + sh '''git add src/''' + sh '''git commit -m "style: Automated code fix" ''' + sh '''git push --set-upstream origin $GIT_BRANCH''' + sh '''exit 1''' + } } } - ) - } - } + } - stage('Tests') { - when { - allOf { - environment name: 'CHANGE_ID', value: '' - anyOf { - not { changelog '.*^Automated release [0-9\\.]+$' } - branch 'master' + stage('ES lint') { + steps { + sh '''docker run --rm --name="$IMAGE_NAME-eslint" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend lint''' } } - } - steps { - parallel( - - "Volto": { - node(label: 'docker') { - script { - try { - sh '''docker pull plone/volto-addon-ci''' - 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''' - sh '''rm -rf xunit-reports''' - sh '''mkdir -p xunit-reports''' - sh '''docker cp $BUILD_TAG-volto:/opt/frontend/my-volto-project/coverage xunit-reports/''' - sh '''docker cp $BUILD_TAG-volto:/opt/frontend/my-volto-project/junit.xml xunit-reports/''' - sh '''docker cp $BUILD_TAG-volto:/opt/frontend/my-volto-project/unit_tests_log.txt xunit-reports/''' - stash name: "xunit-reports", includes: "xunit-reports/**" - archiveArtifacts artifacts: "xunit-reports/unit_tests_log.txt", fingerprint: true - publishHTML (target : [ + + stage('Style lint') { + steps { + sh '''docker run --rm --name="$IMAGE_NAME-stylelint" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend stylelint''' + } + } + + stage('Prettier') { + steps { + sh '''docker run --rm --name="$IMAGE_NAME-prettier" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend prettier''' + } + } + + stage('Coverage Tests') { + parallel { + + stage('Unit tests') { + steps { + script { + try { + sh '''docker run --name="$IMAGE_NAME-volto" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend test-ci''' + sh '''rm -rf xunit-reports''' + sh '''mkdir -p xunit-reports''' + sh '''docker cp $IMAGE_NAME-volto:/app/coverage xunit-reports/''' + sh '''docker cp $IMAGE_NAME-volto:/app/junit.xml xunit-reports/''' + publishHTML(target : [ allowMissing: false, alwaysLinkToLastBuild: true, keepAll: true, @@ -99,100 +151,128 @@ pipeline { catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') { junit testResults: 'xunit-reports/junit.xml', allowEmptyResults: true } - sh script: '''docker rm -v $BUILD_TAG-volto''', returnStatus: true + sh script: '''docker rm -v $IMAGE_NAME-volto''', returnStatus: true + } } } } + + // stage('Integration tests') { + // steps { + // script { + // try { + // 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''' + // sh '''docker run -d --shm-size=3g --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''' + // sh '''timeout -s 9 1800 docker exec --workdir=/app/src/addons/${GIT_NAME} $IMAGE_NAME-cypress make cypress-ci''' + // } finally { + // try { + // sh '''rm -rf cypress-videos cypress-results cypress-coverage cypress-screenshots''' + // sh '''mkdir -p cypress-videos cypress-results cypress-coverage cypress-screenshots''' + // videos = sh script: '''docker cp $IMAGE_NAME-cypress:/app/src/addons/$GIT_NAME/cypress/videos cypress-videos/''', returnStatus: true + // sh '''docker cp $IMAGE_NAME-cypress:/app/src/addons/$GIT_NAME/cypress/reports cypress-results/''' + // screenshots = sh script: '''docker cp $IMAGE_NAME-cypress:/app/src/addons/$GIT_NAME/cypress/screenshots cypress-screenshots''', returnStatus: true + + // archiveArtifacts artifacts: 'cypress-screenshots/**', fingerprint: true, allowEmptyArchive: true + + // coverage = sh script: '''docker cp $IMAGE_NAME-cypress:/app/src/addons/$GIT_NAME/coverage cypress-coverage''', returnStatus: true + + // if ( coverage == 0 ) { + // publishHTML(target : [allowMissing: false, + // alwaysLinkToLastBuild: true, + // keepAll: true, + // reportDir: 'cypress-coverage/coverage/lcov-report', + // reportFiles: 'index.html', + // reportName: 'CypressCoverage', + // reportTitles: 'Integration Tests Code Coverage']) + // } + // if ( videos == 0 ) { + // 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''' + // archiveArtifacts artifacts: 'cypress-videos/**/*.mp4', fingerprint: true, allowEmptyArchive: true + // } + // } finally { + // catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') { + // junit testResults: 'cypress-results/**/*.xml', allowEmptyResults: true + // } + // catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') { + // sh '''docker logs $IMAGE_NAME-cypress''' + // } + // sh script: "docker stop $IMAGE_NAME-cypress", returnStatus: true + // sh script: "docker stop $IMAGE_NAME-plone", returnStatus: true + // sh script: "docker rm -v $IMAGE_NAME-plone", returnStatus: true + // sh script: "docker rm -v $IMAGE_NAME-cypress", returnStatus: true + // } + // } + // } + // } + // } } - ) + } + } + post { + always { + sh script: "docker rmi $IMAGE_NAME-frontend", returnStatus: true + } } } - stage('Integration tests') { + stage('Report to SonarQube') { when { - allOf { - environment name: 'CHANGE_ID', value: '' - anyOf { - not { changelog '.*^Automated release [0-9\\.]+$' } - branch 'master' + anyOf { + allOf { + not { environment name: 'CHANGE_ID', value: '' } + environment name: 'CHANGE_TARGET', value: 'develop' + } + allOf { + environment name: 'CHANGE_ID', value: '' + anyOf { + allOf { + branch 'develop' + not { changelog '.*^Automated release [0-9\\.]+$' } + } + branch 'master' + } } } } steps { - parallel( - - "Cypress": { - node(label: 'docker') { - script { - try { - 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''' - 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''' - } finally { - try { - sh '''rm -rf cypress-reports cypress-results cypress-coverage''' - sh '''mkdir -p cypress-reports cypress-results cypress-coverage''' - sh '''docker cp $BUILD_TAG-cypress:/opt/frontend/my-volto-project/src/addons/$GIT_NAME/cypress/videos cypress-reports/''' - sh '''docker cp $BUILD_TAG-cypress:/opt/frontend/my-volto-project/src/addons/$GIT_NAME/cypress/reports cypress-results/''' - coverage = sh script: '''docker cp $BUILD_TAG-cypress:/opt/frontend/my-volto-project/src/addons/$GIT_NAME/coverage cypress-coverage/''', returnStatus: true - if ( coverage == 0 ) { - publishHTML (target : [allowMissing: false, - alwaysLinkToLastBuild: true, - keepAll: true, - reportDir: 'cypress-coverage/coverage/lcov-report', - reportFiles: 'index.html', - reportName: 'CypressCoverage', - reportTitles: 'Integration Tests Code Coverage']) - } - 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''' - archiveArtifacts artifacts: 'cypress-reports/**/*.mp4', fingerprint: true, allowEmptyArchive: true - stash name: "cypress-coverage", includes: "cypress-coverage/**", allowEmpty: true - } - finally { - catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') { - junit testResults: 'cypress-results/**/*.xml', allowEmptyResults: true - } - sh script: "docker stop $BUILD_TAG-plone", returnStatus: true - sh script: "docker rm -v $BUILD_TAG-plone", returnStatus: true - sh script: "docker rm -v $BUILD_TAG-cypress", returnStatus: true - - } - } - } - } + script { + def scannerHome = tool 'SonarQubeScanner' + def nodeJS = tool 'NodeJS' + withSonarQubeEnv('Sonarqube') { + sh '''sed -i "s#/app/src/addons/${GIT_NAME}/##g" xunit-reports/coverage/lcov.info''' + sh '''sed -i "s#src/addons/${GIT_NAME}/##g" xunit-reports/coverage/lcov.info''' + // 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" + sh "export PATH=${scannerHome}/bin:${nodeJS}/bin:$PATH; sonar-scanner -Dsonar.javascript.lcov.reportPaths=./xunit-reports/coverage/lcov.info -Dsonar.sources=./src -Dsonar.projectKey=$GIT_NAME-$BRANCH_NAME -Dsonar.projectVersion=$BRANCH_NAME-$BUILD_NUMBER" + 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''' } - - ) + } } } - stage('Report to SonarQube') { + stage('SonarQube compare to master') { when { - allOf { - environment name: 'CHANGE_ID', value: '' - anyOf { - branch 'master' - allOf { - branch 'develop' - not { changelog '.*^Automated release [0-9\\.]+$' } - } + anyOf { + allOf { + not { environment name: 'CHANGE_ID', value: '' } + environment name: 'CHANGE_TARGET', value: 'develop' + } + allOf { + environment name: 'CHANGE_ID', value: '' + branch 'develop' + not { changelog '.*^Automated release [0-9\\.]+$' } } } } steps { - node(label: 'swarm') { - script{ - checkout scm - unstash "xunit-reports" - unstash "cypress-coverage" - def scannerHome = tool 'SonarQubeScanner'; - def nodeJS = tool 'NodeJS'; - withSonarQubeEnv('Sonarqube') { - sh '''sed -i "s#/opt/frontend/my-volto-project/src/addons/${GIT_NAME}/##g" xunit-reports/coverage/lcov.info''' - sh '''sed -i "s#src/addons/${GIT_NAME}/##g" xunit-reports/coverage/lcov.info''' - 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" - 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''' - } + script { + sh '''echo "Error" > checkresult.txt''' + catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { + 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''' } + + 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', + text: readFile(file: 'checkresult.txt'), conclusion: "${currentBuild.currentResult}", + detailsURL: "${env.BUILD_URL}display/redirect" } } } @@ -205,20 +285,16 @@ pipeline { environment name: 'CHANGE_TARGET', value: 'master' } steps { - node(label: 'docker') { - script { - if ( env.CHANGE_BRANCH != "develop" ) { - error "Pipeline aborted due to PR not made from develop branch" - } - withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN')]) { - sh '''docker pull eeacms/gitflow''' - 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''' - } + script { + if (env.CHANGE_BRANCH != 'develop') { + error 'Pipeline aborted due to PR not made from develop branch' + } + withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN')]) { + 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''' } } } } - } post { diff --git a/Makefile b/Makefile index aeb0f30..efbf2fb 100644 --- a/Makefile +++ b/Makefile @@ -1,54 +1,100 @@ -SHELL=/bin/bash +############################################################################## +# Run: +# make +# make start +# +# Go to: +# +# http://localhost:3000 +# +# Cypress: +# +# make cypress-open +# +############################################################################## +# SETUP MAKE +# +## Defensive settings for make: https://tech.davis-hansson.com/p/make/ +SHELL:=bash +.ONESHELL: +# for Makefile debugging purposes add -x to the .SHELLFLAGS +.SHELLFLAGS:=-eu -o pipefail -O inherit_errexit -c +.SILENT: +.DELETE_ON_ERROR: +MAKEFLAGS+=--warn-undefined-variables +MAKEFLAGS+=--no-builtin-rules + +# Colors +# OK=Green, warn=yellow, error=red +ifeq ($(TERM),) +# no colors if not in terminal + MARK_COLOR= + OK_COLOR= + WARN_COLOR= + ERROR_COLOR= + NO_COLOR= +else + MARK_COLOR=`tput setaf 6` + OK_COLOR=`tput setaf 2` + WARN_COLOR=`tput setaf 3` + ERROR_COLOR=`tput setaf 1` + NO_COLOR=`tput sgr0` +endif +############################################################################## +# SETTINGS AND VARIABLE DIR=$(shell basename $$(pwd)) -ADDON ?= "@eeacms/volto-industry-theme" +NODE_MODULES?="../../../node_modules" +PLONE_VERSION?=6 +VOLTO_VERSION?=16 +ADDON_PATH="${DIR}" +ADDON_NAME="@eeacms/${ADDON_PATH}" +DOCKER_COMPOSE=PLONE_VERSION=${PLONE_VERSION} VOLTO_VERSION=${VOLTO_VERSION} ADDON_NAME=${ADDON_NAME} ADDON_PATH=${ADDON_PATH} docker compose +RAZZLE_INTERNAL_API_PATH?="http://localhost:8080/Plone" +RAZZLE_DEV_PROXY_API_PATH?="${RAZZLE_INTERNAL_API_PATH}" +CYPRESS_API_PATH="${RAZZLE_DEV_PROXY_API_PATH}" + + + +# Top-level targets +.PHONY: all +all: clean install + +.PHONY: clean +clean: ## Cleanup development environment + ${DOCKER_COMPOSE} down --volumes --remove-orphans + +.PHONY: install +install: ## Build and install development environment + echo "Running: ${DOCKER_COMPOSE} build" + ${DOCKER_COMPOSE} pull + ${DOCKER_COMPOSE} build + +.PHONY: start +start: ## Start development environment + echo "Running: ${DOCKER_COMPOSE} up" + ${DOCKER_COMPOSE} up + +.PHONY: shell +shell: ## Start a shell in the frontend container + echo "Running: ${DOCKER_COMPOSE} run frontend bash" + ${DOCKER_COMPOSE} run --entrypoint=bash frontend -# We like colors -# From: https://coderwall.com/p/izxssa/colored-makefile-for-golang-projects -RED=`tput setaf 1` -GREEN=`tput setaf 2` -RESET=`tput sgr0` -YELLOW=`tput setaf 3` - -ifeq ($(wildcard ./project),) - NODE_MODULES = "../../../node_modules" -else - NODE_MODULES = "./project/node_modules" -endif +.PHONY: cypress-open +cypress-open: ## Open cypress integration tests + CYPRESS_API_PATH="${RAZZLE_DEV_PROXY_API_PATH}" NODE_ENV=development $(NODE_MODULES)/cypress/bin/cypress open -project: - npm install -g yo - npm install -g @plone/generator-volto - npm install -g mrs-developer - yo @plone/volto project --addon ${ADDON} --workspace "src/addons/${DIR}" --no-interactive - ln -sf $$(pwd) project/src/addons/ - cp .project.eslintrc.js .eslintrc.js - cd project && yarn - @echo "-------------------" - @echo "$(GREEN)Volto project is ready!$(RESET)" - @echo "$(RED)Now run: cd project && yarn start$(RESET)" - -all: project - -.PHONY: start-test-backend -start-test-backend: ## Start Test Plone Backend - @echo "$(GREEN)==> Start Test Plone Backend$(RESET)" - docker run -i --rm -e ZSERVER_HOST=0.0.0.0 -e ZSERVER_PORT=55001 -p 55001:55001 -e SITE=plone -e APPLY_PROFILES=plone.app.contenttypes:plone-content,plone.restapi:default,kitconcept.volto:default-homepage -e CONFIGURE_PACKAGES=plone.app.contenttypes,plone.restapi,kitconcept.volto,kitconcept.volto.cors -e ADDONS='plone.app.robotframework plone.app.contenttypes plone.restapi kitconcept.volto' plone ./bin/robot-server plone.app.robotframework.testing.PLONE_ROBOT_TESTING - -.PHONY: start-backend-docker -start-backend-docker: ## Starts a Docker-based backend - @echo "$(GREEN)==> Start Docker-based Plone Backend$(RESET)" - docker run -it --rm --name=plone -p 8080:8080 -e SITE=Plone -e ADDONS="kitconcept.volto" -e ZCML="kitconcept.volto.cors" plone +.PHONY: cypress-run +cypress-run: ## Run cypress integration tests + CYPRESS_API_PATH="${RAZZLE_DEV_PROXY_API_PATH}" NODE_ENV=development $(NODE_MODULES)/cypress/bin/cypress run --browser chromium .PHONY: test test: ## Run jest tests - docker pull plone/volto-addon-ci:alpha - docker run -it --rm -e NAMESPACE="@eeacms" -e GIT_NAME="${DIR}" -e RAZZLE_JEST_CONFIG=jest-addon.config.js -v "$$(pwd):/opt/frontend/my-volto-project/src/addons/${DIR}" -e CI="true" plone/volto-addon-ci:alpha + ${DOCKER_COMPOSE} run -e CI=1 frontend test .PHONY: test-update test-update: ## Update jest tests snapshots - docker pull plone/volto-addon-ci:alpha - docker run -it --rm -e NAMESPACE="@eeacms" -e GIT_NAME="${DIR}" -e RAZZLE_JEST_CONFIG=jest-addon.config.js -v "$$(pwd):/opt/frontend/my-volto-project/src/addons/${DIR}" -e CI="true" plone/volto-addon-ci:alpha yarn test src/addons/${DIR}/src --watchAll=false -u + ${DOCKER_COMPOSE} run -e CI=1 frontend test -u .PHONY: stylelint stylelint: ## Stylelint @@ -56,12 +102,12 @@ stylelint: ## Stylelint .PHONY: stylelint-overrides stylelint-overrides: - $(NODE_MODULES)/.bin/stylelint --syntax less --allow-empty-input 'theme/**/*.overrides' 'src/**/*.overrides' + $(NODE_MODULES)/.bin/stylelint --custom-syntax less --allow-empty-input 'theme/**/*.overrides' 'src/**/*.overrides' .PHONY: stylelint-fix stylelint-fix: ## Fix stylelint $(NODE_MODULES)/stylelint/bin/stylelint.js --allow-empty-input 'src/**/*.{css,less}' --fix - $(NODE_MODULES)/.bin/stylelint --syntax less --allow-empty-input 'theme/**/*.overrides' 'src/**/*.overrides' --fix + $(NODE_MODULES)/.bin/stylelint --custom-syntax less --allow-empty-input 'theme/**/*.overrides' 'src/**/*.overrides' --fix .PHONY: prettier prettier: ## Prettier @@ -84,14 +130,33 @@ i18n: ## i18n rm -rf build/messages NODE_ENV=development $(NODE_MODULES)/.bin/i18n --addon -.PHONY: cypress-run -cypress-run: ## Run cypress integration tests - NODE_ENV=development $(NODE_MODULES)/cypress/bin/cypress run - -.PHONY: cypress-open -cypress-open: ## Open cypress integration tests - NODE_ENV=development $(NODE_MODULES)/cypress/bin/cypress open - .PHONY: help -help: ## Show this help. +help: ## Show this help. @echo -e "$$(grep -hE '^\S+:.*##' $(MAKEFILE_LIST) | sed -e 's/:.*##\s*/:/' -e 's/^\(.\+\):\(.*\)/\\x1b[36m\1\\x1b[m:\2/' | column -c2 -t -s :)" + head -n 14 Makefile + +.PHONY: ci-fix +ci-fix: + echo "Running lint-fix" + make lint-fix + echo "Running prettier-fix" + make prettier-fix + echo "Running stylelint-fix" + make stylelint-fix + +.PHONY: test-ci +test-ci: + cd /app + 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 + +.PHONY: start-ci +start-ci: + cp .coverage.babel.config.js /app/babel.config.js + cd ../.. + yarn start + +.PHONY: cypress-ci +cypress-ci: + $(NODE_MODULES)/.bin/wait-on -t 240000 http://localhost:3000 + NODE_ENV=development make cypress-run + diff --git a/README.md b/README.md index 99d19f8..aa8284e 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,10 @@ Demo GIF 1. Make sure you have a [Plone backend](https://plone.org/download) up-and-running at http://localhost:8080/Plone + ```Bash + docker compose up backend + ``` + 1. Start Volto frontend - If you already have a volto project, just update `package.json`: diff --git a/RELEASE.md b/RELEASE.md index 24f98ee..4e311a0 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -20,9 +20,9 @@ You need to first install the [release-it](https://github.com/release-it/release ``` npm install -g release-it ``` - + Release-it uses the configuration written in the [`.release-it.json`](./.release-it.json) file located in the root of the repository. - + Release-it is a tool that automates 4 important steps in the release process: 1. Version increase in `package.json` ( increased from the current version in `package.json`) @@ -30,45 +30,45 @@ Release-it is a tool that automates 4 important steps in the release process: 3. GitHub release on the commit with the changelog and package.json modification on the develop branch 4. NPM release ( by default it's disabled, but can be enabled in the configuration file ) -To configure the authentification, you need to export GITHUB_TOKEN for [GitHub](https://github.com/settings/tokens) +To configure the authentification, you need to export GITHUB_TOKEN for [GitHub](https://github.com/settings/tokens) ``` export GITHUB_TOKEN=XXX-XXXXXXXXXXXXXXXXXXXXXX ``` - + To configure npm, you can use the `npm login` command or use a configuration file with a TOKEN : - + ``` echo "//registry.npmjs.org/:_authToken=YYYYYYYYYYYYYYYYYYYYYYYYYYYYYY" > .npmrc ``` #### Using release-it tool - + There are 3 yarn scripts that can be run to do the release ##### yarn release-beta -Automatically calculates and presents 3 beta versions - patch, minor and major for you to choose ( or Other for manual input). +Automatically calculates and presents 3 beta versions - patch, minor and major for you to choose ( or Other for manual input). ``` -? Select increment (next version): -❯ prepatch (0.1.1-beta.0) - preminor (0.2.0-beta.0) - premajor (1.0.0-beta.0) - Other, please specify... +? Select increment (next version): +❯ prepatch (0.1.1-beta.0) + preminor (0.2.0-beta.0) + premajor (1.0.0-beta.0) + Other, please specify... ``` ##### yarn release-major-beta Same as `yarn release-beta`, but with premajor version pre-selected. - + ##### yarn release Generic command, does not automatically add the `beta` to version, but you can still manually write it if you choose Other. #### Important notes -> Do not use release-it tool on master branch, the commit on CHANGELOG.md file and the version increase in the package.json file can't be done without a PULL REQUEST. +> Do not use release-it tool on master branch, the commit on CHANGELOG.md file and the version increase in the package.json file can't be done without a PULL REQUEST. > Do not keep Pull Requests from develop to master branches open when you are doing beta releases from the develop branch. As long as a PR to master is open, an automatic script will run on every commit and will update both the version and the changelog to a production-ready state - ( MAJOR.MINOR.PATCH mandatory format for version). diff --git a/cypress.config.js b/cypress.config.js index da8e7ba..02c57eb 100644 --- a/cypress.config.js +++ b/cypress.config.js @@ -5,9 +5,9 @@ module.exports = defineConfig({ defaultCommandTimeout: 8888, chromeWebSecurity: false, reporter: 'junit', - video: true, + video: false, retries: { - runMode: 8, + runMode: 2, openMode: 0, }, reporterOptions: { diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..5d79f5c --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,32 @@ +version: "3" +services: + backend: + image: eeacms/plone-backend + ports: + - "8080:8080" + environment: + SITE: "Plone" + PROFILES: "eea.kitkat:testing" + + frontend: + build: + context: ./ + dockerfile: ./Dockerfile + args: + ADDON_NAME: "${ADDON_NAME}" + ADDON_PATH: "${ADDON_PATH}" + VOLTO_VERSION: ${VOLTO_VERSION:-16} + ports: + - "3000:3000" + - "3001:3001" + depends_on: + - backend + volumes: + - ./:/app/src/addons/${ADDON_PATH} + environment: + CI: "true" + NODE_ENV: "development" + RAZZLE_JEST_CONFIG: "src/addons/${ADDON_PATH}/jest-addon.config.js" + RAZZLE_INTERNAL_API_PATH: "http://backend:8080/Plone" + RAZZLE_DEV_PROXY_API_PATH: "http://backend:8080/Plone" + HOST: "0.0.0.0" diff --git a/locales/de/LC_MESSAGES/volto.po b/locales/de/LC_MESSAGES/volto.po new file mode 100644 index 0000000..12b9a47 --- /dev/null +++ b/locales/de/LC_MESSAGES/volto.po @@ -0,0 +1,14 @@ +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: \n" +"PO-Revision-Date: \n" +"Last-Translator: \n" +"Language: \n" +"Language-Team: \n" +"Content-Type: \n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + + diff --git a/locales/en/LC_MESSAGES/volto.po b/locales/en/LC_MESSAGES/volto.po new file mode 100644 index 0000000..12b9a47 --- /dev/null +++ b/locales/en/LC_MESSAGES/volto.po @@ -0,0 +1,14 @@ +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: \n" +"PO-Revision-Date: \n" +"Last-Translator: \n" +"Language: \n" +"Language-Team: \n" +"Content-Type: \n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + + diff --git a/locales/it/LC_MESSAGES/volto.po b/locales/it/LC_MESSAGES/volto.po new file mode 100644 index 0000000..12b9a47 --- /dev/null +++ b/locales/it/LC_MESSAGES/volto.po @@ -0,0 +1,14 @@ +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: \n" +"PO-Revision-Date: \n" +"Last-Translator: \n" +"Language: \n" +"Language-Team: \n" +"Content-Type: \n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + + diff --git a/locales/ro/LC_MESSAGES/volto.po b/locales/ro/LC_MESSAGES/volto.po new file mode 100644 index 0000000..12b9a47 --- /dev/null +++ b/locales/ro/LC_MESSAGES/volto.po @@ -0,0 +1,14 @@ +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: \n" +"PO-Revision-Date: \n" +"Last-Translator: \n" +"Language: \n" +"Language-Team: \n" +"Content-Type: \n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + + diff --git a/locales/volto.pot b/locales/volto.pot index e69de29..93c2825 100644 --- a/locales/volto.pot +++ b/locales/volto.pot @@ -0,0 +1,16 @@ +msgid "" +msgstr "" +"Project-Id-Version: Plone\n" +"POT-Creation-Date: 2023-06-28T10:48:22.678Z\n" +"Last-Translator: Plone i18n \n" +"Language-Team: Plone i18n \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=1; plural=0;\n" +"Language-Code: en\n" +"Language-Name: English\n" +"Preferred-Encodings: utf-8\n" +"Domain: volto\n" + + diff --git a/package.json b/package.json index 1552363..e03a97b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@eeacms/volto-industry-theme", - "version": "2.0.15", + "version": "2.0.16", "description": "@eeacms/volto-industry-theme: Volto add-on", "main": "src/index.js", "author": "European Environment Agency: IDM2 A-Team", @@ -38,8 +38,31 @@ "@plone/scripts": "*", "babel-plugin-transform-class-properties": "^6.24.1", "cypress-fail-fast": "^5.0.1", + "husky": "^8.0.3", + "lint-staged": "^14.0.1", "md5": "^2.3.0" }, + "lint-staged": { + "src/**/*.{js,jsx,ts,tsx,json}": [ + "make lint-fix", + "make prettier-fix" + ], + "src/**/*.{jsx}": [ + "make i18n" + ], + "theme/**/*.{css,less}": [ + "make stylelint-fix" + ], + "src/**/*.{css,less}": [ + "make stylelint-fix" + ], + "theme/**/*.overrides": [ + "make stylelint-fix" + ], + "src/**/*.overrides": [ + "make stylelint-fix" + ] + }, "scripts": { "release": "release-it", "release-major-beta": "release-it major --preRelease=beta", @@ -57,6 +80,7 @@ "lint:fix": "make lint-fix", "i18n": "make i18n", "cypress:run": "make cypress-run", - "cypress:open": "make cypress-open" + "cypress:open": "make cypress-open", + "prepare": "husky install" } } diff --git a/src/components/PrivacyProtection/PrivacyProtection.jsx b/src/components/PrivacyProtection/PrivacyProtection.jsx index 11d9781..4786ec2 100644 --- a/src/components/PrivacyProtection/PrivacyProtection.jsx +++ b/src/components/PrivacyProtection/PrivacyProtection.jsx @@ -87,7 +87,7 @@ const PrivacyProtection = ({ className="floating-icon mr-1" data-tip={dataprotection.privacy_statement} > - + ) : ( '' diff --git a/src/components/manage/Blocks/IndustryMap/Sidebar.jsx b/src/components/manage/Blocks/IndustryMap/Sidebar.jsx index c9a46fe..77db202 100644 --- a/src/components/manage/Blocks/IndustryMap/Sidebar.jsx +++ b/src/components/manage/Blocks/IndustryMap/Sidebar.jsx @@ -248,7 +248,7 @@ class Sidebar extends React.Component { className="menu-button" title="Toggle sidebar" onClick={() => { - this.setState({ open: !this.state.open }); + this.setState((prevState) => ({ open: !prevState.open })); }} > diff --git a/src/components/manage/Blocks/SiteBlocks/BatConclusions.jsx b/src/components/manage/Blocks/SiteBlocks/BatConclusions.jsx index b04d064..b3ee72b 100644 --- a/src/components/manage/Blocks/SiteBlocks/BatConclusions.jsx +++ b/src/components/manage/Blocks/SiteBlocks/BatConclusions.jsx @@ -20,7 +20,7 @@ const hasConclusions = (data, installations) => { const View = (props) => { const [activeAels, setActiveAels] = React.useState({}); const { data = {}, installationsNth = {}, entity = '' } = props; - const installations = Object.keys(data).sort(); + const installations = Object.keys(data).sort((a, b) => a.localeCompare(b)); return (
@@ -36,7 +36,7 @@ const View = (props) => { content="Number of individual conclusions that indicate which techniques or combinations of techniques are BAT for achieving a specific environmental objective" trigger={
- +
} /> @@ -45,7 +45,9 @@ const View = (props) => { {hasConclusions(data, installations) ? (
{installations.map((installation) => { - const conclusions = Object.keys(data[installation] || {}).sort(); + const conclusions = Object.keys( + data[installation] || {}, + ).sort((a, b) => a.localeCompare(b)); return conclusions.length ? (
{ : rightSVG } size="20px" - color="#E2776B" + color="#289588" onClick={() => { if ( !activeAels[ diff --git a/src/components/manage/Blocks/SiteBlocks/PermitingAuthority.jsx b/src/components/manage/Blocks/SiteBlocks/PermitingAuthority.jsx index f431339..9907d9a 100644 --- a/src/components/manage/Blocks/SiteBlocks/PermitingAuthority.jsx +++ b/src/components/manage/Blocks/SiteBlocks/PermitingAuthority.jsx @@ -24,7 +24,7 @@ const PermitingAuthority = (props) => { content="Authority, body or bodies responsible for issuing a permit to a given facility" trigger={
- +
} /> diff --git a/src/components/manage/Blocks/SiteBlocks/RegulatoryBATConclusions/View.jsx b/src/components/manage/Blocks/SiteBlocks/RegulatoryBATConclusions/View.jsx index b72b0fb..74879ba 100644 --- a/src/components/manage/Blocks/SiteBlocks/RegulatoryBATConclusions/View.jsx +++ b/src/components/manage/Blocks/SiteBlocks/RegulatoryBATConclusions/View.jsx @@ -32,7 +32,7 @@ const View = (props) => { ); const facilities = [ ...new Set(provider_data?.facilityInspireId || []), - ].sort(); + ].sort((a, b) => a.localeCompare(b)); let newBatConclusions = {}; const counter = {}; const nth = {}; @@ -58,7 +58,7 @@ const View = (props) => { }); Object.keys(newBatConclusions) - .sort() + .sort((a, b) => a.localeCompare(b)) .forEach((id, index) => { const installation = newBatConclusions[id]; const facility = installation.facility; diff --git a/src/components/manage/Blocks/SiteBlocks/RegulatoryPermits/View.jsx b/src/components/manage/Blocks/SiteBlocks/RegulatoryPermits/View.jsx index 73d22ae..5116305 100644 --- a/src/components/manage/Blocks/SiteBlocks/RegulatoryPermits/View.jsx +++ b/src/components/manage/Blocks/SiteBlocks/RegulatoryPermits/View.jsx @@ -32,7 +32,7 @@ const View = (props) => { ); const facilities = [ ...new Set(provider_data?.facilityInspireId || []), - ].sort(); + ].sort((a, b) => a.localeCompare(b)); let newPermits = []; const counter = {}; indexes.forEach((index, i) => { diff --git a/src/components/manage/Blocks/SiteBlocks/RegulatorySiteDetails/View.jsx b/src/components/manage/Blocks/SiteBlocks/RegulatorySiteDetails/View.jsx index 96960f5..5dc972f 100644 --- a/src/components/manage/Blocks/SiteBlocks/RegulatorySiteDetails/View.jsx +++ b/src/components/manage/Blocks/SiteBlocks/RegulatorySiteDetails/View.jsx @@ -38,7 +38,7 @@ const View = (props) => { content="Information regarding the facilities included in the industrial site" trigger={
- +
} /> diff --git a/src/components/manage/Blocks/SiteBlocks/RegulatorySitePermits/View.jsx b/src/components/manage/Blocks/SiteBlocks/RegulatorySitePermits/View.jsx index 68c68e5..02ae223 100644 --- a/src/components/manage/Blocks/SiteBlocks/RegulatorySitePermits/View.jsx +++ b/src/components/manage/Blocks/SiteBlocks/RegulatorySitePermits/View.jsx @@ -32,7 +32,7 @@ const View = (props) => { ); const facilities = [ ...new Set(provider_data?.facilityInspireId || []), - ].sort(); + ].sort((a, b) => a.localeCompare(b)); let newPermits = []; const counter = {}; indexes.forEach((index, i) => { diff --git a/src/components/manage/Blocks/SiteBlocks/style.css b/src/components/manage/Blocks/SiteBlocks/style.css index b4a33cd..54cc183 100644 --- a/src/components/manage/Blocks/SiteBlocks/style.css +++ b/src/components/manage/Blocks/SiteBlocks/style.css @@ -244,7 +244,7 @@ h3.orange { .conclusion-wrapper .conclusion-title h3 { - color: #e2776b; + color: #289588; } .bat-conclusions diff --git a/src/components/manage/Blocks/SiteStructureSidebar/View.jsx b/src/components/manage/Blocks/SiteStructureSidebar/View.jsx index b154585..087839b 100644 --- a/src/components/manage/Blocks/SiteStructureSidebar/View.jsx +++ b/src/components/manage/Blocks/SiteStructureSidebar/View.jsx @@ -83,7 +83,9 @@ const View = (props) => { }); setSiteStructure({ ...newSiteStructure, - facilities: newSiteStructure.facilities.sort(), + facilities: newSiteStructure.facilities.sort((a, b) => + a.localeCompare(b), + ), }); } /* eslint-disable-next-line */ diff --git a/src/customizations/volto/components/theme/Header/Header.jsx b/src/customizations/volto/components/theme/Header/Header.jsx index eb90ee3..4e1fad2 100644 --- a/src/customizations/volto/components/theme/Header/Header.jsx +++ b/src/customizations/volto/components/theme/Header/Header.jsx @@ -9,7 +9,7 @@ import PropTypes from 'prop-types'; import { connect } from 'react-redux'; import { Logo, Navigation } from '@plone/volto/components'; -import { Parteners } from '@eeacms/volto-industry-theme/components'; +// import { Parteners } from '@eeacms/volto-industry-theme/components'; /** * Header component class. @@ -59,7 +59,7 @@ class Header extends Component {
- + {/* */}
diff --git a/src/helpers/index.js b/src/helpers/index.js index 5e57bee..0cef3f2 100644 --- a/src/helpers/index.js +++ b/src/helpers/index.js @@ -13,7 +13,7 @@ import { setConnectedDataParameters } from '@eeacms/volto-datablocks/actions'; export function cleanUpText(value) { let text = value.replaceAll('\n', ''); text = text.replaceAll("'", "''"); - text = text.replace(/^\s+|\s+$/gm, ''); + text = text.replace(/(^\s+|\s+$)/gm, ''); return text; } diff --git a/src/index.js b/src/index.js index 5149759..714235e 100644 --- a/src/index.js +++ b/src/index.js @@ -22,9 +22,9 @@ const applyConfig = (config) => { tableauVersion: '2.3.0', available_colors: [ '#81C9DB', - '#5397B2', + '#2e3e4c', '#12435D', - '#E2776B', + '#289588', '#CD3B1F', '#F6F6F6', '#EDEDED', diff --git a/src/theme/site/assets/icons/logo-blue.old.png b/src/theme/site/assets/icons/logo-blue.old.png deleted file mode 100644 index ba596a9..0000000 Binary files a/src/theme/site/assets/icons/logo-blue.old.png and /dev/null differ diff --git a/src/theme/site/assets/icons/logo-colored.png b/src/theme/site/assets/icons/logo-colored.png new file mode 100644 index 0000000..97ee732 Binary files /dev/null and b/src/theme/site/assets/icons/logo-colored.png differ diff --git a/src/theme/site/assets/icons/logo-colored.svg b/src/theme/site/assets/icons/logo-colored.svg new file mode 100644 index 0000000..17ce736 --- /dev/null +++ b/src/theme/site/assets/icons/logo-colored.svg @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/theme/site/assets/icons/logo-white.old.png b/src/theme/site/assets/icons/logo-white.old.png deleted file mode 100644 index b912438..0000000 Binary files a/src/theme/site/assets/icons/logo-white.old.png and /dev/null differ diff --git a/src/theme/site/assets/icons/logo-white.png b/src/theme/site/assets/icons/logo-white.png index 20d608f..84f0a45 100644 Binary files a/src/theme/site/assets/icons/logo-white.png and b/src/theme/site/assets/icons/logo-white.png differ diff --git a/src/theme/site/assets/icons/logo-white.svg b/src/theme/site/assets/icons/logo-white.svg index f5cf176..f460ccc 100644 --- a/src/theme/site/assets/icons/logo-white.svg +++ b/src/theme/site/assets/icons/logo-white.svg @@ -1,152 +1,108 @@ - + + viewBox="0 0 96 45.9" style="enable-background:new 0 0 96 45.9;" xml:space="preserve"> - + + + + + + + + - - + + + + + + + + + + - - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - + diff --git a/src/theme/site/elements/header.overrides b/src/theme/site/elements/header.overrides index a9e7965..f8ef16d 100644 --- a/src/theme/site/elements/header.overrides +++ b/src/theme/site/elements/header.overrides @@ -20,12 +20,12 @@ margin-top: 0; .item { + min-width: 50px; + min-height: 50px; align-self: center; color: rgba(255, 255, 255, 0.8); text-decoration: none; text-transform: uppercase; - min-height: 50px; - min-width: 50px; &.active { background-color: transparent !important; @@ -105,7 +105,7 @@ @media only screen and (max-width: @largestTabletScreen) { .item { - min-height: 50px; min-width: 50px; + min-height: 50px; } -} \ No newline at end of file +} diff --git a/src/theme/site/globals/site.variables b/src/theme/site/globals/site.variables index 370e3db..c339816 100644 --- a/src/theme/site/globals/site.variables +++ b/src/theme/site/globals/site.variables @@ -125,7 +125,7 @@ @pageOverflowX : hidden; @lineHeight : 1.4285em; -@textColor : rgba(0, 0, 0, 0.87); +@textColor : #6989a5; /*------------------- Paragraph @@ -221,12 +221,12 @@ /*--- Colors ---*/ @red : #CD3B1F; -@orange : #E2776B; +@orange : #289588; @yellow : #FBBD08; @olive : #B5CC18; @green : #21BA45; @teal : #00B5AD; -@blue : #5397B2; +@blue : #2e3e4c; @violet : #6435C9; @purple : #A333C8; @pink : #E03997;