@eeacms/volto-eea-website-theme 3.5.4 → 3.6.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/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
+ ### [3.6.0](https://github.com/eea/volto-eea-website-theme/compare/3.5.5...3.6.0) - 30 April 2025
8
+
9
+ #### :bug: Bug Fixes
10
+
11
+ - fix: Create widgets for creators and contributors full name - refs #284007 [Teodor Voicu - [`a3f73ae`](https://github.com/eea/volto-eea-website-theme/commit/a3f73ae02a6a8f92793d7e747e7ba9bbe1f51e05)]
12
+ - fix: Add email tooltip for users in creators and contributors metadata - refs #274362 [Teodor Voicu - [`f00d2bc`](https://github.com/eea/volto-eea-website-theme/commit/f00d2bcb5c0115db40d95f7e4d9618ce7164b71a)]
13
+
14
+ #### :hammer_and_wrench: Others
15
+
16
+ - Release 3.6.0 [Alin Voinea - [`645d434`](https://github.com/eea/volto-eea-website-theme/commit/645d434318c3cf5a0f1765fa0aa539cb2ecedd74)]
17
+ - Update ImageViewWidget [Miu Razvan - [`7b574be`](https://github.com/eea/volto-eea-website-theme/commit/7b574beac1ef64f1ec54c8f42b4c907291d182ea)]
18
+ ### [3.5.5](https://github.com/eea/volto-eea-website-theme/compare/3.5.4...3.5.5) - 25 April 2025
19
+
20
+ #### :bug: Bug Fixes
21
+
22
+ - fix: History compare not working with plotly chart field - refs #281229 [Teodor Voicu - [`d76a35b`](https://github.com/eea/volto-eea-website-theme/commit/d76a35bb3cbf11971e541a96c1ff49bbc30a87aa)]
23
+
24
+ #### :hammer_and_wrench: Others
25
+
7
26
  ### [3.5.4](https://github.com/eea/volto-eea-website-theme/compare/3.5.3...3.5.4) - 30 January 2025
8
27
 
9
28
  #### :bug: Bug Fixes
@@ -104,7 +123,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
104
123
 
105
124
  #### :hammer_and_wrench: Others
106
125
 
107
- - Add Sonarqube tag using bise-frontend addons list [EEA Jenkins - [`e417f83`](https://github.com/eea/volto-eea-website-theme/commit/e417f839312045c56b67ab8134fe5b0622b3e2c3)]
108
126
  ## [3.0.0](https://github.com/eea/volto-eea-website-theme/compare/2.4.0...3.0.0) - 21 October 2024
109
127
 
110
128
  #### :nail_care: Enhancements
@@ -190,7 +208,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
190
208
  - Refs #269520 - other_organisation test [Tripon Eugen - [`7558b27`](https://github.com/eea/volto-eea-website-theme/commit/7558b27a9d1cd6d3480a32b296c7325c796006c9)]
191
209
  - Refs #269520 - other_organisation token widget edit mode [Tripon Eugen - [`b6df127`](https://github.com/eea/volto-eea-website-theme/commit/b6df127bd91b6f55dda8f468e1107037d43752ff)]
192
210
  - Refs #269520 - other_organisation token widget [Tripon Eugen - [`6fd7543`](https://github.com/eea/volto-eea-website-theme/commit/6fd7543894bd2c593a1729116befd95c82ea3c8f)]
193
- - Add Sonarqube tag using marine-frontend addons list [EEA Jenkins - [`cbc36c7`](https://github.com/eea/volto-eea-website-theme/commit/cbc36c74dfcd5f7cb1013a4c673d9c02e0023766)]
194
211
  ### [2.1.1](https://github.com/eea/volto-eea-website-theme/compare/2.1.0...2.1.1) - 28 May 2024
195
212
 
196
213
  #### :bug: Bug Fixes
@@ -275,7 +292,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
275
292
 
276
293
  #### :hammer_and_wrench: Others
277
294
 
278
- - Add Sonarqube tag using insitu-frontend addons list [EEA Jenkins - [`adc6730`](https://github.com/eea/volto-eea-website-theme/commit/adc6730e21a37afb865b842182624401de6a29f5)]
279
295
  ### [1.33.1](https://github.com/eea/volto-eea-website-theme/compare/1.33.0...1.33.1) - 4 April 2024
280
296
 
281
297
  #### :bug: Bug Fixes
@@ -409,8 +425,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
409
425
 
410
426
  - bump version [Razvan - [`721e939`](https://github.com/eea/volto-eea-website-theme/commit/721e939d12e324b459ebfa78a2e656ee7142a3d6)]
411
427
  - merge master into this branch [Razvan - [`586c8f9`](https://github.com/eea/volto-eea-website-theme/commit/586c8f910bac55a043bd8dda60e9444bd2ae1663)]
412
- - Add Sonarqube tag using freshwater-frontend addons list [EEA Jenkins - [`fd90044`](https://github.com/eea/volto-eea-website-theme/commit/fd9004442a9d1d465f7601ecdefe3e23c61e6a9c)]
413
- - Add Sonarqube tag using insitu-frontend addons list [EEA Jenkins - [`4bc3dd3`](https://github.com/eea/volto-eea-website-theme/commit/4bc3dd3ae412a66befd04b5b80fab3716c929240)]
414
428
  - test: Update jest,Jenkinsfile,lint to volto-addons-template PR30 [valentinab25 - [`c4dbd28`](https://github.com/eea/volto-eea-website-theme/commit/c4dbd289358205bc2d849aab7edb11ccf3b89cee)]
415
429
  - fix tests [Razvan - [`042330b`](https://github.com/eea/volto-eea-website-theme/commit/042330bc97d32ffe7ba769b4f2453f71cffed706)]
416
430
  - remove RemoveSchema logic [Razvan - [`08d10f8`](https://github.com/eea/volto-eea-website-theme/commit/08d10f8bf6f75478260e4e4c66d7316ba87b907a)]
@@ -505,11 +519,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
505
519
  - test: Add real image to cypress test [Alin Voinea - [`4ff591a`](https://github.com/eea/volto-eea-website-theme/commit/4ff591ae3318c9588b4e2114582c0fa6cfdf31ae)]
506
520
  - test: Add cypress tests for Image block styling position and align [Alin Voinea - [`7341ef7`](https://github.com/eea/volto-eea-website-theme/commit/7341ef7b92714fc0cc3ab0c31c39033e7b3e19e7)]
507
521
  - Revert "change(tests): commented out rss test since title block config is missing" [Alin Voinea - [`fb61191`](https://github.com/eea/volto-eea-website-theme/commit/fb611918d6ca380b89b594f283dcf9f685a4b294)]
508
- - test: [JENKINS] Use java17 for sonarqube scanner [valentinab25 - [`6a3be30`](https://github.com/eea/volto-eea-website-theme/commit/6a3be3092589411af7808a235f76de5222fd3868)]
509
- - test: [JENKINS] Run cypress in started frontend container [valentinab25 - [`c3978f2`](https://github.com/eea/volto-eea-website-theme/commit/c3978f23375ef066e9fd6f6c2e34ba6c1c058f69)]
510
- - test: [JENKINS] Add cpu limit on cypress docker [valentinab25 - [`f672779`](https://github.com/eea/volto-eea-website-theme/commit/f672779e845bec9240ccc901e9f53ec80c5a1819)]
511
- - test: [JENKINS] Increase shm-size to cypress docker [valentinab25 - [`ae5d8e3`](https://github.com/eea/volto-eea-website-theme/commit/ae5d8e3f4e04dc2808d47ce2ee886e1b23b528da)]
512
- - test: [JENKINS] Improve cypress time [valentinab25 - [`170ff0c`](https://github.com/eea/volto-eea-website-theme/commit/170ff0c8e3b30e69479bdf1117e811fea94f1027)]
513
522
  ### [1.23.0](https://github.com/eea/volto-eea-website-theme/compare/1.22.1...1.23.0) - 2 November 2023
514
523
 
515
524
  #### :rocket: New Features
@@ -522,7 +531,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
522
531
 
523
532
  #### :house: Internal changes
524
533
 
525
- - chore: [JENKINS] Refactor automated testing [valentinab25 - [`f28fce3`](https://github.com/eea/volto-eea-website-theme/commit/f28fce3d1eb815f95fb9aa40de42b10b7e8e30c5)]
526
534
  - chore: husky, lint-staged use fixed versions [valentinab25 - [`6d15088`](https://github.com/eea/volto-eea-website-theme/commit/6d150886c5aeb2ca0b569270486e60f7cc274e2c)]
527
535
  - chore:volto 16 in tests, update docs, fix stylelint overrides [valentinab25 - [`20c0323`](https://github.com/eea/volto-eea-website-theme/commit/20c032380b33c0077c869a05136f93e2fb68e5d4)]
528
536
 
@@ -708,7 +716,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
708
716
 
709
717
  #### :house: Internal changes
710
718
 
711
- - chore: [JENKINS] Deprecate circularity website [valentinab25 - [`370dcbf`](https://github.com/eea/volto-eea-website-theme/commit/370dcbfbf1a8135ce7b1b3b271b004552a631837)]
712
719
 
713
720
  #### :hammer_and_wrench: Others
714
721
 
@@ -864,7 +871,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
864
871
 
865
872
  #### :hammer_and_wrench: Others
866
873
 
867
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`6c5e2f8`](https://github.com/eea/volto-eea-website-theme/commit/6c5e2f80456e2061d9e9c15fd0a0b91b9ac70568)]
868
874
  ### [1.9.1](https://github.com/eea/volto-eea-website-theme/compare/1.9.0...1.9.1) - 28 February 2023
869
875
 
870
876
  #### :bug: Bug Fixes
@@ -1011,7 +1017,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
1011
1017
 
1012
1018
  - For some reasons types is a string [Alin Voinea - [`3769a09`](https://github.com/eea/volto-eea-website-theme/commit/3769a0981181d5b633f3498daebbe96be8b4b833)]
1013
1019
  - Fix(redirect): o.filter - refs #157627 [Alin Voinea - [`deb23da`](https://github.com/eea/volto-eea-website-theme/commit/deb23da846444cc96539697fd798429ae0abe89e)]
1014
- - Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`f1fffc5`](https://github.com/eea/volto-eea-website-theme/commit/f1fffc5db96725440863d545580b4e76cce4b796)]
1015
1020
  ### [1.5.0](https://github.com/eea/volto-eea-website-theme/compare/1.4.2...1.5.0) - 9 January 2023
1016
1021
 
1017
1022
  #### :hammer_and_wrench: Others
@@ -1045,7 +1050,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
1045
1050
 
1046
1051
  - Release 1.4.0 [Alin Voinea - [`bd42a0d`](https://github.com/eea/volto-eea-website-theme/commit/bd42a0d26e928cac5d99933194755da3db06b341)]
1047
1052
  - bump version to use as volto-eea-design-system [David Ichim - [`f4be047`](https://github.com/eea/volto-eea-website-theme/commit/f4be047328b46399b03b612d378b18aaf82e7dc1)]
1048
- - Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`9b7cfef`](https://github.com/eea/volto-eea-website-theme/commit/9b7cfefb4d34fc1c948015e491feb370f9795bd8)]
1049
1053
  - test(Jenkins): Run tests and cypress with latest canary @plone/volto [Alin Voinea - [`df252a9`](https://github.com/eea/volto-eea-website-theme/commit/df252a9bfed0bb86cadf53c59dd1603b1e2cd822)]
1050
1054
  ### [1.3.2](https://github.com/eea/volto-eea-website-theme/compare/1.3.1...1.3.2) - 16 December 2022
1051
1055
 
@@ -1055,7 +1059,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
1055
1059
 
1056
1060
  #### :hammer_and_wrench: Others
1057
1061
 
1058
- - Add Sonarqube tag using cca-frontend addons list [EEA Jenkins - [`a43c658`](https://github.com/eea/volto-eea-website-theme/commit/a43c658a7920c8df95e763b9a637f38ce77eba2c)]
1059
1062
  - Better razzle.config [Tiberiu Ichim - [`81dbf48`](https://github.com/eea/volto-eea-website-theme/commit/81dbf48815fb27facb4f82c9b764540fdf188b2e)]
1060
1063
  - Better razzle.config [Tiberiu Ichim - [`7bc9da2`](https://github.com/eea/volto-eea-website-theme/commit/7bc9da2cd837ab62a95cd29979cdd9b0055b7d67)]
1061
1064
  ### [1.3.1](https://github.com/eea/volto-eea-website-theme/compare/1.3.0...1.3.1) - 28 November 2022
@@ -1066,7 +1069,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
1066
1069
 
1067
1070
  #### :hammer_and_wrench: Others
1068
1071
 
1069
- - yarn 3 [Alin Voinea - [`ea7a709`](https://github.com/eea/volto-eea-website-theme/commit/ea7a7094945312776e9b6f44e371178603e92139)]
1070
1072
  ### [1.3.0](https://github.com/eea/volto-eea-website-theme/compare/1.2.0...1.3.0) - 22 November 2022
1071
1073
 
1072
1074
  #### :rocket: New Features
@@ -1107,7 +1109,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
1107
1109
  - Add subsite class to body [Tiberiu Ichim - [`74d700f`](https://github.com/eea/volto-eea-website-theme/commit/74d700fbfd6249a8604762a7e4e49cce857db0f3)]
1108
1110
  - Add subsite info to header [Tiberiu Ichim - [`47daf8b`](https://github.com/eea/volto-eea-website-theme/commit/47daf8bb6374a1222040626b19d4154df7ba1b83)]
1109
1111
  - fix eslint [Miu Razvan - [`eb8d0a7`](https://github.com/eea/volto-eea-website-theme/commit/eb8d0a790bc70c0aae256c6ff35f63c4885f338e)]
1110
- - Add Sonarqube tag using circularity-frontend addons list [EEA Jenkins - [`cc578a4`](https://github.com/eea/volto-eea-website-theme/commit/cc578a413b205a8e61e091fab3a88f94cedefc89)]
1111
1112
  ### [1.1.0](https://github.com/eea/volto-eea-website-theme/compare/1.0.0...1.1.0) - 28 October 2022
1112
1113
 
1113
1114
  #### :nail_care: Enhancements
@@ -1155,7 +1156,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
1155
1156
 
1156
1157
  #### :hammer_and_wrench: Others
1157
1158
 
1158
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`33b56ac`](https://github.com/eea/volto-eea-website-theme/commit/33b56acb13fbaf0c5b79e8fc6e13c4b699c79c90)]
1159
1159
  ### [0.7.3](https://github.com/eea/volto-eea-website-theme/compare/0.7.2...0.7.3) - 22 September 2022
1160
1160
 
1161
1161
  #### :hammer_and_wrench: Others
@@ -1423,7 +1423,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
1423
1423
  - Header refactor, add custom logo #5 [ichim-david - [`4950235`](https://github.com/eea/volto-eea-website-theme/commit/49502358105437cfeac3b144e6d301cb59aa2346)]
1424
1424
  - Update footer.config with new publication card component [ichim-david - [`2e38e9a`](https://github.com/eea/volto-eea-website-theme/commit/2e38e9a417f835009d60c80d4eb4b30229f55e45)]
1425
1425
  - feature(breadcrumbs): implement eea-design-system breadcrumb as Volto component #32 #7 [ichim-david - [`181af41`](https://github.com/eea/volto-eea-website-theme/commit/181af4125ce2b9ddac56dab4723cb11c26633221)]
1426
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`da8ceb6`](https://github.com/eea/volto-eea-website-theme/commit/da8ceb68ea68bfbc9504e48ccd4d68277f11ab9a)]
1427
1426
  - use breadcrumbs from eea-design-system [nileshgulia1 - [`db2f9e9`](https://github.com/eea/volto-eea-website-theme/commit/db2f9e9a4327420a3cce9a9903cd88549b129eab)]
1428
1427
  - Update theme.config [ichim-david - [`8eca4f4`](https://github.com/eea/volto-eea-website-theme/commit/8eca4f40397a4aeca6d39029c92db78968d37064)]
1429
1428
  - Added keyContent component to theme.config [ichim-david - [`d86f202`](https://github.com/eea/volto-eea-website-theme/commit/d86f202d0274d839487a88b51cae9a0e899beb23)]
@@ -1465,5 +1464,4 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
1465
1464
 
1466
1465
  #### :hammer_and_wrench: Others
1467
1466
 
1468
- - yarn bootstrap [Alin Voinea - [`6995e9e`](https://github.com/eea/volto-eea-website-theme/commit/6995e9e091f21fdbbdffa8a44fc0e2c626f6d46a)]
1469
1467
  - Initial commit [Alin Voinea - [`6a9c03a`](https://github.com/eea/volto-eea-website-theme/commit/6a9c03a7cebe71ca87e82cf58c42904063e9d8d3)]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-eea-website-theme",
3
- "version": "3.5.4",
3
+ "version": "3.6.0",
4
4
  "description": "@eeacms/volto-eea-website-theme: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -0,0 +1,134 @@
1
+ import React from 'react';
2
+ import '@testing-library/jest-dom';
3
+ import { render, screen } from '@testing-library/react';
4
+ import WebReport from './WebReport';
5
+
6
+ // Mock Portal since we are not in real DOM
7
+ jest.mock('react-portal', () => ({
8
+ Portal: ({ children }) => <div data-testid="portal">{children}</div>,
9
+ }));
10
+
11
+ jest.mock('@plone/volto/helpers', () => ({
12
+ BodyClass: ({ className }) => (
13
+ <div data-testid="body-class" className={className} />
14
+ ),
15
+ }));
16
+
17
+ jest.mock('@plone/volto/components', () => ({
18
+ MaybeWrap: ({ condition, as: As, children }) =>
19
+ condition ? <As>{children}</As> : children,
20
+ }));
21
+
22
+ jest.mock(
23
+ '@eeacms/volto-eea-website-theme/components/theme/Banner/View',
24
+ () => (props) => (
25
+ <div data-testid="banner-view">
26
+ {props.data.aboveTitle}
27
+ {props.data.belowTitle}
28
+ </div>
29
+ ),
30
+ );
31
+
32
+ jest.mock('@eeacms/volto-eea-design-system/ui/Banner/Banner', () => {
33
+ const Subtitle = ({ children }) => (
34
+ <div data-testid="banner-subtitle">{children}</div>
35
+ );
36
+ return {
37
+ Subtitle,
38
+ };
39
+ });
40
+
41
+ describe('WebReport', () => {
42
+ it('renders with content type and subtitle', () => {
43
+ const props = {
44
+ isEditMode: false,
45
+ data: {
46
+ hero_header: true,
47
+ content_type: 'Report',
48
+ subtitle: 'This is a subtitle',
49
+ },
50
+ properties: {
51
+ type_title: 'Fallback Title',
52
+ },
53
+ };
54
+
55
+ render(<WebReport {...props} />);
56
+
57
+ // Check portal wrapping
58
+ expect(screen.getByTestId('portal')).toBeInTheDocument();
59
+
60
+ // Check BodyClass applied
61
+ expect(screen.getByTestId('body-class')).toHaveClass(
62
+ 'homepage-inverse',
63
+ 'homepage-header',
64
+ 'light-header',
65
+ 'hero-header',
66
+ );
67
+
68
+ // Check BannerView rendered
69
+ expect(screen.getByTestId('banner-view')).toBeInTheDocument();
70
+
71
+ // Content Type shown
72
+ expect(screen.getByText('Report')).toBeInTheDocument();
73
+
74
+ // Subtitle shown
75
+ expect(screen.getByText('This is a subtitle')).toBeInTheDocument();
76
+ });
77
+
78
+ it('renders fallback type_title when content_type missing', () => {
79
+ const props = {
80
+ isEditMode: false,
81
+ data: {
82
+ hero_header: true,
83
+ subtitle: 'Another subtitle',
84
+ },
85
+ properties: {
86
+ type_title: 'Fallback Title',
87
+ },
88
+ };
89
+
90
+ render(<WebReport {...props} />);
91
+
92
+ // Fallback title used
93
+ expect(screen.getByText('Fallback Title')).toBeInTheDocument();
94
+ });
95
+
96
+ it('hides content type if hideContentType is true', () => {
97
+ const props = {
98
+ isEditMode: false,
99
+ data: {
100
+ hero_header: false,
101
+ hideContentType: true,
102
+ subtitle: 'Hidden subtitle',
103
+ },
104
+ properties: {
105
+ type_title: 'Hidden Title',
106
+ },
107
+ };
108
+
109
+ render(<WebReport {...props} />);
110
+
111
+ // Should NOT find content type div
112
+ expect(screen.queryByText('Hidden Title')).not.toBeInTheDocument();
113
+ });
114
+
115
+ it('renders directly without portal in edit mode', () => {
116
+ const props = {
117
+ isEditMode: true,
118
+ data: {
119
+ subtitle: 'Edit mode subtitle',
120
+ },
121
+ properties: {
122
+ type_title: 'Edit Title',
123
+ },
124
+ };
125
+
126
+ render(<WebReport {...props} />);
127
+
128
+ // Should not wrap with Portal when in edit mode
129
+ expect(screen.queryByTestId('portal')).not.toBeInTheDocument();
130
+
131
+ // Banner still rendered
132
+ expect(screen.getByTestId('banner-view')).toBeInTheDocument();
133
+ });
134
+ });
@@ -0,0 +1,23 @@
1
+ import cx from 'classnames';
2
+
3
+ const ContributorsViewWidget = ({ value, content, children, className }) => {
4
+ const resolvedValue = content?.contributors_fullname || value || [];
5
+ return resolvedValue ? (
6
+ <span className={cx(className, 'array', 'widget')}>
7
+ {resolvedValue.map((item, key) => (
8
+ <>
9
+ {key ? ', ' : ''}
10
+ <span key={item.token || item.title || item}>
11
+ {children
12
+ ? children(item.title || item.token || item)
13
+ : item.title || item.token || item}
14
+ </span>
15
+ </>
16
+ ))}
17
+ </span>
18
+ ) : (
19
+ ''
20
+ );
21
+ };
22
+
23
+ export default ContributorsViewWidget;
@@ -0,0 +1,60 @@
1
+ import React from 'react';
2
+ import renderer from 'react-test-renderer';
3
+ import ContributorsViewWidget from './ContributorsViewWidget';
4
+
5
+ describe('ContributorsViewWidget', () => {
6
+ it('renders an empty array view widget component', () => {
7
+ const component = renderer.create(<ContributorsViewWidget />);
8
+ const json = component.toJSON();
9
+ expect(json).toMatchSnapshot();
10
+ });
11
+
12
+ it('renders a simple array view widget component', () => {
13
+ const component = renderer.create(
14
+ <ContributorsViewWidget className="metadata" value={['foo', 'bar']} />,
15
+ );
16
+ const json = component.toJSON();
17
+ expect(json).toMatchSnapshot();
18
+ });
19
+
20
+ it('renders a vocabulary array view widget component', () => {
21
+ const component = renderer.create(
22
+ <ContributorsViewWidget
23
+ className="metadata"
24
+ value={[{ title: 'Foo' }, { title: 'Bar' }]}
25
+ />,
26
+ );
27
+ const json = component.toJSON();
28
+ expect(json).toMatchSnapshot();
29
+ });
30
+
31
+ it('renders a full vocabulary array view widget component', () => {
32
+ const component = renderer.create(
33
+ <ContributorsViewWidget
34
+ className="metadata"
35
+ value={[
36
+ { title: 'Foo', token: 'foo' },
37
+ { title: 'Bar', token: 'bar' },
38
+ ]}
39
+ />,
40
+ );
41
+ const json = component.toJSON();
42
+ expect(json).toMatchSnapshot();
43
+ });
44
+
45
+ it('renders a full vocabulary array view widget component with children', () => {
46
+ const component = renderer.create(
47
+ <ContributorsViewWidget
48
+ className="metadata"
49
+ value={[
50
+ { title: 'Foo', token: 'foo' },
51
+ { title: 'Bar', token: 'bar' },
52
+ ]}
53
+ >
54
+ {(child) => <strong>{child}</strong>}
55
+ </ContributorsViewWidget>,
56
+ );
57
+ const json = component.toJSON();
58
+ expect(json).toMatchSnapshot();
59
+ });
60
+ });
@@ -0,0 +1,23 @@
1
+ import cx from 'classnames';
2
+
3
+ const CreatorsViewWidget = ({ value, content, children, className }) => {
4
+ const resolvedValue = content?.creators_fullname || value || [];
5
+ return resolvedValue ? (
6
+ <span className={cx(className, 'array', 'widget')}>
7
+ {resolvedValue.map((item, key) => (
8
+ <>
9
+ {key ? ', ' : ''}
10
+ <span key={item.token || item.title || item}>
11
+ {children
12
+ ? children(item.title || item.token || item)
13
+ : item.title || item.token || item}
14
+ </span>
15
+ </>
16
+ ))}
17
+ </span>
18
+ ) : (
19
+ ''
20
+ );
21
+ };
22
+
23
+ export default CreatorsViewWidget;
@@ -0,0 +1,60 @@
1
+ import React from 'react';
2
+ import renderer from 'react-test-renderer';
3
+ import CreatorsViewWidget from './CreatorsViewWidget';
4
+
5
+ describe('CreatorsViewWidget', () => {
6
+ it('renders an empty array view widget component', () => {
7
+ const component = renderer.create(<CreatorsViewWidget />);
8
+ const json = component.toJSON();
9
+ expect(json).toMatchSnapshot();
10
+ });
11
+
12
+ it('renders a simple array view widget component', () => {
13
+ const component = renderer.create(
14
+ <CreatorsViewWidget className="metadata" value={['foo', 'bar']} />,
15
+ );
16
+ const json = component.toJSON();
17
+ expect(json).toMatchSnapshot();
18
+ });
19
+
20
+ it('renders a vocabulary array view widget component', () => {
21
+ const component = renderer.create(
22
+ <CreatorsViewWidget
23
+ className="metadata"
24
+ value={[{ title: 'Foo' }, { title: 'Bar' }]}
25
+ />,
26
+ );
27
+ const json = component.toJSON();
28
+ expect(json).toMatchSnapshot();
29
+ });
30
+
31
+ it('renders a full vocabulary array view widget component', () => {
32
+ const component = renderer.create(
33
+ <CreatorsViewWidget
34
+ className="metadata"
35
+ value={[
36
+ { title: 'Foo', token: 'foo' },
37
+ { title: 'Bar', token: 'bar' },
38
+ ]}
39
+ />,
40
+ );
41
+ const json = component.toJSON();
42
+ expect(json).toMatchSnapshot();
43
+ });
44
+
45
+ it('renders a full vocabulary array view widget component with children', () => {
46
+ const component = renderer.create(
47
+ <CreatorsViewWidget
48
+ className="metadata"
49
+ value={[
50
+ { title: 'Foo', token: 'foo' },
51
+ { title: 'Bar', token: 'bar' },
52
+ ]}
53
+ >
54
+ {(child) => <strong>{child}</strong>}
55
+ </CreatorsViewWidget>,
56
+ );
57
+ const json = component.toJSON();
58
+ expect(json).toMatchSnapshot();
59
+ });
60
+ });
@@ -0,0 +1,3 @@
1
+ export default function ImageViewWidget({ value }) {
2
+ return <img src={value?.download} alt={value?.filename} />;
3
+ }