@eeacms/volto-cca-policy 0.2.41 → 0.2.42

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,15 +4,14 @@ 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.2.42](https://github.com/eea/volto-cca-policy/compare/0.2.41...0.2.42) - 4 June 2024
8
+
7
9
  ### [0.2.41](https://github.com/eea/volto-cca-policy/compare/0.2.40...0.2.41) - 4 June 2024
8
10
 
9
11
  #### :rocket: Dependency updates
10
12
 
11
13
  - Release @eeacms/volto-embed@10.0.1 [EEA Jenkins - [`7e807f4`](https://github.com/eea/volto-cca-policy/commit/7e807f45151eb7335a9f690a038bef8a9f1add80)]
12
14
 
13
- #### :hammer_and_wrench: Others
14
-
15
- - Tweak default expands [Tiberiu Ichim - [`e721114`](https://github.com/eea/volto-cca-policy/commit/e7211143178f25279541cf974ce41e8b4ae2c3b3)]
16
15
  ### [0.2.40](https://github.com/eea/volto-cca-policy/compare/0.2.39...0.2.40) - 31 May 2024
17
16
 
18
17
  #### :bug: Bug Fixes
@@ -1363,10 +1362,13 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
1363
1362
  - Refs #260715 rast-block wip [Tripon Eugen - [`f19d54e`](https://github.com/eea/volto-cca-policy/commit/f19d54e0b9a6a86bf344eb85b6a1cda7f3de91bf)]
1364
1363
  - Refs #260715 rast-block wip [Tripon Eugen - [`2828537`](https://github.com/eea/volto-cca-policy/commit/2828537b6c084cd1a82162d552fb4ef025b71f9f)]
1365
1364
  - Refs #260715 rast-block updates [Tripon Eugen - [`1e803e5`](https://github.com/eea/volto-cca-policy/commit/1e803e5bd3d3fb7558f261c76c68866be7beb8b5)]
1365
+ - test: [JENKINS] Use java17 for sonarqube scanner [valentinab25 - [`0a15e1b`](https://github.com/eea/volto-cca-policy/commit/0a15e1b2ad081233685e80d5b3c60a8663f6b896)]
1366
+ - test: [JENKINS] Run cypress in started frontend container [valentinab25 - [`9554e44`](https://github.com/eea/volto-cca-policy/commit/9554e44c92a621a52b2adb5a4830fb084ee5734b)]
1366
1367
  ### [0.1.49](https://github.com/eea/volto-cca-policy/compare/0.1.48...0.1.49) - 15 November 2023
1367
1368
 
1368
1369
  #### :house: Internal changes
1369
1370
 
1371
+ - chore: [JENKINS] Refactor automated testing [valentinab25 - [`7b820a6`](https://github.com/eea/volto-cca-policy/commit/7b820a6369c2ddd5203b1a4abe352cb4bb43db7a)]
1370
1372
  - chore: husky, lint-staged use fixed versions [valentinab25 - [`f0a8061`](https://github.com/eea/volto-cca-policy/commit/f0a8061c275c236deb00087c23fac9860a073106)]
1371
1373
 
1372
1374
  #### :hammer_and_wrench: Others
@@ -1383,6 +1385,9 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
1383
1385
  - Refs #259267 - jenkins test [Tripon Eugen - [`cacd31e`](https://github.com/eea/volto-cca-policy/commit/cacd31e7b1afe0983674ed5c7632d2e1d7fa752e)]
1384
1386
  - Refs #259267 - jenkins [Tripon Eugen - [`5b3affe`](https://github.com/eea/volto-cca-policy/commit/5b3affee8401239de10097884c1b7f2349d15ec0)]
1385
1387
  - Refs #259267 - add When, lead image and title to files [Tripon Eugen - [`2cedb23`](https://github.com/eea/volto-cca-policy/commit/2cedb237f898af9057e13fba94b615ef71077204)]
1388
+ - test: [JENKINS] Add cpu limit on cypress docker [valentinab25 - [`4d607a5`](https://github.com/eea/volto-cca-policy/commit/4d607a576e9d0a5c34e48c41b409e7df616ee3d6)]
1389
+ - test: [JENKINS] Increase shm-size to cypress docker [valentinab25 - [`b7f74d5`](https://github.com/eea/volto-cca-policy/commit/b7f74d53513a6edbfbca5cb6d19687929bb1e5db)]
1390
+ - test: [JENKINS] Improve cypress time [valentinab25 - [`db65617`](https://github.com/eea/volto-cca-policy/commit/db656173391f65157098d95d388c25f6429753d8)]
1386
1391
  - Refs #259267 - cca event blocks attachments and check not mandatoty fields [Tripon Eugen - [`3138e5a`](https://github.com/eea/volto-cca-policy/commit/3138e5afb5bfbdbed14e27ed457b16867b7fa414)]
1387
1392
  - 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)]
1388
1393
  - Refs #161485 - Fix ECDE name conflict. [GhitaB - [`8bfd99f`](https://github.com/eea/volto-cca-policy/commit/8bfd99ff68bb82a04d1c0ed625fa514fcf46289e)]
@@ -1599,6 +1604,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
1599
1604
 
1600
1605
  #### :house: Internal changes
1601
1606
 
1607
+ - chore: [JENKINS] Remove alpha testing version [valentinab25 - [`ad1ced0`](https://github.com/eea/volto-cca-policy/commit/ad1ced0971ba116c13a3b5fcc039172cc915c919)]
1602
1608
 
1603
1609
  #### :hammer_and_wrench: Others
1604
1610
 
@@ -2079,6 +2085,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
2079
2085
  #### :hammer_and_wrench: Others
2080
2086
 
2081
2087
  - Refs #158294 - Update supported languages list. [GhitaB - [`0a4f91f`](https://github.com/eea/volto-cca-policy/commit/0a4f91f39b7edc367bd4c127d6a8f273c7788361)]
2088
+ - Add Sonarqube tag using cca-frontend addons list [EEA Jenkins - [`8f1f9ce`](https://github.com/eea/volto-cca-policy/commit/8f1f9ce6c22805670cc0800d3c779b6d619d0f31)]
2082
2089
  ### [0.1.1](https://github.com/eea/volto-cca-policy/compare/0.1.0...0.1.1) - 13 December 2022
2083
2090
 
2084
2091
  #### :hammer_and_wrench: Others
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-cca-policy",
3
- "version": "0.2.41",
3
+ "version": "0.2.42",
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",
@@ -4,6 +4,7 @@ export { default as PortalMessage } from './theme/PortalMessage/PortalMessage';
4
4
  export { default as TranslationDisclaimer } from './theme/TranslationDisclaimer/TranslationDisclaimer';
5
5
  export { default as ShareInfoButton } from './theme/ShareInfoButton/ShareInfoButton';
6
6
  export { default as ASTNavigation } from './theme/ASTNavigation/ASTNavigation';
7
+ export { default as RedirectToLogin } from './theme/RedirectToLogin/RedirectToLogin';
7
8
 
8
9
  // Widgets
9
10
  export { default as RASTWidgetView } from './theme/Widgets/RASTWidgetView';
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+
3
+ export default function RedirectToLogin(props) {
4
+ const { token, location, history } = props;
5
+ const { pathname, search } = location;
6
+
7
+ React.useEffect(() => {
8
+ if (!token) {
9
+ const back = encodeURIComponent(`${pathname}${search}`);
10
+ history.push(`/login?return_url=${back}`);
11
+ }
12
+ }, [token, history, pathname, search]);
13
+
14
+ return null;
15
+ }
@@ -0,0 +1,75 @@
1
+ import React from 'react';
2
+ import { MemoryRouter } from 'react-router-dom';
3
+ import configureStore from 'redux-mock-store';
4
+ import { Provider } from 'react-intl-redux';
5
+ import RedirectToLogin from './RedirectToLogin';
6
+ import config from '@plone/volto/registry';
7
+ import { render } from '@testing-library/react';
8
+
9
+ config.blocks = {
10
+ blocksConfig: {
11
+ title: {
12
+ view: () => <div>Title Block Component</div>,
13
+ },
14
+ },
15
+ };
16
+
17
+ const mockStore = configureStore();
18
+
19
+ describe('RedirectToLogin', () => {
20
+ it('redirects to login if no token', () => {
21
+ const store = mockStore({
22
+ userSession: { token: '1234' },
23
+ intl: {
24
+ locale: 'en',
25
+ messages: {},
26
+ },
27
+ });
28
+ const history = { push: jest.fn(() => null) };
29
+ const location = {
30
+ pathname: '/en/metadata/add',
31
+ search: '?type=NewsItem',
32
+ };
33
+
34
+ render(
35
+ <Provider store={store}>
36
+ <MemoryRouter>
37
+ <RedirectToLogin history={history} token={null} location={location} />
38
+ </MemoryRouter>
39
+ </Provider>,
40
+ );
41
+
42
+ expect(history.push.mock.calls[0][0]).toBe(
43
+ '/login?return_url=%2Fen%2Fmetadata%2Fadd%3Ftype%3DNewsItem',
44
+ );
45
+ });
46
+
47
+ it('does not redirect to login if token', () => {
48
+ const store = mockStore({
49
+ userSession: { token: '1234' },
50
+ intl: {
51
+ locale: 'en',
52
+ messages: {},
53
+ },
54
+ });
55
+ const history = { push: jest.fn(() => null) };
56
+ const location = {
57
+ pathname: '/en/metadata/add',
58
+ search: '?type=NewsItem',
59
+ };
60
+
61
+ render(
62
+ <Provider store={store}>
63
+ <MemoryRouter>
64
+ <RedirectToLogin
65
+ history={history}
66
+ token={'something'}
67
+ location={location}
68
+ />
69
+ </MemoryRouter>
70
+ </Provider>,
71
+ );
72
+
73
+ expect(history.push.mock.calls).toHaveLength(0);
74
+ });
75
+ });
package/src/index.js CHANGED
@@ -4,6 +4,7 @@ import DefaultView from '@plone/volto/components/theme/View/DefaultView';
4
4
  import {
5
5
  RASTWidgetView,
6
6
  TranslationDisclaimer,
7
+ RedirectToLogin,
7
8
  } from '@eeacms/volto-cca-policy/components';
8
9
  import { blockAvailableInMission } from '@eeacms/volto-cca-policy/utils';
9
10
 
@@ -382,6 +383,12 @@ const applyConfig = (config) => {
382
383
  match: '',
383
384
  component: TranslationDisclaimer,
384
385
  },
386
+ {
387
+ match: {
388
+ path: /(.*)\/add/,
389
+ },
390
+ component: RedirectToLogin,
391
+ },
385
392
  ];
386
393
 
387
394
  config.settings.apiExpanders = [