From 80e5633bff8265d8d6b5eec78831fdb7955dadd0 Mon Sep 17 00:00:00 2001 From: nileshgulia1 Date: Wed, 24 Jan 2024 15:59:00 +0530 Subject: [PATCH 01/11] fix helpers --- src/helpers.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/helpers.js b/src/helpers.js index 4560ba2..ef71b57 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -2,7 +2,7 @@ import { isArray } from 'lodash'; import Slugger from 'github-slugger'; import config from '@plone/volto/registry'; import { serializeNodes } from '@plone/volto-slate/editor/render'; -import { UniversalLink } from '@plone/volto/components'; +import { Link } from 'react-router-dom'; import { getBlocks } from '@plone/volto/helpers/Blocks/Blocks'; import linkSVG from '@plone/volto/icons/link.svg'; @@ -97,11 +97,11 @@ export const renderLinkElement = (tagName) => { ) : ( {mode === 'view' && slug && ( - + )} {children} From f5d57b697830abba5ed739822dc4379f2a581163 Mon Sep 17 00:00:00 2001 From: valentinab25 Date: Wed, 24 Jan 2024 22:44:46 +0200 Subject: [PATCH 02/11] test: Update jest,Jenkinsfile,lint to volto-addons-template PR30 --- .env | 3 +++ .eslintrc.js | 55 ++++++++++++++++++++++++++++++++++++++++++++ .gitignore | 1 - jest-addon.config.js | 12 ++++++---- package.json | 3 ++- 5 files changed, 68 insertions(+), 6 deletions(-) create mode 100644 .env create mode 100644 .eslintrc.js diff --git a/.env b/.env new file mode 100644 index 0000000..ef282fa --- /dev/null +++ b/.env @@ -0,0 +1,3 @@ +# Jest configuration variables +# - possible values: ON, OFF +JEST_USE_SETUP=OFF \ No newline at end of file diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..b7f17fb --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,55 @@ +const fs = require('fs'); +const path = require('path'); + +const projectRootPath = fs.existsSync('./project') + ? fs.realpathSync('./project') + : fs.realpathSync('./../../../'); +const packageJson = require(path.join(projectRootPath, 'package.json')); +const jsConfig = require(path.join(projectRootPath, 'jsconfig.json')).compilerOptions; + +const pathsConfig = jsConfig.paths; + +let voltoPath = path.join(projectRootPath, 'node_modules/@plone/volto'); + +Object.keys(pathsConfig).forEach(pkg => { + if (pkg === '@plone/volto') { + voltoPath = `./${jsConfig.baseUrl}/${pathsConfig[pkg][0]}`; + } +}); +const AddonConfigurationRegistry = require(`${voltoPath}/addon-registry.js`); +const reg = new AddonConfigurationRegistry(projectRootPath); + +// Extends ESlint configuration for adding the aliases to `src` directories in Volto addons +const addonAliases = Object.keys(reg.packages).map(o => [ + o, + reg.packages[o].modulePath, +]); + + +module.exports = { + extends: `${projectRootPath}/node_modules/@plone/volto/.eslintrc`, + settings: { + 'import/resolver': { + alias: { + map: [ + ['@plone/volto', '@plone/volto/src'], + ...addonAliases, + ['@package', `${__dirname}/src`], + ['~', `${__dirname}/src`], + ], + extensions: ['.js', '.jsx', '.json'], + }, + 'babel-plugin-root-import': { + rootPathSuffix: 'src', + }, + }, + }, + rules: { + 'react/jsx-no-target-blank': [ + 'error', + { + allowReferrer: true, + }, + ], + } +}; diff --git a/.gitignore b/.gitignore index 53b9801..f1be4ff 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ .vscode/ .history -.eslintrc.js .nyc_output project coverage diff --git a/jest-addon.config.js b/jest-addon.config.js index 64d8179..a71273d 100644 --- a/jest-addon.config.js +++ b/jest-addon.config.js @@ -1,3 +1,5 @@ +require('dotenv').config({ path: __dirname + '/.env' }) + module.exports = { testMatch: ['**/src/addons/**/?(*.)+(spec|test).[jt]s?(x)'], collectCoverageFrom: [ @@ -38,7 +40,9 @@ module.exports = { statements: 5, }, }, - setupFilesAfterEnv: [ - '/node_modules/@eeacms/volto-anchors/jest.setup.js', - ], -}; + ...(process.env.JEST_USE_SETUP === 'ON' && { + setupFilesAfterEnv: [ + '/node_modules/@eeacms/volto-anchors/jest.setup.js', + ], + }), +} diff --git a/package.json b/package.json index c34dda0..11bf9d8 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,8 @@ "cypress-fail-fast": "^5.0.1", "husky": "^8.0.3", "lint-staged": "^14.0.1", - "md5": "^2.3.0" + "md5": "^2.3.0", + "dotenv": "^16.3.2" }, "lint-staged": { "src/**/*.{js,jsx,ts,tsx,json}": [ From 9fc360620c0ce329d48815980439dccaa363d31c Mon Sep 17 00:00:00 2001 From: valentinab25 Date: Thu, 25 Jan 2024 20:01:02 +0200 Subject: [PATCH 03/11] test: Update jest,Jenkinsfile,lint to volto-addons-template PR30 --- .eslintrc.js | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index b7f17fb..0cbd65c 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,40 +1,43 @@ const fs = require('fs'); const path = require('path'); - -const projectRootPath = fs.existsSync('./project') - ? fs.realpathSync('./project') - : fs.realpathSync('./../../../'); -const packageJson = require(path.join(projectRootPath, 'package.json')); -const jsConfig = require(path.join(projectRootPath, 'jsconfig.json')).compilerOptions; - -const pathsConfig = jsConfig.paths; +const projectRootPath = fs.realpathSync(__dirname + '/../../../'); let voltoPath = path.join(projectRootPath, 'node_modules/@plone/volto'); +let configFile; +if (fs.existsSync(`${projectRootPath}/tsconfig.json`)) + configFile = `${projectRootPath}/tsconfig.json`; +else if (fs.existsSync(`${projectRootPath}/jsconfig.json`)) + configFile = `${projectRootPath}/jsconfig.json`; + +if (configFile) { + const jsConfig = require(configFile).compilerOptions; + const pathsConfig = jsConfig.paths; + if (pathsConfig['@plone/volto']) + voltoPath = `./${jsConfig.baseUrl}/${pathsConfig['@plone/volto'][0]}`; +} -Object.keys(pathsConfig).forEach(pkg => { - if (pkg === '@plone/volto') { - voltoPath = `./${jsConfig.baseUrl}/${pathsConfig[pkg][0]}`; - } -}); const AddonConfigurationRegistry = require(`${voltoPath}/addon-registry.js`); const reg = new AddonConfigurationRegistry(projectRootPath); // Extends ESlint configuration for adding the aliases to `src` directories in Volto addons -const addonAliases = Object.keys(reg.packages).map(o => [ +const addonAliases = Object.keys(reg.packages).map((o) => [ o, reg.packages[o].modulePath, ]); +const addonExtenders = reg.getEslintExtenders().map((m) => require(m)); -module.exports = { - extends: `${projectRootPath}/node_modules/@plone/volto/.eslintrc`, +const defaultConfig = { + extends: `${voltoPath}/.eslintrc`, settings: { 'import/resolver': { alias: { map: [ ['@plone/volto', '@plone/volto/src'], + ['@plone/volto-slate', '@plone/volto/packages/volto-slate/src'], ...addonAliases, ['@package', `${__dirname}/src`], + ['@root', `${__dirname}/src`], ['~', `${__dirname}/src`], ], extensions: ['.js', '.jsx', '.json'], @@ -53,3 +56,10 @@ module.exports = { ], } }; + +const config = addonExtenders.reduce( + (acc, extender) => extender.modify(acc), + defaultConfig, +); + +module.exports = config; From ea1f44c9ea68ba37877d9213550ba5c4e4cd841e Mon Sep 17 00:00:00 2001 From: valentinab25 Date: Thu, 25 Jan 2024 20:05:41 +0200 Subject: [PATCH 04/11] test: Update jest,Jenkinsfile,lint to volto-addons-template PR30 --- .project.eslintrc.js | 48 -------------------------------------------- 1 file changed, 48 deletions(-) delete mode 100644 .project.eslintrc.js diff --git a/.project.eslintrc.js b/.project.eslintrc.js deleted file mode 100644 index 765070f..0000000 --- a/.project.eslintrc.js +++ /dev/null @@ -1,48 +0,0 @@ -const fs = require('fs'); -const path = require('path'); - -const projectRootPath = fs.existsSync('./project') - ? fs.realpathSync('./project') - : fs.realpathSync('./../../../'); -const packageJson = require(path.join(projectRootPath, 'package.json')); -const jsConfig = require(path.join(projectRootPath, 'jsconfig.json')).compilerOptions; - -const pathsConfig = jsConfig.paths; - -let voltoPath = path.join(projectRootPath, 'node_modules/@plone/volto'); - -Object.keys(pathsConfig).forEach(pkg => { - if (pkg === '@plone/volto') { - voltoPath = `./${jsConfig.baseUrl}/${pathsConfig[pkg][0]}`; - } -}); -const AddonConfigurationRegistry = require(`${voltoPath}/addon-registry.js`); -const reg = new AddonConfigurationRegistry(projectRootPath); - -// Extends ESlint configuration for adding the aliases to `src` directories in Volto addons -const addonAliases = Object.keys(reg.packages).map(o => [ - o, - reg.packages[o].modulePath, -]); - - -module.exports = { - extends: `${projectRootPath}/node_modules/@plone/volto/.eslintrc`, - settings: { - 'import/resolver': { - alias: { - map: [ - ['@plone/volto', '@plone/volto/src'], - ...addonAliases, - ['@package', `${__dirname}/src`], - ['~', `${__dirname}/src`], - ], - extensions: ['.js', '.jsx', '.json'], - }, - 'babel-plugin-root-import': { - rootPathSuffix: 'src', - }, - }, - }, -}; - From 97929a3a3aae2646edabc5b2d973ff869ccc6413 Mon Sep 17 00:00:00 2001 From: Miu Razvan Date: Fri, 26 Jan 2024 11:42:10 +0200 Subject: [PATCH 05/11] set JEST_USE_SETUP=ON --- .env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env b/.env index ef282fa..3d65a40 100644 --- a/.env +++ b/.env @@ -1,3 +1,3 @@ # Jest configuration variables # - possible values: ON, OFF -JEST_USE_SETUP=OFF \ No newline at end of file +JEST_USE_SETUP=ON \ No newline at end of file From 5a9d684bd468cb44a580758b390007ea2414af52 Mon Sep 17 00:00:00 2001 From: David Ichim Date: Fri, 26 Jan 2024 17:56:54 +0200 Subject: [PATCH 06/11] Remove unused target and title attributes from renderLinkElement function --- src/__snapshots__/helpers.test.js.snap | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/__snapshots__/helpers.test.js.snap b/src/__snapshots__/helpers.test.js.snap index 0b2bb7f..70f5e59 100644 --- a/src/__snapshots__/helpers.test.js.snap +++ b/src/__snapshots__/helpers.test.js.snap @@ -11,8 +11,6 @@ exports[`renderLinkElement renders a UniversalLink when mode is set to view 1`] href="/#test" onClick={[Function]} tabIndex={-1} - target={null} - title={null} > Date: Thu, 1 Feb 2024 12:50:46 +0200 Subject: [PATCH 07/11] chore: package.json --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 11bf9d8..ca91935 100644 --- a/package.json +++ b/package.json @@ -24,10 +24,10 @@ "@plone/scripts": "*", "babel-plugin-transform-class-properties": "^6.24.1", "cypress-fail-fast": "^5.0.1", + "dotenv": "^16.3.2", "husky": "^8.0.3", "lint-staged": "^14.0.1", - "md5": "^2.3.0", - "dotenv": "^16.3.2" + "md5": "^2.3.0" }, "lint-staged": { "src/**/*.{js,jsx,ts,tsx,json}": [ From 2da79762d9d64ca92049efcc5c89746f69fde403 Mon Sep 17 00:00:00 2001 From: EEA Jenkins Date: Thu, 1 Feb 2024 20:06:10 +0200 Subject: [PATCH 08/11] Add Sonarqube tag using insitu-frontend addons list --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 51e4275..8ec9dbf 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -8,7 +8,7 @@ pipeline { environment { GIT_NAME = "volto-anchors" NAMESPACE = "@eeacms" - SONARQUBE_TAGS = "volto.eea.europa.eu,demo-www.eea.europa.eu,biodiversity.europa.eu,www.eea.europa.eu-ims,clmsdemo.devel6cph.eea.europa.eu,climate-advisory-board.europa.eu,forest.eea.europa.eu,climate-adapt.eea.europa.eu,www.eea.europa.eu-en,water.europa.eu-marine,industry.eea.europa.eu,climate-energy.eea.europa.eu,water.europa.eu-freshwater,land.copernicus.eu" + SONARQUBE_TAGS = "volto.eea.europa.eu,demo-www.eea.europa.eu,biodiversity.europa.eu,www.eea.europa.eu-ims,clmsdemo.devel6cph.eea.europa.eu,climate-advisory-board.europa.eu,forest.eea.europa.eu,climate-adapt.eea.europa.eu,www.eea.europa.eu-en,water.europa.eu-marine,industry.eea.europa.eu,climate-energy.eea.europa.eu,water.europa.eu-freshwater,land.copernicus.eu,insitu-frontend.eionet.europa.eu" DEPENDENCIES = "" BACKEND_PROFILES = "eea.kitkat:testing" BACKEND_ADDONS = "" From d9316ae298746df976d9053f6a9ea708ac870483 Mon Sep 17 00:00:00 2001 From: Razvan Date: Fri, 16 Feb 2024 17:19:00 +0200 Subject: [PATCH 09/11] fix(toc): make it work, refs #265201 --- .../volto-slate/blocks/Text/TextBlockView.jsx | 2 +- .../manage/Blocks/ToC/variations/index.js | 18 ++++++++++++++++++ src/index.js | 6 ++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 src/customizations/volto/components/manage/Blocks/ToC/variations/index.js diff --git a/src/customizations/@plone/volto-slate/blocks/Text/TextBlockView.jsx b/src/customizations/@plone/volto-slate/blocks/Text/TextBlockView.jsx index a21753a..b929693 100644 --- a/src/customizations/@plone/volto-slate/blocks/Text/TextBlockView.jsx +++ b/src/customizations/@plone/volto-slate/blocks/Text/TextBlockView.jsx @@ -16,7 +16,7 @@ const TextBlockView = (props) => { const res = { ...styling }; if (node.type && isEqual(path, [0])) { if (topLevelTargetElements.includes(node.type) || override_toc) { - const text = serializeNodesToText(node?.children || []); + const text = serializeNodesToText([node] || []); const slug = Slugger.slug(text); res.id = slug || id; res['data-block'] = id; diff --git a/src/customizations/volto/components/manage/Blocks/ToC/variations/index.js b/src/customizations/volto/components/manage/Blocks/ToC/variations/index.js new file mode 100644 index 0000000..ca49592 --- /dev/null +++ b/src/customizations/volto/components/manage/Blocks/ToC/variations/index.js @@ -0,0 +1,18 @@ +import DefaultTocRenderer from './DefaultTocRenderer'; +import HorizontalMenu from './HorizontalMenu'; + +const ToCVariations = [ + { + id: 'default', + title: 'Listing (default)', + view: DefaultTocRenderer, + isDefault: true, + }, + { + id: 'horizontalMenu', + title: 'Horizontal Menu', + view: HorizontalMenu, + }, +]; + +export default ToCVariations; diff --git a/src/index.js b/src/index.js index 424227b..df80c5b 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,6 @@ import ScrollToAnchor from './components/ScrollToAnchor'; import { renderLinkElement } from './helpers'; +import tocVariations from './customizations/volto/components/manage/Blocks/ToC/variations'; const applyConfig = (config) => { config.settings.slate.useLinkedHeadings = true; @@ -20,6 +21,11 @@ const applyConfig = (config) => { }, ]; } + + config.blocks.blocksConfig.toc = { + ...config.blocks.blocksConfig.toc, + variations: tocVariations, + }; return config; }; From db8e899b29c5ffbe5169d867a3a64af5ee663a22 Mon Sep 17 00:00:00 2001 From: Razvan Date: Fri, 16 Feb 2024 17:19:20 +0200 Subject: [PATCH 10/11] bump version --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ca91935..8112025 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@eeacms/volto-anchors", - "version": "0.5.0", + "version": "0.6.0", "description": "@eeacms/volto-anchors: Volto add-on", "main": "src/index.js", "author": "European Environment Agency: IDM2 A-Team", @@ -70,4 +70,4 @@ "cypress:open": "make cypress-open", "prepare": "husky install" } -} +} \ No newline at end of file From e9e2bbf9455af0f8165fc74de2b3d2d94bbe8e19 Mon Sep 17 00:00:00 2001 From: EEA Jenkins <@users.noreply.github.com> Date: Fri, 16 Feb 2024 15:29:26 +0000 Subject: [PATCH 11/11] Automated release 0.6.0 --- CHANGELOG.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 76f7d59..9a0827e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,25 @@ 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). +### [0.6.0](https://github.com/eea/volto-anchors/compare/0.5.0...0.6.0) - 16 February 2024 + +#### :bug: Bug Fixes + +- fix(toc): make it work, refs #265201 [Razvan - [`d9316ae`](https://github.com/eea/volto-anchors/commit/d9316ae298746df976d9053f6a9ea708ac870483)] + +#### :house: Internal changes + +- chore: package.json [Alin Voinea - [`1bed96f`](https://github.com/eea/volto-anchors/commit/1bed96f3fb4a4a2ad7dd5621822ce9729b4e7683)] + +#### :hammer_and_wrench: Others + +- bump version [Razvan - [`db8e899`](https://github.com/eea/volto-anchors/commit/db8e899b29c5ffbe5169d867a3a64af5ee663a22)] +- Remove unused target and title attributes from renderLinkElement function [David Ichim - [`5a9d684`](https://github.com/eea/volto-anchors/commit/5a9d684bd468cb44a580758b390007ea2414af52)] +- set JEST_USE_SETUP=ON [Miu Razvan - [`97929a3`](https://github.com/eea/volto-anchors/commit/97929a3a3aae2646edabc5b2d973ff869ccc6413)] +- test: Update jest,Jenkinsfile,lint to volto-addons-template PR30 [valentinab25 - [`ea1f44c`](https://github.com/eea/volto-anchors/commit/ea1f44c9ea68ba37877d9213550ba5c4e4cd841e)] +- test: Update jest,Jenkinsfile,lint to volto-addons-template PR30 [valentinab25 - [`9fc3606`](https://github.com/eea/volto-anchors/commit/9fc360620c0ce329d48815980439dccaa363d31c)] +- test: Update jest,Jenkinsfile,lint to volto-addons-template PR30 [valentinab25 - [`f5d57b6`](https://github.com/eea/volto-anchors/commit/f5d57b697830abba5ed739822dc4379f2a581163)] +- fix helpers [nileshgulia1 - [`80e5633`](https://github.com/eea/volto-anchors/commit/80e5633bff8265d8d6b5eec78831fdb7955dadd0)] ### [0.5.0](https://github.com/eea/volto-anchors/compare/0.4.2...0.5.0) - 17 January 2024 #### :house: Internal changes @@ -13,7 +32,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). #### :hammer_and_wrench: Others -- Release 0.5.0 [Alin Voinea - [`7ce0db5`](https://github.com/eea/volto-anchors/commit/7ce0db50c0a6a75486560f66b15ee5ef70e545e3)] - fix tests [Miu Razvan - [`1777cba`](https://github.com/eea/volto-anchors/commit/1777cba0d12a7828c90a447f6076f5feed8db6b0)] - fix jest [Miu Razvan - [`56d727a`](https://github.com/eea/volto-anchors/commit/56d727a2d276daa49df0733e66ab0f8b5b163620)] - fix jest [Miu Razvan - [`8f2fd76`](https://github.com/eea/volto-anchors/commit/8f2fd76d21e59dab6136e59ae054f6ecaa8eb8c8)]