@eeacms/volto-cca-policy 0.3.57 → 0.3.58

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,12 @@ 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.58](https://github.com/eea/volto-cca-policy/compare/0.3.57...0.3.58) - 3 July 2025
8
+
9
+ #### :hammer_and_wrench: Others
10
+
11
+ - Solve eslint [Tiberiu Ichim - [`29f656a`](https://github.com/eea/volto-cca-policy/commit/29f656a48416a04a2ebdf82091f25134b117cd7d)]
12
+ - Solve problem in redirection [Tiberiu Ichim - [`6afb231`](https://github.com/eea/volto-cca-policy/commit/6afb231df59acc0b2ff4f162420ae9c93040ee09)]
7
13
  ### [0.3.57](https://github.com/eea/volto-cca-policy/compare/0.3.56...0.3.57) - 27 June 2025
8
14
 
9
15
  #### :house: Internal changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-cca-policy",
3
- "version": "0.3.57",
3
+ "version": "0.3.58",
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",
@@ -44,7 +44,6 @@ import {
44
44
  getContent,
45
45
  getNavigation,
46
46
  getTypes,
47
- getWorkflow,
48
47
  } from '@plone/volto/actions';
49
48
 
50
49
  import clearSVG from '@plone/volto/icons/clear.svg';
@@ -316,11 +315,6 @@ export function connectAppComponent(AppComponent) {
316
315
  }
317
316
  },
318
317
  },
319
- {
320
- key: 'workflow',
321
- promise: ({ location, store: { dispatch } }) =>
322
- __SERVER__ && dispatch(getWorkflow(getBaseUrl(location.pathname))),
323
- },
324
318
  ]),
325
319
  injectIntl,
326
320
  connect((state, props) => {
@@ -0,0 +1,7 @@
1
+ copied from volto, override with this bit:
2
+
3
+ if (Object.keys(action.result).length === 0) {
4
+ return state;
5
+ }
6
+
7
+ solves problem of crash when the get_content redirects
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Actions reducer.
3
+ * @module reducers/actions/actions
4
+ */
5
+
6
+ import { GET_CONTENT, LIST_ACTIONS } from '@plone/volto/constants/ActionTypes';
7
+ import {
8
+ flattenToAppURL,
9
+ getBaseUrl,
10
+ hasApiExpander,
11
+ } from '@plone/volto/helpers';
12
+
13
+ const initialState = {
14
+ error: null,
15
+ actions: {
16
+ object: [],
17
+ object_buttons: [],
18
+ site_actions: [],
19
+ user: [],
20
+ document_actions: [],
21
+ portal_tabs: [],
22
+ },
23
+ loaded: false,
24
+ loading: false,
25
+ };
26
+
27
+ /**
28
+ * Actions reducer.
29
+ * @function actions
30
+ * @param {Object} state Current state.
31
+ * @param {Object} action Action to be handled.
32
+ * @returns {Object} New state.
33
+ */
34
+ export default function actions(state = initialState, action = {}) {
35
+ let hasExpander;
36
+ switch (action.type) {
37
+ case `${LIST_ACTIONS}_PENDING`:
38
+ return {
39
+ ...state,
40
+ error: null,
41
+ loaded: false,
42
+ loading: true,
43
+ };
44
+ case `${GET_CONTENT}_SUCCESS`:
45
+ if (Object.keys(action.result).length === 0) {
46
+ return state;
47
+ }
48
+ hasExpander = hasApiExpander(
49
+ 'actions',
50
+ getBaseUrl(flattenToAppURL(action.result['@id'])),
51
+ );
52
+ if (hasExpander && !action.subrequest) {
53
+ return {
54
+ ...state,
55
+ error: null,
56
+ actions: action.result['@components']?.actions,
57
+ loaded: true,
58
+ loading: false,
59
+ };
60
+ }
61
+ return state;
62
+ case `${LIST_ACTIONS}_SUCCESS`:
63
+ // Even if the expander is set or not, if the LIST_ACTIONS is
64
+ // called, we want it to store the data if the actions data is
65
+ // not set in the expander data (['@components']) but in the "normal"
66
+ // action result (we look for the object property returned by the endpoint)
67
+ // Unfortunately, this endpoint returns all the actions in a plain object
68
+ // with no structure :(
69
+ if (action.result.object) {
70
+ return {
71
+ ...state,
72
+ error: null,
73
+ actions: action.result,
74
+ loaded: true,
75
+ loading: false,
76
+ };
77
+ }
78
+ return state;
79
+ case `${LIST_ACTIONS}_FAIL`:
80
+ return {
81
+ ...state,
82
+ error: action.error,
83
+ actions: {},
84
+ loaded: false,
85
+ loading: false,
86
+ };
87
+ default:
88
+ return state;
89
+ }
90
+ }
@@ -0,0 +1,280 @@
1
+ import actions from './actions';
2
+ import { GET_CONTENT, LIST_ACTIONS } from '@plone/volto/constants/ActionTypes';
3
+ import config from '@plone/volto/registry';
4
+
5
+ describe('Actions reducer', () => {
6
+ it('should return the initial state', () => {
7
+ expect(actions()).toEqual({
8
+ error: null,
9
+ actions: {
10
+ object: [],
11
+ object_buttons: [],
12
+ site_actions: [],
13
+ user: [],
14
+ document_actions: [],
15
+ portal_tabs: [],
16
+ },
17
+ loaded: false,
18
+ loading: false,
19
+ });
20
+ });
21
+
22
+ it('should handle LIST_ACTIONS_PENDING', () => {
23
+ expect(
24
+ actions(undefined, {
25
+ type: `${LIST_ACTIONS}_PENDING`,
26
+ }),
27
+ ).toEqual({
28
+ error: null,
29
+ actions: {
30
+ object: [],
31
+ object_buttons: [],
32
+ site_actions: [],
33
+ user: [],
34
+ document_actions: [],
35
+ portal_tabs: [],
36
+ },
37
+ loaded: false,
38
+ loading: true,
39
+ });
40
+ });
41
+
42
+ it('should handle LIST_ACTIONS_SUCCESS', () => {
43
+ expect(
44
+ actions(undefined, {
45
+ type: `${LIST_ACTIONS}_SUCCESS`,
46
+ result: {
47
+ object: [],
48
+ object_buttons: [],
49
+ site_actions: [],
50
+ user: [
51
+ {
52
+ icon: '',
53
+ id: 'preferences',
54
+ title: 'Preferences',
55
+ },
56
+ {
57
+ icon: '',
58
+ id: 'dashboard',
59
+ title: 'Dashboard',
60
+ },
61
+ {
62
+ icon: '',
63
+ id: 'plone_setup',
64
+ title: 'Site Setup',
65
+ },
66
+ {
67
+ icon: '',
68
+ id: 'logout',
69
+ title: 'Log out',
70
+ },
71
+ ],
72
+ document_actions: [],
73
+ portal_tabs: [],
74
+ },
75
+ }),
76
+ ).toEqual({
77
+ error: null,
78
+ actions: {
79
+ object: [],
80
+ object_buttons: [],
81
+ site_actions: [],
82
+ user: [
83
+ {
84
+ icon: '',
85
+ id: 'preferences',
86
+ title: 'Preferences',
87
+ },
88
+ {
89
+ icon: '',
90
+ id: 'dashboard',
91
+ title: 'Dashboard',
92
+ },
93
+ {
94
+ icon: '',
95
+ id: 'plone_setup',
96
+ title: 'Site Setup',
97
+ },
98
+ {
99
+ icon: '',
100
+ id: 'logout',
101
+ title: 'Log out',
102
+ },
103
+ ],
104
+ document_actions: [],
105
+ portal_tabs: [],
106
+ },
107
+ loaded: true,
108
+ loading: false,
109
+ });
110
+ });
111
+
112
+ it('should handle LIST_ACTIONS_FAIL', () => {
113
+ expect(
114
+ actions(undefined, {
115
+ type: `${LIST_ACTIONS}_FAIL`,
116
+ error: 'failed',
117
+ }),
118
+ ).toEqual({
119
+ error: 'failed',
120
+ actions: {},
121
+ loaded: false,
122
+ loading: false,
123
+ });
124
+ });
125
+ });
126
+
127
+ describe('Actions reducer - (ACTIONS)GET_CONTENT', () => {
128
+ beforeEach(() => {
129
+ config.settings.apiExpanders = [
130
+ {
131
+ match: '',
132
+ GET_CONTENT: ['actions'],
133
+ },
134
+ ];
135
+ });
136
+
137
+ it('should handle (ACTIONS)GET_CONTENT', () => {
138
+ expect(
139
+ actions(undefined, {
140
+ type: `${GET_CONTENT}_SUCCESS`,
141
+ result: {
142
+ '@components': {
143
+ actions: {
144
+ object: [],
145
+ object_buttons: [],
146
+ site_actions: [],
147
+ user: [
148
+ {
149
+ icon: '',
150
+ id: 'preferences',
151
+ title: 'Preferences',
152
+ },
153
+ {
154
+ icon: '',
155
+ id: 'dashboard',
156
+ title: 'Dashboard',
157
+ },
158
+ {
159
+ icon: '',
160
+ id: 'plone_setup',
161
+ title: 'Site Setup',
162
+ },
163
+ {
164
+ icon: '',
165
+ id: 'logout',
166
+ title: 'Log out',
167
+ },
168
+ ],
169
+ document_actions: [],
170
+ portal_tabs: [],
171
+ },
172
+ },
173
+ },
174
+ }),
175
+ ).toEqual({
176
+ error: null,
177
+ actions: {
178
+ object: [],
179
+ object_buttons: [],
180
+ site_actions: [],
181
+ user: [
182
+ {
183
+ icon: '',
184
+ id: 'preferences',
185
+ title: 'Preferences',
186
+ },
187
+ {
188
+ icon: '',
189
+ id: 'dashboard',
190
+ title: 'Dashboard',
191
+ },
192
+ {
193
+ icon: '',
194
+ id: 'plone_setup',
195
+ title: 'Site Setup',
196
+ },
197
+ {
198
+ icon: '',
199
+ id: 'logout',
200
+ title: 'Log out',
201
+ },
202
+ ],
203
+ document_actions: [],
204
+ portal_tabs: [],
205
+ },
206
+ loaded: true,
207
+ loading: false,
208
+ });
209
+ });
210
+
211
+ it('should handle (ACTIONS)LIST_ACTIONS (standalone with apiExpander enabled)', () => {
212
+ expect(
213
+ actions(undefined, {
214
+ type: `${LIST_ACTIONS}_SUCCESS`,
215
+ result: {
216
+ object: [],
217
+ object_buttons: [],
218
+ site_actions: [],
219
+ user: [
220
+ {
221
+ icon: '',
222
+ id: 'preferences',
223
+ title: 'Preferences',
224
+ },
225
+ {
226
+ icon: '',
227
+ id: 'dashboard',
228
+ title: 'Dashboard',
229
+ },
230
+ {
231
+ icon: '',
232
+ id: 'plone_setup',
233
+ title: 'Site Setup',
234
+ },
235
+ {
236
+ icon: '',
237
+ id: 'logout',
238
+ title: 'Log out',
239
+ },
240
+ ],
241
+ document_actions: [],
242
+ portal_tabs: [],
243
+ },
244
+ }),
245
+ ).toEqual({
246
+ error: null,
247
+ actions: {
248
+ object: [],
249
+ object_buttons: [],
250
+ site_actions: [],
251
+ user: [
252
+ {
253
+ icon: '',
254
+ id: 'preferences',
255
+ title: 'Preferences',
256
+ },
257
+ {
258
+ icon: '',
259
+ id: 'dashboard',
260
+ title: 'Dashboard',
261
+ },
262
+ {
263
+ icon: '',
264
+ id: 'plone_setup',
265
+ title: 'Site Setup',
266
+ },
267
+ {
268
+ icon: '',
269
+ id: 'logout',
270
+ title: 'Log out',
271
+ },
272
+ ],
273
+ document_actions: [],
274
+ portal_tabs: [],
275
+ },
276
+ loaded: true,
277
+ loading: false,
278
+ });
279
+ });
280
+ });
@@ -0,0 +1,7 @@
1
+ copied from volto, override with this bit:
2
+
3
+ if (Object.keys(action.result).length === 0) {
4
+ return state;
5
+ }
6
+
7
+ solves problem of crash when the get_content redirects
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Breadcrumbs reducer.
3
+ * @module reducers/breadcrumbs/breadcrumbs
4
+ */
5
+
6
+ import { map } from 'lodash';
7
+ import {
8
+ flattenToAppURL,
9
+ getBaseUrl,
10
+ hasApiExpander,
11
+ } from '@plone/volto/helpers';
12
+
13
+ import {
14
+ GET_BREADCRUMBS,
15
+ GET_CONTENT,
16
+ } from '@plone/volto/constants/ActionTypes';
17
+
18
+ const initialState = {
19
+ error: null,
20
+ items: [],
21
+ root: null,
22
+ loaded: false,
23
+ loading: false,
24
+ };
25
+
26
+ /**
27
+ * Breadcrumbs reducer.
28
+ * @function breadcrumbs
29
+ * @param {Object} state Current state.
30
+ * @param {Object} action Action to be handled.
31
+ * @returns {Object} New state.
32
+ */
33
+ export default function breadcrumbs(state = initialState, action = {}) {
34
+ let hasExpander;
35
+ switch (action.type) {
36
+ case `${GET_BREADCRUMBS}_PENDING`:
37
+ return {
38
+ ...state,
39
+ error: null,
40
+ loaded: false,
41
+ loading: true,
42
+ };
43
+ case `${GET_CONTENT}_SUCCESS`:
44
+ if (Object.keys(action.result).length === 0) {
45
+ return state;
46
+ }
47
+ hasExpander = hasApiExpander(
48
+ 'breadcrumbs',
49
+ getBaseUrl(flattenToAppURL(action.result['@id'])),
50
+ );
51
+ if (hasExpander && !action.subrequest) {
52
+ return {
53
+ ...state,
54
+ error: null,
55
+ items: map(
56
+ action.result['@components'].breadcrumbs.items,
57
+ (item) => ({
58
+ title: item.title,
59
+ url: flattenToAppURL(item['@id']),
60
+ }),
61
+ ),
62
+ root: flattenToAppURL(action.result['@components'].breadcrumbs.root),
63
+ loaded: true,
64
+ loading: false,
65
+ };
66
+ }
67
+ return state;
68
+ case `${GET_BREADCRUMBS}_SUCCESS`:
69
+ hasExpander = hasApiExpander(
70
+ 'breadcrumbs',
71
+ getBaseUrl(flattenToAppURL(action.result['@id'])),
72
+ );
73
+ if (!hasExpander) {
74
+ return {
75
+ ...state,
76
+ error: null,
77
+ items: map(action.result.items, (item) => ({
78
+ title: item.title,
79
+ url: flattenToAppURL(item['@id']),
80
+ })),
81
+ root: flattenToAppURL(action.result.root),
82
+ loaded: true,
83
+ loading: false,
84
+ };
85
+ }
86
+ return state;
87
+ case `${GET_BREADCRUMBS}_FAIL`:
88
+ return {
89
+ ...state,
90
+ error: action.error,
91
+ items: [],
92
+ loaded: false,
93
+ loading: false,
94
+ };
95
+ default:
96
+ return state;
97
+ }
98
+ }
@@ -0,0 +1,120 @@
1
+ import config from '@plone/volto/registry';
2
+ import breadcrumbs from './breadcrumbs';
3
+ import {
4
+ GET_BREADCRUMBS,
5
+ GET_CONTENT,
6
+ } from '@plone/volto/constants/ActionTypes';
7
+
8
+ const { settings } = config;
9
+
10
+ describe('Breadcrumbs reducer', () => {
11
+ it('should return the initial state', () => {
12
+ expect(breadcrumbs()).toEqual({
13
+ error: null,
14
+ items: [],
15
+ root: null,
16
+ loaded: false,
17
+ loading: false,
18
+ });
19
+ });
20
+
21
+ it('should handle GET_BREADCRUMBS_PENDING', () => {
22
+ expect(
23
+ breadcrumbs(undefined, {
24
+ type: `${GET_BREADCRUMBS}_PENDING`,
25
+ }),
26
+ ).toEqual({
27
+ error: null,
28
+ items: [],
29
+ root: null,
30
+ loaded: false,
31
+ loading: true,
32
+ });
33
+ });
34
+
35
+ it('should handle GET_BREADCRUMBS_SUCCESS', () => {
36
+ expect(
37
+ breadcrumbs(undefined, {
38
+ type: `${GET_BREADCRUMBS}_SUCCESS`,
39
+ result: {
40
+ items: [
41
+ {
42
+ title: 'Welcome to Plone!',
43
+ '@id': `${settings.apiPath}/front-page`,
44
+ },
45
+ ],
46
+ root: settings.apiPath,
47
+ },
48
+ }),
49
+ ).toEqual({
50
+ error: null,
51
+ items: [
52
+ {
53
+ title: 'Welcome to Plone!',
54
+ url: '/front-page',
55
+ },
56
+ ],
57
+ root: '',
58
+ loaded: true,
59
+ loading: false,
60
+ });
61
+ });
62
+
63
+ it('should handle GET_BREADCRUMBS_FAIL', () => {
64
+ expect(
65
+ breadcrumbs(undefined, {
66
+ type: `${GET_BREADCRUMBS}_FAIL`,
67
+ error: 'failed',
68
+ }),
69
+ ).toEqual({
70
+ error: 'failed',
71
+ items: [],
72
+ root: null,
73
+ loaded: false,
74
+ loading: false,
75
+ });
76
+ });
77
+ });
78
+
79
+ describe('Breadcrumbs reducer - (BREADCRUMBS)GET_CONTENT', () => {
80
+ beforeEach(() => {
81
+ config.settings.apiExpanders = [
82
+ {
83
+ match: '',
84
+ GET_CONTENT: ['breadcrumbs'],
85
+ },
86
+ ];
87
+ });
88
+
89
+ it('should handle (BREADCRUMBS)GET_CONTENT_SUCCESS', () => {
90
+ expect(
91
+ breadcrumbs(undefined, {
92
+ type: `${GET_CONTENT}_SUCCESS`,
93
+ result: {
94
+ '@components': {
95
+ breadcrumbs: {
96
+ items: [
97
+ {
98
+ title: 'Welcome to Plone!',
99
+ '@id': `${settings.apiPath}/front-page`,
100
+ },
101
+ ],
102
+ root: settings.apiPath,
103
+ },
104
+ },
105
+ },
106
+ }),
107
+ ).toEqual({
108
+ error: null,
109
+ items: [
110
+ {
111
+ title: 'Welcome to Plone!',
112
+ url: '/front-page',
113
+ },
114
+ ],
115
+ root: '',
116
+ loaded: true,
117
+ loading: false,
118
+ });
119
+ });
120
+ });
@@ -57,6 +57,9 @@ export default function navigation(state = initialState, action = {}) {
57
57
  loading: true,
58
58
  };
59
59
  case `${GET_CONTENT}_SUCCESS`:
60
+ if (Object.keys(action.result).length === 0) {
61
+ return state;
62
+ }
60
63
  hasExpander = hasApiExpander(
61
64
  'navigation',
62
65
  getBaseUrl(flattenToAppURL(action.result['@id'])),
package/src/index.js CHANGED
@@ -544,7 +544,7 @@ const applyConfig = (config) => {
544
544
  },
545
545
  {
546
546
  match: '',
547
- GET_CONTENT: ['navigation', 'breadcrumbs', 'actions'],
547
+ GET_CONTENT: ['navigation', 'breadcrumbs', 'actions', 'workflow'],
548
548
  querystring: { 'expand.navigation.depth': '3' },
549
549
  },
550
550
  ];