@eeacms/volto-cca-policy 0.3.54 → 0.3.56
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 +19 -0
- package/package.json +2 -2
- package/src/customizations/@eeacms/volto-eea-website-theme/components/theme/DraftBackground/DraftBackground.jsx +95 -0
- package/src/customizations/@eeacms/volto-eea-website-theme/components/theme/DraftBackground/README.md +1 -0
- package/theme/globals/views.less +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,25 @@ 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.56](https://github.com/eea/volto-cca-policy/compare/0.3.55...0.3.56) - 25 June 2025
|
|
8
|
+
|
|
9
|
+
#### :nail_care: Enhancements
|
|
10
|
+
|
|
11
|
+
- change: better draft background handling by excluding 'archived' state [kreafox - [`1181696`](https://github.com/eea/volto-cca-policy/commit/1181696f724e1852eba80de3368cfafdabd1eff2)]
|
|
12
|
+
|
|
13
|
+
#### :house: Internal changes
|
|
14
|
+
|
|
15
|
+
- style: Automated code fix [eea-jenkins - [`3ca17fb`](https://github.com/eea/volto-cca-policy/commit/3ca17fb185321b363081de02876f1b10e6e7a009)]
|
|
16
|
+
|
|
17
|
+
#### :hammer_and_wrench: Others
|
|
18
|
+
|
|
19
|
+
- format code [kreafox - [`92fe10f`](https://github.com/eea/volto-cca-policy/commit/92fe10f50961faaf4604f64bfdaddad19e991a58)]
|
|
20
|
+
### [0.3.55](https://github.com/eea/volto-cca-policy/compare/0.3.54...0.3.55) - 25 June 2025
|
|
21
|
+
|
|
22
|
+
#### :rocket: Dependency updates
|
|
23
|
+
|
|
24
|
+
- Release @eeacms/volto-openlayers-map@1.0.1 [EEA Jenkins - [`a7882a3`](https://github.com/eea/volto-cca-policy/commit/a7882a3c97f75188b7a5c8546dfd2d8647772923)]
|
|
25
|
+
|
|
7
26
|
### [0.3.54](https://github.com/eea/volto-cca-policy/compare/0.3.53...0.3.54) - 24 June 2025
|
|
8
27
|
|
|
9
28
|
#### :bug: Bug Fixes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eeacms/volto-cca-policy",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.56",
|
|
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": "1.0.
|
|
37
|
+
"@eeacms/volto-openlayers-map": "1.0.1",
|
|
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,95 @@
|
|
|
1
|
+
import { BodyClass, flattenToAppURL } from '@plone/volto/helpers';
|
|
2
|
+
import { connect } from 'react-redux';
|
|
3
|
+
import { withRouter } from 'react-router-dom';
|
|
4
|
+
import { compose } from 'redux';
|
|
5
|
+
import '@eeacms/volto-eea-website-theme/components/theme/DraftBackground/draft.css';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Removes any trailing slashes from the given string.
|
|
9
|
+
*
|
|
10
|
+
* @param {string} str - The input string to remove trailing slashes from.
|
|
11
|
+
* @returns {string} The input string with any trailing slashes removed.
|
|
12
|
+
*/
|
|
13
|
+
const removeTrailingSlash = (str) => {
|
|
14
|
+
return str.replace(/\/+$/, '');
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Checks if a given date is in the future.
|
|
19
|
+
*
|
|
20
|
+
* @param {string} date - The date to check.
|
|
21
|
+
* @returns {boolean} `true` if the date is in the future, `false` otherwise.
|
|
22
|
+
*/
|
|
23
|
+
const dateIsInFuture = (date) => {
|
|
24
|
+
return (
|
|
25
|
+
date && date !== 'None' && new Date(date).getTime() > new Date().getTime()
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Checks if the current content is published.
|
|
31
|
+
*
|
|
32
|
+
* This function checks the review state and effective date of the current content
|
|
33
|
+
* to determine if it should be considered published. It handles various cases,
|
|
34
|
+
* such as when the review state is null, when the content has a parent, and when
|
|
35
|
+
* the effective date is in the future.
|
|
36
|
+
*
|
|
37
|
+
* @param {object} props - The props object containing information about the current content.
|
|
38
|
+
* @param {string} props.contentId - The ID of the current content.
|
|
39
|
+
* @param {string} props.pathname - The current URL pathname.
|
|
40
|
+
* @param {object} props.content - The content object.
|
|
41
|
+
* @param {string} props.review_state - The review state of the current content.
|
|
42
|
+
* @returns {boolean} - True if the content is considered published, false otherwise.
|
|
43
|
+
*/
|
|
44
|
+
export const checkIfPublished = (props) => {
|
|
45
|
+
//case 0: the state is not for the current content-type eg: Go to /contents from a page
|
|
46
|
+
if (props.contentId !== removeTrailingSlash(props.pathname)) return true;
|
|
47
|
+
|
|
48
|
+
// set draft image if effective date is set and is in the future
|
|
49
|
+
// regardless of review_state
|
|
50
|
+
const effectiveDate = props?.content?.effective;
|
|
51
|
+
if (dateIsInFuture(effectiveDate)) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const reviewState = props?.review_state;
|
|
56
|
+
|
|
57
|
+
//case 1 : review_state published or archived (customization)
|
|
58
|
+
if (reviewState === 'published' || reviewState === 'archived') return true;
|
|
59
|
+
|
|
60
|
+
//case 2: review_state null, but parent is published eg:Image in published folder
|
|
61
|
+
// is marked as published, or not published if the effective date of parent
|
|
62
|
+
// is in the future
|
|
63
|
+
const parent = props?.content?.parent;
|
|
64
|
+
const parentReviewState = parent?.review_state;
|
|
65
|
+
if (!reviewState && parentReviewState === 'published') {
|
|
66
|
+
if (dateIsInFuture(parent?.effective)) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
//case 3: review_state null, but there is no parent eg: PloneSite
|
|
73
|
+
if (!reviewState && Object.keys(parent || {}).length === 0) return true;
|
|
74
|
+
|
|
75
|
+
//case 4: review_state null, and review state of parent is null, eg: Image in PloneSite
|
|
76
|
+
if (!reviewState && !parentReviewState) return true;
|
|
77
|
+
return false;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const DraftBackground = (props) => {
|
|
81
|
+
let draftClass = 'wf-state-is-draft';
|
|
82
|
+
|
|
83
|
+
if (checkIfPublished(props)) {
|
|
84
|
+
draftClass = '';
|
|
85
|
+
}
|
|
86
|
+
return draftClass ? <BodyClass className={draftClass} /> : '';
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export default compose(
|
|
90
|
+
withRouter,
|
|
91
|
+
connect((state, props) => ({
|
|
92
|
+
review_state: state.content.data?.review_state,
|
|
93
|
+
contentId: flattenToAppURL(state.content.data?.['@id']),
|
|
94
|
+
})),
|
|
95
|
+
)(DraftBackground);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Included the 'archived' review state in the published check to ensure archived content does not display the draft background.
|