@eeacms/volto-cca-policy 0.3.52 → 0.3.54

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,31 @@ 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.3.54](https://github.com/eea/volto-cca-policy/compare/0.3.53...0.3.54) - 24 June 2025
8
+
9
+ #### :bug: Bug Fixes
10
+
11
+ - fix(mission): add more checks; code cleanup [kreafox - [`35bb513`](https://github.com/eea/volto-cca-policy/commit/35bb513dfb124e8001a3743680176c6b9643b0ac)]
12
+
13
+ #### :nail_care: Enhancements
14
+
15
+ - change(view): remove draft background on archived items; add portal message - refs #289196 [kreafox - [`a5aa7b5`](https://github.com/eea/volto-cca-policy/commit/a5aa7b53284faced93b8c1ae0751a64743347183)]
16
+ - change(view): remove archived item info message - refs #289196 [kreafox - [`b65e876`](https://github.com/eea/volto-cca-policy/commit/b65e876efae651c30d2d0e7a91ee7839ed904d90)]
17
+ - change(mission): small refactoring [kreafox - [`58e51ee`](https://github.com/eea/volto-cca-policy/commit/58e51ee704efd42671c9e360c74f7d930ceda604)]
18
+
19
+ #### :house: Internal changes
20
+
21
+ - chore: update package.json [kreafox - [`5b6449b`](https://github.com/eea/volto-cca-policy/commit/5b6449b5167a72fd49d3ff7c17ac50d95a302da2)]
22
+
23
+ #### :hammer_and_wrench: Others
24
+
25
+ - test: increase coverage [kreafox - [`9b97e31`](https://github.com/eea/volto-cca-policy/commit/9b97e3164c8fe8122d18d39b667144133c669ada)]
26
+ - test: increase coverage [kreafox - [`63170f2`](https://github.com/eea/volto-cca-policy/commit/63170f29afef7176910a96dee906df74953329a0)]
27
+ - Don't need the migration buttons anymore [Tiberiu Ichim - [`98d0812`](https://github.com/eea/volto-cca-policy/commit/98d08124818dd7dff1f4c41c3fc98fde9c84d06f)]
28
+ - update tests [kreafox - [`e4c1992`](https://github.com/eea/volto-cca-policy/commit/e4c1992da98dd30718884c1d0b228db4ef6f4180)]
29
+ - Redirect without ++api++ [Tiberiu Ichim - [`f268921`](https://github.com/eea/volto-cca-policy/commit/f268921307ff0f08a1f15e20db3c08bfe261260c)]
30
+ ### [0.3.53](https://github.com/eea/volto-cca-policy/compare/0.3.52...0.3.53) - 28 May 2025
31
+
7
32
  ### [0.3.52](https://github.com/eea/volto-cca-policy/compare/0.3.51...0.3.52) - 27 May 2025
8
33
 
9
34
  #### :hammer_and_wrench: Others
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-cca-policy",
3
- "version": "0.3.52",
3
+ "version": "0.3.54",
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",
@@ -34,7 +34,7 @@
34
34
  "@eeacms/volto-embed": "^9.1.1",
35
35
  "@eeacms/volto-globalsearch": "2.1.2",
36
36
  "@eeacms/volto-hero-block": "^7.1.0",
37
- "@eeacms/volto-openlayers-map": "github:eea/volto-openlayers-map#1.0.0-alpha.1",
37
+ "@eeacms/volto-openlayers-map": "1.0.0",
38
38
  "@eeacms/volto-searchlib": "2.0.16",
39
39
  "@eeacms/volto-slate-label": "^0.6.0",
40
40
  "@eeacms/volto-tabs-block": "^7.5.1",
@@ -0,0 +1,26 @@
1
+ import '@testing-library/jest-dom/extend-expect';
2
+ import { render, screen, fireEvent } from '@testing-library/react';
3
+ import ReadMoreView from './ReadMoreView';
4
+
5
+ describe('ReadMoreView', () => {
6
+ it('renders with default labels and toggles on click', () => {
7
+ const data = {
8
+ label_closed: 'Show more',
9
+ label_opened: 'Show less',
10
+ label_position: 'left',
11
+ height: '200px',
12
+ };
13
+
14
+ const { container } = render(<ReadMoreView data={data} mode="view" />);
15
+
16
+ expect(screen.getByText('Show more')).toBeInTheDocument();
17
+
18
+ fireEvent.click(screen.getByRole('button'));
19
+ expect(screen.getByText('Show less')).toBeInTheDocument();
20
+
21
+ fireEvent.click(screen.getByRole('button'));
22
+ expect(screen.getByText('Show more')).toBeInTheDocument();
23
+
24
+ expect(container).toBeTruthy();
25
+ });
26
+ });
@@ -0,0 +1,90 @@
1
+ import '@testing-library/jest-dom/extend-expect';
2
+ import { render, screen } from '@testing-library/react';
3
+ import { MemoryRouter } from 'react-router-dom';
4
+ import { Provider } from 'react-intl-redux';
5
+ import configureStore from 'redux-mock-store';
6
+ import TransRegionSelectView from './TransRegionSelectView';
7
+
8
+ const mockStore = configureStore();
9
+
10
+ describe('TransRegionSelectView', () => {
11
+ it('renders in view mode with regions and countries', () => {
12
+ const store = mockStore({
13
+ intl: {
14
+ locale: 'en',
15
+ messages: {},
16
+ },
17
+ });
18
+
19
+ const mockProps = {
20
+ data: {
21
+ title: 'Transnational Region',
22
+ },
23
+ metadata: {
24
+ title: 'Sample Region',
25
+ '@components': {
26
+ transnationalregion: {
27
+ regions: [
28
+ { title: 'Region A', url: '/region-a' },
29
+ { title: 'Region B', url: '/region-b' },
30
+ ],
31
+ countries: [
32
+ [
33
+ ['Country X', '/country-x'],
34
+ ['Country Y', '/country-y'],
35
+ ],
36
+ ],
37
+ },
38
+ },
39
+ },
40
+ };
41
+
42
+ render(
43
+ <Provider store={store}>
44
+ <MemoryRouter>
45
+ <TransRegionSelectView {...mockProps} />
46
+ </MemoryRouter>
47
+ </Provider>,
48
+ );
49
+
50
+ // Dropdown should appear
51
+ expect(screen.getByText('Choose a region')).toBeInTheDocument();
52
+
53
+ // Title should render
54
+ expect(screen.getByText('Transnational Region')).toBeInTheDocument();
55
+
56
+ // Countries should be rendered as links
57
+ expect(screen.getByText('Country X,')).toBeInTheDocument();
58
+ expect(screen.getByText('Country Y')).toBeInTheDocument();
59
+
60
+ // Dropdown options should exist
61
+ expect(screen.getByText('Region A')).toBeInTheDocument();
62
+ expect(screen.getByText('Region B')).toBeInTheDocument();
63
+ });
64
+
65
+ it('renders edit mode correctly', () => {
66
+ const store = mockStore({
67
+ intl: {
68
+ locale: 'en',
69
+ messages: {},
70
+ },
71
+ });
72
+
73
+ const mockProps = {
74
+ mode: 'edit',
75
+ data: {
76
+ region: 'Region A',
77
+ },
78
+ };
79
+
80
+ const { container } = render(
81
+ <Provider store={store}>
82
+ <MemoryRouter>
83
+ <TransRegionSelectView {...mockProps} />
84
+ </MemoryRouter>
85
+ </Provider>,
86
+ );
87
+
88
+ expect(container).toHaveTextContent('TransRegionSelectView: Region A');
89
+ });
90
+ });
@@ -0,0 +1,9 @@
1
+ import { Tab } from 'semantic-ui-react';
2
+
3
+ const NoDataReported = ({ label }) => (
4
+ <Tab.Pane>
5
+ <h5>{label}</h5>
6
+ </Tab.Pane>
7
+ );
8
+
9
+ export default NoDataReported;
@@ -1,10 +1,9 @@
1
1
  import { Tab, Grid } from 'semantic-ui-react';
2
2
  import { Callout } from '@eeacms/volto-eea-design-system/ui';
3
3
  import { HTMLField } from '@eeacms/volto-cca-policy/helpers';
4
- import { formatTextToHTML } from '@eeacms/volto-cca-policy/utils';
4
+ import { formatTextToHTML, isEmpty } from '@eeacms/volto-cca-policy/utils';
5
5
  import AccordionList from '../AccordionList';
6
-
7
- const isEmpty = (arr) => !Array.isArray(arr) || arr.length === 0;
6
+ import NoDataReported from '../NoDataReported';
8
7
 
9
8
  const ActionsTabContent = ({ action }) => {
10
9
  const hasHazards = action?.Climate_Hazards?.length > 0;
@@ -77,11 +76,7 @@ const ActionPagesTab = ({ result, general_text }) => {
77
76
  const NoResults = isEmpty(action_text) && isEmpty(actions);
78
77
 
79
78
  if (NoResults) {
80
- return (
81
- <Tab.Pane>
82
- <p>{No_Data_Reported_Label}</p>
83
- </Tab.Pane>
84
- );
79
+ return <NoDataReported label={No_Data_Reported_Label} />;
85
80
  }
86
81
 
87
82
  return (
@@ -6,6 +6,11 @@ jest.mock('@eeacms/volto-eea-design-system/ui', () => ({
6
6
  Callout: ({ children }) => <div>{children}</div>,
7
7
  }));
8
8
 
9
+ jest.mock('@eeacms/volto-cca-policy/utils', () => ({
10
+ isEmpty: (arr) => !arr || arr.length === 0,
11
+ formatTextToHTML: (text) => text,
12
+ }));
13
+
9
14
  jest.mock('./../AccordionList', () => ({ variation, accordions }) => (
10
15
  <div>
11
16
  {accordions.map((item, index) => (
@@ -1,13 +1,12 @@
1
1
  import { Tab, Image, Segment, Item } from 'semantic-ui-react';
2
2
  import { Callout } from '@eeacms/volto-eea-design-system/ui';
3
3
  import { HTMLField } from '@eeacms/volto-cca-policy/helpers';
4
- import { formatTextToHTML } from '@eeacms/volto-cca-policy/utils';
4
+ import { formatTextToHTML, isEmpty } from '@eeacms/volto-cca-policy/utils';
5
5
  import AccordionList from '../AccordionList';
6
+ import NoDataReported from '../NoDataReported';
6
7
 
7
8
  import image from '@eeacms/volto-cca-policy/../theme//assets/images/image-narrow.svg';
8
9
 
9
- const isEmpty = (arr) => !Array.isArray(arr) || arr.length === 0;
10
-
11
10
  const ItemsSection = ({ items }) => {
12
11
  if (!items?.length) return null;
13
12
 
@@ -61,7 +60,6 @@ const AssessmentTab = ({ result, general_text }) => {
61
60
  const assessment_risks = result.assessment_risks || [];
62
61
  const assessment_hazards_sectors = result.assessment_hazards_sectors || [];
63
62
  const { No_Data_Reported_Label } = general_text || {};
64
- // const [activeIndex, setActiveIndex] = React.useState(0);
65
63
 
66
64
  const NoResults =
67
65
  isEmpty(result.assessment_text) &&
@@ -70,11 +68,7 @@ const AssessmentTab = ({ result, general_text }) => {
70
68
  isEmpty(result.assessment_hazards_sectors);
71
69
 
72
70
  if (NoResults) {
73
- return (
74
- <Tab.Pane>
75
- <p>{No_Data_Reported_Label}</p>
76
- </Tab.Pane>
77
- );
71
+ return <NoDataReported label={No_Data_Reported_Label} />;
78
72
  }
79
73
 
80
74
  return (
@@ -90,32 +84,39 @@ const AssessmentTab = ({ result, general_text }) => {
90
84
 
91
85
  <div className="tab-section-wrapper assessment">
92
86
  {Cra_Title && <h3>{Cra_Title}</h3>}
93
- {Cra_Abstract && <h5>{Cra_Abstract}</h5>}
94
-
95
- <ItemsSection items={result.assessment_factors} />
96
-
97
- {Attachments && <h4>{Attachments}</h4>}
98
-
99
- {assessment_risks.map((risk, index) => {
100
- const title = risk?.Attachment_Title
101
- ? `${risk.Assessment_Id}. ${risk.Attachment_Title} - ${
102
- risk.Year_Of_Publication || ''
103
- }`
104
- : null;
105
- return (
106
- <div key={index}>
107
- <AccordionList
108
- variation="tertiary"
109
- accordions={[
110
- {
111
- title: title,
112
- content: <AssessmentAccordionContent result={risk} />,
113
- },
114
- ]}
115
- />
116
- </div>
117
- );
118
- })}
87
+
88
+ {result.assessment_factors.length > 0 && (
89
+ <>
90
+ {Cra_Abstract && <h5>{Cra_Abstract}</h5>}
91
+ <ItemsSection items={result.assessment_factors} />
92
+ </>
93
+ )}
94
+
95
+ {assessment_risks.length > 0 && (
96
+ <>
97
+ {Attachments && <h4>{Attachments}</h4>}
98
+ {assessment_risks.map((risk, index) => {
99
+ const title = risk?.Attachment_Title
100
+ ? `${risk.Assessment_Id}. ${risk.Attachment_Title} - ${
101
+ risk.Year_Of_Publication || ''
102
+ }`
103
+ : null;
104
+ return (
105
+ <div key={index}>
106
+ <AccordionList
107
+ variation="tertiary"
108
+ accordions={[
109
+ {
110
+ title: title,
111
+ content: <AssessmentAccordionContent result={risk} />,
112
+ },
113
+ ]}
114
+ />
115
+ </div>
116
+ );
117
+ })}
118
+ </>
119
+ )}
119
120
  </div>
120
121
 
121
122
  {Hazards_Title && <h3>{Hazards_Title}</h3>}
@@ -140,59 +141,6 @@ const AssessmentTab = ({ result, general_text }) => {
140
141
  }))}
141
142
  />
142
143
  )}
143
-
144
- {/* <Tab
145
- menu={{
146
- fluid: true,
147
- className: 'secondary',
148
- vertical: true,
149
- pointing: true,
150
- }}
151
- grid={{ paneWidth: 9, tabWidth: 3, stackable: true }}
152
- activeIndex={activeIndex}
153
- onTabChange={(e, { activeIndex }) => setActiveIndex(activeIndex)}
154
- panes={[
155
- {
156
- menuItem: 'Water related',
157
- render: () => (
158
- <AccordionList
159
- accordions={[
160
- {
161
- title: 'Vestibulum ante ipsum primis',
162
- content: 'No additional details provided.',
163
- },
164
- {
165
- title: 'Etiam accumsan urna a mauris',
166
- content: 'No additional details provided.',
167
- },
168
- ]}
169
- />
170
- ),
171
- },
172
- {
173
- menuItem: 'Heat related',
174
- render: () => (
175
- <div>
176
- Nam tempor finibus lorem, nec varius arcu convallis sed. Nunc id
177
- orci a neque vehicula malesuada. Donec vehicula libero vel leo
178
- convallis, nec tincidunt felis tincidunt. Maecenas euismod
179
- tristique leo, vel malesuada ligula malesuada sed.
180
- </div>
181
- ),
182
- },
183
- {
184
- menuItem: 'Other hazards',
185
- render: () => (
186
- <div>
187
- Nam tempor finibus lorem, nec varius arcu convallis sed. Nunc id
188
- orci a neque vehicula malesuada. Donec vehicula libero vel leo
189
- convallis, nec tincidunt felis tincidunt. Maecenas euismod
190
- tristique leo, vel malesuada ligula malesuada sed.
191
- </div>
192
- ),
193
- },
194
- ]}
195
- /> */}
196
144
  </Tab.Pane>
197
145
  );
198
146
  };
@@ -6,6 +6,11 @@ jest.mock('@eeacms/volto-eea-design-system/ui', () => ({
6
6
  Callout: ({ children }) => <div>{children}</div>,
7
7
  }));
8
8
 
9
+ jest.mock('@eeacms/volto-cca-policy/utils', () => ({
10
+ isEmpty: (arr) => !arr || arr.length === 0,
11
+ formatTextToHTML: (text) => text,
12
+ }));
13
+
9
14
  const mockData = {
10
15
  assessment_text: [
11
16
  {
@@ -5,12 +5,12 @@ import { HTMLField } from '@eeacms/volto-cca-policy/helpers';
5
5
  import {
6
6
  formatTextToHTML,
7
7
  extractPlanNameAndURL,
8
+ isEmpty,
8
9
  } from '@eeacms/volto-cca-policy/utils';
9
10
  import AccordionList from '../AccordionList';
11
+ import NoDataReported from '../NoDataReported';
10
12
  import image from '@eeacms/volto-cca-policy/../theme/assets/images/image-narrow.svg';
11
13
 
12
- const isEmpty = (arr) => !Array.isArray(arr) || arr.length === 0;
13
-
14
14
  const ItemsSection = ({ items }) => {
15
15
  if (!items?.length) return null;
16
16
 
@@ -94,11 +94,7 @@ const PlanningTab = ({ result, general_text }) => {
94
94
  isEmpty(planning_climate_action);
95
95
 
96
96
  if (NoResults) {
97
- return (
98
- <Tab.Pane>
99
- <p>{No_Data_Reported_Label}</p>
100
- </Tab.Pane>
101
- );
97
+ return <NoDataReported label={No_Data_Reported_Label} />;
102
98
  }
103
99
 
104
100
  return (
@@ -9,6 +9,7 @@ jest.mock('@eeacms/volto-cca-policy/helpers', () => ({
9
9
  }));
10
10
 
11
11
  jest.mock('@eeacms/volto-cca-policy/utils', () => ({
12
+ isEmpty: (arr) => !arr || arr.length === 0,
12
13
  formatTextToHTML: (text) => text,
13
14
  extractPlanNameAndURL: (str) => ({
14
15
  name: 'Plan Example',
@@ -28,9 +28,8 @@ function EventView(props) {
28
28
 
29
29
  return (
30
30
  <div className="cca-event-view">
31
- <PortalMessage content={content} />
32
-
33
31
  <Container>
32
+ <PortalMessage content={content} />
34
33
  <Grid columns="12">
35
34
  <Grid.Row>
36
35
  <Grid.Column mobile={12} tablet={12} computer={8}>
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import { Container } from 'semantic-ui-react';
3
3
  import { filterBlocks } from '@eeacms/volto-cca-policy/utils';
4
- import { PortalMessage } from '@eeacms/volto-cca-policy/components';
5
4
  import { HTMLField, SubjectTags } from '@eeacms/volto-cca-policy/helpers';
5
+ import { PortalMessage } from '@eeacms/volto-cca-policy/components';
6
6
  import RenderBlocks from '@plone/volto/components/theme/View/RenderBlocks';
7
7
  import { UniversalLink } from '@plone/volto/components';
8
8
 
@@ -11,6 +11,7 @@ import {
11
11
  ShareInfoButton,
12
12
  PortalMessage,
13
13
  } from '@eeacms/volto-cca-policy/components';
14
+
14
15
  import { FormattedMessage } from 'react-intl';
15
16
 
16
17
  import config from '@plone/volto/registry';
package/src/constants.js CHANGED
@@ -3,7 +3,8 @@ export const download_fields = [
3
3
  { field: 'about', name: 'About' },
4
4
  { field: 'title', name: 'Title' },
5
5
  { field: 'created', name: 'Creation Date' },
6
- { field: 'issued', name: 'Publication Date' },
6
+ { field: 'issued', name: 'Issued Date' },
7
+ { field: 'publication_date', name: 'Publication Date' },
7
8
  { field: 'creators', name: 'Creator' },
8
9
  { field: 'objectProvides', name: 'Content type' },
9
10
  { field: 'fulltext', name: 'Description' },
package/src/index.js CHANGED
@@ -22,9 +22,7 @@ import C3SIndicatorView from './components/theme/Views/C3SIndicatorView';
22
22
  import DatabaseItemView from './components/theme/Views/DatabaseItemView';
23
23
 
24
24
  import GeocharsWidget from './components/theme/Widgets/GeocharsWidget';
25
- // import GeolocationWidget from './components/theme/Widgets/GeolocationWidget';
26
25
  import PromotionalImageWidget from './components/theme/Widgets/PromotionalImageWidget';
27
- import MigrationButtons from './components/MigrationButtons';
28
26
  import HealthHorizontalCardItem from './components/Result/HealthHorizontalCardItem';
29
27
  import ClusterHorizontalCardItem from './components/Result/ClusterHorizontalCardItem';
30
28
 
@@ -45,6 +43,9 @@ import BrokenLinks from './components/theme/Views/BrokenLinks';
45
43
 
46
44
  import { eea_languages, non_eu_langs } from './constants';
47
45
 
46
+ // import GeolocationWidget from './components/theme/Widgets/GeolocationWidget';
47
+ // import MigrationButtons from './components/MigrationButtons';
48
+
48
49
  const getEnv = () => (typeof window !== 'undefined' ? window.env : process.env);
49
50
 
50
51
  const pathToNegRegex = (p) => `(?!(${p}))`;
@@ -511,10 +512,10 @@ const applyConfig = (config) => {
511
512
 
512
513
  config.settings.appExtras = [
513
514
  ...(config.settings.appExtras || []),
514
- {
515
- match: '',
516
- component: MigrationButtons,
517
- },
515
+ // {
516
+ // match: '',
517
+ // component: MigrationButtons,
518
+ // },
518
519
  {
519
520
  match: '',
520
521
  component: TranslationDisclaimer,
@@ -16,6 +16,13 @@ export const langRedirection = ({ dispatch, getState }) => (next) => (
16
16
  const urlParams = new URLSearchParams(queryString);
17
17
  const hasLanguageQueryParam = urlParams.has('set_language');
18
18
 
19
+ // sometimes there's Links where the target has moved
20
+ const nonApiPathname = pathname.replaceAll('++api++', '');
21
+ if (nonApiPathname !== pathname) {
22
+ action.payload.location.pathname = nonApiPathname;
23
+ window.history.replaceState(window.history.state, '', nonApiPathname);
24
+ }
25
+
19
26
  if (
20
27
  locale !== 'en' &&
21
28
  !isSearchPage &&
package/src/utils.js CHANGED
@@ -127,3 +127,5 @@ export const extractPlanNameAndURL = (text) => {
127
127
  url,
128
128
  };
129
129
  };
130
+
131
+ export const isEmpty = (arr) => !Array.isArray(arr) || arr.length === 0;
@@ -335,3 +335,8 @@ hr {
335
335
  border-radius: 4px;
336
336
  border: 1px solid #e5e5e5;
337
337
  }
338
+
339
+
340
+ body.view-viewview.wf-state-is-draft {
341
+ background-image: none !important;
342
+ }