From 4867cf362a91ea38bded8598d1937d33b35a12ab Mon Sep 17 00:00:00 2001 From: EEA Jenkins Date: Thu, 17 Nov 2022 14:37:16 +0200 Subject: [PATCH 01/13] Add Sonarqube tag using forests-frontend addons list --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 49091b4..2f3640e 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,prod-www.eea.europa.eu,circularity.eea.europa.eu" + SONARQUBE_TAGS = "volto.eea.europa.eu,demo-www.eea.europa.eu,prod-www.eea.europa.eu,circularity.eea.europa.eu,forest.eea.europa.eu" DEPENDENCIES = "" VOLTO = "alpha" } From 6d44be88d8aabd57a8b74a3e16be7032dfda5eee Mon Sep 17 00:00:00 2001 From: EEA Jenkins Date: Fri, 18 Nov 2022 09:17:03 +0200 Subject: [PATCH 02/13] Add Sonarqube tag using demo-kitkat-frontend addons list --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2f3640e..db3fdc1 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,prod-www.eea.europa.eu,circularity.eea.europa.eu,forest.eea.europa.eu" + SONARQUBE_TAGS = "volto.eea.europa.eu,demo-www.eea.europa.eu,prod-www.eea.europa.eu,circularity.eea.europa.eu,forest.eea.europa.eu,demo-kitkat.dev2aws.eea.europa.eu" DEPENDENCIES = "" VOLTO = "alpha" } From e05f0dd0cf782872b4105f3305c7f40ccb69cbb9 Mon Sep 17 00:00:00 2001 From: EEA Jenkins Date: Tue, 22 Nov 2022 18:02:02 +0200 Subject: [PATCH 03/13] Add Sonarqube tag using clms-frontend addons list --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index db3fdc1..54b3e0b 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,prod-www.eea.europa.eu,circularity.eea.europa.eu,forest.eea.europa.eu,demo-kitkat.dev2aws.eea.europa.eu" + SONARQUBE_TAGS = "volto.eea.europa.eu,demo-www.eea.europa.eu,prod-www.eea.europa.eu,circularity.eea.europa.eu,forest.eea.europa.eu,demo-kitkat.dev2aws.eea.europa.eu,clmsdemo.devel6cph.eea.europa.eu" DEPENDENCIES = "" VOLTO = "alpha" } From 440cd71451fd5d5ef0316b5c74b61e66170444a7 Mon Sep 17 00:00:00 2001 From: EEA Jenkins Date: Wed, 23 Nov 2022 15:41:22 +0200 Subject: [PATCH 04/13] Add Sonarqube tag using marine-frontend addons list --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 54b3e0b..5d0ed37 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,prod-www.eea.europa.eu,circularity.eea.europa.eu,forest.eea.europa.eu,demo-kitkat.dev2aws.eea.europa.eu,clmsdemo.devel6cph.eea.europa.eu" + SONARQUBE_TAGS = "volto.eea.europa.eu,demo-www.eea.europa.eu,prod-www.eea.europa.eu,circularity.eea.europa.eu,forest.eea.europa.eu,demo-kitkat.dev2aws.eea.europa.eu,clmsdemo.devel6cph.eea.europa.eu,water.europa.eu-marine" DEPENDENCIES = "" VOLTO = "alpha" } From 8bfd09a161d1d0b3174585c172a3804e56315dea Mon Sep 17 00:00:00 2001 From: Alin Voinea Date: Fri, 25 Nov 2022 15:07:11 +0200 Subject: [PATCH 05/13] yarn 3 --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 00a4d06..04a0cde 100644 --- a/package.json +++ b/package.json @@ -16,10 +16,9 @@ "type": "git", "url": "git@github.com:eea/volto-call-to-action-block.git" }, - "dependencies": {}, "devDependencies": { - "@plone/scripts": "*", "@cypress/code-coverage": "^3.10.0", + "@plone/scripts": "*", "babel-plugin-transform-class-properties": "^6.24.1", "md5": "^2.3.0" }, From fd6b7f31d28e05ed254a32bb213ad662e2635c96 Mon Sep 17 00:00:00 2001 From: EEA Jenkins Date: Fri, 9 Dec 2022 13:47:04 +0200 Subject: [PATCH 06/13] Add Sonarqube tag using bise-frontend addons list --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5d0ed37..79b5552 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,prod-www.eea.europa.eu,circularity.eea.europa.eu,forest.eea.europa.eu,demo-kitkat.dev2aws.eea.europa.eu,clmsdemo.devel6cph.eea.europa.eu,water.europa.eu-marine" + SONARQUBE_TAGS = "volto.eea.europa.eu,demo-www.eea.europa.eu,prod-www.eea.europa.eu,circularity.eea.europa.eu,forest.eea.europa.eu,demo-kitkat.dev2aws.eea.europa.eu,clmsdemo.devel6cph.eea.europa.eu,water.europa.eu-marine,biodiversity.europa.eu" DEPENDENCIES = "" VOLTO = "alpha" } From 4dea10962560c760c2c44db27d3446a4268ded57 Mon Sep 17 00:00:00 2001 From: EEA Jenkins Date: Tue, 13 Dec 2022 14:49:55 +0200 Subject: [PATCH 07/13] Add Sonarqube tag using cca-frontend addons list --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 79b5552..12354bc 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,prod-www.eea.europa.eu,circularity.eea.europa.eu,forest.eea.europa.eu,demo-kitkat.dev2aws.eea.europa.eu,clmsdemo.devel6cph.eea.europa.eu,water.europa.eu-marine,biodiversity.europa.eu" + SONARQUBE_TAGS = "volto.eea.europa.eu,demo-www.eea.europa.eu,prod-www.eea.europa.eu,circularity.eea.europa.eu,forest.eea.europa.eu,demo-kitkat.dev2aws.eea.europa.eu,clmsdemo.devel6cph.eea.europa.eu,water.europa.eu-marine,biodiversity.europa.eu,climate-adapt.eea.europa.eu" DEPENDENCIES = "" VOLTO = "alpha" } From d1ba7b844f114305604e7f8c8b3158746dd59a7b Mon Sep 17 00:00:00 2001 From: Alin Voinea Date: Fri, 16 Dec 2022 17:51:35 +0200 Subject: [PATCH 08/13] test(Jenkins): Run tests and cypress with latest canary @plone/volto --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 12354bc..acaacd4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,7 +6,7 @@ pipeline { NAMESPACE = "@eeacms" SONARQUBE_TAGS = "volto.eea.europa.eu,demo-www.eea.europa.eu,prod-www.eea.europa.eu,circularity.eea.europa.eu,forest.eea.europa.eu,demo-kitkat.dev2aws.eea.europa.eu,clmsdemo.devel6cph.eea.europa.eu,water.europa.eu-marine,biodiversity.europa.eu,climate-adapt.eea.europa.eu" DEPENDENCIES = "" - VOLTO = "alpha" + VOLTO = "" } stages { From 8ff40cc8fb5087bd0f56fbc3e38a26f5d61d63fa Mon Sep 17 00:00:00 2001 From: EEA Jenkins Date: Tue, 20 Dec 2022 16:10:28 +0200 Subject: [PATCH 09/13] Add Sonarqube tag using climate-energy-frontend addons list --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index acaacd4..a86f532 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,prod-www.eea.europa.eu,circularity.eea.europa.eu,forest.eea.europa.eu,demo-kitkat.dev2aws.eea.europa.eu,clmsdemo.devel6cph.eea.europa.eu,water.europa.eu-marine,biodiversity.europa.eu,climate-adapt.eea.europa.eu" + SONARQUBE_TAGS = "volto.eea.europa.eu,demo-www.eea.europa.eu,prod-www.eea.europa.eu,circularity.eea.europa.eu,forest.eea.europa.eu,demo-kitkat.dev2aws.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" DEPENDENCIES = "" VOLTO = "" } From 184e4d527764cbb754398b7c1975268c0eacdc86 Mon Sep 17 00:00:00 2001 From: EEA Jenkins Date: Tue, 20 Dec 2022 16:33:38 +0200 Subject: [PATCH 10/13] Add Sonarqube tag using advisory-board-frontend addons list --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index a86f532..bb85cb1 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,prod-www.eea.europa.eu,circularity.eea.europa.eu,forest.eea.europa.eu,demo-kitkat.dev2aws.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" + SONARQUBE_TAGS = "volto.eea.europa.eu,demo-www.eea.europa.eu,prod-www.eea.europa.eu,circularity.eea.europa.eu,forest.eea.europa.eu,demo-kitkat.dev2aws.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" DEPENDENCIES = "" VOLTO = "" } From e46fb392ba15f9280e1a2d91b38e4acaa3105486 Mon Sep 17 00:00:00 2001 From: EEA Jenkins Date: Mon, 9 Jan 2023 17:42:18 +0200 Subject: [PATCH 11/13] Add Sonarqube tag using advisory-board-frontend addons list --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index bb85cb1..be51ad9 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,prod-www.eea.europa.eu,circularity.eea.europa.eu,forest.eea.europa.eu,demo-kitkat.dev2aws.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" + SONARQUBE_TAGS = "volto.eea.europa.eu,demo-www.eea.europa.eu,prod-www.eea.europa.eu,circularity.eea.europa.eu,forest.eea.europa.eu,demo-kitkat.dev2aws.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" DEPENDENCIES = "" VOLTO = "" } From b80ff96346b62a26d6d7bd5884ef9aad5077d78b Mon Sep 17 00:00:00 2001 From: Alin Voinea Date: Fri, 20 Jan 2023 12:11:04 +0200 Subject: [PATCH 12/13] Add support for mailto: tel:... - refs #159823 (#9) * Copy UrlWidget unchanged from @plone/volto 16.8.1 * feat(CallToAction): Add support for mailto: tel:... - refs #159823 --- package.json | 2 +- src/components/Schema.js | 2 +- src/components/View.jsx | 9 +- src/components/Widget.jsx | 186 ++++++++++++++++++++++++++++++++++++++ src/index.js | 6 ++ 5 files changed, 199 insertions(+), 6 deletions(-) create mode 100644 src/components/Widget.jsx diff --git a/package.json b/package.json index 04a0cde..cb2f4cf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@eeacms/volto-call-to-action-block", - "version": "2.0.0", + "version": "3.0.0", "description": "@eeacms/volto-call-to-action-block: Volto add-on", "main": "src/index.js", "author": "European Environment Agency: IDM2 A-Team", diff --git a/src/components/Schema.js b/src/components/Schema.js index ecd1cf8..a83d48b 100644 --- a/src/components/Schema.js +++ b/src/components/Schema.js @@ -94,7 +94,7 @@ export const EditSchema = ({ intl }) => ({ }, href: { title: intl.formatMessage(messages.Link), - widget: 'object_browser', + widget: 'call_to_action', mode: 'link', selectedItemAttrs: ['Title', 'Description', 'hasPreviewImage'], allowExternals: true, diff --git a/src/components/View.jsx b/src/components/View.jsx index 9176477..e5f5fe9 100644 --- a/src/components/View.jsx +++ b/src/components/View.jsx @@ -35,7 +35,8 @@ const View = ({ data, isEditMode }) => { } }, [isEditMode, data.href]); - const As = hasLink && isInternalURL(data.href[0]['@id']) ? Link : 'a'; + const url = flattenToAppURL(data.href?.[0]?.['@id'] || data.href); + const As = hasLink && isInternalURL(url) ? Link : 'a'; return (
{ : '', data.styles?.theme, )} - href={hasLink ? flattenToAppURL(data.href[0]['@id']) : null} - to={hasLink ? flattenToAppURL(data.href[0]['@id']) : null} - title={hasLink ? data.href[0]['title'] : ''} + href={hasLink ? url : null} + to={hasLink ? url : null} + title={hasLink ? data.text : ''} target={data.target} > diff --git a/src/components/Widget.jsx b/src/components/Widget.jsx new file mode 100644 index 0000000..16ff177 --- /dev/null +++ b/src/components/Widget.jsx @@ -0,0 +1,186 @@ +/** + * CallToActionWidget component. + * @module components/Widget + */ + +import React, { useState } from 'react'; +import { compose } from 'redux'; +import PropTypes from 'prop-types'; +import { Input, Button } from 'semantic-ui-react'; +import { FormFieldWrapper, Icon } from '@plone/volto/components'; +import { + addAppURL, + isInternalURL, + flattenToAppURL, + URLUtils, +} from '@plone/volto/helpers'; +import withObjectBrowser from '@plone/volto/components/manage/Sidebar/ObjectBrowser'; +import clearSVG from '@plone/volto/icons/clear.svg'; +import navTreeSVG from '@plone/volto/icons/nav.svg'; + +/** Widget to edit urls + * + * This is the default widget used for the `remoteUrl` field. You can also use + * it by declaring a field like: + * + * ```jsx + * { + * title: "URL", + * widget: 'url', + * } + * ``` + */ +export const CallToActionWidget = (props) => { + const { + id, + onChange, + onBlur, + onClick, + minLength, + maxLength, + placeholder, + isDisabled, + } = props; + const inputId = `field-${id}`; + + const [value, setValue] = useState( + flattenToAppURL(props.value?.[0]?.['@id'] || props.value), + ); + const [isInvalid, setIsInvalid] = useState(false); + /** + * Clear handler + * @method clear + * @param {Object} value Value + * @returns {undefined} + */ + const clear = () => { + setValue(''); + onChange(id, undefined); + }; + + const onChangeValue = (_value) => { + let newValue = _value; + if (newValue?.length > 0) { + if (isInvalid && URLUtils.isUrl(URLUtils.normalizeUrl(newValue))) { + setIsInvalid(false); + } + + if (isInternalURL(newValue)) { + newValue = flattenToAppURL(newValue); + } + } + + setValue(newValue); + + newValue = isInternalURL(newValue) ? addAppURL(newValue) : newValue; + + if (!isInternalURL(newValue) && newValue.length > 0) { + const checkedURL = URLUtils.checkAndNormalizeUrl(newValue); + newValue = checkedURL.url; + if (!checkedURL.isValid) { + setIsInvalid(true); + } + } + + onChange(id, newValue === '' ? undefined : newValue); + }; + + return ( + +
+ onChangeValue(target.value)} + onBlur={({ target }) => + onBlur(id, target.value === '' ? undefined : target.value) + } + onClick={() => onClick()} + minLength={minLength || null} + maxLength={maxLength || null} + error={isInvalid} + /> + {value?.length > 0 ? ( + + + + ) : ( + + + + )} +
+
+ ); +}; + +/** + * Property types + * @property {Object} propTypes Property types. + * @static + */ +CallToActionWidget.propTypes = { + id: PropTypes.string.isRequired, + title: PropTypes.string.isRequired, + description: PropTypes.string, + required: PropTypes.bool, + error: PropTypes.arrayOf(PropTypes.string), + onChange: PropTypes.func.isRequired, + onBlur: PropTypes.func, + onClick: PropTypes.func, + minLength: PropTypes.number, + maxLength: PropTypes.number, + openObjectBrowser: PropTypes.func.isRequired, + placeholder: PropTypes.string, +}; + +/** + * Default properties. + * @property {Object} defaultProps Default properties. + * @static + */ +CallToActionWidget.defaultProps = { + description: null, + required: false, + error: [], + value: null, + onChange: () => {}, + onBlur: () => {}, + onClick: () => {}, + minLength: null, + maxLength: null, +}; + +export default compose(withObjectBrowser)(CallToActionWidget); diff --git a/src/index.js b/src/index.js index f167686..44a24e7 100644 --- a/src/index.js +++ b/src/index.js @@ -1,11 +1,16 @@ import callToActionSVG from '@plone/volto/icons/circle-right.svg'; import Edit from './components/Edit'; import View from './components/View'; +import Widget from './components/Widget'; import { StylingSchema, EditSchema } from './components/Schema'; import './theme/main.less'; const applyConfig = (config) => { + // Custom Call to Action URL Widget + config.widgets.widget.call_to_action = Widget; + + // Call to Action Block config.blocks.blocksConfig.callToActionBlock = { id: 'callToActionBlock', title: 'Call to Action', @@ -23,6 +28,7 @@ const applyConfig = (config) => { view: [], }, }; + return config; }; From 42cf7f2a54d159aa744e85b011acea72b4f46acc Mon Sep 17 00:00:00 2001 From: EEA Jenkins <@users.noreply.github.com> Date: Tue, 24 Jan 2023 20:34:43 +0000 Subject: [PATCH 13/13] Automated release 3.0.0 --- CHANGELOG.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9298772..545448e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,12 @@ 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.0](https://github.com/eea/volto-call-to-action-block/compare/1.0.0...2.0.0) - 15 November 2022 +### [3.0.0](https://github.com/eea/volto-call-to-action-block/compare/2.0.0...3.0.0) - 24 January 2023 + +#### :hammer_and_wrench: Others + +- 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)] +## [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