@eeacms/volto-tabs-block 8.0.1 → 8.1.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,23 @@ 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
+ ### [8.1.0](https://github.com/eea/volto-tabs-block/compare/8.0.1...8.1.0) - 26 August 2024
8
+
9
+ #### :rocket: New Features
10
+
11
+ - feat(tabs): hide empty tabs, ref #273963 [Miu Razvan - [`39c0af7`](https://github.com/eea/volto-tabs-block/commit/39c0af75e530f0c21a9a3b2a2a9117002473d3b8)]
12
+
13
+ #### :house: Internal changes
14
+
15
+ - chore: package.json [Alin Voinea - [`244a1de`](https://github.com/eea/volto-tabs-block/commit/244a1de20a7e9a8a2282f91715b26990a83454a8)]
16
+
17
+ #### :hammer_and_wrench: Others
18
+
19
+ - test isTabEmpty function [Miu Razvan - [`d3e569c`](https://github.com/eea/volto-tabs-block/commit/d3e569c6dcd244b31349616dc97b47566ac053c1)]
20
+ - clean up [Miu Razvan - [`4cf2260`](https://github.com/eea/volto-tabs-block/commit/4cf2260a9bb9e8ed1743ca7f9db4c6c6c6fd710f)]
21
+ - update empty tab logic [Miu Razvan - [`f859684`](https://github.com/eea/volto-tabs-block/commit/f859684cfce0508cf5122ad82af958ad4f035871)]
22
+ - fix [Miu Razvan - [`d532df2`](https://github.com/eea/volto-tabs-block/commit/d532df2ba65603ccc40a6f6c713129a4d84bc58a)]
23
+ - bump version [Miu Razvan - [`93e4894`](https://github.com/eea/volto-tabs-block/commit/93e48949777d970793665edb782705e0d3ac66b1)]
7
24
  ### [8.0.1](https://github.com/eea/volto-tabs-block/compare/8.0.0...8.0.1) - 6 August 2024
8
25
 
9
26
  #### :bug: Bug Fixes
@@ -19,8 +36,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
19
36
 
20
37
  #### :hammer_and_wrench: Others
21
38
 
22
- - Add Sonarqube tag using insitu-frontend addons list [EEA Jenkins - [`cb58ea7`](https://github.com/eea/volto-tabs-block/commit/cb58ea7417e8dd237b66908fd53f1f3ca8726566)]
23
- - Add Sonarqube tag using freshwater-frontend addons list [EEA Jenkins - [`4377ffc`](https://github.com/eea/volto-tabs-block/commit/4377ffc350a92f62cbe77b17b67dd331c71cbcd7)]
24
39
  ### [7.5.1](https://github.com/eea/volto-tabs-block/compare/7.5.0...7.5.1) - 28 March 2024
25
40
 
26
41
  #### :nail_care: Enhancements
@@ -63,7 +78,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
63
78
  - Update react-slick version to 0.30.1 [David Ichim - [`3369176`](https://github.com/eea/volto-tabs-block/commit/33691768899e7f91d2cd15319dbe3ebe66cf1513)]
64
79
  - update [Razvan - [`61b19e8`](https://github.com/eea/volto-tabs-block/commit/61b19e8584ff6023320b3671414392ea11449ff0)]
65
80
  - use DefaultEdit variation for responsive accordion, refs #266327 [Razvan - [`11acf6c`](https://github.com/eea/volto-tabs-block/commit/11acf6ce5afe022ddd30bff42c9a3321d1284da6)]
66
- - Add Sonarqube tag using insitu-frontend addons list [EEA Jenkins - [`5045757`](https://github.com/eea/volto-tabs-block/commit/5045757a275477ba382551b301998d835741b716)]
67
81
  ### [7.0.5](https://github.com/eea/volto-tabs-block/compare/7.0.4...7.0.5) - 10 December 2023
68
82
 
69
83
  #### :rocket: New Features
@@ -95,8 +109,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
95
109
 
96
110
  #### :hammer_and_wrench: Others
97
111
 
98
- - test: [JENKINS] Use java17 for sonarqube scanner [valentinab25 - [`3b87d12`](https://github.com/eea/volto-tabs-block/commit/3b87d12df4d01031231b15eb4196f6ff6937706b)]
99
- - test: [JENKINS] Run cypress in started frontend container [valentinab25 - [`f5f3430`](https://github.com/eea/volto-tabs-block/commit/f5f343024b45bb0206e0169cce6dd0e8472b6795)]
100
112
  ### [7.0.1](https://github.com/eea/volto-tabs-block/compare/7.0.0...7.0.1) - 9 November 2023
101
113
 
102
114
  #### :bug: Bug Fixes
@@ -106,14 +118,10 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
106
118
 
107
119
  #### :hammer_and_wrench: Others
108
120
 
109
- - test: [JENKINS] Add cpu limit on cypress docker [valentinab25 - [`bd6ffd4`](https://github.com/eea/volto-tabs-block/commit/bd6ffd42a00a2d77ff59545d9adaab7a45361446)]
110
- - test: [JENKINS] Increase shm-size to cypress docker [valentinab25 - [`d481e25`](https://github.com/eea/volto-tabs-block/commit/d481e25c4d61d7ff6ea11ff75c99fbdd730ecd82)]
111
- - test: [JENKINS] Improve cypress time [valentinab25 - [`6c39efc`](https://github.com/eea/volto-tabs-block/commit/6c39efcc30bddfebb6c61f8a8cd714f61828ec69)]
112
121
  ## [7.0.0](https://github.com/eea/volto-tabs-block/compare/6.0.3...7.0.0) - 31 October 2023
113
122
 
114
123
  #### :house: Internal changes
115
124
 
116
- - chore: [JENKINS] Refactor automated testing [valentinab25 - [`f2e3d39`](https://github.com/eea/volto-tabs-block/commit/f2e3d3973c026f0331b82e0f691ec9bdc5899672)]
117
125
 
118
126
  #### :hammer_and_wrench: Others
119
127
 
@@ -326,7 +334,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
326
334
 
327
335
  #### :house: Internal changes
328
336
 
329
- - chore: [JENKINS] Deprecate circularity website [valentinab25 - [`820aaa9`](https://github.com/eea/volto-tabs-block/commit/820aaa963e978a893a23b77f694bb011f3d768c1)]
330
337
 
331
338
  #### :hammer_and_wrench: Others
332
339
 
@@ -417,7 +424,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
417
424
 
418
425
  #### :hammer_and_wrench: Others
419
426
 
420
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`52bc1b0`](https://github.com/eea/volto-tabs-block/commit/52bc1b0fbd4611173b8ca9dc2cf4033b31474420)]
421
427
  ## [4.0.0](https://github.com/eea/volto-tabs-block/compare/3.0.1...4.0.0) - 10 March 2023
422
428
 
423
429
  #### :house: Internal changes
@@ -428,13 +434,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
428
434
  #### :hammer_and_wrench: Others
429
435
 
430
436
  - Release 4.0.0 [Alin Voinea - [`8fc4cc9`](https://github.com/eea/volto-tabs-block/commit/8fc4cc9d8dc71e623e6586b95871cb3b98dc385f)]
431
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`22d5bdc`](https://github.com/eea/volto-tabs-block/commit/22d5bdc1b3579cc46c73ce855041ca09154eb502)]
432
- - Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`fde4324`](https://github.com/eea/volto-tabs-block/commit/fde4324f962cde8e8de0d76a44bee4b67d216bf8)]
433
- - Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`9175e47`](https://github.com/eea/volto-tabs-block/commit/9175e470d793edc63b62a99940aed25dd45f3713)]
434
437
  - test(Jenkins): Run tests and cypress with latest canary @plone/volto [Alin Voinea - [`3348950`](https://github.com/eea/volto-tabs-block/commit/334895036f8e367281abb35a20879c32dfbfc292)]
435
- - Add Sonarqube tag using cca-frontend addons list [EEA Jenkins - [`39bfb39`](https://github.com/eea/volto-tabs-block/commit/39bfb39fa6e8483e639491ff998293e758ac6384)]
436
- - yarn 3 [Alin Voinea - [`7e98df5`](https://github.com/eea/volto-tabs-block/commit/7e98df59669d71945be461e86e282b913538b805)]
437
- - Add Sonarqube tag using demo-kitkat-frontend addons list [EEA Jenkins - [`079d7a4`](https://github.com/eea/volto-tabs-block/commit/079d7a43480e92fe280a9372399ff2d4d28537ae)]
438
438
  ### [3.0.1](https://github.com/eea/volto-tabs-block/compare/3.0.0...3.0.1) - 16 November 2022
439
439
 
440
440
  #### :hammer_and_wrench: Others
@@ -458,9 +458,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
458
458
 
459
459
  #### :hammer_and_wrench: Others
460
460
 
461
- - Add Sonarqube tag using marine-frontend addons list [EEA Jenkins - [`a00e419`](https://github.com/eea/volto-tabs-block/commit/a00e419aef4c82a25f277f5e25e3d512c7838264)]
462
461
  - lint fix [David Ichim - [`c0a898c`](https://github.com/eea/volto-tabs-block/commit/c0a898c54461478baed2ac2f149ae580d4c89aeb)]
463
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`3b284e6`](https://github.com/eea/volto-tabs-block/commit/3b284e65e0eafa9b5ad8c92b4cb77628ffcc8103)]
464
462
  ### [2.2.0](https://github.com/eea/volto-tabs-block/compare/2.1.0...2.2.0) - 25 August 2022
465
463
 
466
464
  #### :hammer_and_wrench: Others
@@ -476,7 +474,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
476
474
 
477
475
  - Release 2.1.0 [Alin Voinea - [`3cdfa30`](https://github.com/eea/volto-tabs-block/commit/3cdfa30d4d03d864be8ad63f0648b4717298734a)]
478
476
  - Squashed commit of the following: [Alin Voinea - [`ca241f5`](https://github.com/eea/volto-tabs-block/commit/ca241f56a96817679a1948154e2a8cc0e17b96fe)]
479
- - Add Sonarqube tag using circularity-frontend addons list [EEA Jenkins - [`68ea5a6`](https://github.com/eea/volto-tabs-block/commit/68ea5a6b971fc36840cf5716a04f68316b229b2b)]
480
477
  ### [2.0.2](https://github.com/eea/volto-tabs-block/compare/2.0.1...2.0.2) - 16 June 2022
481
478
 
482
479
  ### [2.0.1](https://github.com/eea/volto-tabs-block/compare/2.0.0...2.0.1) - 10 June 2022
@@ -520,8 +517,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
520
517
  - Let theme addon to set default values for default template schema [Miu Razvan - [`55f148d`](https://github.com/eea/volto-tabs-block/commit/55f148d1a95417f8a0b55681ce250acde8463c1c)]
521
518
  - Render pane as container if tabs-block has full-width class [Miu Razvan - [`bbffb96`](https://github.com/eea/volto-tabs-block/commit/bbffb96b908476ddee447af3ce79bafb1a12f9a8)]
522
519
  - Refactor default template [Miu Razvan - [`58eff52`](https://github.com/eea/volto-tabs-block/commit/58eff5281adb08a5f8fe6d21fd43330252012277)]
523
- - Add Sonarqube tag using clms-frontend addons list [EEA Jenkins - [`72a6735`](https://github.com/eea/volto-tabs-block/commit/72a6735cbbc0e7d57b4bb7ea83fea9becc317018)]
524
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`e928da1`](https://github.com/eea/volto-tabs-block/commit/e928da1df7e4680bd4be9b5d46406800d721b8c5)]
525
520
  ### [1.2.12](https://github.com/eea/volto-tabs-block/compare/1.2.11...1.2.12) - 21 January 2022
526
521
 
527
522
  ### [1.2.11](https://github.com/eea/volto-tabs-block/compare/1.2.10...1.2.11) - 4 January 2022
@@ -536,17 +531,11 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
536
531
 
537
532
  #### :hammer_and_wrench: Others
538
533
 
539
- - Add Sonarqube tag using freshwater-frontend addons list [EEA Jenkins - [`cd2e2ac`](https://github.com/eea/volto-tabs-block/commit/cd2e2ac1d127bfc688ecf16e17734603ab727a34)]
540
534
  ### [1.2.8](https://github.com/eea/volto-tabs-block/compare/1.2.7...1.2.8) - 10 December 2021
541
535
 
542
536
  #### :hammer_and_wrench: Others
543
537
 
544
538
  - Refs #142010 - Optimize Volto-addons gitflow pipelines [valentinab25 - [`d10c0b3`](https://github.com/eea/volto-tabs-block/commit/d10c0b3d35d25c530d19eebde38dfe5da8fda01b)]
545
- - Add Sonarqube tag using industry-frontend addons list [EEA Jenkins - [`1a7187f`](https://github.com/eea/volto-tabs-block/commit/1a7187f10b2bd9e1307dabf51823f63ccd766864)]
546
- - Add Sonarqube tag using clms-frontend addons list [EEA Jenkins - [`72a7550`](https://github.com/eea/volto-tabs-block/commit/72a755025b38e1d8dd7fe206273a70585e4b9ac8)]
547
- - Add Sonarqube tag using forests-frontend addons list [EEA Jenkins - [`022b277`](https://github.com/eea/volto-tabs-block/commit/022b2779a5d7fd7217c2d8a559eafab0bd86ce23)]
548
- - Add Sonarqube tag using sustainability-frontend addons list [EEA Jenkins - [`84c9bea`](https://github.com/eea/volto-tabs-block/commit/84c9bea7a0aba2fe9ef9713e7131de6da6e0bcce)]
549
- - Add Sonarqube tag using ims-frontend addons list [EEA Jenkins - [`020aa97`](https://github.com/eea/volto-tabs-block/commit/020aa97bc70a643ea3857566c5a1dc3a5200c2be)]
550
539
  ### [1.2.7](https://github.com/eea/volto-tabs-block/compare/1.2.6...1.2.7) - 27 August 2021
551
540
 
552
541
  #### :hammer_and_wrench: Others
@@ -563,8 +552,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
563
552
 
564
553
  - Move less import in View instead of Edit [Tiberiu Ichim - [`84aeff0`](https://github.com/eea/volto-tabs-block/commit/84aeff04a980076f54687c546691d37b6e790478)]
565
554
  - gitignore tweaks [Tiberiu Ichim - [`f4c993d`](https://github.com/eea/volto-tabs-block/commit/f4c993d004b126f08f16651ab9460546fa9e9cad)]
566
- - Add Sonarqube tag using frontend addons list [EEA Jenkins - [`865906a`](https://github.com/eea/volto-tabs-block/commit/865906a0deb261d44cc23e26bfd2d1dd0e319640)]
567
- - Add Sonarqube tag using frontend addons list [EEA Jenkins - [`5383861`](https://github.com/eea/volto-tabs-block/commit/538386100adbc868e693c1c2a5ba13461307ffee)]
568
555
  - Style update [razvanMiu - [`323aaaf`](https://github.com/eea/volto-tabs-block/commit/323aaafcad01d8fdf0e713a1fc254ae9fe319f43)]
569
556
  - Fix 'scroll to' feature on carousel [razvanMiu - [`16c6a08`](https://github.com/eea/volto-tabs-block/commit/16c6a08f6db687542ea38e07a92b265e592f6173)]
570
557
  - Better accesibility [razvanMiu - [`3511611`](https://github.com/eea/volto-tabs-block/commit/351161197270a4807f01d85a7055cbaadae72f8e)]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-tabs-block",
3
- "version": "8.0.1",
3
+ "version": "8.1.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",
@@ -31,11 +31,11 @@
31
31
  "@cypress/code-coverage": "^3.10.0",
32
32
  "@plone/scripts": "*",
33
33
  "babel-plugin-transform-class-properties": "^6.24.1",
34
+ "cypress": "13.1.0",
34
35
  "dotenv": "^16.3.2",
35
36
  "husky": "^8.0.3",
36
37
  "lint-staged": "^14.0.1",
37
- "md5": "^2.3.0",
38
- "cypress": "13.1.0"
38
+ "md5": "^2.3.0"
39
39
  },
40
40
  "lint-staged": {
41
41
  "src/**/*.{js,jsx,ts,tsx,json}": [
@@ -122,9 +122,9 @@ class EditBlockWrapper extends React.Component {
122
122
  basic
123
123
  title="Add block"
124
124
  onClick={() => {
125
- this.setState({
126
- addNewBlockOpened: !this.state.addNewBlockOpened,
127
- });
125
+ this.setState((prevState) => ({
126
+ addNewBlockOpened: !prevState.addNewBlockOpened,
127
+ }));
128
128
  }}
129
129
  className="column-block-add-button"
130
130
  >
@@ -4,7 +4,10 @@ import { compose } from 'redux';
4
4
  import { withRouter } from 'react-router';
5
5
  import { StyleWrapperView } from '@eeacms/volto-block-style/StyleWrapper';
6
6
  import { TABS_BLOCK } from '@eeacms/volto-tabs-block/constants';
7
- import { getParentTabFromHash } from '@eeacms/volto-tabs-block/helpers';
7
+ import {
8
+ isTabEmpty,
9
+ getParentTabFromHash,
10
+ } from '@eeacms/volto-tabs-block/helpers';
8
11
  import { DefaultView } from './templates/default';
9
12
  import { withScrollToTarget } from '@eeacms/volto-tabs-block/hocs';
10
13
 
@@ -19,8 +22,10 @@ const View = (props) => {
19
22
  const metadata = props.metadata || props.properties;
20
23
  const template = data.variation || 'default';
21
24
  const tabsData = data.data || {};
22
- const tabsList = tabsData.blocks_layout?.items || [];
23
25
  const tabs = tabsData.blocks || {};
26
+ const tabsList = (tabsData.blocks_layout?.items || []).filter((tab) => {
27
+ return data.hideEmptyTabs ? !isTabEmpty(tabs[tab]) : true;
28
+ });
24
29
  const [activeTab, setActiveTab] = React.useState(tabsList?.[0]);
25
30
  const activeTabIndex = tabsList.indexOf(activeTab);
26
31
  const tabData = tabs[activeTab] || {};
@@ -86,6 +86,10 @@ const messages = defineMessages({
86
86
  id: 'hideTitle',
87
87
  defaultMessage: 'Hide tab title?',
88
88
  },
89
+ HideEmptyTabs: {
90
+ id: 'hideEmptyTabs',
91
+ defaultMessage: 'Hide empty tabs in view?',
92
+ },
89
93
  Large: {
90
94
  id: 'large',
91
95
  defaultMessage: 'Large',
@@ -191,7 +195,13 @@ export const blockSchema = (props) => {
191
195
  {
192
196
  id: 'default',
193
197
  title: intl.formatMessage(messages.Default),
194
- fields: ['title', 'description', 'verticalAlign', 'data'],
198
+ fields: [
199
+ 'title',
200
+ 'description',
201
+ 'verticalAlign',
202
+ 'hideEmptyTabs',
203
+ 'data',
204
+ ],
195
205
  },
196
206
  ],
197
207
  properties: {
@@ -216,6 +226,10 @@ export const blockSchema = (props) => {
216
226
  ],
217
227
  default: 'flex-start',
218
228
  },
229
+ hideEmptyTabs: {
230
+ title: intl.formatMessage(messages.HideEmptyTabs),
231
+ type: 'boolean',
232
+ },
219
233
  },
220
234
  required: [],
221
235
  };
package/src/helpers.js CHANGED
@@ -1,5 +1,10 @@
1
1
  import { v4 as uuid } from 'uuid';
2
- import { emptyBlocksForm, applySchemaDefaults } from '@plone/volto/helpers';
2
+ import {
3
+ emptyBlocksForm,
4
+ applySchemaDefaults,
5
+ getBlocksFieldname,
6
+ getBlocksLayoutFieldname,
7
+ } from '@plone/volto/helpers';
3
8
  import { visitBlocks, toSlug } from '@eeacms/volto-anchors/helpers';
4
9
 
5
10
  export const empty = ({ schema, intl }) => {
@@ -56,3 +61,22 @@ export const getParentTabFromHash = (tabsBlockData, urlHash) => {
56
61
  }
57
62
  return null;
58
63
  };
64
+
65
+ export const isTabEmpty = (content) => {
66
+ const blocks_field = getBlocksFieldname(content);
67
+ const blocks_layout_field = getBlocksLayoutFieldname(content);
68
+ const blocks = content[blocks_field] || {};
69
+ const blocksNo = content[blocks_layout_field]?.items?.length || 0;
70
+
71
+ if (blocksNo === 1) {
72
+ const blockId = content[blocks_layout_field].items[0];
73
+ const block = blocks[blockId];
74
+ if (block['@type'] === 'slate' && !block['plaintext']) {
75
+ return true;
76
+ }
77
+ }
78
+ if (blocksNo === 0) {
79
+ return true;
80
+ }
81
+ return false;
82
+ };
@@ -3,6 +3,7 @@ import {
3
3
  emptyTab,
4
4
  scrollToTarget,
5
5
  getParentTabFromHash,
6
+ isTabEmpty,
6
7
  } from './helpers';
7
8
  // import { emptyBlocksForm } from '@plone/volto/helpers';
8
9
  import { visitBlocks, toSlug } from '@eeacms/volto-anchors/helpers';
@@ -42,6 +43,19 @@ describe('emptyTab function', () => {
42
43
  });
43
44
  });
44
45
 
46
+ describe('isTabEmpty function', () => {
47
+ it('returns if a tab is empty', () => {
48
+ // emptyBlocksForm.mockReturnValue({});
49
+ const result = isTabEmpty({
50
+ blocks: {},
51
+ blocks_layout: {
52
+ items: [],
53
+ },
54
+ });
55
+ expect(result).toEqual(true);
56
+ });
57
+ });
58
+
45
59
  describe('scrollToTarget', () => {
46
60
  it('should call window.scrollTo with the correct arguments', () => {
47
61
  window.scrollTo = jest.fn();