@eeacms/volto-widget-toggle 3.1.4 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.eslintrc.js ADDED
@@ -0,0 +1,65 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const projectRootPath = fs.realpathSync(__dirname + '/../../../');
4
+
5
+ let voltoPath = path.join(projectRootPath, 'node_modules/@plone/volto');
6
+ let configFile;
7
+ if (fs.existsSync(`${projectRootPath}/tsconfig.json`))
8
+ configFile = `${projectRootPath}/tsconfig.json`;
9
+ else if (fs.existsSync(`${projectRootPath}/jsconfig.json`))
10
+ configFile = `${projectRootPath}/jsconfig.json`;
11
+
12
+ if (configFile) {
13
+ const jsConfig = require(configFile).compilerOptions;
14
+ const pathsConfig = jsConfig.paths;
15
+ if (pathsConfig['@plone/volto'])
16
+ voltoPath = `./${jsConfig.baseUrl}/${pathsConfig['@plone/volto'][0]}`;
17
+ }
18
+
19
+ const AddonConfigurationRegistry = require(`${voltoPath}/addon-registry.js`);
20
+ const reg = new AddonConfigurationRegistry(projectRootPath);
21
+
22
+ // Extends ESlint configuration for adding the aliases to `src` directories in Volto addons
23
+ const addonAliases = Object.keys(reg.packages).map((o) => [
24
+ o,
25
+ reg.packages[o].modulePath,
26
+ ]);
27
+
28
+ const addonExtenders = reg.getEslintExtenders().map((m) => require(m));
29
+
30
+ const defaultConfig = {
31
+ extends: `${voltoPath}/.eslintrc`,
32
+ settings: {
33
+ 'import/resolver': {
34
+ alias: {
35
+ map: [
36
+ ['@plone/volto', '@plone/volto/src'],
37
+ ['@plone/volto-slate', '@plone/volto/packages/volto-slate/src'],
38
+ ...addonAliases,
39
+ ['@package', `${__dirname}/src`],
40
+ ['@root', `${__dirname}/src`],
41
+ ['~', `${__dirname}/src`],
42
+ ],
43
+ extensions: ['.js', '.jsx', '.json'],
44
+ },
45
+ 'babel-plugin-root-import': {
46
+ rootPathSuffix: 'src',
47
+ },
48
+ },
49
+ },
50
+ rules: {
51
+ 'react/jsx-no-target-blank': [
52
+ 'error',
53
+ {
54
+ allowReferrer: true,
55
+ },
56
+ ],
57
+ }
58
+ };
59
+
60
+ const config = addonExtenders.reduce(
61
+ (acc, extender) => extender.modify(acc),
62
+ defaultConfig,
63
+ );
64
+
65
+ module.exports = config;
package/CHANGELOG.md CHANGED
@@ -4,6 +4,19 @@ All notable changes to this project will be documented in this file. Dates are d
4
4
 
5
5
  Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
6
6
 
7
+ ### [4.0.0](https://github.com/eea/volto-widget-toggle/compare/3.1.4...4.0.0) - 22 April 2024
8
+
9
+ #### :rocket: New Features
10
+
11
+ - feat: Release 4.0.0 - Volto 17 support [alin - [`b1db508`](https://github.com/eea/volto-widget-toggle/commit/b1db5088cca5e0a580b97a00836365e8b2c39921)]
12
+ - feat: Volto 17 support - refs #264527 [EEA Jenkins - [`06fd934`](https://github.com/eea/volto-widget-toggle/commit/06fd9344ec36b88810c16288030bf91ce1a854a8)]
13
+
14
+ #### :house: Internal changes
15
+
16
+ - chore: husky, lint-staged use fixed versions [valentinab25 - [`78c47fe`](https://github.com/eea/volto-widget-toggle/commit/78c47fea7a704d1addd796ac5f515d262379da92)]
17
+
18
+ #### :hammer_and_wrench: Others
19
+
7
20
  ### [3.1.4](https://github.com/eea/volto-widget-toggle/compare/3.1.3...3.1.4) - 16 October 2023
8
21
 
9
22
  #### :house: Internal changes
@@ -28,7 +41,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
28
41
 
29
42
  - test: EN locales, pre-commit fix, feature PRs checks Refs #257193 [valentinab25 - [`b2f509e`](https://github.com/eea/volto-widget-toggle/commit/b2f509eb236e0beeccfc8bc89f4c6527a3fca223)]
30
43
  - test: Fix package.json scripts to use makefile [Alin Voinea - [`72e8245`](https://github.com/eea/volto-widget-toggle/commit/72e8245a4741988849eaa73e5fd238ff6d340fa9)]
31
- - test: Fix eslint and yarn i18n [Alin Voinea - [`034eaf8`](https://github.com/eea/volto-widget-toggle/commit/034eaf890faa3a9c09aa6f4ddca1bc04e46782a8)]
32
44
  - i18n: Add en [Alin Voinea - [`e60d799`](https://github.com/eea/volto-widget-toggle/commit/e60d799a64230544e37e1f4796dc73bbc0e674c6)]
33
45
  - test: Update Makefile and docker-compose to align it with Jenkinsfile [valentinab25 - [`f86b2f7`](https://github.com/eea/volto-widget-toggle/commit/f86b2f7119f24b637e8bc8101effc2c2c3416a65)]
34
46
  ### [3.1.2](https://github.com/eea/volto-widget-toggle/compare/3.1.1...3.1.2) - 24 July 2023
@@ -39,20 +51,11 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
39
51
 
40
52
  - test: jest should look for addons in node_modules Refs #253277 [valentinab25 - [`da228a9`](https://github.com/eea/volto-widget-toggle/commit/da228a925ea784b4b418f37ea07418de87759670)]
41
53
  - test: Fix test config, coverage Refs #253277 [valentinab25 - [`b4f3492`](https://github.com/eea/volto-widget-toggle/commit/b4f3492448826968dfbb979fad00f0b65d644017)]
42
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`08bfec1`](https://github.com/eea/volto-widget-toggle/commit/08bfec176ebdf6dff13a7db969a73ca9d8415ee8)]
43
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`1324cce`](https://github.com/eea/volto-widget-toggle/commit/1324cceab3305bf02ab2004a4ff77d492f44481e)]
44
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`13d684d`](https://github.com/eea/volto-widget-toggle/commit/13d684daf218103723779a470ff3dc7f101e93c1)]
45
54
  ### [3.1.0](https://github.com/eea/volto-widget-toggle/compare/3.0.1...3.1.0) - 27 March 2023
46
55
 
47
56
  #### :hammer_and_wrench: Others
48
57
 
49
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`11a80c7`](https://github.com/eea/volto-widget-toggle/commit/11a80c7ce1f66aa0c7ec600c626875ab7ac8c1cb)]
50
- - Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`c353ca1`](https://github.com/eea/volto-widget-toggle/commit/c353ca1794b99b2e5f6681ad93ab844ef33e117e)]
51
- - Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`143e5be`](https://github.com/eea/volto-widget-toggle/commit/143e5be8400af60658baa34a7934f707df121f83)]
52
58
  - test(Jenkins): Run tests and cypress with latest canary @plone/volto [Alin Voinea - [`c658d9f`](https://github.com/eea/volto-widget-toggle/commit/c658d9f0fc0fc6cc4b26041b79c93c0982b152c5)]
53
- - Add Sonarqube tag using cca-frontend addons list [EEA Jenkins - [`6f8b43e`](https://github.com/eea/volto-widget-toggle/commit/6f8b43e0fe92d2065725be355b800446fedf2992)]
54
- - yarn 3 [Alin Voinea - [`02d53da`](https://github.com/eea/volto-widget-toggle/commit/02d53daff4ee2886f5533ce8afd0d4e67cd0a9f1)]
55
- - Add Sonarqube tag using demo-kitkat-frontend addons list [EEA Jenkins - [`42059ef`](https://github.com/eea/volto-widget-toggle/commit/42059efe39cf11c31b1a48ddf6503aaf9da14db7)]
56
59
  ### [3.0.1](https://github.com/eea/volto-widget-toggle/compare/3.0.0...3.0.1) - 16 November 2022
57
60
 
58
61
  #### :hammer_and_wrench: Others
@@ -65,21 +68,15 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
65
68
  - Cleanup [Alin Voinea - [`f0bfe89`](https://github.com/eea/volto-widget-toggle/commit/f0bfe892db782472d0911b3562346d80bed2fb94)]
66
69
  - Typo [Miu Razvan - [`f1faa3d`](https://github.com/eea/volto-widget-toggle/commit/f1faa3d1c0239d377a75b375dcf092cea048c121)]
67
70
  - Use latest cypress [Miu Razvan - [`165ef4a`](https://github.com/eea/volto-widget-toggle/commit/165ef4a017833e757a69da734985acd18155228e)]
68
- - Add Sonarqube tag using marine-frontend addons list [EEA Jenkins - [`45037b0`](https://github.com/eea/volto-widget-toggle/commit/45037b01295d0593929af9ff6f53823e51129f43)]
69
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`de17f98`](https://github.com/eea/volto-widget-toggle/commit/de17f983029cda87580f39b6ab7b1a0139e080cd)]
70
71
  - update(jest): add @plone/volto-slate resolver refs- #153447 [nileshgulia1 - [`b5e6889`](https://github.com/eea/volto-widget-toggle/commit/b5e6889bc22efaeec2025bd79dfe2a839650e4a6)]
71
72
  ### [2.2.7](https://github.com/eea/volto-widget-toggle/compare/2.2.6...2.2.7) - 30 June 2022
72
73
 
73
74
  #### :hammer_and_wrench: Others
74
75
 
75
- - Add Sonarqube tag using circularity-frontend addons list [EEA Jenkins - [`78e846a`](https://github.com/eea/volto-widget-toggle/commit/78e846a63de32fc42db181a07859a886b10d8b4e)]
76
- - Add Sonarqube tag using clms-frontend addons list [EEA Jenkins - [`75191c3`](https://github.com/eea/volto-widget-toggle/commit/75191c366506d17db335e2b305e5ea8f058e9dfb)]
77
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`3806c6c`](https://github.com/eea/volto-widget-toggle/commit/3806c6c481c069ab939b7603c7d3e102563276dd)]
78
76
  ### [2.2.6](https://github.com/eea/volto-widget-toggle/compare/2.2.5...2.2.6) - 3 January 2022
79
77
 
80
78
  #### :hammer_and_wrench: Others
81
79
 
82
- - Add Sonarqube tag using freshwater-frontend addons list [EEA Jenkins - [`c2e3484`](https://github.com/eea/volto-widget-toggle/commit/c2e3484b3396dbabf38a8b9e8f6df0b89d4aa663)]
83
80
  ### [2.2.5](https://github.com/eea/volto-widget-toggle/compare/2.2.4...2.2.5) - 16 December 2021
84
81
 
85
82
  ### [2.2.4](https://github.com/eea/volto-widget-toggle/compare/2.2.3...2.2.4) - 10 December 2021
@@ -87,13 +84,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
87
84
  #### :hammer_and_wrench: Others
88
85
 
89
86
  - Refs #142010 - Optimize Volto-addons gitflow pipelines [valentinab25 - [`2bd2039`](https://github.com/eea/volto-widget-toggle/commit/2bd203979963ee5cb15592470e1d341d1bd65291)]
90
- - Add Sonarqube tag using industry-frontend addons list [EEA Jenkins - [`af5afe1`](https://github.com/eea/volto-widget-toggle/commit/af5afe1263aff21801bbb8239163ac01644f2a7e)]
91
- - Add Sonarqube tag using clms-frontend addons list [EEA Jenkins - [`2d60373`](https://github.com/eea/volto-widget-toggle/commit/2d60373b280dcb2f902e4dc6fff0bdb8ea7d7ac7)]
92
- - Add Sonarqube tag using bise-frontend addons list [EEA Jenkins - [`80527c1`](https://github.com/eea/volto-widget-toggle/commit/80527c1f72bd8cc325ff1c072def18d24c3e99ae)]
93
- - Add Sonarqube tag using sustainability-frontend addons list [EEA Jenkins - [`bc52e72`](https://github.com/eea/volto-widget-toggle/commit/bc52e72e32197ca82f93bac645f0094bc7db7ab1)]
94
- - Add Sonarqube tag using climate-energy-frontend addons list [EEA Jenkins - [`30397bd`](https://github.com/eea/volto-widget-toggle/commit/30397bde9a045be3c2e6614af798ce11f18e3039)]
95
- - Add Sonarqube tag using ims-frontend addons list [EEA Jenkins - [`dd3fb67`](https://github.com/eea/volto-widget-toggle/commit/dd3fb67693900db1ce6d8f631c61a2a5c25d9b70)]
96
- - Add Sonarqube tag using frontend addons list [EEA Jenkins - [`54d09d1`](https://github.com/eea/volto-widget-toggle/commit/54d09d164591f1cf3d47a69838ccbd9abb8f22b6)]
97
87
  ### [2.2.3](https://github.com/eea/volto-widget-toggle/compare/2.2.2...2.2.3) - 28 June 2021
98
88
 
99
89
  #### :hammer_and_wrench: Others
@@ -127,7 +117,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
127
117
 
128
118
  - Release 1.0.1 [Alin Voinea - [`454220f`](https://github.com/eea/volto-widget-toggle/commit/454220fa61495427f874fb9b56401fe69689f4fe)]
129
119
  - Auto-release npm [Alin Voinea - [`10b31b3`](https://github.com/eea/volto-widget-toggle/commit/10b31b3b64330d41f69a033a45030e49d20c16b5)]
130
- - yarn prettier [Alin Voinea - [`5136059`](https://github.com/eea/volto-widget-toggle/commit/51360595bf452c815e526ce10f15aa8a84ad186f)]
131
120
  ## [1.0.0](https://github.com/eea/volto-widget-toggle/compare/0.1.0...1.0.0) - 29 September 2020
132
121
 
133
122
  #### :hammer_and_wrench: Others
package/cypress.config.js CHANGED
@@ -2,12 +2,12 @@ const { defineConfig } = require('cypress');
2
2
 
3
3
  module.exports = defineConfig({
4
4
  viewportWidth: 1280,
5
- defaultCommandTimeout: 5000,
5
+ defaultCommandTimeout: 8888,
6
6
  chromeWebSecurity: false,
7
7
  reporter: 'junit',
8
- video: true,
8
+ video: false,
9
9
  retries: {
10
- runMode: 1,
10
+ runMode: 2,
11
11
  openMode: 0,
12
12
  },
13
13
  reporterOptions: {
@@ -1,3 +1,5 @@
1
+ require('dotenv').config({ path: __dirname + '/.env' })
2
+
1
3
  module.exports = {
2
4
  testMatch: ['**/src/addons/**/?(*.)+(spec|test).[jt]s?(x)'],
3
5
  collectCoverageFrom: [
@@ -9,18 +11,26 @@ module.exports = {
9
11
  '@plone/volto/cypress': '<rootDir>/node_modules/@plone/volto/cypress',
10
12
  '@plone/volto/babel': '<rootDir>/node_modules/@plone/volto/babel',
11
13
  '@plone/volto/(.*)$': '<rootDir>/node_modules/@plone/volto/src/$1',
12
- '@package/(.*)$': '<rootDir>/src/$1',
13
- '@root/(.*)$': '<rootDir>/src/$1',
14
+ '@package/(.*)$': '<rootDir>/node_modules/@plone/volto/src/$1',
15
+ '@root/(.*)$': '<rootDir>/node_modules/@plone/volto/src/$1',
14
16
  '@plone/volto-quanta/(.*)$': '<rootDir>/src/addons/volto-quanta/src/$1',
17
+ '@eeacms/search/(.*)$': '<rootDir>/src/addons/volto-searchlib/searchlib/$1',
18
+ '@eeacms/search': '<rootDir>/src/addons/volto-searchlib/searchlib',
15
19
  '@eeacms/(.*?)/(.*)$': '<rootDir>/node_modules/@eeacms/$1/src/$2',
16
- '@plone/volto-slate':
20
+ '@plone/volto-slate$':
17
21
  '<rootDir>/node_modules/@plone/volto/packages/volto-slate/src',
22
+ '@plone/volto-slate/(.*)$':
23
+ '<rootDir>/node_modules/@plone/volto/packages/volto-slate/src/$1',
18
24
  '~/(.*)$': '<rootDir>/src/$1',
19
25
  'load-volto-addons':
20
26
  '<rootDir>/node_modules/@plone/volto/jest-addons-loader.js',
21
27
  },
28
+ transformIgnorePatterns: [
29
+ '/node_modules/(?!(@plone|@root|@package|@eeacms)/).*/',
30
+ ],
22
31
  transform: {
23
32
  '^.+\\.js(x)?$': 'babel-jest',
33
+ '^.+\\.ts(x)?$': 'babel-jest',
24
34
  '^.+\\.(png)$': 'jest-file',
25
35
  '^.+\\.(jpg)$': 'jest-file',
26
36
  '^.+\\.(svg)$': './node_modules/@plone/volto/jest-svgsystem-transform.js',
@@ -33,4 +43,9 @@ module.exports = {
33
43
  statements: 5,
34
44
  },
35
45
  },
36
- };
46
+ ...(process.env.JEST_USE_SETUP === 'ON' && {
47
+ setupFilesAfterEnv: [
48
+ '<rootDir>/node_modules/@eeacms/volto-widget-toggle/jest.setup.js',
49
+ ],
50
+ }),
51
+ }
package/jest.setup.js ADDED
@@ -0,0 +1,65 @@
1
+ import { jest } from '@jest/globals';
2
+ import configureStore from 'redux-mock-store';
3
+ import thunk from 'redux-thunk';
4
+ import { blocksConfig } from '@plone/volto/config/Blocks';
5
+ import installSlate from '@plone/volto-slate/index';
6
+
7
+ var mockSemanticComponents = jest.requireActual('semantic-ui-react');
8
+ var mockComponents = jest.requireActual('@plone/volto/components');
9
+ var config = jest.requireActual('@plone/volto/registry').default;
10
+
11
+ config.blocks.blocksConfig = {
12
+ ...blocksConfig,
13
+ ...config.blocks.blocksConfig,
14
+ };
15
+
16
+ jest.doMock('semantic-ui-react', () => ({
17
+ __esModule: true,
18
+ ...mockSemanticComponents,
19
+ Popup: ({ content, trigger }) => {
20
+ return (
21
+ <div className="popup">
22
+ <div className="trigger">{trigger}</div>
23
+ <div className="content">{content}</div>
24
+ </div>
25
+ );
26
+ },
27
+ }));
28
+
29
+ jest.doMock('@plone/volto/components', () => {
30
+ return {
31
+ __esModule: true,
32
+ ...mockComponents,
33
+ SidebarPortal: ({ children }) => <div id="sidebar">{children}</div>,
34
+ };
35
+ });
36
+
37
+ jest.doMock('@plone/volto/registry', () =>
38
+ [installSlate].reduce((acc, apply) => apply(acc), config),
39
+ );
40
+
41
+ const mockStore = configureStore([thunk]);
42
+
43
+ global.fetch = jest.fn(() =>
44
+ Promise.resolve({
45
+ json: () => Promise.resolve({}),
46
+ }),
47
+ );
48
+
49
+ global.store = mockStore({
50
+ intl: {
51
+ locale: 'en',
52
+ messages: {},
53
+ formatMessage: jest.fn(),
54
+ },
55
+ content: {
56
+ create: {},
57
+ subrequests: [],
58
+ },
59
+ connected_data_parameters: {},
60
+ screen: {
61
+ page: {
62
+ width: 768,
63
+ },
64
+ },
65
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-widget-toggle",
3
- "version": "3.1.4",
3
+ "version": "4.0.0",
4
4
  "description": "volto-widget-toggle: Volto add-on to replace checkboxes with toggle buttons",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -22,8 +22,9 @@
22
22
  "@cypress/code-coverage": "^3.10.0",
23
23
  "@plone/scripts": "*",
24
24
  "babel-plugin-transform-class-properties": "^6.24.1",
25
- "husky": "*",
26
- "lint-staged": "*",
25
+ "dotenv": "^16.3.2",
26
+ "husky": "^8.0.3",
27
+ "lint-staged": "^14.0.1",
27
28
  "md5": "^2.3.0"
28
29
  },
29
30
  "lint-staged": {
@@ -1,48 +0,0 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
-
4
- const projectRootPath = fs.existsSync('./project')
5
- ? fs.realpathSync('./project')
6
- : fs.realpathSync('./../../../');
7
- const packageJson = require(path.join(projectRootPath, 'package.json'));
8
- const jsConfig = require(path.join(projectRootPath, 'jsconfig.json')).compilerOptions;
9
-
10
- const pathsConfig = jsConfig.paths;
11
-
12
- let voltoPath = path.join(projectRootPath, 'node_modules/@plone/volto');
13
-
14
- Object.keys(pathsConfig).forEach(pkg => {
15
- if (pkg === '@plone/volto') {
16
- voltoPath = `./${jsConfig.baseUrl}/${pathsConfig[pkg][0]}`;
17
- }
18
- });
19
- const AddonConfigurationRegistry = require(`${voltoPath}/addon-registry.js`);
20
- const reg = new AddonConfigurationRegistry(projectRootPath);
21
-
22
- // Extends ESlint configuration for adding the aliases to `src` directories in Volto addons
23
- const addonAliases = Object.keys(reg.packages).map(o => [
24
- o,
25
- reg.packages[o].modulePath,
26
- ]);
27
-
28
-
29
- module.exports = {
30
- extends: `${projectRootPath}/node_modules/@plone/volto/.eslintrc`,
31
- settings: {
32
- 'import/resolver': {
33
- alias: {
34
- map: [
35
- ['@plone/volto', '@plone/volto/src'],
36
- ...addonAliases,
37
- ['@package', `${__dirname}/src`],
38
- ['~', `${__dirname}/src`],
39
- ],
40
- extensions: ['.js', '.jsx', '.json'],
41
- },
42
- 'babel-plugin-root-import': {
43
- rootPathSuffix: 'src',
44
- },
45
- },
46
- },
47
- };
48
-