@eeacms/volto-cca-policy 0.3.118 → 0.3.120

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,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.3.120](https://github.com/eea/volto-cca-policy/compare/0.3.119...0.3.120) - 30 April 2026
8
+
9
+ #### :bug: Bug Fixes
10
+
11
+ - fix: hide ArchivedVersionListing for archived indicators in DatabaseItemView [kreafox - [`ff7bd0a`](https://github.com/eea/volto-cca-policy/commit/ff7bd0aab3b5facd2ebfba3bd46fd089e0a9fe8f)]
12
+
13
+ ### [0.3.119](https://github.com/eea/volto-cca-policy/compare/0.3.118...0.3.119) - 30 April 2026
14
+
15
+ #### :rocket: New Features
16
+
17
+ - feat: add ArchivedVersionListing component and update DatabaseItemView to display archived indicator versions [kreafox - [`858e868`](https://github.com/eea/volto-cca-policy/commit/858e868f124642cd112fea45f079a13dcd27d39e)]
18
+
19
+ #### :hammer_and_wrench: Others
20
+
21
+ - test: add unit tests for ArchivedVersionListing component [kreafox - [`010ef2c`](https://github.com/eea/volto-cca-policy/commit/010ef2c127bf851ab602cb1518d1e1012894e2d9)]
22
+ - test: update ArchivedVersionNotice test cases to use archived_versions instead of relatedItems [kreafox - [`09a7619`](https://github.com/eea/volto-cca-policy/commit/09a761987dc28b710798effb62496eb6d6165543)]
7
23
  ### [0.3.118](https://github.com/eea/volto-cca-policy/compare/0.3.117...0.3.118) - 28 April 2026
8
24
 
9
25
  #### :rocket: New Features
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-cca-policy",
3
- "version": "0.3.118",
3
+ "version": "0.3.120",
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",
@@ -16,5 +16,6 @@ export { default as ImageWidget } from './theme/Widgets/ImageWidget';
16
16
  export { default as CreateArchivedCopyButton } from './manage/CreateArchivedCopyButton/CreateArchivedCopyButton';
17
17
 
18
18
  // Views
19
+ export { default as ArchivedVersionListing } from './theme/Views/ArchivedVersionListing';
19
20
  export { default as ArchivedVersionNotice } from './theme/Views/ArchivedVersionNotice';
20
21
  export { default as VersionsGroup } from './theme/Views/VersionsGroup';
@@ -0,0 +1,40 @@
1
+ import React from 'react';
2
+ import { Link } from 'react-router-dom';
3
+ import { FormattedMessage } from 'react-intl';
4
+ import { flattenToAppURL } from '@plone/volto/helpers';
5
+ import { AccordionList } from '@eeacms/volto-cca-policy/components';
6
+
7
+ function ArchivedVersionListing({ content }) {
8
+ const { archived_versions } = content;
9
+
10
+ const items = archived_versions?.map((version) => (
11
+ <div key={version['@id']}>
12
+ <Link to={flattenToAppURL(version['@id'])}>
13
+ {version.title || flattenToAppURL(version['@id'])}
14
+ </Link>
15
+ </div>
16
+ ));
17
+
18
+ if (!items?.length) {
19
+ return null;
20
+ }
21
+
22
+ return (
23
+ <AccordionList
24
+ variation="secondary"
25
+ accordions={[
26
+ {
27
+ title: (
28
+ <FormattedMessage
29
+ id="Previous versions of this indicator"
30
+ defaultMessage="Previous versions of this indicator"
31
+ />
32
+ ),
33
+ content: items,
34
+ },
35
+ ]}
36
+ />
37
+ );
38
+ }
39
+
40
+ export default ArchivedVersionListing;
@@ -0,0 +1,106 @@
1
+ import React from 'react';
2
+ import { MemoryRouter } from 'react-router-dom';
3
+ import '@testing-library/jest-dom/extend-expect';
4
+ import { render, screen } from '@testing-library/react';
5
+ import ArchivedVersionListing from './ArchivedVersionListing';
6
+
7
+ jest.mock('@plone/volto/helpers', () => ({
8
+ flattenToAppURL: (url) => url.replace('http://localhost:3000', ''),
9
+ }));
10
+
11
+ jest.mock('@eeacms/volto-cca-policy/components', () => ({
12
+ AccordionList: ({ accordions }) => (
13
+ <div className="accordion-list">
14
+ {accordions.map((accordion, index) => (
15
+ <div key={index}>
16
+ <div>{accordion.title}</div>
17
+ <div>{accordion.content}</div>
18
+ </div>
19
+ ))}
20
+ </div>
21
+ ),
22
+ }));
23
+
24
+ describe('ArchivedVersionListing', () => {
25
+ it('returns null when there are no archived versions', () => {
26
+ const content = {
27
+ archived_versions: [],
28
+ };
29
+
30
+ const { container } = render(
31
+ <MemoryRouter>
32
+ <ArchivedVersionListing content={content} />
33
+ </MemoryRouter>,
34
+ );
35
+
36
+ expect(container.innerHTML).toBe('');
37
+ });
38
+
39
+ it('returns null when archived_versions is missing', () => {
40
+ const content = {};
41
+
42
+ const { container } = render(
43
+ <MemoryRouter>
44
+ <ArchivedVersionListing content={content} />
45
+ </MemoryRouter>,
46
+ );
47
+
48
+ expect(container.innerHTML).toBe('');
49
+ });
50
+
51
+ it('renders archived version links', () => {
52
+ const content = {
53
+ archived_versions: [
54
+ {
55
+ '@id': 'http://localhost:3000/indicator-v1',
56
+ title: 'Indicator v1',
57
+ },
58
+ {
59
+ '@id': 'http://localhost:3000/indicator-v2',
60
+ title: 'Indicator v2',
61
+ },
62
+ ],
63
+ };
64
+
65
+ render(
66
+ <MemoryRouter>
67
+ <ArchivedVersionListing content={content} />
68
+ </MemoryRouter>,
69
+ );
70
+
71
+ expect(
72
+ screen.getByText('Previous versions of this indicator'),
73
+ ).toBeInTheDocument();
74
+
75
+ expect(screen.getByText('Indicator v1')).toHaveAttribute(
76
+ 'href',
77
+ '/indicator-v1',
78
+ );
79
+
80
+ expect(screen.getByText('Indicator v2')).toHaveAttribute(
81
+ 'href',
82
+ '/indicator-v2',
83
+ );
84
+ });
85
+
86
+ it('uses the URL as link text when title is missing', () => {
87
+ const content = {
88
+ archived_versions: [
89
+ {
90
+ '@id': 'http://localhost:3000/indicator-v1',
91
+ },
92
+ ],
93
+ };
94
+
95
+ render(
96
+ <MemoryRouter>
97
+ <ArchivedVersionListing content={content} />
98
+ </MemoryRouter>,
99
+ );
100
+
101
+ expect(screen.getByText('/indicator-v1')).toHaveAttribute(
102
+ 'href',
103
+ '/indicator-v1',
104
+ );
105
+ });
106
+ });
@@ -7,8 +7,8 @@ import { flattenToAppURL } from '@plone/volto/helpers';
7
7
  function ArchivedVersionNotice({ content }) {
8
8
  if (content?.review_state !== 'archived') return null;
9
9
 
10
- const relatedItems = content?.relatedItems || [];
11
- const latestVersion = relatedItems.find(
10
+ const archivedVersions = content?.archived_versions || [];
11
+ const latestVersion = archivedVersions.find(
12
12
  (item) => item.review_state === 'published',
13
13
  );
14
14
 
@@ -21,7 +21,7 @@ describe('ArchivedVersionNotice', () => {
21
21
  const content = {
22
22
  '@type': 'Document',
23
23
  review_state: 'published',
24
- relatedItems: [],
24
+ archived_versions: [],
25
25
  };
26
26
  const { container } = render(
27
27
  <Provider store={store}>
@@ -37,13 +37,14 @@ describe('ArchivedVersionNotice', () => {
37
37
  const content = {
38
38
  '@type': 'Document',
39
39
  review_state: 'archived',
40
- relatedItems: [
40
+ archived_versions: [
41
41
  {
42
42
  '@id': 'http://localhost:3000/another-archived',
43
43
  review_state: 'archived',
44
44
  },
45
45
  ],
46
46
  };
47
+
47
48
  const { container } = render(
48
49
  <Provider store={store}>
49
50
  <MemoryRouter>
@@ -51,6 +52,7 @@ describe('ArchivedVersionNotice', () => {
51
52
  </MemoryRouter>
52
53
  </Provider>,
53
54
  );
55
+
54
56
  expect(container.innerHTML).toBe('');
55
57
  });
56
58
 
@@ -60,7 +62,7 @@ describe('ArchivedVersionNotice', () => {
60
62
  '@type': 'Indicator',
61
63
  review_state: 'archived',
62
64
  title: 'My Indicator (Archived)',
63
- relatedItems: [
65
+ archived_versions: [
64
66
  {
65
67
  '@id': 'http://localhost:3000/my-indicator',
66
68
  review_state: 'published',
@@ -68,6 +70,7 @@ describe('ArchivedVersionNotice', () => {
68
70
  },
69
71
  ],
70
72
  };
73
+
71
74
  const { container } = render(
72
75
  <Provider store={store}>
73
76
  <MemoryRouter>
@@ -75,6 +78,7 @@ describe('ArchivedVersionNotice', () => {
75
78
  </MemoryRouter>
76
79
  </Provider>,
77
80
  );
81
+
78
82
  expect(
79
83
  container.querySelector('.archived-version-notice'),
80
84
  ).toBeInTheDocument();
@@ -30,6 +30,7 @@ import {
30
30
  } from '@eeacms/volto-cca-policy/helpers';
31
31
  import {
32
32
  ArchivedVersionNotice,
33
+ ArchivedVersionListing,
33
34
  // VersionsGroup, // commented out - relatedItems already shows versions
34
35
  } from '@eeacms/volto-cca-policy/components';
35
36
 
@@ -297,6 +298,10 @@ const DatabaseItemView = (props) => {
297
298
  </>
298
299
  )}
299
300
  </Grid>
301
+
302
+ {type === INDICATOR && content?.review_state !== 'archived' && (
303
+ <ArchivedVersionListing content={content} />
304
+ )}
300
305
  </Container>
301
306
  </div>
302
307
  );