@eeacms/volto-cca-policy 0.1.89 → 0.1.91

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/CHANGELOG.md CHANGED
@@ -4,7 +4,22 @@ 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
- ### [0.1.89](https://github.com/eea/volto-cca-policy/compare/0.1.88...0.1.89) - 4 March 2024
7
+ ### [0.1.91](https://github.com/eea/volto-cca-policy/compare/0.1.90...0.1.91) - 5 March 2024
8
+
9
+ #### :bug: Bug Fixes
10
+
11
+ - fix(test): update tests for UniversalLink + generate snapshot [kreafox - [`4b2e0c2`](https://github.com/eea/volto-cca-policy/commit/4b2e0c265601f1420a95a9cf0056fc3ea73baf59)]
12
+
13
+ #### :hammer_and_wrench: Others
14
+
15
+ - Add test file [Tiberiu Ichim - [`282e32c`](https://github.com/eea/volto-cca-policy/commit/282e32cde07122150379df996b19d37eed3e0260)]
16
+ - Add override for UniversalLink, see #266263 [Tiberiu Ichim - [`63242f5`](https://github.com/eea/volto-cca-policy/commit/63242f5fc4b0e54d1170b8f8ee31dba46e997eee)]
17
+ ### [0.1.90](https://github.com/eea/volto-cca-policy/compare/0.1.89...0.1.90) - 5 March 2024
18
+
19
+ #### :hammer_and_wrench: Others
20
+
21
+ - Fix default [Tiberiu Ichim - [`03849ee`](https://github.com/eea/volto-cca-policy/commit/03849ee821516ef131e863378ae6e12e4b6a41cd)]
22
+ ### [0.1.89](https://github.com/eea/volto-cca-policy/compare/0.1.88...0.1.89) - 5 March 2024
8
23
 
9
24
  #### :bug: Bug Fixes
10
25
 
@@ -563,10 +578,13 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
563
578
  - Refs #260715 rast-block wip [Tripon Eugen - [`f19d54e`](https://github.com/eea/volto-cca-policy/commit/f19d54e0b9a6a86bf344eb85b6a1cda7f3de91bf)]
564
579
  - Refs #260715 rast-block wip [Tripon Eugen - [`2828537`](https://github.com/eea/volto-cca-policy/commit/2828537b6c084cd1a82162d552fb4ef025b71f9f)]
565
580
  - Refs #260715 rast-block updates [Tripon Eugen - [`1e803e5`](https://github.com/eea/volto-cca-policy/commit/1e803e5bd3d3fb7558f261c76c68866be7beb8b5)]
581
+ - test: [JENKINS] Use java17 for sonarqube scanner [valentinab25 - [`0a15e1b`](https://github.com/eea/volto-cca-policy/commit/0a15e1b2ad081233685e80d5b3c60a8663f6b896)]
582
+ - test: [JENKINS] Run cypress in started frontend container [valentinab25 - [`9554e44`](https://github.com/eea/volto-cca-policy/commit/9554e44c92a621a52b2adb5a4830fb084ee5734b)]
566
583
  ### [0.1.49](https://github.com/eea/volto-cca-policy/compare/0.1.48...0.1.49) - 15 November 2023
567
584
 
568
585
  #### :house: Internal changes
569
586
 
587
+ - chore: [JENKINS] Refactor automated testing [valentinab25 - [`7b820a6`](https://github.com/eea/volto-cca-policy/commit/7b820a6369c2ddd5203b1a4abe352cb4bb43db7a)]
570
588
  - chore: husky, lint-staged use fixed versions [valentinab25 - [`f0a8061`](https://github.com/eea/volto-cca-policy/commit/f0a8061c275c236deb00087c23fac9860a073106)]
571
589
 
572
590
  #### :hammer_and_wrench: Others
@@ -583,6 +601,9 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
583
601
  - Refs #259267 - jenkins test [Tripon Eugen - [`cacd31e`](https://github.com/eea/volto-cca-policy/commit/cacd31e7b1afe0983674ed5c7632d2e1d7fa752e)]
584
602
  - Refs #259267 - jenkins [Tripon Eugen - [`5b3affe`](https://github.com/eea/volto-cca-policy/commit/5b3affee8401239de10097884c1b7f2349d15ec0)]
585
603
  - Refs #259267 - add When, lead image and title to files [Tripon Eugen - [`2cedb23`](https://github.com/eea/volto-cca-policy/commit/2cedb237f898af9057e13fba94b615ef71077204)]
604
+ - test: [JENKINS] Add cpu limit on cypress docker [valentinab25 - [`4d607a5`](https://github.com/eea/volto-cca-policy/commit/4d607a576e9d0a5c34e48c41b409e7df616ee3d6)]
605
+ - test: [JENKINS] Increase shm-size to cypress docker [valentinab25 - [`b7f74d5`](https://github.com/eea/volto-cca-policy/commit/b7f74d53513a6edbfbca5cb6d19687929bb1e5db)]
606
+ - test: [JENKINS] Improve cypress time [valentinab25 - [`db65617`](https://github.com/eea/volto-cca-policy/commit/db656173391f65157098d95d388c25f6429753d8)]
586
607
  - Refs #259267 - cca event blocks attachments and check not mandatoty fields [Tripon Eugen - [`3138e5a`](https://github.com/eea/volto-cca-policy/commit/3138e5afb5bfbdbed14e27ed457b16867b7fa414)]
587
608
  - Refs #256681 - Fix error in CCA Event view menu. ([React Intl] An id must be provided to format a message.) [GhitaB - [`517eeb8`](https://github.com/eea/volto-cca-policy/commit/517eeb817264a47bbfd6b9b7d22aaf22d44ed224)]
588
609
  - Refs #161485 - Fix ECDE name conflict. [GhitaB - [`8bfd99f`](https://github.com/eea/volto-cca-policy/commit/8bfd99ff68bb82a04d1c0ed625fa514fcf46289e)]
@@ -799,6 +820,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
799
820
 
800
821
  #### :house: Internal changes
801
822
 
823
+ - chore: [JENKINS] Remove alpha testing version [valentinab25 - [`ad1ced0`](https://github.com/eea/volto-cca-policy/commit/ad1ced0971ba116c13a3b5fcc039172cc915c919)]
802
824
 
803
825
  #### :hammer_and_wrench: Others
804
826
 
@@ -1279,6 +1301,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
1279
1301
  #### :hammer_and_wrench: Others
1280
1302
 
1281
1303
  - Refs #158294 - Update supported languages list. [GhitaB - [`0a4f91f`](https://github.com/eea/volto-cca-policy/commit/0a4f91f39b7edc367bd4c127d6a8f273c7788361)]
1304
+ - Add Sonarqube tag using cca-frontend addons list [EEA Jenkins - [`8f1f9ce`](https://github.com/eea/volto-cca-policy/commit/8f1f9ce6c22805670cc0800d3c779b6d619d0f31)]
1282
1305
  ### [0.1.1](https://github.com/eea/volto-cca-policy/compare/0.1.0...0.1.1) - 13 December 2022
1283
1306
 
1284
1307
  #### :hammer_and_wrench: Others
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-cca-policy",
3
- "version": "0.1.89",
3
+ "version": "0.1.91",
4
4
  "description": "@eeacms/volto-cca-policy: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -51,7 +51,7 @@ const Schema = () => {
51
51
  ['SearchBlock', 'Volto Search block'],
52
52
  ['EEASemanticSearch', 'EEA Semantic Search'],
53
53
  ],
54
- default: 'ListingBlock',
54
+ default: 'SearchBlock',
55
55
  },
56
56
  showLabel: {
57
57
  type: 'boolean',
@@ -0,0 +1,3 @@
1
+ Customization of https://github.com/eea/volto-eea-website-theme/blob/e12e85279d0973ed17ffadf9897f0bc8f4368227/src/customizations/volto/components/manage/UniversalLink/UniversalLink.jsx
2
+
3
+ Because we always want to open external links in new tabs
@@ -0,0 +1,152 @@
1
+ /*
2
+ * UniversalLink
3
+ * @module components/UniversalLink
4
+ * Removed noreferrer from rel attribute
5
+ */
6
+
7
+ import React from 'react';
8
+ import PropTypes from 'prop-types';
9
+ import { HashLink as Link } from 'react-router-hash-link';
10
+ import { useSelector } from 'react-redux';
11
+ import {
12
+ flattenToAppURL,
13
+ isInternalURL,
14
+ URLUtils,
15
+ } from '@plone/volto/helpers/Url/Url';
16
+
17
+ import config from '@plone/volto/registry';
18
+
19
+ const UniversalLink = ({
20
+ href,
21
+ item = null,
22
+ openLinkInNewTab,
23
+ download = false,
24
+ children,
25
+ className = null,
26
+ title = null,
27
+ ...props
28
+ }) => {
29
+ const token = useSelector((state) => state.userSession?.token);
30
+
31
+ let url = href;
32
+ if (!href && item) {
33
+ if (!item['@id']) {
34
+ // eslint-disable-next-line no-console
35
+ console.error(
36
+ 'Invalid item passed to UniversalLink',
37
+ item,
38
+ props,
39
+ children,
40
+ );
41
+ url = '#';
42
+ } else {
43
+ //case: generic item
44
+ url = flattenToAppURL(item['@id']);
45
+
46
+ //case: item like a Link
47
+ let remoteUrl = item.remoteUrl || item.getRemoteUrl;
48
+ if (!token && remoteUrl) {
49
+ url = remoteUrl;
50
+ }
51
+
52
+ //case: item of type 'File'
53
+ if (
54
+ !token &&
55
+ config.settings.downloadableObjects.includes(item['@type'])
56
+ ) {
57
+ url = `${url}/@@download/file`;
58
+ }
59
+
60
+ if (
61
+ !token &&
62
+ config.settings.viewableInBrowserObjects.includes(item['@type'])
63
+ ) {
64
+ url = `${url}/@@display-file/file`;
65
+ }
66
+ }
67
+ }
68
+
69
+ const isExternal = !isInternalURL(url);
70
+
71
+ const isDownload = (!isExternal && url.includes('@@download')) || download;
72
+ const isDisplayFile =
73
+ (!isExternal && url.includes('@@display-file')) || false;
74
+
75
+ const checkedURL = URLUtils.checkAndNormalizeUrl(url);
76
+
77
+ url = checkedURL.url;
78
+ let tag = (
79
+ <Link
80
+ to={flattenToAppURL(url)}
81
+ target={openLinkInNewTab ?? false ? '_blank' : null}
82
+ title={title}
83
+ className={className}
84
+ smooth={config.settings.hashLinkSmoothScroll}
85
+ {...props}
86
+ >
87
+ {children}
88
+ </Link>
89
+ );
90
+
91
+ const isBlank =
92
+ (isExternal || openLinkInNewTab) &&
93
+ (!checkedURL.isMail || !checkedURL.isTelephone);
94
+
95
+ if (isExternal) {
96
+ tag = (
97
+ <a
98
+ href={url}
99
+ title={title}
100
+ target={isBlank ? '_blank' : null}
101
+ rel="noopener"
102
+ className={className}
103
+ {...props}
104
+ >
105
+ {children}
106
+ </a>
107
+ );
108
+ } else if (isDownload) {
109
+ tag = (
110
+ <a
111
+ href={flattenToAppURL(url)}
112
+ download
113
+ title={title}
114
+ className={className}
115
+ {...props}
116
+ >
117
+ {children}
118
+ </a>
119
+ );
120
+ } else if (isDisplayFile) {
121
+ tag = (
122
+ <a
123
+ href={flattenToAppURL(url)}
124
+ title={title}
125
+ rel="noopener"
126
+ className={className}
127
+ {...props}
128
+ >
129
+ {children}
130
+ </a>
131
+ );
132
+ }
133
+ return tag;
134
+ };
135
+
136
+ UniversalLink.propTypes = {
137
+ href: PropTypes.string,
138
+ openLinkInNewTab: PropTypes.bool,
139
+ download: PropTypes.bool,
140
+ className: PropTypes.string,
141
+ title: PropTypes.string,
142
+ item: PropTypes.shape({
143
+ '@id': PropTypes.string.isRequired,
144
+ remoteUrl: PropTypes.string, //of plone @type 'Link'
145
+ }),
146
+ children: PropTypes.oneOfType([
147
+ PropTypes.arrayOf(PropTypes.node),
148
+ PropTypes.node,
149
+ ]),
150
+ };
151
+
152
+ export default UniversalLink;
@@ -0,0 +1,229 @@
1
+ import React from 'react';
2
+ import renderer from 'react-test-renderer';
3
+ import { Provider } from 'react-intl-redux';
4
+ import configureStore from 'redux-mock-store';
5
+ import { render } from '@testing-library/react';
6
+ import { MemoryRouter } from 'react-router-dom';
7
+ import UniversalLink from './UniversalLink';
8
+ import config from '@plone/volto/registry';
9
+
10
+ const mockStore = configureStore();
11
+ const store = mockStore({
12
+ userSession: {
13
+ token: null,
14
+ },
15
+ intl: {
16
+ locale: 'en',
17
+ messages: {},
18
+ },
19
+ });
20
+
21
+ global.console.error = jest.fn();
22
+
23
+ describe('UniversalLink', () => {
24
+ it('renders a UniversalLink component with internal link', () => {
25
+ const component = renderer.create(
26
+ <Provider store={store}>
27
+ <MemoryRouter>
28
+ <UniversalLink href={'/en/welcome-to-volto'}>
29
+ <h1>Title</h1>
30
+ </UniversalLink>
31
+ </MemoryRouter>
32
+ </Provider>,
33
+ );
34
+ const json = component.toJSON();
35
+ expect(json).toMatchSnapshot();
36
+ });
37
+
38
+ it('renders a UniversalLink component with external link', () => {
39
+ const component = renderer.create(
40
+ <Provider store={store}>
41
+ <MemoryRouter>
42
+ <UniversalLink href="https://github.com/plone/volto">
43
+ <h1>Title</h1>
44
+ </UniversalLink>
45
+ </MemoryRouter>
46
+ </Provider>,
47
+ );
48
+ const json = component.toJSON();
49
+ expect(json).toMatchSnapshot();
50
+ });
51
+
52
+ it('renders a UniversalLink component if no external(href) link passed', () => {
53
+ const component = renderer.create(
54
+ <Provider store={store}>
55
+ <MemoryRouter>
56
+ <UniversalLink
57
+ item={{
58
+ '@id': 'http://localhost:3000/en/welcome-to-volto',
59
+ }}
60
+ >
61
+ <h1>Title</h1>
62
+ </UniversalLink>
63
+ </MemoryRouter>
64
+ </Provider>,
65
+ );
66
+ const json = component.toJSON();
67
+ expect(json).toMatchSnapshot();
68
+ });
69
+
70
+ it('check UniversalLink set rel attribute for ext links', () => {
71
+ const { getByTitle } = render(
72
+ <Provider store={store}>
73
+ <MemoryRouter>
74
+ <UniversalLink
75
+ href="https://github.com/plone/volto"
76
+ title="Volto GitHub repository"
77
+ >
78
+ <h1>Title</h1>
79
+ </UniversalLink>
80
+ </MemoryRouter>
81
+ </Provider>,
82
+ );
83
+
84
+ expect(getByTitle('Volto GitHub repository').getAttribute('rel')).toBe(
85
+ 'noopener',
86
+ );
87
+ });
88
+
89
+ it('check UniversalLink set target attribute for ext links', () => {
90
+ const { getByTitle } = render(
91
+ <Provider store={store}>
92
+ <MemoryRouter>
93
+ <UniversalLink
94
+ href="https://github.com/plone/volto"
95
+ title="Volto GitHub repository"
96
+ >
97
+ <h1>Title</h1>
98
+ </UniversalLink>
99
+ </MemoryRouter>
100
+ </Provider>,
101
+ );
102
+
103
+ expect(getByTitle('Volto GitHub repository').getAttribute('target')).toBe(
104
+ '_blank',
105
+ );
106
+ });
107
+
108
+ it('check UniversalLink can unset target for ext links with prop', () => {
109
+ const { getByTitle } = render(
110
+ <Provider store={store}>
111
+ <MemoryRouter>
112
+ <UniversalLink
113
+ href="https://github.com/plone/volto"
114
+ title="Volto GitHub repository"
115
+ openLinkInNewTab={false}
116
+ >
117
+ <h1>Title</h1>
118
+ </UniversalLink>
119
+ </MemoryRouter>
120
+ </Provider>,
121
+ );
122
+
123
+ expect(getByTitle('Volto GitHub repository').getAttribute('target')).toBe(
124
+ '_blank',
125
+ );
126
+ });
127
+
128
+ it('check UniversalLink renders ext link for blacklisted urls', () => {
129
+ config.settings.externalRoutes = [
130
+ {
131
+ match: {
132
+ path: '/external-app',
133
+ exact: true,
134
+ strict: false,
135
+ },
136
+ url(payload) {
137
+ return payload.location.pathname;
138
+ },
139
+ },
140
+ ];
141
+
142
+ const { getByTitle } = render(
143
+ <Provider store={store}>
144
+ <MemoryRouter>
145
+ <UniversalLink
146
+ href="http://localhost:3000/external-app"
147
+ title="Blacklisted route"
148
+ >
149
+ <h1>Title</h1>
150
+ </UniversalLink>
151
+ </MemoryRouter>
152
+ </Provider>,
153
+ );
154
+
155
+ expect(getByTitle('Blacklisted route').getAttribute('target')).toBe(
156
+ '_blank',
157
+ );
158
+ });
159
+
160
+ it('UniversalLink renders external link where link is blacklisted', () => {
161
+ const notInEN = /^(?!.*(#|\/en|\/static|\/controlpanel|\/cypress|\/login|\/logout|\/contact-form)).*$/;
162
+ config.settings.externalRoutes = [
163
+ {
164
+ match: {
165
+ path: notInEN,
166
+ exact: false,
167
+ strict: false,
168
+ },
169
+ url(payload) {
170
+ return payload.location.pathname;
171
+ },
172
+ },
173
+ ];
174
+
175
+ const { getByTitle } = render(
176
+ <Provider store={store}>
177
+ <MemoryRouter>
178
+ <UniversalLink
179
+ href="http://localhost:3000/blacklisted-app"
180
+ title="External blacklisted app"
181
+ >
182
+ <h1>Title</h1>
183
+ </UniversalLink>
184
+ </MemoryRouter>
185
+ </Provider>,
186
+ );
187
+
188
+ expect(getByTitle('External blacklisted app').getAttribute('target')).toBe(
189
+ '_blank',
190
+ );
191
+ expect(getByTitle('External blacklisted app').getAttribute('rel')).toBe(
192
+ 'noopener',
193
+ );
194
+ });
195
+
196
+ it('check UniversalLink does not break with error in item', () => {
197
+ const component = renderer.create(
198
+ <Provider store={store}>
199
+ <MemoryRouter>
200
+ <UniversalLink
201
+ item={{
202
+ error: 'Error while fetching content',
203
+ message: 'Something went wrong',
204
+ }}
205
+ >
206
+ <h1>Title</h1>
207
+ </UniversalLink>
208
+ </MemoryRouter>
209
+ </Provider>,
210
+ );
211
+ const json = component.toJSON();
212
+ expect(json).toMatchSnapshot();
213
+ expect(global.console.error).toHaveBeenCalled();
214
+ });
215
+ });
216
+
217
+ it('renders a UniversalLink component when url ends with @@display-file', () => {
218
+ const component = renderer.create(
219
+ <Provider store={store}>
220
+ <MemoryRouter>
221
+ <UniversalLink href="http://localhost:3000/en/welcome-to-volto/@@display-file">
222
+ <h1>Title</h1>
223
+ </UniversalLink>
224
+ </MemoryRouter>
225
+ </Provider>,
226
+ );
227
+ const json = component.toJSON();
228
+ expect(json).toMatchSnapshot();
229
+ });
package/src/index.js CHANGED
@@ -211,6 +211,27 @@ const applyConfig = (config) => {
211
211
  };
212
212
  }
213
213
 
214
+ const { facetWidgets } = config.blocks.blocksConfig.search.extensions;
215
+ const { rewriteOptions } = facetWidgets;
216
+ const origin_website_blacklist = ['AdapteCCA', 'DRMKC'];
217
+ facetWidgets.rewriteOptions = (name, choices) => {
218
+ let base = rewriteOptions(name, choices);
219
+ if (name === 'origin_website') {
220
+ base.forEach((pair) => {
221
+ if (pair.value === 'Lancet Countdown') {
222
+ pair.label = 'Lancet Countdown in Europe';
223
+ }
224
+ if (pair.value === 'C3S') {
225
+ pair.label = 'Copernicus (C3S)';
226
+ }
227
+ });
228
+ base = base.filter(
229
+ (f) => origin_website_blacklist.indexOf(f.value) === -1,
230
+ );
231
+ }
232
+ return base;
233
+ };
234
+
214
235
  // Move blocks to Site group
215
236
  const move_to_site = [
216
237
  'countryFlag',