@eeacms/volto-eea-website-theme 3.5.5 → 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,7 +4,18 @@ 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.5.5](https://github.com/eea/volto-eea-website-theme/compare/3.5.4...3.5.5) - 15 April 2025
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
8
19
 
9
20
  #### :bug: Bug Fixes
10
21
 
@@ -12,8 +23,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
12
23
 
13
24
  #### :hammer_and_wrench: Others
14
25
 
15
- - Add Sonarqube tag using fise-frontend addons list [EEA Jenkins - [`3d50874`](https://github.com/eea/volto-eea-website-theme/commit/3d50874281ebcb91a1ae3727248f656a6f26c603)]
16
- - Add Sonarqube tag using ied-frontend addons list [EEA Jenkins - [`a3f7676`](https://github.com/eea/volto-eea-website-theme/commit/a3f76767d99cb6dd93cc7fa0eafdea57e9000b2c)]
17
26
  ### [3.5.4](https://github.com/eea/volto-eea-website-theme/compare/3.5.3...3.5.4) - 30 January 2025
18
27
 
19
28
  #### :bug: Bug Fixes
@@ -114,7 +123,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
114
123
 
115
124
  #### :hammer_and_wrench: Others
116
125
 
117
- - Add Sonarqube tag using bise-frontend addons list [EEA Jenkins - [`e417f83`](https://github.com/eea/volto-eea-website-theme/commit/e417f839312045c56b67ab8134fe5b0622b3e2c3)]
118
126
  ## [3.0.0](https://github.com/eea/volto-eea-website-theme/compare/2.4.0...3.0.0) - 21 October 2024
119
127
 
120
128
  #### :nail_care: Enhancements
@@ -200,7 +208,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
200
208
  - Refs #269520 - other_organisation test [Tripon Eugen - [`7558b27`](https://github.com/eea/volto-eea-website-theme/commit/7558b27a9d1cd6d3480a32b296c7325c796006c9)]
201
209
  - Refs #269520 - other_organisation token widget edit mode [Tripon Eugen - [`b6df127`](https://github.com/eea/volto-eea-website-theme/commit/b6df127bd91b6f55dda8f468e1107037d43752ff)]
202
210
  - Refs #269520 - other_organisation token widget [Tripon Eugen - [`6fd7543`](https://github.com/eea/volto-eea-website-theme/commit/6fd7543894bd2c593a1729116befd95c82ea3c8f)]
203
- - Add Sonarqube tag using marine-frontend addons list [EEA Jenkins - [`cbc36c7`](https://github.com/eea/volto-eea-website-theme/commit/cbc36c74dfcd5f7cb1013a4c673d9c02e0023766)]
204
211
  ### [2.1.1](https://github.com/eea/volto-eea-website-theme/compare/2.1.0...2.1.1) - 28 May 2024
205
212
 
206
213
  #### :bug: Bug Fixes
@@ -285,7 +292,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
285
292
 
286
293
  #### :hammer_and_wrench: Others
287
294
 
288
- - Add Sonarqube tag using insitu-frontend addons list [EEA Jenkins - [`adc6730`](https://github.com/eea/volto-eea-website-theme/commit/adc6730e21a37afb865b842182624401de6a29f5)]
289
295
  ### [1.33.1](https://github.com/eea/volto-eea-website-theme/compare/1.33.0...1.33.1) - 4 April 2024
290
296
 
291
297
  #### :bug: Bug Fixes
@@ -419,8 +425,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
419
425
 
420
426
  - bump version [Razvan - [`721e939`](https://github.com/eea/volto-eea-website-theme/commit/721e939d12e324b459ebfa78a2e656ee7142a3d6)]
421
427
  - merge master into this branch [Razvan - [`586c8f9`](https://github.com/eea/volto-eea-website-theme/commit/586c8f910bac55a043bd8dda60e9444bd2ae1663)]
422
- - Add Sonarqube tag using freshwater-frontend addons list [EEA Jenkins - [`fd90044`](https://github.com/eea/volto-eea-website-theme/commit/fd9004442a9d1d465f7601ecdefe3e23c61e6a9c)]
423
- - Add Sonarqube tag using insitu-frontend addons list [EEA Jenkins - [`4bc3dd3`](https://github.com/eea/volto-eea-website-theme/commit/4bc3dd3ae412a66befd04b5b80fab3716c929240)]
424
428
  - test: Update jest,Jenkinsfile,lint to volto-addons-template PR30 [valentinab25 - [`c4dbd28`](https://github.com/eea/volto-eea-website-theme/commit/c4dbd289358205bc2d849aab7edb11ccf3b89cee)]
425
429
  - fix tests [Razvan - [`042330b`](https://github.com/eea/volto-eea-website-theme/commit/042330bc97d32ffe7ba769b4f2453f71cffed706)]
426
430
  - remove RemoveSchema logic [Razvan - [`08d10f8`](https://github.com/eea/volto-eea-website-theme/commit/08d10f8bf6f75478260e4e4c66d7316ba87b907a)]
@@ -515,11 +519,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
515
519
  - test: Add real image to cypress test [Alin Voinea - [`4ff591a`](https://github.com/eea/volto-eea-website-theme/commit/4ff591ae3318c9588b4e2114582c0fa6cfdf31ae)]
516
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)]
517
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)]
518
- - test: [JENKINS] Use java17 for sonarqube scanner [valentinab25 - [`6a3be30`](https://github.com/eea/volto-eea-website-theme/commit/6a3be3092589411af7808a235f76de5222fd3868)]
519
- - test: [JENKINS] Run cypress in started frontend container [valentinab25 - [`c3978f2`](https://github.com/eea/volto-eea-website-theme/commit/c3978f23375ef066e9fd6f6c2e34ba6c1c058f69)]
520
- - test: [JENKINS] Add cpu limit on cypress docker [valentinab25 - [`f672779`](https://github.com/eea/volto-eea-website-theme/commit/f672779e845bec9240ccc901e9f53ec80c5a1819)]
521
- - test: [JENKINS] Increase shm-size to cypress docker [valentinab25 - [`ae5d8e3`](https://github.com/eea/volto-eea-website-theme/commit/ae5d8e3f4e04dc2808d47ce2ee886e1b23b528da)]
522
- - test: [JENKINS] Improve cypress time [valentinab25 - [`170ff0c`](https://github.com/eea/volto-eea-website-theme/commit/170ff0c8e3b30e69479bdf1117e811fea94f1027)]
523
522
  ### [1.23.0](https://github.com/eea/volto-eea-website-theme/compare/1.22.1...1.23.0) - 2 November 2023
524
523
 
525
524
  #### :rocket: New Features
@@ -532,7 +531,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
532
531
 
533
532
  #### :house: Internal changes
534
533
 
535
- - chore: [JENKINS] Refactor automated testing [valentinab25 - [`f28fce3`](https://github.com/eea/volto-eea-website-theme/commit/f28fce3d1eb815f95fb9aa40de42b10b7e8e30c5)]
536
534
  - chore: husky, lint-staged use fixed versions [valentinab25 - [`6d15088`](https://github.com/eea/volto-eea-website-theme/commit/6d150886c5aeb2ca0b569270486e60f7cc274e2c)]
537
535
  - chore:volto 16 in tests, update docs, fix stylelint overrides [valentinab25 - [`20c0323`](https://github.com/eea/volto-eea-website-theme/commit/20c032380b33c0077c869a05136f93e2fb68e5d4)]
538
536
 
@@ -718,7 +716,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
718
716
 
719
717
  #### :house: Internal changes
720
718
 
721
- - chore: [JENKINS] Deprecate circularity website [valentinab25 - [`370dcbf`](https://github.com/eea/volto-eea-website-theme/commit/370dcbfbf1a8135ce7b1b3b271b004552a631837)]
722
719
 
723
720
  #### :hammer_and_wrench: Others
724
721
 
@@ -874,7 +871,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
874
871
 
875
872
  #### :hammer_and_wrench: Others
876
873
 
877
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`6c5e2f8`](https://github.com/eea/volto-eea-website-theme/commit/6c5e2f80456e2061d9e9c15fd0a0b91b9ac70568)]
878
874
  ### [1.9.1](https://github.com/eea/volto-eea-website-theme/compare/1.9.0...1.9.1) - 28 February 2023
879
875
 
880
876
  #### :bug: Bug Fixes
@@ -1021,7 +1017,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
1021
1017
 
1022
1018
  - For some reasons types is a string [Alin Voinea - [`3769a09`](https://github.com/eea/volto-eea-website-theme/commit/3769a0981181d5b633f3498daebbe96be8b4b833)]
1023
1019
  - Fix(redirect): o.filter - refs #157627 [Alin Voinea - [`deb23da`](https://github.com/eea/volto-eea-website-theme/commit/deb23da846444cc96539697fd798429ae0abe89e)]
1024
- - Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`f1fffc5`](https://github.com/eea/volto-eea-website-theme/commit/f1fffc5db96725440863d545580b4e76cce4b796)]
1025
1020
  ### [1.5.0](https://github.com/eea/volto-eea-website-theme/compare/1.4.2...1.5.0) - 9 January 2023
1026
1021
 
1027
1022
  #### :hammer_and_wrench: Others
@@ -1055,7 +1050,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
1055
1050
 
1056
1051
  - Release 1.4.0 [Alin Voinea - [`bd42a0d`](https://github.com/eea/volto-eea-website-theme/commit/bd42a0d26e928cac5d99933194755da3db06b341)]
1057
1052
  - bump version to use as volto-eea-design-system [David Ichim - [`f4be047`](https://github.com/eea/volto-eea-website-theme/commit/f4be047328b46399b03b612d378b18aaf82e7dc1)]
1058
- - Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`9b7cfef`](https://github.com/eea/volto-eea-website-theme/commit/9b7cfefb4d34fc1c948015e491feb370f9795bd8)]
1059
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)]
1060
1054
  ### [1.3.2](https://github.com/eea/volto-eea-website-theme/compare/1.3.1...1.3.2) - 16 December 2022
1061
1055
 
@@ -1065,7 +1059,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
1065
1059
 
1066
1060
  #### :hammer_and_wrench: Others
1067
1061
 
1068
- - Add Sonarqube tag using cca-frontend addons list [EEA Jenkins - [`a43c658`](https://github.com/eea/volto-eea-website-theme/commit/a43c658a7920c8df95e763b9a637f38ce77eba2c)]
1069
1062
  - Better razzle.config [Tiberiu Ichim - [`81dbf48`](https://github.com/eea/volto-eea-website-theme/commit/81dbf48815fb27facb4f82c9b764540fdf188b2e)]
1070
1063
  - Better razzle.config [Tiberiu Ichim - [`7bc9da2`](https://github.com/eea/volto-eea-website-theme/commit/7bc9da2cd837ab62a95cd29979cdd9b0055b7d67)]
1071
1064
  ### [1.3.1](https://github.com/eea/volto-eea-website-theme/compare/1.3.0...1.3.1) - 28 November 2022
@@ -1076,7 +1069,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
1076
1069
 
1077
1070
  #### :hammer_and_wrench: Others
1078
1071
 
1079
- - yarn 3 [Alin Voinea - [`ea7a709`](https://github.com/eea/volto-eea-website-theme/commit/ea7a7094945312776e9b6f44e371178603e92139)]
1080
1072
  ### [1.3.0](https://github.com/eea/volto-eea-website-theme/compare/1.2.0...1.3.0) - 22 November 2022
1081
1073
 
1082
1074
  #### :rocket: New Features
@@ -1117,7 +1109,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
1117
1109
  - Add subsite class to body [Tiberiu Ichim - [`74d700f`](https://github.com/eea/volto-eea-website-theme/commit/74d700fbfd6249a8604762a7e4e49cce857db0f3)]
1118
1110
  - Add subsite info to header [Tiberiu Ichim - [`47daf8b`](https://github.com/eea/volto-eea-website-theme/commit/47daf8bb6374a1222040626b19d4154df7ba1b83)]
1119
1111
  - fix eslint [Miu Razvan - [`eb8d0a7`](https://github.com/eea/volto-eea-website-theme/commit/eb8d0a790bc70c0aae256c6ff35f63c4885f338e)]
1120
- - Add Sonarqube tag using circularity-frontend addons list [EEA Jenkins - [`cc578a4`](https://github.com/eea/volto-eea-website-theme/commit/cc578a413b205a8e61e091fab3a88f94cedefc89)]
1121
1112
  ### [1.1.0](https://github.com/eea/volto-eea-website-theme/compare/1.0.0...1.1.0) - 28 October 2022
1122
1113
 
1123
1114
  #### :nail_care: Enhancements
@@ -1165,7 +1156,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
1165
1156
 
1166
1157
  #### :hammer_and_wrench: Others
1167
1158
 
1168
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`33b56ac`](https://github.com/eea/volto-eea-website-theme/commit/33b56acb13fbaf0c5b79e8fc6e13c4b699c79c90)]
1169
1159
  ### [0.7.3](https://github.com/eea/volto-eea-website-theme/compare/0.7.2...0.7.3) - 22 September 2022
1170
1160
 
1171
1161
  #### :hammer_and_wrench: Others
@@ -1433,7 +1423,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
1433
1423
  - Header refactor, add custom logo #5 [ichim-david - [`4950235`](https://github.com/eea/volto-eea-website-theme/commit/49502358105437cfeac3b144e6d301cb59aa2346)]
1434
1424
  - Update footer.config with new publication card component [ichim-david - [`2e38e9a`](https://github.com/eea/volto-eea-website-theme/commit/2e38e9a417f835009d60c80d4eb4b30229f55e45)]
1435
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)]
1436
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`da8ceb6`](https://github.com/eea/volto-eea-website-theme/commit/da8ceb68ea68bfbc9504e48ccd4d68277f11ab9a)]
1437
1426
  - use breadcrumbs from eea-design-system [nileshgulia1 - [`db2f9e9`](https://github.com/eea/volto-eea-website-theme/commit/db2f9e9a4327420a3cce9a9903cd88549b129eab)]
1438
1427
  - Update theme.config [ichim-david - [`8eca4f4`](https://github.com/eea/volto-eea-website-theme/commit/8eca4f40397a4aeca6d39029c92db78968d37064)]
1439
1428
  - Added keyContent component to theme.config [ichim-david - [`d86f202`](https://github.com/eea/volto-eea-website-theme/commit/d86f202d0274d839487a88b51cae9a0e899beb23)]
@@ -1475,5 +1464,4 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
1475
1464
 
1476
1465
  #### :hammer_and_wrench: Others
1477
1466
 
1478
- - yarn bootstrap [Alin Voinea - [`6995e9e`](https://github.com/eea/volto-eea-website-theme/commit/6995e9e091f21fdbbdffa8a44fc0e2c626f6d46a)]
1479
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.5",
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
+ });
@@ -1,3 +1,3 @@
1
1
  export default function ImageViewWidget({ value }) {
2
- return <img src={value.download} alt={value.filename} />;
2
+ return <img src={value?.download} alt={value?.filename} />;
3
3
  }