@eeacms/volto-bise-policy 1.2.0 → 1.2.1

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,11 +4,13 @@ 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
- ### [1.2.0](https://github.com/eea/volto-bise-policy/compare/1.1.1...1.2.0) - 16 June 2023
7
+ ### [1.2.1](https://github.com/eea/volto-bise-policy/compare/1.2.0...1.2.1) - 16 June 2023
8
8
 
9
- #### :rocket: New Features
9
+ #### :hammer_and_wrench: Others
10
10
 
11
- - feat: redirect to error page if id_eunis is 0 on species page [Miu Razvan - [`383b20d`](https://github.com/eea/volto-bise-policy/commit/383b20d9ce870d8b79d671703476423610077183)]
11
+ - update [Miu Razvan - [`7e4089d`](https://github.com/eea/volto-bise-policy/commit/7e4089dad4f0987d6bf8c2ea93912b6f9555ebf8)]
12
+ - Don't override breadcrumbs [Miu Razvan - [`e490248`](https://github.com/eea/volto-bise-policy/commit/e49024841c35a420bb43a84cb5fb3be23acce54a)]
13
+ ### [1.2.0](https://github.com/eea/volto-bise-policy/compare/1.1.1...1.2.0) - 16 June 2023
12
14
 
13
15
  #### :nail_care: Enhancements
14
16
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-bise-policy",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "@eeacms/volto-bise-policy: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -0,0 +1,96 @@
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 (action.subrequest) return state;
45
+ hasExpander = hasApiExpander(
46
+ 'breadcrumbs',
47
+ getBaseUrl(flattenToAppURL(action.result['@id'])),
48
+ );
49
+ if (hasExpander) {
50
+ return {
51
+ ...state,
52
+ error: null,
53
+ items: map(
54
+ action.result['@components'].breadcrumbs.items,
55
+ (item) => ({
56
+ title: item.title,
57
+ url: flattenToAppURL(item['@id']),
58
+ }),
59
+ ),
60
+ root: flattenToAppURL(action.result['@components'].breadcrumbs.root),
61
+ loaded: true,
62
+ loading: false,
63
+ };
64
+ }
65
+ return state;
66
+ case `${GET_BREADCRUMBS}_SUCCESS`:
67
+ hasExpander = hasApiExpander(
68
+ 'breadcrumbs',
69
+ getBaseUrl(flattenToAppURL(action.result['@id'])),
70
+ );
71
+ if (!hasExpander) {
72
+ return {
73
+ ...state,
74
+ error: null,
75
+ items: map(action.result.items, (item) => ({
76
+ title: item.title,
77
+ url: flattenToAppURL(item['@id']),
78
+ })),
79
+ root: flattenToAppURL(action.result.root),
80
+ loaded: true,
81
+ loading: false,
82
+ };
83
+ }
84
+ return state;
85
+ case `${GET_BREADCRUMBS}_FAIL`:
86
+ return {
87
+ ...state,
88
+ error: action.error,
89
+ items: [],
90
+ loaded: false,
91
+ loading: false,
92
+ };
93
+ default:
94
+ return state;
95
+ }
96
+ }
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Navigation reducer.
3
+ * @module reducers/navigation/navigation
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_CONTENT,
15
+ GET_NAVIGATION,
16
+ } from '@plone/volto/constants/ActionTypes';
17
+
18
+ const initialState = {
19
+ error: null,
20
+ items: [],
21
+ loaded: false,
22
+ loading: false,
23
+ };
24
+
25
+ /**
26
+ * Recursive function that process the items returned by the navigation
27
+ * endpoint
28
+ * @function getRecursiveItems
29
+ * @param {array} items The items inside a navigation response.
30
+ * @returns {*} The navigation items object (recursive)
31
+ */
32
+ function getRecursiveItems(items) {
33
+ return map(items, (item) => ({
34
+ title: item.title,
35
+ description: item.description,
36
+ url: flattenToAppURL(item['@id']),
37
+ ...(item.items && { items: getRecursiveItems(item.items) }),
38
+ }));
39
+ }
40
+
41
+ /**
42
+ * Navigation reducer.
43
+ * @function navigation
44
+ * @param {Object} state Current state.
45
+ * @param {Object} action Action to be handled.
46
+ * @returns {Object} New state.
47
+ */
48
+ export default function navigation(state = initialState, action = {}) {
49
+ let hasExpander;
50
+ switch (action.type) {
51
+ case `${GET_NAVIGATION}_PENDING`:
52
+ return {
53
+ ...state,
54
+ error: null,
55
+ loaded: false,
56
+ loading: true,
57
+ };
58
+ case `${GET_CONTENT}_SUCCESS`:
59
+ if (action.subrequest) return state;
60
+ hasExpander = hasApiExpander(
61
+ 'navigation',
62
+ getBaseUrl(flattenToAppURL(action.result['@id'])),
63
+ );
64
+ if (hasExpander && !action.subrequest) {
65
+ return {
66
+ ...state,
67
+ error: null,
68
+ items: getRecursiveItems(
69
+ action.result['@components'].navigation.items,
70
+ ),
71
+ loaded: true,
72
+ loading: false,
73
+ };
74
+ }
75
+ return state;
76
+ case `${GET_NAVIGATION}_SUCCESS`:
77
+ hasExpander = hasApiExpander(
78
+ 'navigation',
79
+ getBaseUrl(flattenToAppURL(action.result['@id'])),
80
+ );
81
+ if (!hasExpander) {
82
+ return {
83
+ ...state,
84
+ error: null,
85
+ items: getRecursiveItems(action.result.items),
86
+ loaded: true,
87
+ loading: false,
88
+ };
89
+ }
90
+ return state;
91
+ case `${GET_NAVIGATION}_FAIL`:
92
+ return {
93
+ ...state,
94
+ error: action.error,
95
+ items: [],
96
+ loaded: false,
97
+ loading: false,
98
+ };
99
+ default:
100
+ return state;
101
+ }
102
+ }
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Types reducer.
3
+ * @module reducers/types/types
4
+ */
5
+
6
+ import { GET_CONTENT, GET_TYPES } 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
+ loaded: false,
16
+ loading: false,
17
+ types: [],
18
+ };
19
+
20
+ /**
21
+ * Types reducer.
22
+ * @function types
23
+ * @param {Object} state Current state.
24
+ * @param {Object} action Action to be handled.
25
+ * @returns {Object} New state.
26
+ */
27
+ export default function types(state = initialState, action = {}) {
28
+ let hasExpander;
29
+ switch (action.type) {
30
+ case `${GET_TYPES}_PENDING`:
31
+ return {
32
+ ...state,
33
+ error: null,
34
+ loading: true,
35
+ loaded: false,
36
+ };
37
+ case `${GET_CONTENT}_SUCCESS`:
38
+ if (action.subrequest) return state;
39
+ hasExpander = hasApiExpander(
40
+ 'types',
41
+ getBaseUrl(flattenToAppURL(action.result['@id'])),
42
+ );
43
+ if (hasExpander && !action.subrequest) {
44
+ return {
45
+ ...state,
46
+ error: null,
47
+ loading: false,
48
+ loaded: true,
49
+ types: action.result['@components'].types,
50
+ };
51
+ }
52
+ return state;
53
+ case `${GET_TYPES}_SUCCESS`:
54
+ hasExpander = hasApiExpander(
55
+ 'types',
56
+ getBaseUrl(flattenToAppURL(action.result['@id'])),
57
+ );
58
+ if (!hasExpander) {
59
+ return {
60
+ ...state,
61
+ error: null,
62
+ loading: false,
63
+ loaded: true,
64
+ types: action.result,
65
+ };
66
+ }
67
+ return state;
68
+ case `${GET_TYPES}_FAIL`:
69
+ return {
70
+ ...state,
71
+ error: action.error,
72
+ loading: false,
73
+ loaded: false,
74
+ types: [],
75
+ };
76
+ default:
77
+ return state;
78
+ }
79
+ }