@eeacms/volto-eea-versions 0.2.0 → 1.0.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,15 +4,32 @@ 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.2.0](https://github.com/eea/volto-eea-versions/compare/0.1.0...0.2.0) - 18 December 2024
7
+ ### [1.0.1](https://github.com/eea/volto-eea-versions/compare/1.0.0...1.0.1) - 8 January 2025
8
8
 
9
9
  #### :bug: Bug Fixes
10
10
 
11
- - fix: DEVELOP.md [alin - [`e9fa771`](https://github.com/eea/volto-eea-versions/commit/e9fa771d8bac089521b2526ebf11e43deeacf650)]
11
+ - fix(AllVersions): improve conditional rendering for version lists to show only if we have older or newer versions [David Ichim - [`8896678`](https://github.com/eea/volto-eea-versions/commit/88966780cdeda327d86fbffe293d599f76315297)]
12
+ - fix: modify versionBlockhasValue [nileshgulia1 - [`c3cec74`](https://github.com/eea/volto-eea-versions/commit/c3cec74ce20ad3f43f0fbd3d90cd4c9ff07250a9)]
13
+ - fix: only show current version when old or new are present refs#282065 [nileshgulia1 - [`58405a4`](https://github.com/eea/volto-eea-versions/commit/58405a4c14c62332edde59c40527f22e5817c677)]
14
+
15
+ #### :nail_care: Enhancements
16
+
17
+ - refactor(eea_latest_version):add blockHasValue config refs#282065 [nileshgulia1 - [`a93cf26`](https://github.com/eea/volto-eea-versions/commit/a93cf262bc2b0695626114f5192efc806539924d)]
12
18
 
13
19
  #### :hammer_and_wrench: Others
14
20
 
15
- - Release 0.2.0 [alin - [`559624d`](https://github.com/eea/volto-eea-versions/commit/559624d4cb475453de5086b7ba9486c60a2a1529)]
21
+ ## [1.0.0](https://github.com/eea/volto-eea-versions/compare/0.2.0...1.0.0) - 18 December 2024
22
+
23
+ #### :nail_care: Enhancements
24
+
25
+ - refactor: Rename blocks to eea_versions and eea_latest_version - refs #280462 [alin - [`23fccb8`](https://github.com/eea/volto-eea-versions/commit/23fccb835e5cceb40743c949ffa685bbf8df7317)]
26
+
27
+ ### [0.2.0](https://github.com/eea/volto-eea-versions/compare/0.1.0...0.2.0) - 18 December 2024
28
+
29
+ #### :bug: Bug Fixes
30
+
31
+ - fix: DEVELOP.md [alin - [`e9fa771`](https://github.com/eea/volto-eea-versions/commit/e9fa771d8bac089521b2526ebf11e43deeacf650)]
32
+
16
33
  ### 0.1.0 - 18 December 2024
17
34
 
18
35
  #### :rocket: New Features
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-eea-versions",
3
- "version": "0.2.0",
3
+ "version": "1.0.1",
4
4
  "description": "@eeacms/volto-eea-versions: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -10,6 +10,8 @@ const propsAreEqual = (prevProps, nextProps) => {
10
10
  const AllVersions = (props) => {
11
11
  const olderVersions = props.versions?.older_versions?.items || [];
12
12
  const newerVersions = props.versions?.newer_versions?.items || [];
13
+ const hasOlderVersions = olderVersions?.length > 0;
14
+ const hasNewerVersions = newerVersions?.length > 0;
13
15
  const properties = props.properties || {};
14
16
  const title = properties.title || '';
15
17
  const effective = properties.effective || '';
@@ -22,9 +24,10 @@ const AllVersions = (props) => {
22
24
  if (isEdit && (olderVersions.length === 0 || newerVersions.length === 0)) {
23
25
  return <p>All versions block edit</p>;
24
26
  }
25
- return (
27
+
28
+ return hasOlderVersions || hasNewerVersions ? (
26
29
  <ul className="eea-versions">
27
- {newerVersions?.length > 0 &&
30
+ {hasNewerVersions &&
28
31
  newerVersions.map((version) => (
29
32
  <li key={version['@id']} className="eea-versions-list-item">
30
33
  <UniversalLink
@@ -36,7 +39,7 @@ const AllVersions = (props) => {
36
39
  </li>
37
40
  ))}
38
41
  <li>{`(current) ${title} ${currentEffective}`}</li>
39
- {olderVersions?.length > 0 &&
42
+ {hasOlderVersions &&
40
43
  olderVersions.map((version) => (
41
44
  <li key={version['@id']} className="eea-versions-list-item">
42
45
  <UniversalLink
@@ -48,7 +51,7 @@ const AllVersions = (props) => {
48
51
  </li>
49
52
  ))}
50
53
  </ul>
51
- );
54
+ ) : null;
52
55
  };
53
56
 
54
57
  export default React.memo(withEEAVersions(AllVersions), propsAreEqual);
@@ -20,7 +20,7 @@ const LatestVersion = (props) => {
20
20
  return <p>Latest version block edit</p>;
21
21
  }
22
22
  return version ? (
23
- <p className="report-latest-version">
23
+ <p className="eea-latest-version">
24
24
  <strong>Latest version of this report: </strong>
25
25
  <UniversalLink href={version['@id']} className="eea-versions-list-link">
26
26
  {version.title} {formattedEffective}
@@ -3,16 +3,21 @@ import AllVersions from './AllVersions';
3
3
  import LatestVersion from './LatestVersion';
4
4
  import BlockSettingsSchema from '@plone/volto/components/manage/Blocks/Block/Schema';
5
5
 
6
+ const hasVersionsBlockValue = (blockData) => {
7
+ return blockData.results ?? false;
8
+ };
9
+
6
10
  const applyConfig = (config) => {
7
- config.blocks.blocksConfig.report_latest_version = {
8
- id: 'report_latest_version',
9
- title: 'Report latest version',
11
+ config.blocks.blocksConfig.eea_latest_version = {
12
+ id: 'eea_latest_version',
13
+ title: 'Latest version',
10
14
  icon: codeSVG,
11
15
  group: 'common',
12
16
  view: LatestVersion,
13
17
  schema: BlockSettingsSchema,
14
18
  restricted: false,
15
19
  mostUsed: false,
20
+ blockHasValue: hasVersionsBlockValue,
16
21
  blockHasOwnFocusManagement: false,
17
22
  sidebarTab: 1,
18
23
  security: {
@@ -21,14 +26,15 @@ const applyConfig = (config) => {
21
26
  },
22
27
  };
23
28
 
24
- config.blocks.blocksConfig.report_versions = {
25
- id: 'report_versions',
26
- title: 'Report versions',
29
+ config.blocks.blocksConfig.eea_versions = {
30
+ id: 'eea_versions',
31
+ title: 'Versions',
27
32
  icon: codeSVG,
28
33
  group: 'common',
29
34
  view: AllVersions,
30
35
  schema: BlockSettingsSchema,
31
36
  restricted: false,
37
+ blockHasValue: hasVersionsBlockValue,
32
38
  mostUsed: false,
33
39
  blockHasOwnFocusManagement: false,
34
40
  sidebarTab: 1,