@eeacms/volto-cca-policy 0.2.33 → 0.2.35

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,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
+ ### [0.2.35](https://github.com/eea/volto-cca-policy/compare/0.2.34...0.2.35) - 24 May 2024
8
+
9
+ #### :bug: Bug Fixes
10
+
11
+ - fix: don't break view without blocks [kreafox - [`0a63710`](https://github.com/eea/volto-cca-policy/commit/0a63710bb682f033b4a9f0f8df51720c10dc7644)]
12
+
13
+ #### :hammer_and_wrench: Others
14
+
15
+ - test: increase coverage [kreafox - [`5a349cf`](https://github.com/eea/volto-cca-policy/commit/5a349cf8f2d04f4e491537c3c6d0ed442ac6481f)]
16
+ - test: fix issues reported by sonarqube [kreafox - [`a84e309`](https://github.com/eea/volto-cca-policy/commit/a84e309de1d8da69832a28c0a9bc037a57cd4ddb)]
17
+ - update snapshot [kreafox - [`0e1b2cc`](https://github.com/eea/volto-cca-policy/commit/0e1b2ccf6d3088d5c3867287050d99adcd93f655)]
18
+ ### [0.2.34](https://github.com/eea/volto-cca-policy/compare/0.2.33...0.2.34) - 24 May 2024
19
+
7
20
  ### [0.2.33](https://github.com/eea/volto-cca-policy/compare/0.2.32...0.2.33) - 23 May 2024
8
21
 
9
22
  #### :bug: Bug Fixes
@@ -1294,10 +1307,13 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
1294
1307
  - Refs #260715 rast-block wip [Tripon Eugen - [`f19d54e`](https://github.com/eea/volto-cca-policy/commit/f19d54e0b9a6a86bf344eb85b6a1cda7f3de91bf)]
1295
1308
  - Refs #260715 rast-block wip [Tripon Eugen - [`2828537`](https://github.com/eea/volto-cca-policy/commit/2828537b6c084cd1a82162d552fb4ef025b71f9f)]
1296
1309
  - Refs #260715 rast-block updates [Tripon Eugen - [`1e803e5`](https://github.com/eea/volto-cca-policy/commit/1e803e5bd3d3fb7558f261c76c68866be7beb8b5)]
1310
+ - test: [JENKINS] Use java17 for sonarqube scanner [valentinab25 - [`0a15e1b`](https://github.com/eea/volto-cca-policy/commit/0a15e1b2ad081233685e80d5b3c60a8663f6b896)]
1311
+ - test: [JENKINS] Run cypress in started frontend container [valentinab25 - [`9554e44`](https://github.com/eea/volto-cca-policy/commit/9554e44c92a621a52b2adb5a4830fb084ee5734b)]
1297
1312
  ### [0.1.49](https://github.com/eea/volto-cca-policy/compare/0.1.48...0.1.49) - 15 November 2023
1298
1313
 
1299
1314
  #### :house: Internal changes
1300
1315
 
1316
+ - chore: [JENKINS] Refactor automated testing [valentinab25 - [`7b820a6`](https://github.com/eea/volto-cca-policy/commit/7b820a6369c2ddd5203b1a4abe352cb4bb43db7a)]
1301
1317
  - chore: husky, lint-staged use fixed versions [valentinab25 - [`f0a8061`](https://github.com/eea/volto-cca-policy/commit/f0a8061c275c236deb00087c23fac9860a073106)]
1302
1318
 
1303
1319
  #### :hammer_and_wrench: Others
@@ -1314,6 +1330,9 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
1314
1330
  - Refs #259267 - jenkins test [Tripon Eugen - [`cacd31e`](https://github.com/eea/volto-cca-policy/commit/cacd31e7b1afe0983674ed5c7632d2e1d7fa752e)]
1315
1331
  - Refs #259267 - jenkins [Tripon Eugen - [`5b3affe`](https://github.com/eea/volto-cca-policy/commit/5b3affee8401239de10097884c1b7f2349d15ec0)]
1316
1332
  - Refs #259267 - add When, lead image and title to files [Tripon Eugen - [`2cedb23`](https://github.com/eea/volto-cca-policy/commit/2cedb237f898af9057e13fba94b615ef71077204)]
1333
+ - test: [JENKINS] Add cpu limit on cypress docker [valentinab25 - [`4d607a5`](https://github.com/eea/volto-cca-policy/commit/4d607a576e9d0a5c34e48c41b409e7df616ee3d6)]
1334
+ - test: [JENKINS] Increase shm-size to cypress docker [valentinab25 - [`b7f74d5`](https://github.com/eea/volto-cca-policy/commit/b7f74d53513a6edbfbca5cb6d19687929bb1e5db)]
1335
+ - test: [JENKINS] Improve cypress time [valentinab25 - [`db65617`](https://github.com/eea/volto-cca-policy/commit/db656173391f65157098d95d388c25f6429753d8)]
1317
1336
  - Refs #259267 - cca event blocks attachments and check not mandatoty fields [Tripon Eugen - [`3138e5a`](https://github.com/eea/volto-cca-policy/commit/3138e5afb5bfbdbed14e27ed457b16867b7fa414)]
1318
1337
  - 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)]
1319
1338
  - Refs #161485 - Fix ECDE name conflict. [GhitaB - [`8bfd99f`](https://github.com/eea/volto-cca-policy/commit/8bfd99ff68bb82a04d1c0ed625fa514fcf46289e)]
@@ -1530,6 +1549,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
1530
1549
 
1531
1550
  #### :house: Internal changes
1532
1551
 
1552
+ - chore: [JENKINS] Remove alpha testing version [valentinab25 - [`ad1ced0`](https://github.com/eea/volto-cca-policy/commit/ad1ced0971ba116c13a3b5fcc039172cc915c919)]
1533
1553
 
1534
1554
  #### :hammer_and_wrench: Others
1535
1555
 
@@ -2010,6 +2030,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
2010
2030
  #### :hammer_and_wrench: Others
2011
2031
 
2012
2032
  - Refs #158294 - Update supported languages list. [GhitaB - [`0a4f91f`](https://github.com/eea/volto-cca-policy/commit/0a4f91f39b7edc367bd4c127d6a8f273c7788361)]
2033
+ - Add Sonarqube tag using cca-frontend addons list [EEA Jenkins - [`8f1f9ce`](https://github.com/eea/volto-cca-policy/commit/8f1f9ce6c22805670cc0800d3c779b6d619d0f31)]
2013
2034
  ### [0.1.1](https://github.com/eea/volto-cca-policy/compare/0.1.0...0.1.1) - 13 December 2022
2014
2035
 
2015
2036
  #### :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.33",
3
+ "version": "0.2.35",
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",
@@ -25,7 +25,7 @@ const messages = defineMessages({
25
25
  jul: { id: 'Jul', defaultMessage: 'Jul' },
26
26
  aug: { id: 'Aug', defaultMessage: 'Aug' },
27
27
  sep: { id: 'Sep', defaultMessage: 'Sep' },
28
- oct: { id: 'Oct', defaultMessage: 'Ott' },
28
+ oct: { id: 'Oct', defaultMessage: 'Oct' },
29
29
  nov: { id: 'Nov', defaultMessage: 'Nov' },
30
30
  dec: { id: 'Dec', defaultMessage: 'Dec' },
31
31
 
@@ -1,13 +1,15 @@
1
1
  import React from 'react';
2
- import {
3
- BannerTitle,
4
- PortalMessage,
5
- } from '@eeacms/volto-cca-policy/components';
6
- import RenderBlocks from '@plone/volto/components/theme/View/RenderBlocks';
7
- import { Grid, Container, Segment, Button, Icon } from 'semantic-ui-react';
8
- import { useIntl, defineMessages, FormattedMessage } from 'react-intl';
9
- import { SubjectTags, EventDetails } from '@eeacms/volto-cca-policy/helpers';
10
2
  import { expandToBackendURL } from '@plone/volto/helpers';
3
+ import { useIntl, defineMessages, FormattedMessage } from 'react-intl';
4
+ import { Grid, Container, Segment, Button, Icon } from 'semantic-ui-react';
5
+ import RenderBlocks from '@plone/volto/components/theme/View/RenderBlocks';
6
+ import {
7
+ SubjectTags,
8
+ EventDetails,
9
+ HTMLField,
10
+ } from '@eeacms/volto-cca-policy/helpers';
11
+ import { filterBlocks } from '@eeacms/volto-cca-policy/utils';
12
+ import { PortalMessage } from '@eeacms/volto-cca-policy/components';
11
13
 
12
14
  const messages = defineMessages({
13
15
  downloadEvent: {
@@ -16,20 +18,39 @@ const messages = defineMessages({
16
18
  },
17
19
  });
18
20
 
19
- function CcaEventView(props) {
20
- const { content } = props;
21
+ function EventView(props) {
21
22
  const intl = useIntl();
23
+ const { content } = props;
24
+ const {
25
+ blocks: filtered_blocks,
26
+ blocks_layout: filtered_blocks_layout,
27
+ hasBlockType,
28
+ } = filterBlocks(content, 'tabs_block');
22
29
 
23
30
  return (
24
31
  <div className="cca-event-view">
25
- <BannerTitle content={content} />
32
+ <PortalMessage content={content} />
26
33
 
27
34
  <Container>
28
- <PortalMessage content={content} />
29
35
  <Grid columns="12">
30
36
  <Grid.Row>
31
37
  <Grid.Column mobile={12} tablet={12} computer={8}>
32
- <RenderBlocks {...props} />
38
+ {hasBlockType && (
39
+ <>
40
+ <p className="documentDescription">{content.description}</p>
41
+ <HTMLField value={content.text} className="content-text" />
42
+ </>
43
+ )}
44
+
45
+ <RenderBlocks
46
+ {...props}
47
+ content={{
48
+ ...content,
49
+ blocks: filtered_blocks,
50
+ blocks_layout: filtered_blocks_layout,
51
+ }}
52
+ />
53
+
33
54
  <SubjectTags {...props} />
34
55
  </Grid.Column>
35
56
  <Grid.Column mobile={12} tablet={12} computer={4}>
@@ -37,9 +58,9 @@ function CcaEventView(props) {
37
58
  <EventDetails {...props} />
38
59
  {content?.event_url && (
39
60
  <>
40
- <h3>
61
+ <h4>
41
62
  <FormattedMessage id="Web" defaultMessage="Web" />
42
- </h3>
63
+ </h4>
43
64
  <p>
44
65
  <a href={content.event_url} target="_blank">
45
66
  <FormattedMessage
@@ -79,4 +100,4 @@ function CcaEventView(props) {
79
100
  );
80
101
  }
81
102
 
82
- export default CcaEventView;
103
+ export default EventView;
@@ -0,0 +1,143 @@
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 EventView from './EventView';
6
+ import config from '@plone/volto/registry';
7
+
8
+ config.blocks = {
9
+ blocksConfig: {
10
+ title: {
11
+ view: () => <div>Title Block Component</div>,
12
+ },
13
+ },
14
+ };
15
+
16
+ const mockStore = configureStore();
17
+
18
+ const store = mockStore({
19
+ intl: {
20
+ locale: 'en',
21
+ messages: {},
22
+ },
23
+ });
24
+
25
+ jest.mock('react-router-dom', () => ({
26
+ ...jest.requireActual('react-router-dom'),
27
+ useLocation: () => ({
28
+ pathname: '/',
29
+ hash: '',
30
+ search: '',
31
+ state: undefined,
32
+ }),
33
+ }));
34
+
35
+ jest.mock('@plone/volto/helpers/Loadable/Loadable');
36
+ beforeAll(
37
+ async () =>
38
+ await require('@plone/volto/helpers/Loadable/Loadable').__setLoadables(),
39
+ );
40
+
41
+ const { settings } = config;
42
+
43
+ test('renders an event view component with all props', () => {
44
+ const component = renderer.create(
45
+ <Provider store={store}>
46
+ <EventView
47
+ content={{
48
+ '@id': 'http://localhost:8080/Plone/my-page',
49
+ title: 'Hello World!',
50
+ description: 'Hi',
51
+ text: {
52
+ data: '<p>Hello World!</p>',
53
+ },
54
+ attendees: ['John Doe', 'Mario Rossi'],
55
+ contact_email: 'test@example.com',
56
+ contact_name: 'John Doe',
57
+ contact_phone: '0123456789',
58
+ end: '2019-06-24T15:20:00+00:00',
59
+ event_url: 'https://www.example.com',
60
+ location: 'Volto, Plone',
61
+ open_end: false,
62
+ recurrence: 'RRULE:FREQ=DAILY;INTERVAL=7;COUNT=7',
63
+ start: '2019-06-23T15:20:00+00:00',
64
+ subjects: ['Volto'],
65
+ whole_day: false,
66
+ blocks: {
67
+ '6cc87646-cbd3-40ea-8b18-8a737b4ec803': {
68
+ '@type': 'title',
69
+ copyrightIcon: 'ri-copyright-line',
70
+ styles: {},
71
+ },
72
+ },
73
+ blocks_layout: {
74
+ items: ['6cc87646-cbd3-40ea-8b18-8a737b4ec803'],
75
+ },
76
+ }}
77
+ />
78
+ </Provider>,
79
+ );
80
+ const json = component.toJSON();
81
+ expect(json).toMatchSnapshot();
82
+ });
83
+
84
+ test('renders an event view component with only required props', () => {
85
+ const component = renderer.create(
86
+ <Provider store={store}>
87
+ <EventView
88
+ content={{
89
+ '@id': 'http://localhost:8080/Plone/my-page',
90
+ title: 'Hello World!',
91
+ attendees: [],
92
+ end: '2019-06-23T16:20:00+00:00',
93
+ start: '2019-06-23T15:20:00+00:00',
94
+ subjects: ['Volto'],
95
+ blocks: {
96
+ '6cc87646-cbd3-40ea-8b18-8a737b4ec803': {
97
+ '@type': 'title',
98
+ copyrightIcon: 'ri-copyright-line',
99
+ styles: {},
100
+ },
101
+ },
102
+ blocks_layout: {
103
+ items: ['6cc87646-cbd3-40ea-8b18-8a737b4ec803'],
104
+ },
105
+ }}
106
+ />
107
+ </Provider>,
108
+ );
109
+ const json = component.toJSON();
110
+ expect(json).toMatchSnapshot();
111
+ });
112
+
113
+ test('renders an event view component without links to api in the text', () => {
114
+ const component = renderer.create(
115
+ <Provider store={store}>
116
+ <EventView
117
+ content={{
118
+ '@id': 'http://localhost:8080/Plone/my-page',
119
+ title: 'Hello World!',
120
+ attendees: [],
121
+ end: '2019-06-23T16:20:00+00:00',
122
+ start: '2019-06-23T15:20:00+00:00',
123
+ subjects: ['Volto'],
124
+ text: {
125
+ data: `<p>Hello World!</p><p>This is an <a href="${settings.apiPath}/foo/bar">internal link</a> and a <a href="${settings.apiPath}/foo/baz">second link</a></p>`,
126
+ },
127
+ blocks: {
128
+ '6cc87646-cbd3-40ea-8b18-8a737b4ec803': {
129
+ '@type': 'title',
130
+ copyrightIcon: 'ri-copyright-line',
131
+ styles: {},
132
+ },
133
+ },
134
+ blocks_layout: {
135
+ items: ['6cc87646-cbd3-40ea-8b18-8a737b4ec803'],
136
+ },
137
+ }}
138
+ />
139
+ </Provider>,
140
+ );
141
+ const json = component.toJSON();
142
+ expect(json).toMatchSnapshot();
143
+ });
@@ -1,33 +1,51 @@
1
1
  import React from 'react';
2
- import {
3
- BannerTitle,
4
- PortalMessage,
5
- } from '@eeacms/volto-cca-policy/components';
6
2
  import { Container } from 'semantic-ui-react';
7
- import { SubjectTags } from '@eeacms/volto-cca-policy/helpers';
3
+ import { filterBlocks } from '@eeacms/volto-cca-policy/utils';
4
+ import { PortalMessage } from '@eeacms/volto-cca-policy/components';
5
+ import { HTMLField, SubjectTags } from '@eeacms/volto-cca-policy/helpers';
8
6
  import RenderBlocks from '@plone/volto/components/theme/View/RenderBlocks';
9
- // import { When } from '@plone/volto/components/theme/View/EventDatesInfo';
7
+ import { When } from '@plone/volto/components/theme/View/EventDatesInfo';
10
8
 
11
- // const Date = (props) => {
12
- // const date = props.content?.effective;
13
- // return date ? (
14
- // <>
15
- // <When start={date} end={date} whole_day={true} open_end={false} />
16
- // </>
17
- // ) : null;
18
- // };
9
+ const PublicationDate = (props) => {
10
+ const date = props.content?.effective;
11
+ return date ? (
12
+ <div className="news-date-info">
13
+ Date:
14
+ <When start={date} end={date} whole_day={true} open_end={false} />
15
+ </div>
16
+ ) : null;
17
+ };
19
18
 
20
19
  function NewsItemView(props) {
21
20
  const { content } = props;
21
+ const {
22
+ blocks: filtered_blocks,
23
+ blocks_layout: filtered_blocks_layout,
24
+ hasBlockType,
25
+ } = filterBlocks(content, 'tabs_block');
22
26
 
23
27
  return (
24
28
  <div className="cca-newsitem-view">
25
- <BannerTitle content={content} />
29
+ <PortalMessage content={content} />
26
30
 
27
31
  <Container>
28
- <PortalMessage content={content} />
29
- <RenderBlocks {...props} />
30
- {/* <Date {...props} /> */}
32
+ {hasBlockType && (
33
+ <>
34
+ <p className="documentDescription">{content.description}</p>
35
+ <HTMLField value={content.text} className="content-text" />
36
+ </>
37
+ )}
38
+
39
+ <RenderBlocks
40
+ {...props}
41
+ content={{
42
+ ...content,
43
+ blocks: filtered_blocks,
44
+ blocks_layout: filtered_blocks_layout,
45
+ }}
46
+ />
47
+
48
+ <PublicationDate {...props} />
31
49
  <SubjectTags {...props} />
32
50
  </Container>
33
51
  </div>
@@ -454,9 +454,9 @@ export const EventDetails = (props) => {
454
454
 
455
455
  return (
456
456
  <>
457
- <h3>
457
+ <h4>
458
458
  <FormattedMessage id="When" defaultMessage="When" />
459
- </h3>
459
+ </h4>
460
460
  <When
461
461
  start={content.start}
462
462
  end={content.end}
@@ -465,17 +465,17 @@ export const EventDetails = (props) => {
465
465
  />
466
466
  {content?.location !== null && (
467
467
  <>
468
- <h3>
468
+ <h4>
469
469
  <FormattedMessage id="Where" defaultMessage="Where" />
470
- </h3>
470
+ </h4>
471
471
  <p>{content.location}</p>
472
472
  </>
473
473
  )}
474
474
  {!!content.contact_email && (
475
475
  <>
476
- <h3>
476
+ <h4>
477
477
  <FormattedMessage id="Info" defaultMessage="Info" />
478
- </h3>
478
+ </h4>
479
479
  <p>{content.contact_email}</p>
480
480
  </>
481
481
  )}
package/src/utils.js CHANGED
@@ -50,3 +50,23 @@ export const hasTypeOfBlock = (obj, type, name) => {
50
50
 
51
51
  return false;
52
52
  };
53
+
54
+ export const filterBlocks = (content, block_type) => {
55
+ const filteredBlocks = { ...content.blocks };
56
+ const filteredBlocksLayout = { ...content.blocks_layout };
57
+
58
+ const filteredBlockUID = Object.keys(filteredBlocks)?.filter(
59
+ (key) => filteredBlocks[key]['@type'] === block_type,
60
+ );
61
+ filteredBlockUID.forEach((key) => delete filteredBlocks[key]);
62
+ filteredBlocksLayout.items = filteredBlocksLayout?.items?.filter(
63
+ (item) => !filteredBlockUID.includes(item),
64
+ );
65
+ const hasBlockType = filteredBlockUID.length > 0;
66
+
67
+ return {
68
+ blocks: filteredBlocks,
69
+ blocks_layout: filteredBlocksLayout,
70
+ hasBlockType,
71
+ };
72
+ };
@@ -302,3 +302,17 @@ hr {
302
302
  }
303
303
  }
304
304
  }
305
+
306
+ .cca-newsitem-view,
307
+ .cca-event-view {
308
+ .news-date-info {
309
+ display: flex;
310
+ gap: 3px;
311
+ justify-content: flex-end;
312
+ }
313
+
314
+ .content-text p {
315
+ margin: 0em 0em 1em;
316
+ line-height: 1.5;
317
+ }
318
+ }