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 e412852..1c2c573 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,11 +4,27 @@ 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). -### [4.1.4](https://github.com/eea/volto-call-to-action-block/compare/4.1.3...4.1.4) - 16 June 2023 +### [4.2.0](https://github.com/eea/volto-call-to-action-block/compare/4.1.4...4.2.0) - 28 September 2023 + +#### :rocket: New Features + +- feat: I18n and docs update [Alin Voinea - [`f7b80e8`](https://github.com/eea/volto-call-to-action-block/commit/f7b80e8d9791b1d1ed69b2b3b28578f97be81ad5)] #### :house: Internal changes -- chore: Fix dependencies pin [Alin Voinea - [`16bc89d`](https://github.com/eea/volto-call-to-action-block/commit/16bc89db73885399eb1fe15f92d886f16037f07c)] +- style: lint-staged reorder in package.json [Alin Voinea - [`1fde0b2`](https://github.com/eea/volto-call-to-action-block/commit/1fde0b2726c52acdb1a0d590b9919a15eed487f3)] + +#### :house: Documentation changes + +- docs: Cleanup Makefile, update DEVELOP documentation, i18n - refs #254894 [valentinab25 - [`390eb9e`](https://github.com/eea/volto-call-to-action-block/commit/390eb9e0da885d978855aa51978faf25fd972c89)] + +#### :hammer_and_wrench: Others + +- test: Temp. disable SonarQube coverage to be able to release [Alin Voinea - [`760e1eb`](https://github.com/eea/volto-call-to-action-block/commit/760e1eb2079c9f294b6fd942331813c3f041fc8e)] +- test: EN locales, pre-commit fix, feature PRs checks Refs #257193 [valentinab25 - [`8522a41`](https://github.com/eea/volto-call-to-action-block/commit/8522a4181a5a622c2e30482dee26cd740d6c3d09)] +- i18n: Add en [Alin Voinea - [`be35c5d`](https://github.com/eea/volto-call-to-action-block/commit/be35c5dc9ba4f29d5abd6c8eb261371e8daf23bf)] +- test: Update Makefile and docker-compose to align it with Jenkinsfile [valentinab25 - [`567a4ac`](https://github.com/eea/volto-call-to-action-block/commit/567a4ac159360e799ddc5fdcdbef5ec1e453dbe9)] +### [4.1.4](https://github.com/eea/volto-call-to-action-block/compare/4.1.3...4.1.4) - 16 June 2023 ### [4.1.3](https://github.com/eea/volto-call-to-action-block/compare/4.1.2...4.1.3) - 14 June 2023 @@ -16,13 +32,11 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). #### :house: Internal changes -- chore: [JENKINS] Deprecate circularity website [valentinab25 - [`2e2d8ad`](https://github.com/eea/volto-call-to-action-block/commit/2e2d8ad039cd60ac5391b63d5359b5bf7cb4d4a5)] #### :hammer_and_wrench: Others - test: jest should look for addons in node_modules Refs #253277 [valentinab25 - [`e9c4a3f`](https://github.com/eea/volto-call-to-action-block/commit/e9c4a3f6fd4ecad1e1ff2ef28876dcb500ecd4b3)] - test: Fix test config, coverage Refs #253277 [valentinab25 - [`8a67d7f`](https://github.com/eea/volto-call-to-action-block/commit/8a67d7f21794a33976bbf46b84309cca0c9e58fd)] -- Add Sonarqube tag using industry-frontend addons list [EEA Jenkins - [`3ae3cb5`](https://github.com/eea/volto-call-to-action-block/commit/3ae3cb51c08b53530cca88921fd8bbc097fa6b70)] ### [4.1.1](https://github.com/eea/volto-call-to-action-block/compare/4.1.0...4.1.1) - 4 April 2023 #### :nail_care: Enhancements @@ -34,8 +48,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). #### :hammer_and_wrench: Others -- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`8911bba`](https://github.com/eea/volto-call-to-action-block/commit/8911bbadbe3036432c8d083cc836d3ab7f36c01c)] -- Add Sonarqube tag using ims-frontend addons list [EEA Jenkins - [`d58685c`](https://github.com/eea/volto-call-to-action-block/commit/d58685ca755e59cd77090ddeb446855d56a73876)] ## [4.0.0](https://github.com/eea/volto-call-to-action-block/compare/3.0.1...4.0.0) - 7 February 2023 #### :nail_care: Enhancements @@ -55,17 +67,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). #### :hammer_and_wrench: Others -- Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`e46fb39`](https://github.com/eea/volto-call-to-action-block/commit/e46fb392ba15f9280e1a2d91b38e4acaa3105486)] -- Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`184e4d5`](https://github.com/eea/volto-call-to-action-block/commit/184e4d527764cbb754398b7c1975268c0eacdc86)] -- Add Sonarqube tag using climate-energy-frontend addons list [EEA Jenkins - [`8ff40cc`](https://github.com/eea/volto-call-to-action-block/commit/8ff40cc8fb5087bd0f56fbc3e38a26f5d61d63fa)] - test(Jenkins): Run tests and cypress with latest canary @plone/volto [Alin Voinea - [`d1ba7b8`](https://github.com/eea/volto-call-to-action-block/commit/d1ba7b844f114305604e7f8c8b3158746dd59a7b)] -- Add Sonarqube tag using cca-frontend addons list [EEA Jenkins - [`4dea109`](https://github.com/eea/volto-call-to-action-block/commit/4dea10962560c760c2c44db27d3446a4268ded57)] -- Add Sonarqube tag using bise-frontend addons list [EEA Jenkins - [`fd6b7f3`](https://github.com/eea/volto-call-to-action-block/commit/fd6b7f31d28e05ed254a32bb213ad662e2635c96)] -- yarn 3 [Alin Voinea - [`8bfd09a`](https://github.com/eea/volto-call-to-action-block/commit/8bfd09a161d1d0b3174585c172a3804e56315dea)] -- Add Sonarqube tag using marine-frontend addons list [EEA Jenkins - [`440cd71`](https://github.com/eea/volto-call-to-action-block/commit/440cd71451fd5d5ef0316b5c74b61e66170444a7)] -- Add Sonarqube tag using clms-frontend addons list [EEA Jenkins - [`e05f0dd`](https://github.com/eea/volto-call-to-action-block/commit/e05f0dd0cf782872b4105f3305c7f40ccb69cbb9)] -- Add Sonarqube tag using demo-kitkat-frontend addons list [EEA Jenkins - [`6d44be8`](https://github.com/eea/volto-call-to-action-block/commit/6d44be88d8aabd57a8b74a3e16be7032dfda5eee)] -- Add Sonarqube tag using forests-frontend addons list [EEA Jenkins - [`4867cf3`](https://github.com/eea/volto-call-to-action-block/commit/4867cf362a91ea38bded8598d1937d33b35a12ab)] ## [2.0.0](https://github.com/eea/volto-call-to-action-block/compare/1.0.0...2.0.0) - 16 November 2022 #### :nail_care: Enhancements @@ -75,7 +77,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). #### :hammer_and_wrench: Others - test(estlint): Fix .project.eslintrc.js [Alin Voinea - [`39e8df4`](https://github.com/eea/volto-call-to-action-block/commit/39e8df468509414924327917154f035235ec5798)] -- Add Sonarqube tag using circularity-frontend addons list [EEA Jenkins - [`0e06348`](https://github.com/eea/volto-call-to-action-block/commit/0e06348412feed9eeea6ae5d06ae59b8c21e4eff)] - test(cypress): Rename [Alin Voinea - [`ef8b823`](https://github.com/eea/volto-call-to-action-block/commit/ef8b82323a0c108e58f73c180f5b4cb23ed04f0e)] ## [1.0.0](https://github.com/eea/volto-call-to-action-block/compare/0.2.4...1.0.0) - 28 October 2022 @@ -89,7 +90,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - test(cypress): Fix typo [Alin Voinea - [`f3cc342`](https://github.com/eea/volto-call-to-action-block/commit/f3cc3424ace81d26b296882b8484d6b6b12b0d28)] - Cleanup [Alin Voinea - [`2e63ef6`](https://github.com/eea/volto-call-to-action-block/commit/2e63ef665d3812d44b6a87bac6c7f657e40e2147)] - Update dependencies [Alin Voinea - [`cfb5062`](https://github.com/eea/volto-call-to-action-block/commit/cfb50627df9a9a15ebe67adc43dac97379c64efb)] -- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`09c7c14`](https://github.com/eea/volto-call-to-action-block/commit/09c7c14265b0e63f054c3373530ba1dfbd39f4f7)] ### [0.2.4](https://github.com/eea/volto-call-to-action-block/compare/0.2.3...0.2.4) - 30 June 2022 ### [0.2.3](https://github.com/eea/volto-call-to-action-block/compare/0.2.2...0.2.3) - 30 June 2022 @@ -97,7 +97,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). #### :hammer_and_wrench: Others - Add tertiary theming option [Alin Voinea - [`c133291`](https://github.com/eea/volto-call-to-action-block/commit/c133291f17c7a8800271bafe96c008dae3b4ee79)] -- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`720a9a6`](https://github.com/eea/volto-call-to-action-block/commit/720a9a62f1505906b5e6e0667272e07598a67972)] ### [0.2.2](https://github.com/eea/volto-call-to-action-block/compare/0.2.1...0.2.2) - 2 June 2022 ### [0.2.1](https://github.com/eea/volto-call-to-action-block/compare/0.2.0...0.2.1) - 2 June 2022 @@ -120,5 +119,4 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). #### :hammer_and_wrench: Others -- yarn bootstrap [Alin Voinea - [`12f3e83`](https://github.com/eea/volto-call-to-action-block/commit/12f3e834d6d3e257cb9e7b6dde80dab783613a01)] - Initial commit [Alin Voinea - [`00f39c8`](https://github.com/eea/volto-call-to-action-block/commit/00f39c8a36327a821cc613a772bf228451a71e67)] diff --git a/DEVELOP.md b/DEVELOP.md index 09b2117..bdc420c 100644 --- a/DEVELOP.md +++ b/DEVELOP.md @@ -2,6 +2,31 @@ ## Develop +1. Make sure you have `docker` and `docker compose` installed and running on your machine: + + ```Bash + git clone https://github.com/eea/volto-call-to-action-block.git + cd volto-call-to-action-block + 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-call-to-action-block 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 +51,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 +71,37 @@ Before starting make sure your development environment is properly set. See [Vol 1. Happy hacking! cd src/addons/volto-call-to-action-block/ + +## 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-call-to-action-block` to `mrs.developer.json` + +Go to: + + ```BASH + cd src/addons/volto-call-to-action-block/ + ``` + +Start: + + ```Bash + make + make start + ``` + +This will build and start with Docker a clean `Plone backend` and `Volto Frontend` with `volto-call-to-action-block` 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..bd8e10d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +# syntax=docker/dockerfile:1 +ARG VOLTO_VERSION +FROM plone/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 5545861..b6f02ef 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,7 +4,7 @@ pipeline { environment { GIT_NAME = "volto-call-to-action-block" NAMESPACE = "@eeacms" - SONARQUBE_TAGS = "volto.eea.europa.eu,demo-www.eea.europa.eu,forest.eea.europa.eu,clmsdemo.devel6cph.eea.europa.eu,water.europa.eu-marine,biodiversity.europa.eu,climate-adapt.eea.europa.eu,climate-energy.eea.europa.eu,climate-advisory-board.devel4cph.eea.europa.eu,climate-advisory-board.europa.eu,www.eea.europa.eu-ims,www.eea.europa.eu-en,industry.eea.europa.eu" + SONARQUBE_TAGS = "volto.eea.europa.eu,demo-www.eea.europa.eu,forest.eea.europa.eu,clmsdemo.devel6cph.eea.europa.eu,water.europa.eu-marine,biodiversity.europa.eu,climate-adapt.eea.europa.eu,climate-energy.eea.europa.eu,climate-advisory-board.devel4cph.eea.europa.eu,climate-advisory-board.europa.eu,www.eea.europa.eu-ims,www.eea.europa.eu-en,industry.eea.europa.eu,water.europa.eu-freshwater" DEPENDENCIES = "" VOLTO = "" } @@ -62,11 +62,17 @@ pipeline { stage('Tests') { 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 { + not { changelog '.*^Automated release [0-9\\.]+$' } + branch 'master' + } } } } @@ -110,11 +116,17 @@ pipeline { stage('Integration tests') { 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 { + not { changelog '.*^Automated release [0-9\\.]+$' } + branch 'master' + } } } } @@ -167,13 +179,19 @@ pipeline { stage('Report to SonarQube') { 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: '' + anyOf { + allOf { + branch 'develop' + not { changelog '.*^Automated release [0-9\\.]+$' } + } + branch 'master' } } } @@ -197,6 +215,37 @@ pipeline { } } + // stage('SonarQube compare to master') { + // when { + // 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: 'docker') { + // script { + // sh '''docker pull eeacms/gitflow''' + // sh '''echo "Error" > checkresult.txt''' + // catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { + // 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''' + // } + + // 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" + // } + // } + // } + // } + stage('Pull Request') { when { not { diff --git a/Makefile b/Makefile index c0ed91e..4a5cbed 100644 --- a/Makefile +++ b/Makefile @@ -1,54 +1,95 @@ -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-call-to-action-block" - -# 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` +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 + +# 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 -ifeq ($(wildcard ./project),) - NODE_MODULES = "../../../node_modules" -else - NODE_MODULES = "./project/node_modules" -endif +.PHONY: cypress-open +cypress-open: ## Open cypress integration tests + 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 + NODE_ENV=development $(NODE_MODULES)/cypress/bin/cypress run .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 @@ -84,14 +125,7 @@ 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 diff --git a/README.md b/README.md index b594733..97876a0 100644 --- a/README.md +++ b/README.md @@ -19,42 +19,33 @@ ## Features -![Call to Action](https://github.com/eea/volto-call-to-action-block/raw/develop/docs/call-to-action.gif) +### Demo (Internal link) -## Upgrade +![Call to Action](https://github.com/eea/volto-call-to-action-block/raw/master/docs/call-to-action.gif) -### Upgrading to 2.x +### Demo (External link) -This version requires: `@plone/volto >= 16.0.0.alpha.46` (schemaEnhancer / addStyling). +![Call to Action](https://github.com/eea/volto-call-to-action-block/raw/master/docs/call-to-action-external.gif) ## Getting started -### Try volto-call-to-action-block with Docker +### Try volto-statistic-block with Docker -1. Get the latest Docker images + git clone https://github.com/eea/volto-call-to-action-block.git + cd volto-statistic-block + make + make start - ``` - docker pull plone - docker pull plone/volto - ``` - -1. Start Plone backend - ``` - docker run -d --name plone -p 8080:8080 -e SITE=Plone -e PROFILES="profile-plone.restapi:blocks" plone - ``` - -1. Start Volto frontend - - ``` - docker run -it --rm -p 3000:3000 --link plone -e ADDONS="@eeacms/volto-call-to-action-block" plone/volto - ``` - -1. Go to http://localhost:3000 +Go to http://localhost:3000 ### Add volto-call-to-action-block to your Volto project 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`: @@ -65,7 +56,7 @@ This version requires: `@plone/volto >= 16.0.0.alpha.46` (schemaEnhancer / addSt ], "dependencies": { - "@eeacms/volto-call-to-action-block": "^1.0.0" + "@eeacms/volto-call-to-action-block": "*" } ``` diff --git a/cypress.config.js b/cypress.config.js index 30be8ac..4846ce9 100644 --- a/cypress.config.js +++ b/cypress.config.js @@ -2,12 +2,12 @@ const { defineConfig } = require('cypress'); module.exports = defineConfig({ viewportWidth: 1280, - defaultCommandTimeout: 8888, + defaultCommandTimeout: 5000, chromeWebSecurity: false, reporter: 'junit', video: true, retries: { - runMode: 8, + runMode: 1, openMode: 0, }, reporterOptions: { diff --git a/cypress/e2e/02-dexterity-controlpanel-layout.cy.js b/cypress/e2e/02-dexterity-controlpanel-layout.cy.js new file mode 100644 index 0000000..2a402fe --- /dev/null +++ b/cypress/e2e/02-dexterity-controlpanel-layout.cy.js @@ -0,0 +1,63 @@ +import { slateLayoutBeforeEach, slateLayoutAfterEach } from '../support/e2e'; + +describe('ControlPanel: Dexterity Content-Types Layout', () => { + beforeEach(slateLayoutBeforeEach); + afterEach(slateLayoutAfterEach); + + it('Edit Blocks Layout for Book', () => { + cy.visit('/controlpanel/dexterity-types'); + cy.waitForResourceToLoad('@navigation'); + cy.waitForResourceToLoad('@breadcrumbs'); + cy.waitForResourceToLoad('@actions'); + cy.waitForResourceToLoad('@types'); + + cy.get('a[href="/controlpanel/dexterity-types/book"]').should( + 'have.text', + 'book', + ); + + cy.visit('/controlpanel/dexterity-types/book/layout'); + cy.get('#page-controlpanel-layout').contains( + 'Can not edit Layout for book', + ); + cy.get('#page-controlpanel-layout button').click(); + + // Wait a bit for draftjs to load, without this the title block + // custom placeholder is missing and cypress gives a timeout error + cy.wait(1000); + cy.get('input[id="field-placeholder"]').type('Book title'); + cy.get('label[for="field-required"]').click(); + cy.get('label[for="field-fixed"]').click(); + + cy.getSlate().click(); + + cy.get('.ui.basic.icon.button.block-add-button:visible').click(); + cy.get('.blocks-chooser .title').contains('Common').click(); + cy.get('.content.active.common .button.callToActionBlock') + .contains('Call to Action') + .click({ force: true }); + + cy.get('#toolbar-save').click(); + + cy.visit('/cypress'); + cy.waitForResourceToLoad('@navigation'); + cy.waitForResourceToLoad('@breadcrumbs'); + cy.waitForResourceToLoad('@actions'); + cy.waitForResourceToLoad('@types'); + + cy.get('button[class="add"]').click(); + cy.get('#toolbar-add-book').click(); + cy.get('.block.title').contains('Book title'); + + // Change book title + cy.clearSlateTitle(); + cy.getSlateTitle().type('My First Book'); + cy.get('.documentFirstHeading').contains('My First Book'); + cy.get('.call-to-action').click(); + cy.get('.text #field-text').click().clear().type('My Button'); + + cy.get('#toolbar-save').click(); + cy.get('.documentFirstHeading').contains('My First Book'); + cy.get('.call-to-action').contains('My Button'); + }); +}); diff --git a/cypress/support/e2e.js b/cypress/support/e2e.js index f696418..90fe032 100644 --- a/cypress/support/e2e.js +++ b/cypress/support/e2e.js @@ -61,6 +61,22 @@ export const slateJsonAfterEach = (contentType = 'slate') => { slateAfterEach(); }; +export const slateLayoutBeforeEach = (contentType = 'book') => { + cy.autologin(); + cy.addContentType(contentType); + cy.createContent({ + contentType: 'Document', + contentId: 'cypress', + contentTitle: 'Cypress', + }); +}; + +export const slateLayoutAfterEach = (contentType = 'book') => { + cy.autologin(); + cy.removeContentType(contentType); + cy.removeContent('cypress'); +}; + export const getSelectedSlateEditor = () => { return cy.get('.slate-editor.selected [contenteditable=true]').click(); }; 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/docs/call-to-action-external.gif b/docs/call-to-action-external.gif new file mode 100644 index 0000000..1b5010e Binary files /dev/null and b/docs/call-to-action-external.gif differ diff --git a/locales/de/LC_MESSAGES/volto.po b/locales/de/LC_MESSAGES/volto.po new file mode 100644 index 0000000..54c5546 --- /dev/null +++ b/locales/de/LC_MESSAGES/volto.po @@ -0,0 +1,98 @@ +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" + +#: components/Schema +# defaultMessage: Alignment +msgid "Alignment" +msgstr "" + +#: components/Edit +#: components/Schema +# defaultMessage: Call to Action +msgid "Call to Action" +msgstr "" + +#: components/Schema +# defaultMessage: Click here +msgid "Click here" +msgstr "" + +#: components/Schema +# defaultMessage: Icon +msgid "Icon" +msgstr "" + +#: components/Schema +# defaultMessage: Icon on the right +msgid "Icon on the right" +msgstr "" + +#: components/Schema +# defaultMessage: Inverted +msgid "Inverted" +msgstr "" + +#: components/Schema +# defaultMessage: Label +msgid "Label" +msgstr "" + +#: components/Schema +# defaultMessage: Link +msgid "Link" +msgstr "" + +#: components/Schema +# defaultMessage: Open in new window +msgid "Open in new window" +msgstr "" + +#: components/Schema +# defaultMessage: undefined +msgid "Open in parent window / frame" +msgstr "" + +#: components/Schema +# defaultMessage: Open in this window / frame +msgid "Open in this window / frame" +msgstr "" + +#: components/Schema +# defaultMessage: Open in top frame (replaces all frames) +msgid "Open in top frame (replaces all frames)" +msgstr "" + +#: components/Schema +# defaultMessage: Primary +msgid "Primary" +msgstr "" + +#: components/Schema +# defaultMessage: Secondary +msgid "Secondary" +msgstr "" + +#: components/Schema +# defaultMessage: Target +msgid "Target" +msgstr "" + +#: components/Schema +# defaultMessage: Tertiary +msgid "Tertiary" +msgstr "" + +#: components/Schema +# defaultMessage: Theme +msgid "Theme" +msgstr "" diff --git a/locales/en/LC_MESSAGES/volto.po b/locales/en/LC_MESSAGES/volto.po new file mode 100644 index 0000000..54c5546 --- /dev/null +++ b/locales/en/LC_MESSAGES/volto.po @@ -0,0 +1,98 @@ +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" + +#: components/Schema +# defaultMessage: Alignment +msgid "Alignment" +msgstr "" + +#: components/Edit +#: components/Schema +# defaultMessage: Call to Action +msgid "Call to Action" +msgstr "" + +#: components/Schema +# defaultMessage: Click here +msgid "Click here" +msgstr "" + +#: components/Schema +# defaultMessage: Icon +msgid "Icon" +msgstr "" + +#: components/Schema +# defaultMessage: Icon on the right +msgid "Icon on the right" +msgstr "" + +#: components/Schema +# defaultMessage: Inverted +msgid "Inverted" +msgstr "" + +#: components/Schema +# defaultMessage: Label +msgid "Label" +msgstr "" + +#: components/Schema +# defaultMessage: Link +msgid "Link" +msgstr "" + +#: components/Schema +# defaultMessage: Open in new window +msgid "Open in new window" +msgstr "" + +#: components/Schema +# defaultMessage: undefined +msgid "Open in parent window / frame" +msgstr "" + +#: components/Schema +# defaultMessage: Open in this window / frame +msgid "Open in this window / frame" +msgstr "" + +#: components/Schema +# defaultMessage: Open in top frame (replaces all frames) +msgid "Open in top frame (replaces all frames)" +msgstr "" + +#: components/Schema +# defaultMessage: Primary +msgid "Primary" +msgstr "" + +#: components/Schema +# defaultMessage: Secondary +msgid "Secondary" +msgstr "" + +#: components/Schema +# defaultMessage: Target +msgid "Target" +msgstr "" + +#: components/Schema +# defaultMessage: Tertiary +msgid "Tertiary" +msgstr "" + +#: components/Schema +# defaultMessage: Theme +msgid "Theme" +msgstr "" diff --git a/locales/es/LC_MESSAGES/volto.po b/locales/es/LC_MESSAGES/volto.po new file mode 100644 index 0000000..54c5546 --- /dev/null +++ b/locales/es/LC_MESSAGES/volto.po @@ -0,0 +1,98 @@ +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" + +#: components/Schema +# defaultMessage: Alignment +msgid "Alignment" +msgstr "" + +#: components/Edit +#: components/Schema +# defaultMessage: Call to Action +msgid "Call to Action" +msgstr "" + +#: components/Schema +# defaultMessage: Click here +msgid "Click here" +msgstr "" + +#: components/Schema +# defaultMessage: Icon +msgid "Icon" +msgstr "" + +#: components/Schema +# defaultMessage: Icon on the right +msgid "Icon on the right" +msgstr "" + +#: components/Schema +# defaultMessage: Inverted +msgid "Inverted" +msgstr "" + +#: components/Schema +# defaultMessage: Label +msgid "Label" +msgstr "" + +#: components/Schema +# defaultMessage: Link +msgid "Link" +msgstr "" + +#: components/Schema +# defaultMessage: Open in new window +msgid "Open in new window" +msgstr "" + +#: components/Schema +# defaultMessage: undefined +msgid "Open in parent window / frame" +msgstr "" + +#: components/Schema +# defaultMessage: Open in this window / frame +msgid "Open in this window / frame" +msgstr "" + +#: components/Schema +# defaultMessage: Open in top frame (replaces all frames) +msgid "Open in top frame (replaces all frames)" +msgstr "" + +#: components/Schema +# defaultMessage: Primary +msgid "Primary" +msgstr "" + +#: components/Schema +# defaultMessage: Secondary +msgid "Secondary" +msgstr "" + +#: components/Schema +# defaultMessage: Target +msgid "Target" +msgstr "" + +#: components/Schema +# defaultMessage: Tertiary +msgid "Tertiary" +msgstr "" + +#: components/Schema +# defaultMessage: Theme +msgid "Theme" +msgstr "" diff --git a/locales/it/LC_MESSAGES/volto.po b/locales/it/LC_MESSAGES/volto.po new file mode 100644 index 0000000..54c5546 --- /dev/null +++ b/locales/it/LC_MESSAGES/volto.po @@ -0,0 +1,98 @@ +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" + +#: components/Schema +# defaultMessage: Alignment +msgid "Alignment" +msgstr "" + +#: components/Edit +#: components/Schema +# defaultMessage: Call to Action +msgid "Call to Action" +msgstr "" + +#: components/Schema +# defaultMessage: Click here +msgid "Click here" +msgstr "" + +#: components/Schema +# defaultMessage: Icon +msgid "Icon" +msgstr "" + +#: components/Schema +# defaultMessage: Icon on the right +msgid "Icon on the right" +msgstr "" + +#: components/Schema +# defaultMessage: Inverted +msgid "Inverted" +msgstr "" + +#: components/Schema +# defaultMessage: Label +msgid "Label" +msgstr "" + +#: components/Schema +# defaultMessage: Link +msgid "Link" +msgstr "" + +#: components/Schema +# defaultMessage: Open in new window +msgid "Open in new window" +msgstr "" + +#: components/Schema +# defaultMessage: undefined +msgid "Open in parent window / frame" +msgstr "" + +#: components/Schema +# defaultMessage: Open in this window / frame +msgid "Open in this window / frame" +msgstr "" + +#: components/Schema +# defaultMessage: Open in top frame (replaces all frames) +msgid "Open in top frame (replaces all frames)" +msgstr "" + +#: components/Schema +# defaultMessage: Primary +msgid "Primary" +msgstr "" + +#: components/Schema +# defaultMessage: Secondary +msgid "Secondary" +msgstr "" + +#: components/Schema +# defaultMessage: Target +msgid "Target" +msgstr "" + +#: components/Schema +# defaultMessage: Tertiary +msgid "Tertiary" +msgstr "" + +#: components/Schema +# defaultMessage: Theme +msgid "Theme" +msgstr "" diff --git a/locales/pt_BR/LC_MESSAGES/volto.po b/locales/pt_BR/LC_MESSAGES/volto.po new file mode 100644 index 0000000..54c5546 --- /dev/null +++ b/locales/pt_BR/LC_MESSAGES/volto.po @@ -0,0 +1,98 @@ +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" + +#: components/Schema +# defaultMessage: Alignment +msgid "Alignment" +msgstr "" + +#: components/Edit +#: components/Schema +# defaultMessage: Call to Action +msgid "Call to Action" +msgstr "" + +#: components/Schema +# defaultMessage: Click here +msgid "Click here" +msgstr "" + +#: components/Schema +# defaultMessage: Icon +msgid "Icon" +msgstr "" + +#: components/Schema +# defaultMessage: Icon on the right +msgid "Icon on the right" +msgstr "" + +#: components/Schema +# defaultMessage: Inverted +msgid "Inverted" +msgstr "" + +#: components/Schema +# defaultMessage: Label +msgid "Label" +msgstr "" + +#: components/Schema +# defaultMessage: Link +msgid "Link" +msgstr "" + +#: components/Schema +# defaultMessage: Open in new window +msgid "Open in new window" +msgstr "" + +#: components/Schema +# defaultMessage: undefined +msgid "Open in parent window / frame" +msgstr "" + +#: components/Schema +# defaultMessage: Open in this window / frame +msgid "Open in this window / frame" +msgstr "" + +#: components/Schema +# defaultMessage: Open in top frame (replaces all frames) +msgid "Open in top frame (replaces all frames)" +msgstr "" + +#: components/Schema +# defaultMessage: Primary +msgid "Primary" +msgstr "" + +#: components/Schema +# defaultMessage: Secondary +msgid "Secondary" +msgstr "" + +#: components/Schema +# defaultMessage: Target +msgid "Target" +msgstr "" + +#: components/Schema +# defaultMessage: Tertiary +msgid "Tertiary" +msgstr "" + +#: components/Schema +# defaultMessage: Theme +msgid "Theme" +msgstr "" diff --git a/locales/ro/LC_MESSAGES/volto.po b/locales/ro/LC_MESSAGES/volto.po new file mode 100644 index 0000000..459549d --- /dev/null +++ b/locales/ro/LC_MESSAGES/volto.po @@ -0,0 +1,98 @@ +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" + +#: components/Schema +# defaultMessage: Alignment +msgid "Alignment" +msgstr "Aliniere" + +#: components/Edit +#: components/Schema +# defaultMessage: Call to Action +msgid "Call to Action" +msgstr "Buton acțiune" + +#: components/Schema +# defaultMessage: Click here +msgid "Click here" +msgstr "Apasă aici" + +#: components/Schema +# defaultMessage: Icon +msgid "Icon" +msgstr "Pictogramă" + +#: components/Schema +# defaultMessage: Icon on the right +msgid "Icon on the right" +msgstr "Pictogramă pe dreapta" + +#: components/Schema +# defaultMessage: Inverted +msgid "Inverted" +msgstr "Inversat" + +#: components/Schema +# defaultMessage: Label +msgid "Label" +msgstr "Etichetă" + +#: components/Schema +# defaultMessage: Link +msgid "Link" +msgstr "Legătură" + +#: components/Schema +# defaultMessage: Open in new window +msgid "Open in new window" +msgstr "Deschide în fereastră nouă" + +#: components/Schema +# defaultMessage: undefined +msgid "Open in parent window / frame" +msgstr "Deschide în tab nou" + +#: components/Schema +# defaultMessage: Open in this window / frame +msgid "Open in this window / frame" +msgstr "Deschide în această fereastră" + +#: components/Schema +# defaultMessage: Open in top frame (replaces all frames) +msgid "Open in top frame (replaces all frames)" +msgstr "Deschide în cadrul superior" + +#: components/Schema +# defaultMessage: Primary +msgid "Primary" +msgstr "Primară" + +#: components/Schema +# defaultMessage: Secondary +msgid "Secondary" +msgstr "Secundară" + +#: components/Schema +# defaultMessage: Target +msgid "Target" +msgstr "Țintă" + +#: components/Schema +# defaultMessage: Tertiary +msgid "Tertiary" +msgstr "Terțiară" + +#: components/Schema +# defaultMessage: Theme +msgid "Theme" +msgstr "Temă" diff --git a/locales/volto.pot b/locales/volto.pot index 2b4d00b..2d807d6 100644 --- a/locales/volto.pot +++ b/locales/volto.pot @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: Plone\n" -"POT-Creation-Date: 2022-05-31T18:04:15.692Z\n" +"POT-Creation-Date: 2023-08-29T17:12:31.348Z\n" "Last-Translator: Plone i18n \n" "Language-Team: Plone i18n \n" "MIME-Version: 1.0\n" @@ -44,6 +44,11 @@ msgstr "" msgid "Inverted" msgstr "" +#: components/Schema +# defaultMessage: Label +msgid "Label" +msgstr "" + #: components/Schema # defaultMessage: Link msgid "Link" @@ -85,8 +90,8 @@ msgid "Target" msgstr "" #: components/Schema -# defaultMessage: Text -msgid "Text" +# defaultMessage: Tertiary +msgid "Tertiary" msgstr "" #: components/Schema diff --git a/package.json b/package.json index 246d63c..8a74c08 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@eeacms/volto-call-to-action-block", - "version": "4.1.4", + "version": "4.2.0", "description": "@eeacms/volto-call-to-action-block: Volto add-on", "main": "src/index.js", "author": "European Environment Agency: IDM2 A-Team", @@ -23,8 +23,31 @@ "@cypress/code-coverage": "^3.10.0", "@plone/scripts": "*", "babel-plugin-transform-class-properties": "^6.24.1", + "husky": "*", + "lint-staged": "*", "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", @@ -42,6 +65,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" } }