From da1cf7d96f01e677293eeba2602804727a360571 Mon Sep 17 00:00:00 2001 From: valentinab25 Date: Thu, 1 Jun 2023 12:20:03 +0300 Subject: [PATCH 1/5] chore: [JENKINS] Deprecate circularity website --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6d85c2d..f34502f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,7 +4,7 @@ pipeline { environment { GIT_NAME = "volto-object-widget" NAMESPACE = "@eeacms" - SONARQUBE_TAGS = "volto.eea.europa.eu,forest.eea.europa.eu,biodiversity.europa.eu,www.eea.europa.eu-ims,climate-energy.eea.europa.eu,sustainability.eionet.europa.eu,clms.land.copernicus.eu,industry.eea.europa.eu,water.europa.eu-freshwater,demo-www.eea.europa.eu,clmsdemo.devel6cph.eea.europa.eu,circularity.eea.europa.eu,water.europa.eu-marine,climate-adapt.eea.europa.eu,climate-advisory-board.devel4cph.eea.europa.eu,climate-advisory-board.europa.eu,www.eea.europa.eu-en" + SONARQUBE_TAGS = "volto.eea.europa.eu,forest.eea.europa.eu,biodiversity.europa.eu,www.eea.europa.eu-ims,climate-energy.eea.europa.eu,sustainability.eionet.europa.eu,clms.land.copernicus.eu,industry.eea.europa.eu,water.europa.eu-freshwater,demo-www.eea.europa.eu,clmsdemo.devel6cph.eea.europa.eu,water.europa.eu-marine,climate-adapt.eea.europa.eu,climate-advisory-board.devel4cph.eea.europa.eu,climate-advisory-board.europa.eu,www.eea.europa.eu-en" DEPENDENCIES = "" VOLTO = "" } From 62fb1d01ea85cab458e496ecb011f114d9ffa88a Mon Sep 17 00:00:00 2001 From: dobri1408 <50819975+dobri1408@users.noreply.github.com> Date: Thu, 1 Jun 2023 18:48:02 +0300 Subject: [PATCH 2/5] feat: File picker object browser - refs #253430 --- src/Widget/AttachedFileWidget.jsx | 206 ++++++++++++++++++++++++++++++ src/Widget/index.js | 1 + src/Widget/style.css | 9 ++ src/index.js | 3 + 4 files changed, 219 insertions(+) create mode 100644 src/Widget/AttachedFileWidget.jsx diff --git a/src/Widget/AttachedFileWidget.jsx b/src/Widget/AttachedFileWidget.jsx new file mode 100644 index 0000000..f6f1a81 --- /dev/null +++ b/src/Widget/AttachedFileWidget.jsx @@ -0,0 +1,206 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { Button, Dimmer, Input } from 'semantic-ui-react'; +import { readAsDataURL } from 'promise-file-reader'; +import { injectIntl } from 'react-intl'; +import deleteSVG from '@plone/volto/icons/delete.svg'; +import { Icon, FormFieldWrapper } from '@plone/volto/components'; +import loadable from '@loadable/component'; +import { flattenToAppURL, isInternalURL } from '@plone/volto/helpers'; +import { useSelector } from 'react-redux'; +import withObjectBrowser from '@plone/volto/components/manage/Sidebar/ObjectBrowser'; +import { defineMessages, useIntl } from 'react-intl'; +import navTreeSVG from '@plone/volto/icons/nav.svg'; +import aheadSVG from '@plone/volto/icons/ahead.svg'; +import './style.css'; + +const Dropzone = loadable(() => import('react-dropzone')); + +const messages = defineMessages({ + dragOrUpload: { + id: 'Drop files here or click to upload', + defaultMessage: 'Drop files here or click to upload', + }, + editFile: { + id: 'Drop files here or click to upload', + defaultMessage: 'Drop files here or click to upload', + }, + FilePickerWidgetInputPlaceholder: { + id: 'Browse the site', + defaultMessage: 'Browse the site', + }, +}); + +const FileWidget = (props) => { + const { id, value, onChange, isDisabled, openObjectBrowser } = props; + const [nameOfFile, setNameOfFile] = React.useState(''); + const intl = useIntl(); + const [url, setUrl] = React.useState( + typeof props.value === 'string' ? props.value : '', + ); + const placeholder = + props.placeholder || + intl.formatMessage(messages.FilePickerWidgetInputPlaceholder); + const pathname = useSelector((state) => state.router.location.pathname); + + /** + * Submit url handler + * @method onSubmitUrl + * @param {object} e Event + * @returns {undefined} + */ + const onSubmitUrl = () => { + onChange(id, flattenToAppURL(url)); + }; + + const onChangeUrl = ({ target }) => { + setUrl(target.value); + }; + + /** + * Drop handler + * @method onDrop + * @param {array} files File objects + * @returns {undefined} + */ + const onDrop = (files) => { + const file = files[0]; + readAsDataURL(file).then((data) => { + const fields = data.match(/^data:(.*);(.*),(.*)$/); + onChange(id, { + data: fields[3], + encoding: fields[2], + 'content-type': fields[1], + filename: file.name, + }); + }); + let reader = new FileReader(); + reader.readAsDataURL(files[0]); + }; + + React.useEffect(() => { + if (typeof value === 'string' && isInternalURL(value)) { + setNameOfFile(value.split('/').at(-1)); + } else if (value) setNameOfFile(value.filename); + }, [value]); + + return ( + + {value !== undefined && value !== null ? ( +
+ {nameOfFile} + +
+ ) : ( + <> + + {({ getRootProps, getInputProps, isDragActive }) => ( + <> +
+ {isDragActive && } + +
+

+ {intl.formatMessage(messages.dragOrUpload)} +

+ +
+
+ + )} +
+
+ + + + + +
+ + )} +
+ ); +}; + +/** + * Property types. + * @property {Object} propTypes Property types. + * @static + */ +FileWidget.propTypes = { + id: PropTypes.string.isRequired, + title: PropTypes.string.isRequired, + description: PropTypes.string, + required: PropTypes.bool, + error: PropTypes.arrayOf(PropTypes.string), + onChange: PropTypes.func.isRequired, + wrapped: PropTypes.bool, + openObjectBrowser: PropTypes.func.isRequired, + value: PropTypes.any, +}; + +/** + * Default properties. + * @property {Object} defaultProps Default properties. + * @static + */ +FileWidget.defaultProps = { + description: null, + required: false, + error: [], + value: null, +}; + +export default withObjectBrowser(injectIntl(FileWidget)); diff --git a/src/Widget/index.js b/src/Widget/index.js index 90c699f..dd2e0e4 100644 --- a/src/Widget/index.js +++ b/src/Widget/index.js @@ -4,3 +4,4 @@ export ObjectListInlineWidget from './ObjectListInlineWidget'; export ObjectByTypeWidget from './ObjectByTypeWidget'; export MappingWidget from './MappingWidget'; export ObjectTypesWidget from './ObjectTypesWidget'; +export AttachedFileWidget from './AttachedFileWidget'; diff --git a/src/Widget/style.css b/src/Widget/style.css index 8d92d85..c9d30f4 100644 --- a/src/Widget/style.css +++ b/src/Widget/style.css @@ -8,6 +8,15 @@ } } +.file-picker-toolbar { + display: flex; + justify-content: space-between; +} + +.input-toolbar { + width: 60% !important; +} + .field-just-changed { animation: field-just-changed-anim 0.5s; } diff --git a/src/index.js b/src/index.js index f50b338..b27b5d4 100644 --- a/src/index.js +++ b/src/index.js @@ -4,6 +4,7 @@ import { ObjectListInlineWidget, ObjectByTypeWidget, MappingWidget, + AttachedFileWidget, ObjectTypesWidget, } from './Widget'; @@ -13,6 +14,7 @@ export { ObjectByTypeWidget, MappingWidget, ObjectTypesWidget, + AttachedFileWidget, } from './Widget'; export installDemo from './demo'; @@ -24,6 +26,7 @@ const applyConfig = (config) => { config.widgets.widget.object_by_type = ObjectByTypeWidget; config.widgets.widget.option_mapping = MappingWidget; config.widgets.widget.attachedimage = AttachedImageWidget; + config.widgets.widget.attachedfile = AttachedFileWidget; config.widgets.widget.object_types_widget = ObjectTypesWidget; } From 12f23fc78fffd8ffde62f24321022d20fd704725 Mon Sep 17 00:00:00 2001 From: valentinab25 Date: Thu, 8 Jun 2023 20:48:57 +0300 Subject: [PATCH 3/5] test: Fix test config, coverage Refs #253277 --- Jenkinsfile | 1 + jest-addon.config.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index f34502f..f2537cc 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -188,6 +188,7 @@ pipeline { 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''' } diff --git a/jest-addon.config.js b/jest-addon.config.js index da38318..e23a6c3 100644 --- a/jest-addon.config.js +++ b/jest-addon.config.js @@ -5,6 +5,7 @@ module.exports = { '!src/**/*.d.ts', ], moduleNameMapper: { + '\\.(css|less|scss|sass)$': 'identity-obj-proxy', '@plone/volto/cypress': '/node_modules/@plone/volto/cypress', '@plone/volto/babel': '/node_modules/@plone/volto/babel', '@plone/volto/(.*)$': '/node_modules/@plone/volto/src/$1', @@ -17,7 +18,6 @@ module.exports = { '~/(.*)$': '/src/$1', 'load-volto-addons': '/node_modules/@plone/volto/jest-addons-loader.js', - '\\.(css|less|scss|sass)$': 'identity-obj-proxy', }, transform: { '^.+\\.js(x)?$': 'babel-jest', From 6a639c5917f66e6addb614d629988b195cda4ad7 Mon Sep 17 00:00:00 2001 From: valentinab25 Date: Fri, 9 Jun 2023 20:36:36 +0300 Subject: [PATCH 4/5] test: jest should look for addons in node_modules Refs #253277 --- jest-addon.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jest-addon.config.js b/jest-addon.config.js index e23a6c3..3c86610 100644 --- a/jest-addon.config.js +++ b/jest-addon.config.js @@ -12,7 +12,7 @@ module.exports = { '@package/(.*)$': '/src/$1', '@root/(.*)$': '/src/$1', '@plone/volto-quanta/(.*)$': '/src/addons/volto-quanta/src/$1', - '@eeacms/(.*?)/(.*)$': '/src/addons/$1/src/$2', + '@eeacms/(.*?)/(.*)$': '/node_modules/@eeacms/$1/src/$2', '@plone/volto-slate': '/node_modules/@plone/volto/packages/volto-slate/src', '~/(.*)$': '/src/$1', From 8eb406446bd8b7651d0aab70ea5bcdd2d1b8065a Mon Sep 17 00:00:00 2001 From: EEA Jenkins <@users.noreply.github.com> Date: Mon, 12 Jun 2023 17:33:51 +0000 Subject: [PATCH 5/5] Automated release 5.1.2 --- CHANGELOG.md | 35 +++++++++++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 549fe31..be471bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,20 @@ 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). +### [5.1.2](https://github.com/eea/volto-object-widget/compare/5.1.1...5.1.2) - 12 June 2023 + +#### :rocket: New Features + +- feat: File picker object browser - refs #253430 [dobri1408 - [`62fb1d0`](https://github.com/eea/volto-object-widget/commit/62fb1d01ea85cab458e496ecb011f114d9ffa88a)] + +#### :house: Internal changes + +- chore: [JENKINS] Deprecate circularity website [valentinab25 - [`da1cf7d`](https://github.com/eea/volto-object-widget/commit/da1cf7d96f01e677293eeba2602804727a360571)] + +#### :hammer_and_wrench: Others + +- test: jest should look for addons in node_modules Refs #253277 [valentinab25 - [`6a639c5`](https://github.com/eea/volto-object-widget/commit/6a639c5917f66e6addb614d629988b195cda4ad7)] +- test: Fix test config, coverage Refs #253277 [valentinab25 - [`12f23fc`](https://github.com/eea/volto-object-widget/commit/12f23fc78fffd8ffde62f24321022d20fd704725)] ### [5.1.1](https://github.com/eea/volto-object-widget/compare/5.1.0...5.1.1) - 26 April 2023 #### :rocket: New Features @@ -20,11 +34,19 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - * version [andreiggr - [`052c684`](https://github.com/eea/volto-object-widget/commit/052c684180dd1f46af435e4cbc9e7e8641abebe7)] - Revert changes on AttachedImageWidget [Miu Razvan - [`88eafeb`](https://github.com/eea/volto-object-widget/commit/88eafeb363f495faae7d915aa1f8867c86a5f1d6)] - Revert fc658b5 [Miu Razvan - [`669d06f`](https://github.com/eea/volto-object-widget/commit/669d06f8b8856599feab29f96981eb67e21dc2b0)] +- Revert "Add Sonarqube tag using eea-website-frontend addons list" [Miu Razvan - [`fc658b5`](https://github.com/eea/volto-object-widget/commit/fc658b5291c1c4fdebd21da609463f85841b38ce)] +- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`45e4f91`](https://github.com/eea/volto-object-widget/commit/45e4f9134390f4ee2f1636edc17320365d2f13d7)] ### [5.1.0](https://github.com/eea/volto-object-widget/compare/5.0.1...5.1.0) - 27 March 2023 #### :hammer_and_wrench: Others +- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`38ae79f`](https://github.com/eea/volto-object-widget/commit/38ae79f2d63a0240885a9685ce9a0e5f698ef957)] +- Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`ea09d1e`](https://github.com/eea/volto-object-widget/commit/ea09d1ec24dc6e46c79d57d8b90f2b943e3b41e3)] +- Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`48e235e`](https://github.com/eea/volto-object-widget/commit/48e235e0a1f3aa6fcf6fe6b8021cbf57d89f3bff)] - test(Jenkins): Run tests and cypress with latest canary @plone/volto [Alin Voinea - [`33ab4d9`](https://github.com/eea/volto-object-widget/commit/33ab4d94a61939763e245c721acc9c300e8deba6)] +- Add Sonarqube tag using cca-frontend addons list [EEA Jenkins - [`e95a916`](https://github.com/eea/volto-object-widget/commit/e95a91628659c5447ceea8668162109ac10a67ff)] +- yarn 3 [Alin Voinea - [`aabc72c`](https://github.com/eea/volto-object-widget/commit/aabc72cb720dced56f7888bfaaf6d9b7668392b8)] +- Add Sonarqube tag using demo-kitkat-frontend addons list [EEA Jenkins - [`bcbaa9e`](https://github.com/eea/volto-object-widget/commit/bcbaa9e6644bdd53cf9d269ef9eede823706d2ae)] ### [5.0.1](https://github.com/eea/volto-object-widget/compare/5.0.0...5.0.1) - 16 November 2022 #### :hammer_and_wrench: Others @@ -39,11 +61,14 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - Typo [Miu Razvan - [`0eac194`](https://github.com/eea/volto-object-widget/commit/0eac194761c04db9807ca63381b25c13c7a854bd)] - Prepare 5.0.0 release [Miu Razvan - [`2a12c37`](https://github.com/eea/volto-object-widget/commit/2a12c377a7bf5a1a51966ab1e1c867f1b55ccb95)] - Update babel & jest config [Miu Razvan - [`8269b4a`](https://github.com/eea/volto-object-widget/commit/8269b4ac4aa9d487579b35ff41d0fea9dce5fc45)] +- Add Sonarqube tag using marine-frontend addons list [EEA Jenkins - [`2b550d7`](https://github.com/eea/volto-object-widget/commit/2b550d76313569397fda8967147e0052176f823e)] +- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`08aa211`](https://github.com/eea/volto-object-widget/commit/08aa211cdfa1b48817a4af6a21c3b033ef6642ea)] - update(jest): add @plone/volto-slate resolver refs- #153447 [nileshgulia1 - [`6963a87`](https://github.com/eea/volto-object-widget/commit/6963a87a0c84910c0ef695652d944115d487b24e)] ### [4.0.2](https://github.com/eea/volto-object-widget/compare/4.0.1...4.0.2) - 30 June 2022 #### :hammer_and_wrench: Others +- Add Sonarqube tag using circularity-frontend addons list [EEA Jenkins - [`f7e9285`](https://github.com/eea/volto-object-widget/commit/f7e928506f881dcf6bcd5f1bd5897148af2c4c38)] ### [4.0.1](https://github.com/eea/volto-object-widget/compare/4.0.0...4.0.1) - 20 May 2022 ## [4.0.0](https://github.com/eea/volto-object-widget/compare/3.0.3...4.0.0) - 19 May 2022 @@ -57,23 +82,33 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - Release 4.0.0 [Alin Voinea - [`553e4ab`](https://github.com/eea/volto-object-widget/commit/553e4ab8b5888a2af43dcaf8be6d955cc3949513)] - Improved style for attached image widget [Miu Razvan - [`8c770cd`](https://github.com/eea/volto-object-widget/commit/8c770cdeb6af776208bd9a3936f33f5370d70fd7)] - Release 3.1.0 [Alin Voinea - [`61dd13b`](https://github.com/eea/volto-object-widget/commit/61dd13b20b2e00305af00b762e3e4d734a03cf0d)] +- Add Sonarqube tag using clms-frontend addons list [EEA Jenkins - [`0912594`](https://github.com/eea/volto-object-widget/commit/09125945f04192d8af200c6828c9388a29f4e8ff)] +- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`beb8f0b`](https://github.com/eea/volto-object-widget/commit/beb8f0ba5091911428b885e39b2bcdcdf390104c)] ### [3.0.3](https://github.com/eea/volto-object-widget/compare/3.0.2...3.0.3) - 3 January 2022 ### [3.0.2](https://github.com/eea/volto-object-widget/compare/3.0.1...3.0.2) - 18 December 2021 #### :hammer_and_wrench: Others +- Add Sonarqube tag using freshwater-frontend addons list [EEA Jenkins - [`5f6c212`](https://github.com/eea/volto-object-widget/commit/5f6c212134fee7d1096c9733e215a517d9842279)] ### [3.0.1](https://github.com/eea/volto-object-widget/compare/3.0.0...3.0.1) - 10 December 2021 #### :hammer_and_wrench: Others - Refs #142010 - Optimize Volto-addons gitflow pipelines [valentinab25 - [`0598f50`](https://github.com/eea/volto-object-widget/commit/0598f50fd11e720e3b78d039987d92580ad6c7d6)] +- Add Sonarqube tag using industry-frontend addons list [EEA Jenkins - [`0eb9ee2`](https://github.com/eea/volto-object-widget/commit/0eb9ee20b47872dcd13fbd016443226968b93e6b)] +- Add Sonarqube tag using clms-frontend addons list [EEA Jenkins - [`da90a9b`](https://github.com/eea/volto-object-widget/commit/da90a9bcd52894ca8e2303e9f4d6f39f6e7c727a)] +- Add Sonarqube tag using sustainability-frontend addons list [EEA Jenkins - [`b9f9262`](https://github.com/eea/volto-object-widget/commit/b9f9262a51f8c7b21081ed7a3c471ed1f54d600d)] +- Add Sonarqube tag using climate-energy-frontend addons list [EEA Jenkins - [`5374fa5`](https://github.com/eea/volto-object-widget/commit/5374fa5d6fb973c1534d1608a623f1e0a1ec5266)] +- Add Sonarqube tag using ims-frontend addons list [EEA Jenkins - [`c954416`](https://github.com/eea/volto-object-widget/commit/c9544161ee8717e6568535527d720f884347160c)] ## [3.0.0](https://github.com/eea/volto-object-widget/compare/2.2.3...3.0.0) - 3 September 2021 #### :hammer_and_wrench: Others - Fix ObjectListWidget tests [Alin Voinea - [`149c3ae`](https://github.com/eea/volto-object-widget/commit/149c3aee0fe40c5a80d58cc8a12bd1b67a66366f)] - Remove DEPRECATED ObjectWidget. Moved to Volto core. [Alin Voinea - [`415e7a9`](https://github.com/eea/volto-object-widget/commit/415e7a91652d7fc68e0c0dd6648f9bc5a50170f9)] +- Add Sonarqube tag using frontend addons list [EEA Jenkins - [`49e4e6e`](https://github.com/eea/volto-object-widget/commit/49e4e6e6376bbacbf657925811ae087da3bd2d30)] +- Add Sonarqube tag using frontend addons list [EEA Jenkins - [`4c3c118`](https://github.com/eea/volto-object-widget/commit/4c3c118290cbd25432111c60090f6aade1bac1d2)] ### [2.2.3](https://github.com/eea/volto-object-widget/compare/2.2.2...2.2.3) - 4 June 2021 #### :hammer_and_wrench: Others diff --git a/package.json b/package.json index 7faec3d..ab1b001 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@eeacms/volto-object-widget", - "version": "5.1.1", + "version": "5.1.2", "description": "volto-object-widget: Volto add-on", "main": "src/index.js", "author": "European Environment Agency: IDM2 A-Team",