@eeacms/volto-tabs-block 7.0.4 → 7.5.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 +42 -27
- package/jest-addon.config.js +1 -0
- package/package.json +2 -2
- package/src/components/View.jsx +3 -4
- package/src/components/View.test.jsx +109 -0
- package/src/components/templates/accordion/Edit.jsx +16 -205
- package/src/components/templates/accordion/index.js +2 -2
- package/src/components/templates/default/Edit.jsx +6 -4
- package/src/components/templates/default/View.jsx +2 -2
- package/src/components/templates/horizontal-responsive/Edit.jsx +5 -3
- package/src/components/templates/horizontal-responsive/View.jsx +4 -2
- package/src/index.js +1 -0
- package/src/less/menu.less +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,48 @@ 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
|
+
### [7.5.0](https://github.com/eea/volto-tabs-block/compare/7.0.5...7.5.0) - 7 March 2024
|
|
8
|
+
|
|
9
|
+
#### :boom: Breaking Change
|
|
10
|
+
|
|
11
|
+
- breaking(tabs): menu-item-text markup is now span instead of p tag [David Ichim - [`5aa7981`](https://github.com/eea/volto-tabs-block/commit/5aa798140654b4b6e3487c082483640432eddd65)]
|
|
12
|
+
|
|
13
|
+
#### :bug: Bug Fixes
|
|
14
|
+
|
|
15
|
+
- fix(tests): after change from p tag to reference the .menu-item-text class [David Ichim - [`9a45825`](https://github.com/eea/volto-tabs-block/commit/9a45825f80162f734872786fd0fe9359dd57ad9f)]
|
|
16
|
+
- fix: update 'Add Tabs default template' cypress test - Default tabs text to be inside a span within the tab link instead of a p tag [Claudia Ifrim - [`4209573`](https://github.com/eea/volto-tabs-block/commit/4209573f6ab25019814902ec38685f908958f6a7)]
|
|
17
|
+
- fix: remove AccordionEdit import form index [Claudia Ifrim - [`24323cc`](https://github.com/eea/volto-tabs-block/commit/24323cc0e0c674697fddac62df22c646785ec41b)]
|
|
18
|
+
|
|
19
|
+
#### :nail_care: Enhancements
|
|
20
|
+
|
|
21
|
+
- change(tabs): use default edit for accordion tab edit [David Ichim - [`7ed5f4e`](https://github.com/eea/volto-tabs-block/commit/7ed5f4e61ab1747ede5641138119c47d8b3dd6c1)]
|
|
22
|
+
|
|
23
|
+
#### :house: Internal changes
|
|
24
|
+
|
|
25
|
+
- style: Automated code fix [eea-jenkins - [`e37f2d4`](https://github.com/eea/volto-tabs-block/commit/e37f2d4c26a9ff72ffb09263caa96c55e3161551)]
|
|
26
|
+
- style: Automated code fix [eea-jenkins - [`0520da7`](https://github.com/eea/volto-tabs-block/commit/0520da7ad50e7be1d62d574308d4acc5a858a401)]
|
|
27
|
+
|
|
28
|
+
#### :hammer_and_wrench: Others
|
|
29
|
+
|
|
30
|
+
- Bump package version to 7.5 from 7.0.5 [David Ichim - [`a675429`](https://github.com/eea/volto-tabs-block/commit/a675429308f6d9a2b39e101396e7a5b195982f30)]
|
|
31
|
+
- Prettier and stylelint [David Ichim - [`f6182d1`](https://github.com/eea/volto-tabs-block/commit/f6182d142b790b2256e24ad7ed49e8904ec73aa8)]
|
|
32
|
+
- Fixed call to stylelint within MakeFile [David Ichim - [`dd53ee8`](https://github.com/eea/volto-tabs-block/commit/dd53ee84f4bb97b55d5d26e0447cff2f07268afc)]
|
|
33
|
+
- Revert "update" [David Ichim - [`ceb8ab7`](https://github.com/eea/volto-tabs-block/commit/ceb8ab7fd216d369ed487a7fe63aec876e2c4624)]
|
|
34
|
+
- fix cypress [Razvan - [`6fe2bb4`](https://github.com/eea/volto-tabs-block/commit/6fe2bb46de04c9c2c0115d3fc97caf9ea5952b6e)]
|
|
35
|
+
- Update react-slick version to 0.30.1 [David Ichim - [`3369176`](https://github.com/eea/volto-tabs-block/commit/33691768899e7f91d2cd15319dbe3ebe66cf1513)]
|
|
36
|
+
- update [Razvan - [`61b19e8`](https://github.com/eea/volto-tabs-block/commit/61b19e8584ff6023320b3671414392ea11449ff0)]
|
|
37
|
+
- use DefaultEdit variation for responsive accordion, refs #266327 [Razvan - [`11acf6c`](https://github.com/eea/volto-tabs-block/commit/11acf6ce5afe022ddd30bff42c9a3321d1284da6)]
|
|
38
|
+
### [7.0.5](https://github.com/eea/volto-tabs-block/compare/7.0.4...7.0.5) - 10 December 2023
|
|
39
|
+
|
|
40
|
+
#### :rocket: New Features
|
|
41
|
+
|
|
42
|
+
- feat: add more tests for view/edit component [hazigabriel - [`72d0467`](https://github.com/eea/volto-tabs-block/commit/72d0467e74042b103630aacb8cffafb7c7a4a83f)]
|
|
43
|
+
- feat: refactor custom useQuery hook to avoid uncessary rerender [hazigabriel - [`6f28052`](https://github.com/eea/volto-tabs-block/commit/6f28052336db391ef9c918b2b329da4ae1639850)]
|
|
44
|
+
|
|
45
|
+
#### :bug: Bug Fixes
|
|
46
|
+
|
|
47
|
+
- fix: add jest config to fix jenkins error [hazigabriel - [`63fa962`](https://github.com/eea/volto-tabs-block/commit/63fa962f7f49ac8986ff250db57f544292aa951c)]
|
|
48
|
+
|
|
7
49
|
### [7.0.4](https://github.com/eea/volto-tabs-block/compare/7.0.3...7.0.4) - 4 December 2023
|
|
8
50
|
|
|
9
51
|
#### :bug: Bug Fixes
|
|
@@ -24,8 +66,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
24
66
|
|
|
25
67
|
#### :hammer_and_wrench: Others
|
|
26
68
|
|
|
27
|
-
- test: [JENKINS] Use java17 for sonarqube scanner [valentinab25 - [`3b87d12`](https://github.com/eea/volto-tabs-block/commit/3b87d12df4d01031231b15eb4196f6ff6937706b)]
|
|
28
|
-
- test: [JENKINS] Run cypress in started frontend container [valentinab25 - [`f5f3430`](https://github.com/eea/volto-tabs-block/commit/f5f343024b45bb0206e0169cce6dd0e8472b6795)]
|
|
29
69
|
### [7.0.1](https://github.com/eea/volto-tabs-block/compare/7.0.0...7.0.1) - 9 November 2023
|
|
30
70
|
|
|
31
71
|
#### :bug: Bug Fixes
|
|
@@ -35,14 +75,10 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
35
75
|
|
|
36
76
|
#### :hammer_and_wrench: Others
|
|
37
77
|
|
|
38
|
-
- test: [JENKINS] Add cpu limit on cypress docker [valentinab25 - [`bd6ffd4`](https://github.com/eea/volto-tabs-block/commit/bd6ffd42a00a2d77ff59545d9adaab7a45361446)]
|
|
39
|
-
- test: [JENKINS] Increase shm-size to cypress docker [valentinab25 - [`d481e25`](https://github.com/eea/volto-tabs-block/commit/d481e25c4d61d7ff6ea11ff75c99fbdd730ecd82)]
|
|
40
|
-
- test: [JENKINS] Improve cypress time [valentinab25 - [`6c39efc`](https://github.com/eea/volto-tabs-block/commit/6c39efcc30bddfebb6c61f8a8cd714f61828ec69)]
|
|
41
78
|
## [7.0.0](https://github.com/eea/volto-tabs-block/compare/6.0.3...7.0.0) - 31 October 2023
|
|
42
79
|
|
|
43
80
|
#### :house: Internal changes
|
|
44
81
|
|
|
45
|
-
- chore: [JENKINS] Refactor automated testing [valentinab25 - [`f2e3d39`](https://github.com/eea/volto-tabs-block/commit/f2e3d3973c026f0331b82e0f691ec9bdc5899672)]
|
|
46
82
|
|
|
47
83
|
#### :hammer_and_wrench: Others
|
|
48
84
|
|
|
@@ -255,7 +291,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
255
291
|
|
|
256
292
|
#### :house: Internal changes
|
|
257
293
|
|
|
258
|
-
- chore: [JENKINS] Deprecate circularity website [valentinab25 - [`820aaa9`](https://github.com/eea/volto-tabs-block/commit/820aaa963e978a893a23b77f694bb011f3d768c1)]
|
|
259
294
|
|
|
260
295
|
#### :hammer_and_wrench: Others
|
|
261
296
|
|
|
@@ -346,7 +381,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
346
381
|
|
|
347
382
|
#### :hammer_and_wrench: Others
|
|
348
383
|
|
|
349
|
-
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`52bc1b0`](https://github.com/eea/volto-tabs-block/commit/52bc1b0fbd4611173b8ca9dc2cf4033b31474420)]
|
|
350
384
|
## [4.0.0](https://github.com/eea/volto-tabs-block/compare/3.0.1...4.0.0) - 10 March 2023
|
|
351
385
|
|
|
352
386
|
#### :house: Internal changes
|
|
@@ -357,13 +391,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
357
391
|
#### :hammer_and_wrench: Others
|
|
358
392
|
|
|
359
393
|
- Release 4.0.0 [Alin Voinea - [`8fc4cc9`](https://github.com/eea/volto-tabs-block/commit/8fc4cc9d8dc71e623e6586b95871cb3b98dc385f)]
|
|
360
|
-
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`22d5bdc`](https://github.com/eea/volto-tabs-block/commit/22d5bdc1b3579cc46c73ce855041ca09154eb502)]
|
|
361
|
-
- Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`fde4324`](https://github.com/eea/volto-tabs-block/commit/fde4324f962cde8e8de0d76a44bee4b67d216bf8)]
|
|
362
|
-
- Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`9175e47`](https://github.com/eea/volto-tabs-block/commit/9175e470d793edc63b62a99940aed25dd45f3713)]
|
|
363
394
|
- test(Jenkins): Run tests and cypress with latest canary @plone/volto [Alin Voinea - [`3348950`](https://github.com/eea/volto-tabs-block/commit/334895036f8e367281abb35a20879c32dfbfc292)]
|
|
364
|
-
- Add Sonarqube tag using cca-frontend addons list [EEA Jenkins - [`39bfb39`](https://github.com/eea/volto-tabs-block/commit/39bfb39fa6e8483e639491ff998293e758ac6384)]
|
|
365
|
-
- yarn 3 [Alin Voinea - [`7e98df5`](https://github.com/eea/volto-tabs-block/commit/7e98df59669d71945be461e86e282b913538b805)]
|
|
366
|
-
- Add Sonarqube tag using demo-kitkat-frontend addons list [EEA Jenkins - [`079d7a4`](https://github.com/eea/volto-tabs-block/commit/079d7a43480e92fe280a9372399ff2d4d28537ae)]
|
|
367
395
|
### [3.0.1](https://github.com/eea/volto-tabs-block/compare/3.0.0...3.0.1) - 16 November 2022
|
|
368
396
|
|
|
369
397
|
#### :hammer_and_wrench: Others
|
|
@@ -387,9 +415,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
387
415
|
|
|
388
416
|
#### :hammer_and_wrench: Others
|
|
389
417
|
|
|
390
|
-
- Add Sonarqube tag using marine-frontend addons list [EEA Jenkins - [`a00e419`](https://github.com/eea/volto-tabs-block/commit/a00e419aef4c82a25f277f5e25e3d512c7838264)]
|
|
391
418
|
- lint fix [David Ichim - [`c0a898c`](https://github.com/eea/volto-tabs-block/commit/c0a898c54461478baed2ac2f149ae580d4c89aeb)]
|
|
392
|
-
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`3b284e6`](https://github.com/eea/volto-tabs-block/commit/3b284e65e0eafa9b5ad8c92b4cb77628ffcc8103)]
|
|
393
419
|
### [2.2.0](https://github.com/eea/volto-tabs-block/compare/2.1.0...2.2.0) - 25 August 2022
|
|
394
420
|
|
|
395
421
|
#### :hammer_and_wrench: Others
|
|
@@ -405,7 +431,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
405
431
|
|
|
406
432
|
- Release 2.1.0 [Alin Voinea - [`3cdfa30`](https://github.com/eea/volto-tabs-block/commit/3cdfa30d4d03d864be8ad63f0648b4717298734a)]
|
|
407
433
|
- Squashed commit of the following: [Alin Voinea - [`ca241f5`](https://github.com/eea/volto-tabs-block/commit/ca241f56a96817679a1948154e2a8cc0e17b96fe)]
|
|
408
|
-
- Add Sonarqube tag using circularity-frontend addons list [EEA Jenkins - [`68ea5a6`](https://github.com/eea/volto-tabs-block/commit/68ea5a6b971fc36840cf5716a04f68316b229b2b)]
|
|
409
434
|
### [2.0.2](https://github.com/eea/volto-tabs-block/compare/2.0.1...2.0.2) - 16 June 2022
|
|
410
435
|
|
|
411
436
|
### [2.0.1](https://github.com/eea/volto-tabs-block/compare/2.0.0...2.0.1) - 10 June 2022
|
|
@@ -449,8 +474,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
449
474
|
- Let theme addon to set default values for default template schema [Miu Razvan - [`55f148d`](https://github.com/eea/volto-tabs-block/commit/55f148d1a95417f8a0b55681ce250acde8463c1c)]
|
|
450
475
|
- Render pane as container if tabs-block has full-width class [Miu Razvan - [`bbffb96`](https://github.com/eea/volto-tabs-block/commit/bbffb96b908476ddee447af3ce79bafb1a12f9a8)]
|
|
451
476
|
- Refactor default template [Miu Razvan - [`58eff52`](https://github.com/eea/volto-tabs-block/commit/58eff5281adb08a5f8fe6d21fd43330252012277)]
|
|
452
|
-
- Add Sonarqube tag using clms-frontend addons list [EEA Jenkins - [`72a6735`](https://github.com/eea/volto-tabs-block/commit/72a6735cbbc0e7d57b4bb7ea83fea9becc317018)]
|
|
453
|
-
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`e928da1`](https://github.com/eea/volto-tabs-block/commit/e928da1df7e4680bd4be9b5d46406800d721b8c5)]
|
|
454
477
|
### [1.2.12](https://github.com/eea/volto-tabs-block/compare/1.2.11...1.2.12) - 21 January 2022
|
|
455
478
|
|
|
456
479
|
### [1.2.11](https://github.com/eea/volto-tabs-block/compare/1.2.10...1.2.11) - 4 January 2022
|
|
@@ -465,17 +488,11 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
465
488
|
|
|
466
489
|
#### :hammer_and_wrench: Others
|
|
467
490
|
|
|
468
|
-
- Add Sonarqube tag using freshwater-frontend addons list [EEA Jenkins - [`cd2e2ac`](https://github.com/eea/volto-tabs-block/commit/cd2e2ac1d127bfc688ecf16e17734603ab727a34)]
|
|
469
491
|
### [1.2.8](https://github.com/eea/volto-tabs-block/compare/1.2.7...1.2.8) - 10 December 2021
|
|
470
492
|
|
|
471
493
|
#### :hammer_and_wrench: Others
|
|
472
494
|
|
|
473
495
|
- Refs #142010 - Optimize Volto-addons gitflow pipelines [valentinab25 - [`d10c0b3`](https://github.com/eea/volto-tabs-block/commit/d10c0b3d35d25c530d19eebde38dfe5da8fda01b)]
|
|
474
|
-
- Add Sonarqube tag using industry-frontend addons list [EEA Jenkins - [`1a7187f`](https://github.com/eea/volto-tabs-block/commit/1a7187f10b2bd9e1307dabf51823f63ccd766864)]
|
|
475
|
-
- Add Sonarqube tag using clms-frontend addons list [EEA Jenkins - [`72a7550`](https://github.com/eea/volto-tabs-block/commit/72a755025b38e1d8dd7fe206273a70585e4b9ac8)]
|
|
476
|
-
- Add Sonarqube tag using forests-frontend addons list [EEA Jenkins - [`022b277`](https://github.com/eea/volto-tabs-block/commit/022b2779a5d7fd7217c2d8a559eafab0bd86ce23)]
|
|
477
|
-
- Add Sonarqube tag using sustainability-frontend addons list [EEA Jenkins - [`84c9bea`](https://github.com/eea/volto-tabs-block/commit/84c9bea7a0aba2fe9ef9713e7131de6da6e0bcce)]
|
|
478
|
-
- Add Sonarqube tag using ims-frontend addons list [EEA Jenkins - [`020aa97`](https://github.com/eea/volto-tabs-block/commit/020aa97bc70a643ea3857566c5a1dc3a5200c2be)]
|
|
479
496
|
### [1.2.7](https://github.com/eea/volto-tabs-block/compare/1.2.6...1.2.7) - 27 August 2021
|
|
480
497
|
|
|
481
498
|
#### :hammer_and_wrench: Others
|
|
@@ -492,8 +509,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
492
509
|
|
|
493
510
|
- Move less import in View instead of Edit [Tiberiu Ichim - [`84aeff0`](https://github.com/eea/volto-tabs-block/commit/84aeff04a980076f54687c546691d37b6e790478)]
|
|
494
511
|
- gitignore tweaks [Tiberiu Ichim - [`f4c993d`](https://github.com/eea/volto-tabs-block/commit/f4c993d004b126f08f16651ab9460546fa9e9cad)]
|
|
495
|
-
- Add Sonarqube tag using frontend addons list [EEA Jenkins - [`865906a`](https://github.com/eea/volto-tabs-block/commit/865906a0deb261d44cc23e26bfd2d1dd0e319640)]
|
|
496
|
-
- Add Sonarqube tag using frontend addons list [EEA Jenkins - [`5383861`](https://github.com/eea/volto-tabs-block/commit/538386100adbc868e693c1c2a5ba13461307ffee)]
|
|
497
512
|
- Style update [razvanMiu - [`323aaaf`](https://github.com/eea/volto-tabs-block/commit/323aaafcad01d8fdf0e713a1fc254ae9fe319f43)]
|
|
498
513
|
- Fix 'scroll to' feature on carousel [razvanMiu - [`16c6a08`](https://github.com/eea/volto-tabs-block/commit/16c6a08f6db687542ea38e07a92b265e592f6173)]
|
|
499
514
|
- Better accesibility [razvanMiu - [`3511611`](https://github.com/eea/volto-tabs-block/commit/351161197270a4807f01d85a7055cbaadae72f8e)]
|
package/jest-addon.config.js
CHANGED
|
@@ -19,6 +19,7 @@ module.exports = {
|
|
|
19
19
|
'load-volto-addons':
|
|
20
20
|
'<rootDir>/node_modules/@plone/volto/jest-addons-loader.js',
|
|
21
21
|
},
|
|
22
|
+
transformIgnorePatterns: ['node_modules/(?!@eeacms)/volto-anchors/helpers'],
|
|
22
23
|
transform: {
|
|
23
24
|
'^.+\\.js(x)?$': 'babel-jest',
|
|
24
25
|
'^.+\\.(png)$': 'jest-file',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eeacms/volto-tabs-block",
|
|
3
|
-
"version": "7.0
|
|
3
|
+
"version": "7.5.0",
|
|
4
4
|
"description": "volto-tabs-block: Volto add-on",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"author": "European Environment Agency: IDM2 A-Team",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"@eeacms/volto-anchors": "*",
|
|
25
25
|
"@eeacms/volto-block-style": "*",
|
|
26
26
|
"react-responsive-tabs": "4.4.3",
|
|
27
|
-
"react-slick": "^0.
|
|
27
|
+
"react-slick": "^0.30.1",
|
|
28
28
|
"slick-carousel": "^1.8.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
package/src/components/View.jsx
CHANGED
|
@@ -33,12 +33,11 @@ const View = (props) => {
|
|
|
33
33
|
|
|
34
34
|
const TabsView = activeTemplate?.[0]?.view || DefaultView;
|
|
35
35
|
|
|
36
|
-
const
|
|
36
|
+
const query = React.useMemo(() => {
|
|
37
37
|
const { search } = location;
|
|
38
|
-
return React.useMemo(() => new URLSearchParams(search), [search]);
|
|
39
|
-
};
|
|
40
38
|
|
|
41
|
-
|
|
39
|
+
return new URLSearchParams(search);
|
|
40
|
+
}, [location]);
|
|
42
41
|
const activeTabId = query.get('activeTab');
|
|
43
42
|
|
|
44
43
|
const addQueryParam = (key, value) => {
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, fireEvent } from '@testing-library/react';
|
|
3
|
+
import { BrowserRouter as Router } from 'react-router-dom';
|
|
4
|
+
import View from './View';
|
|
5
|
+
import config from '@plone/volto/registry';
|
|
6
|
+
import configureStore from 'redux-mock-store';
|
|
7
|
+
import { Provider } from 'react-intl-redux';
|
|
8
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
9
|
+
|
|
10
|
+
config.blocks.blocksConfig = {
|
|
11
|
+
tabs_block: {
|
|
12
|
+
variations: [{ id: 'default' }, { id: 'accordion' }],
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
config.settings = {
|
|
16
|
+
integratesBlockStyles: [],
|
|
17
|
+
};
|
|
18
|
+
jest.mock('react-router', () => ({
|
|
19
|
+
withRouter: (WrapperComponent) => (props) => {
|
|
20
|
+
return (
|
|
21
|
+
<WrapperComponent
|
|
22
|
+
{...props}
|
|
23
|
+
location={{
|
|
24
|
+
pathname: '/',
|
|
25
|
+
search: '?activeTab=tab1',
|
|
26
|
+
hash: '',
|
|
27
|
+
key: 'qruhb8',
|
|
28
|
+
}}
|
|
29
|
+
history={{
|
|
30
|
+
push: jest.fn(),
|
|
31
|
+
}}
|
|
32
|
+
/>
|
|
33
|
+
);
|
|
34
|
+
},
|
|
35
|
+
}));
|
|
36
|
+
|
|
37
|
+
jest.mock('@eeacms/volto-block-style/StyleWrapper', () => ({
|
|
38
|
+
StyleWrapperView: (props) => {
|
|
39
|
+
return <div className="mocked-style-wrapper">{props.children}</div>;
|
|
40
|
+
},
|
|
41
|
+
}));
|
|
42
|
+
const mockStore = configureStore();
|
|
43
|
+
const store = mockStore({
|
|
44
|
+
intl: {
|
|
45
|
+
locale: 'en',
|
|
46
|
+
messages: {},
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
describe('View Component', () => {
|
|
51
|
+
it('Should render and switch Tabs', () => {
|
|
52
|
+
const customTabsData = {
|
|
53
|
+
blocks_layout: {
|
|
54
|
+
items: ['tab1', 'tab2', 'tab3'],
|
|
55
|
+
},
|
|
56
|
+
blocks: {
|
|
57
|
+
tab1: {
|
|
58
|
+
title: 'Tab 1 Title',
|
|
59
|
+
content: 'Tab 1 Content',
|
|
60
|
+
},
|
|
61
|
+
tab2: {
|
|
62
|
+
title: 'Tab 2 Title',
|
|
63
|
+
content: 'Tab 2 Content',
|
|
64
|
+
},
|
|
65
|
+
tab3: {
|
|
66
|
+
title: 'Tab 3 Title',
|
|
67
|
+
content: 'Tab 3 Content',
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const { container, getByText } = render(
|
|
73
|
+
<Provider store={store}>
|
|
74
|
+
<Router>
|
|
75
|
+
<View data={{ variation: 'default', data: customTabsData }} />
|
|
76
|
+
</Router>
|
|
77
|
+
</Provider>,
|
|
78
|
+
);
|
|
79
|
+
const tabItemsMenu = container.querySelectorAll(
|
|
80
|
+
'.ui.tabs-secondary-variant.menu a',
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
expect(
|
|
84
|
+
container.querySelector('.tabs-block.default.light.flex-start'),
|
|
85
|
+
).toBeInTheDocument();
|
|
86
|
+
expect(
|
|
87
|
+
container.querySelector('.default.tabs.tabs-accessibility'),
|
|
88
|
+
).toBeInTheDocument();
|
|
89
|
+
expect(
|
|
90
|
+
container.querySelector('.ui.tabs-secondary-variant.menu'),
|
|
91
|
+
).toBeInTheDocument();
|
|
92
|
+
expect(
|
|
93
|
+
container.getElementsByClassName('mocked-style-wrapper'),
|
|
94
|
+
).toHaveLength(2);
|
|
95
|
+
expect(getByText('Tab 1 Title')).toBeInTheDocument();
|
|
96
|
+
|
|
97
|
+
fireEvent.click(getByText('Tab 2 Title'));
|
|
98
|
+
expect(tabItemsMenu).toHaveLength(3);
|
|
99
|
+
expect(tabItemsMenu[0].classList.contains('item'));
|
|
100
|
+
expect(tabItemsMenu[0].classList).not.toContain('active');
|
|
101
|
+
expect(tabItemsMenu[1].classList.contains('active'));
|
|
102
|
+
|
|
103
|
+
fireEvent.click(getByText('Tab 1 Title'));
|
|
104
|
+
expect(tabItemsMenu).toHaveLength(3);
|
|
105
|
+
expect(tabItemsMenu[1].classList.contains('item'));
|
|
106
|
+
expect(tabItemsMenu[1].classList).not.toContain('active');
|
|
107
|
+
expect(tabItemsMenu[0].classList.contains('active'));
|
|
108
|
+
});
|
|
109
|
+
});
|
|
@@ -1,214 +1,25 @@
|
|
|
1
|
-
import
|
|
2
|
-
import cx from 'classnames';
|
|
3
|
-
import { isEmpty } from 'lodash';
|
|
4
|
-
import { useIntl } from 'react-intl';
|
|
5
|
-
import Tabs from 'react-responsive-tabs';
|
|
6
|
-
import EditBlockWrapper from '@eeacms/volto-tabs-block/components/EditBlockWrapper';
|
|
7
|
-
import { MenuItem } from '@eeacms/volto-tabs-block/components/templates/default/Edit';
|
|
8
|
-
import { emptyBlocksForm } from '@plone/volto/helpers';
|
|
9
|
-
import { Icon } from 'semantic-ui-react';
|
|
10
|
-
import { Icon as VoltoIcon, BlocksForm } from '@plone/volto/components';
|
|
11
|
-
import config from '@plone/volto/registry';
|
|
12
|
-
import { TABS_BLOCK } from '@eeacms/volto-tabs-block/constants';
|
|
13
|
-
import { getParentTabFromHash } from '@eeacms/volto-tabs-block/helpers';
|
|
14
|
-
import noop from 'lodash/noop';
|
|
15
|
-
|
|
16
|
-
import '@eeacms/volto-tabs-block/less/menu.less';
|
|
1
|
+
import Edit from '@eeacms/volto-tabs-block/components/templates/default/Edit';
|
|
17
2
|
import { accordionSchemaEnhancer } from '@eeacms/volto-tabs-block/components/templates/accordion/schema';
|
|
3
|
+
import cx from 'classnames';
|
|
18
4
|
|
|
19
|
-
|
|
20
|
-
render() {
|
|
21
|
-
return this.props.children;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const Edit = (props) => {
|
|
26
|
-
const intl = useIntl();
|
|
27
|
-
const {
|
|
28
|
-
data = {},
|
|
29
|
-
tabsList = [],
|
|
30
|
-
tabs = {},
|
|
31
|
-
activeTabIndex = 0,
|
|
32
|
-
setActiveTab = noop,
|
|
33
|
-
editingTab = null,
|
|
34
|
-
activeBlock = null,
|
|
35
|
-
activeTab = null,
|
|
36
|
-
block = null,
|
|
37
|
-
setEditingTab = noop,
|
|
38
|
-
multiSelected = [],
|
|
39
|
-
manage = false,
|
|
40
|
-
metadata = null,
|
|
41
|
-
selected = false,
|
|
42
|
-
onChangeBlock = noop,
|
|
43
|
-
onChangeTabData = noop,
|
|
44
|
-
onSelectBlock = noop,
|
|
45
|
-
emptyTab = noop,
|
|
46
|
-
tabsData = {},
|
|
47
|
-
schema,
|
|
48
|
-
} = props;
|
|
49
|
-
|
|
50
|
-
const { menuInverted, menuSecondary, menuPointing } = data;
|
|
51
|
-
const accordionConfig = config.blocks.blocksConfig[
|
|
52
|
-
TABS_BLOCK
|
|
53
|
-
].variations.filter((v, _i) => v.id === data.variation);
|
|
54
|
-
const { icons, semanticIcon, transformWidth = 800 } =
|
|
55
|
-
accordionConfig?.[0] || {};
|
|
56
|
-
|
|
57
|
-
const tabsContainer = React.useRef();
|
|
58
|
-
const [mounted, setMounted] = React.useState(false);
|
|
59
|
-
const [hashTab, setHashTab] = React.useState(false);
|
|
60
|
-
const [initialWidth, setInitialWidth] = React.useState(transformWidth);
|
|
61
|
-
|
|
62
|
-
const items = tabsList.map((tab, index) => {
|
|
63
|
-
const active = activeTabIndex === index;
|
|
64
|
-
|
|
65
|
-
return {
|
|
66
|
-
title: (
|
|
67
|
-
<>
|
|
68
|
-
{semanticIcon ? (
|
|
69
|
-
<div className="tabs-icon">
|
|
70
|
-
<Icon
|
|
71
|
-
className={active ? semanticIcon.opened : semanticIcon.closed}
|
|
72
|
-
/>
|
|
73
|
-
</div>
|
|
74
|
-
) : (
|
|
75
|
-
<div className="tabs-icon">
|
|
76
|
-
<VoltoIcon
|
|
77
|
-
name={active ? icons.opened : icons.closed}
|
|
78
|
-
size={icons.size}
|
|
79
|
-
className="tabs-icon"
|
|
80
|
-
/>
|
|
81
|
-
</div>
|
|
82
|
-
)}
|
|
83
|
-
<MenuItem
|
|
84
|
-
{...props}
|
|
85
|
-
key={tab}
|
|
86
|
-
editingTab={editingTab}
|
|
87
|
-
index={index}
|
|
88
|
-
setEditingTab={setEditingTab}
|
|
89
|
-
tab={tab}
|
|
90
|
-
schema={schema}
|
|
91
|
-
/>
|
|
92
|
-
</>
|
|
93
|
-
),
|
|
94
|
-
content: (
|
|
95
|
-
<Tab {...props} tab={tab} content={tabs[tab]} aria-hidden={false}>
|
|
96
|
-
<BlocksForm
|
|
97
|
-
allowedBlocks={data?.allowedBlocks}
|
|
98
|
-
description={data?.instructions?.data}
|
|
99
|
-
manage={manage}
|
|
100
|
-
metadata={metadata}
|
|
101
|
-
pathname={props.pathname}
|
|
102
|
-
properties={isEmpty(tabs[tab]) ? emptyBlocksForm() : tabs[tab]}
|
|
103
|
-
selected={selected && activeTab === tab && activeBlock}
|
|
104
|
-
selectedBlock={
|
|
105
|
-
selected && activeTab === tab && activeBlock ? activeBlock : null
|
|
106
|
-
}
|
|
107
|
-
title={data?.placeholder}
|
|
108
|
-
onChangeField={onChangeTabData}
|
|
109
|
-
onChangeFormData={(newFormData) => {
|
|
110
|
-
onChangeBlock(block, {
|
|
111
|
-
...data,
|
|
112
|
-
data: {
|
|
113
|
-
...tabsData,
|
|
114
|
-
blocks: {
|
|
115
|
-
...tabsData.blocks,
|
|
116
|
-
[activeTab]: {
|
|
117
|
-
...(newFormData.blocks_layout.items.length > 0
|
|
118
|
-
? newFormData
|
|
119
|
-
: emptyTab({
|
|
120
|
-
schema: schema?.properties?.data?.schema || {},
|
|
121
|
-
intl,
|
|
122
|
-
})),
|
|
123
|
-
},
|
|
124
|
-
},
|
|
125
|
-
},
|
|
126
|
-
});
|
|
127
|
-
}}
|
|
128
|
-
onSelectBlock={(id, selected, e) => {
|
|
129
|
-
const isMultipleSelection = e
|
|
130
|
-
? e.shiftKey || e.ctrlKey || e.metaKey
|
|
131
|
-
: false;
|
|
132
|
-
onSelectBlock(
|
|
133
|
-
id,
|
|
134
|
-
activeBlock === id ? false : isMultipleSelection,
|
|
135
|
-
e,
|
|
136
|
-
);
|
|
137
|
-
setEditingTab(null);
|
|
138
|
-
}}
|
|
139
|
-
>
|
|
140
|
-
{({ draginfo }, editBlock, blockProps) => {
|
|
141
|
-
return (
|
|
142
|
-
<EditBlockWrapper
|
|
143
|
-
blockProps={blockProps}
|
|
144
|
-
draginfo={draginfo}
|
|
145
|
-
multiSelected={multiSelected.includes(blockProps.block)}
|
|
146
|
-
>
|
|
147
|
-
{editBlock}
|
|
148
|
-
</EditBlockWrapper>
|
|
149
|
-
);
|
|
150
|
-
}}
|
|
151
|
-
</BlocksForm>
|
|
152
|
-
</Tab>
|
|
153
|
-
),
|
|
154
|
-
key: tab,
|
|
155
|
-
tabClassName: cx('ui button item title', { active }, 'remove-menu'),
|
|
156
|
-
panelClassName: cx('ui bottom attached segment tab', {
|
|
157
|
-
active,
|
|
158
|
-
}),
|
|
159
|
-
};
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
React.useEffect(() => {
|
|
163
|
-
setMounted(true);
|
|
164
|
-
}, []);
|
|
165
|
-
React.useEffect(() => {
|
|
166
|
-
if (!mounted) return;
|
|
167
|
-
const { blockWidth, tabsTotalWidth } = tabsContainer.current?.state || {};
|
|
168
|
-
setInitialWidth(
|
|
169
|
-
tabsTotalWidth < blockWidth ? tabsTotalWidth + 1 : blockWidth + 1,
|
|
170
|
-
);
|
|
171
|
-
}, [mounted]);
|
|
172
|
-
|
|
5
|
+
const AccordionEdit = (props) => {
|
|
173
6
|
return (
|
|
174
|
-
<
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
data,
|
|
184
|
-
|
|
185
|
-
);
|
|
186
|
-
if (tabWithHash === tabsList[activeTabIndex] && !hashTab) {
|
|
187
|
-
setHashTab(true);
|
|
188
|
-
} else if (blockWidth <= initialWidth) {
|
|
189
|
-
setActiveTab(null);
|
|
190
|
-
}
|
|
7
|
+
<Edit
|
|
8
|
+
skipColorOption={true}
|
|
9
|
+
{...props}
|
|
10
|
+
addTabsOptions={(data) => {
|
|
11
|
+
return cx(data?.theme ? `${data?.theme}` : '', {
|
|
12
|
+
RRT__tabs: true,
|
|
13
|
+
'tabs-accordion-icon-right': data.accordionIconRight,
|
|
14
|
+
'tabs-accessibility': true,
|
|
15
|
+
inverted: data.menuInverted,
|
|
16
|
+
pointing: data.menuPointing,
|
|
17
|
+
});
|
|
191
18
|
}}
|
|
192
|
-
tabsWrapperClass={cx(
|
|
193
|
-
props?.data?.accordionIconRight ? 'tabs-accordion-icon-right' : '',
|
|
194
|
-
'ui fluid menu tabs-secondary-variant',
|
|
195
|
-
'tabs-accessibility',
|
|
196
|
-
data?.theme ? `${data?.theme}` : '',
|
|
197
|
-
{
|
|
198
|
-
inverted: menuInverted,
|
|
199
|
-
},
|
|
200
|
-
{
|
|
201
|
-
pointing: menuPointing,
|
|
202
|
-
},
|
|
203
|
-
{
|
|
204
|
-
secondary: menuSecondary,
|
|
205
|
-
},
|
|
206
|
-
)}
|
|
207
|
-
showMore={false}
|
|
208
19
|
/>
|
|
209
20
|
);
|
|
210
21
|
};
|
|
211
22
|
|
|
212
|
-
|
|
23
|
+
AccordionEdit.schemaEnhancer = accordionSchemaEnhancer;
|
|
213
24
|
|
|
214
|
-
export default
|
|
25
|
+
export default AccordionEdit;
|
|
@@ -170,7 +170,7 @@ export const MenuItem = (props) => {
|
|
|
170
170
|
}}
|
|
171
171
|
className="remove-margin addition-button"
|
|
172
172
|
>
|
|
173
|
-
<
|
|
173
|
+
<span className="menu-item-text">+</span>
|
|
174
174
|
</Menu.Item>
|
|
175
175
|
</>
|
|
176
176
|
) : (
|
|
@@ -202,6 +202,8 @@ const Edit = (props) => {
|
|
|
202
202
|
onSelectBlock = noop,
|
|
203
203
|
setEditingTab = noop,
|
|
204
204
|
schema,
|
|
205
|
+
skipColorOption = false,
|
|
206
|
+
customTabsClass = '',
|
|
205
207
|
} = props;
|
|
206
208
|
const menuPosition = getMenuPosition(data);
|
|
207
209
|
const {
|
|
@@ -304,16 +306,15 @@ const Edit = (props) => {
|
|
|
304
306
|
},
|
|
305
307
|
};
|
|
306
308
|
});
|
|
307
|
-
|
|
308
309
|
return (
|
|
309
310
|
<>
|
|
310
311
|
<Tab
|
|
311
312
|
activeIndex={activeTabIndex}
|
|
312
|
-
className=
|
|
313
|
+
className={cx('default tabs', customTabsClass)}
|
|
313
314
|
menu={{
|
|
314
315
|
attached: menuPosition.attached,
|
|
315
316
|
borderless: menuBorderless,
|
|
316
|
-
color: menuColor,
|
|
317
|
+
color: !skipColorOption && menuColor,
|
|
317
318
|
compact: menuCompact,
|
|
318
319
|
fluid: menuFluid,
|
|
319
320
|
inverted: menuInverted,
|
|
@@ -333,6 +334,7 @@ const Edit = (props) => {
|
|
|
333
334
|
menuPosition.direction === 'top' ? 'border-bottom' : '',
|
|
334
335
|
menuPosition.direction === 'bottom' ? 'border-top' : '',
|
|
335
336
|
{ container: isContainer },
|
|
337
|
+
props.addTabsOptions ? props.addTabsOptions(data) : '',
|
|
336
338
|
),
|
|
337
339
|
}}
|
|
338
340
|
menuPosition={menuPosition.direction}
|
|
@@ -66,7 +66,7 @@ export const AssetTab = ({ props, tabIndex, tabTitle }) => {
|
|
|
66
66
|
{!hideTitle && (
|
|
67
67
|
<div>
|
|
68
68
|
<span className="menu-item-count">{tabIndex}</span>
|
|
69
|
-
<
|
|
69
|
+
<span className="menu-item-text">{tabTitle}</span>
|
|
70
70
|
</div>
|
|
71
71
|
)}
|
|
72
72
|
</div>
|
|
@@ -143,7 +143,7 @@ const MenuItem = (props) => {
|
|
|
143
143
|
) : (
|
|
144
144
|
<>
|
|
145
145
|
<span className="menu-item-count">{tabIndex}</span>
|
|
146
|
-
<
|
|
146
|
+
<span className="menu-item-text">{tabTitle}</span>
|
|
147
147
|
</>
|
|
148
148
|
)}
|
|
149
149
|
</>
|
|
@@ -134,9 +134,9 @@ const MenuItem = (props) => {
|
|
|
134
134
|
<span className={'menu-item-count'} item-data={tab}>
|
|
135
135
|
{tabIndex}
|
|
136
136
|
</span>
|
|
137
|
-
<
|
|
137
|
+
<span className={'menu-item-text'} item-data={tab}>
|
|
138
138
|
{title || defaultTitle}
|
|
139
|
-
</
|
|
139
|
+
</span>
|
|
140
140
|
</>
|
|
141
141
|
)}
|
|
142
142
|
</Menu.Item>
|
|
@@ -270,7 +270,9 @@ const MenuWrapper = (props) => {
|
|
|
270
270
|
}}
|
|
271
271
|
>
|
|
272
272
|
<span className={'menu-item-count'}>{underlineIndex + 1}</span>
|
|
273
|
-
<
|
|
273
|
+
<span className={'menu-item-text'}>
|
|
274
|
+
{title || defaultTitle}
|
|
275
|
+
</span>
|
|
274
276
|
</Dropdown.Item>
|
|
275
277
|
);
|
|
276
278
|
})}
|
|
@@ -88,7 +88,7 @@ const MenuItem = (props) => {
|
|
|
88
88
|
}}
|
|
89
89
|
>
|
|
90
90
|
<span className={'menu-item-count'}>{tabIndex}</span>
|
|
91
|
-
<
|
|
91
|
+
<span className={'menu-item-text'}>{title || defaultTitle}</span>
|
|
92
92
|
</Button>
|
|
93
93
|
</React.Fragment>
|
|
94
94
|
);
|
|
@@ -169,7 +169,9 @@ const MenuWrapper = (props) => {
|
|
|
169
169
|
}}
|
|
170
170
|
>
|
|
171
171
|
<span className={'menu-item-count'}>{underlineIndex + 1}</span>
|
|
172
|
-
<
|
|
172
|
+
<span className={'menu-item-text'}>
|
|
173
|
+
{title || defaultTitle}
|
|
174
|
+
</span>
|
|
173
175
|
</Dropdown.Item>
|
|
174
176
|
);
|
|
175
177
|
})}
|
package/src/index.js
CHANGED
package/src/less/menu.less
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
border-width: 0 0 4px 0;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
.ui.secondary.inverted.menu .active.item
|
|
24
|
+
.ui.secondary.inverted.menu .active.item {
|
|
25
25
|
background-color: @menuItemInvertedActiveBackgroundColor !important;
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
cursor: pointer;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
.ui.menu:not(.inverted, .pointing) .active.item
|
|
46
|
+
.ui.menu:not(.inverted, .pointing) .active.item {
|
|
47
47
|
background-color: @menuItemActiveBackgroundColor;
|
|
48
48
|
}
|
|
49
49
|
|