@eeacms/volto-eea-website-theme 1.33.2 → 1.34.0
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/package.json
CHANGED
@@ -7,18 +7,45 @@ import { compose } from 'redux';
|
|
7
7
|
import { flattenToAppURL } from '@plone/volto/helpers';
|
8
8
|
|
9
9
|
/**
|
10
|
-
*
|
11
|
-
*
|
10
|
+
* Removes any trailing slashes from the given string.
|
11
|
+
*
|
12
|
+
* @param {string} str - The input string to remove trailing slashes from.
|
13
|
+
* @returns {string} The input string with any trailing slashes removed.
|
12
14
|
*/
|
13
|
-
|
14
15
|
const removeTrailingSlash = (str) => {
|
15
16
|
return str.replace(/\/+$/, '');
|
16
17
|
};
|
17
18
|
|
18
|
-
|
19
|
+
/**
|
20
|
+
* Checks if the current content is published.
|
21
|
+
*
|
22
|
+
* This function checks the review state and effective date of the current content
|
23
|
+
* to determine if it should be considered published. It handles various cases,
|
24
|
+
* such as when the review state is null, when the content has a parent, and when
|
25
|
+
* the effective date is in the future.
|
26
|
+
*
|
27
|
+
* @param {object} props - The props object containing information about the current content.
|
28
|
+
* @param {string} props.contentId - The ID of the current content.
|
29
|
+
* @param {string} props.pathname - The current URL pathname.
|
30
|
+
* @param {object} props.content - The content object.
|
31
|
+
* @param {string} props.review_state - The review state of the current content.
|
32
|
+
* @returns {boolean} - True if the content is considered published, false otherwise.
|
33
|
+
*/
|
34
|
+
export const checkIfPublished = (props) => {
|
19
35
|
//case 0: the state is not for the current content-type eg: Go to /contents from a page
|
20
36
|
if (props.contentId !== removeTrailingSlash(props.pathname)) return true;
|
21
37
|
|
38
|
+
// set draft image if effective date is set and is in the future
|
39
|
+
// regardless of review_state
|
40
|
+
const effectiveDate = props?.content?.effective;
|
41
|
+
if (
|
42
|
+
effectiveDate &&
|
43
|
+
effectiveDate !== 'None' &&
|
44
|
+
new Date(effectiveDate).getTime() > new Date().getTime()
|
45
|
+
) {
|
46
|
+
return false;
|
47
|
+
}
|
48
|
+
|
22
49
|
//case 1 : review_state published
|
23
50
|
if (props?.review_state === 'published') return true;
|
24
51
|
|
package/src/index.js
CHANGED