@eeacms/volto-group-block 6.2.1 → 6.3.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
+ ### [6.3.0](https://github.com/eea/volto-group-block/compare/6.2.1...6.3.0) - 5 September 2023
8
+
9
+ #### :rocket: New Features
10
+
11
+ - feat(group): Variations support refs #157040 #26 from eea/variationsSupport [ichim-david - [`8342ae8`](https://github.com/eea/volto-group-block/commit/8342ae8d843bd672339f9472e1e806cbfeac8d1b)]
12
+
13
+ #### :bug: Bug Fixes
14
+
15
+ - fix: update and fix jest tests [nileshgulia1 - [`97df2cc`](https://github.com/eea/volto-group-block/commit/97df2cc6ac5c3283707ff72bb3d4cd762d5a3b2f)]
16
+
17
+ #### :hammer_and_wrench: Others
18
+
19
+ - Release 6.3.0 [Alin Voinea - [`3d74bb5`](https://github.com/eea/volto-group-block/commit/3d74bb5342e3882e0ddee1aa8edab7e90949def6)]
20
+ - i18n: Add en [Alin Voinea - [`f3385cd`](https://github.com/eea/volto-group-block/commit/f3385cd33bfbe3efe514fd82fd140d17e33051e1)]
21
+ - test: Update Makefile and docker-compose to align it with Jenkinsfile [valentinab25 - [`3aa996b`](https://github.com/eea/volto-group-block/commit/3aa996b4c115da6f37ca771f07f10d58fbfa33e8)]
22
+ - fix eslint warnings [nileshgulia1 - [`cfdf2e9`](https://github.com/eea/volto-group-block/commit/cfdf2e900bcc456fa5a24ce7b03859170ad024ba)]
23
+ - feature: add variations support [nileshgulia1 - [`d981c6b`](https://github.com/eea/volto-group-block/commit/d981c6b59c669712d60feb9cfb04022e228ac001)]
7
24
  ### [6.2.1](https://github.com/eea/volto-group-block/compare/6.2.0...6.2.1) - 18 August 2023
8
25
 
9
26
  #### :bug: Bug Fixes
@@ -30,7 +47,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
30
47
 
31
48
  #### :house: Internal changes
32
49
 
33
- - chore: [JENKINS] Deprecate circularity website [valentinab25 - [`ad30e83`](https://github.com/eea/volto-group-block/commit/ad30e832bb869b67dc4e64ed99590b51cb80ab75)]
34
50
 
35
51
  #### :hammer_and_wrench: Others
36
52
 
@@ -47,19 +63,12 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
47
63
 
48
64
  #### :hammer_and_wrench: Others
49
65
 
50
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`37ffae5`](https://github.com/eea/volto-group-block/commit/37ffae512967b36af22cbed208a3ec9e1ddc392b)]
51
66
  ## [6.0.0](https://github.com/eea/volto-group-block/compare/5.0.1...6.0.0) - 24 March 2023
52
67
 
53
68
  #### :hammer_and_wrench: Others
54
69
 
55
70
  - (feat): Possibility to copy/cut/paste blocks within section group block - refs #157469 [dobri1408 - [`e9fc098`](https://github.com/eea/volto-group-block/commit/e9fc09825ba2ae258feb77864491d97d94c585b4)]
56
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`db4b09a`](https://github.com/eea/volto-group-block/commit/db4b09a6c14a8b271dec0c766886ffbcc3fe205e)]
57
- - Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`b8c2bf4`](https://github.com/eea/volto-group-block/commit/b8c2bf471868bb0394b2dbbf75ccb7917a9ef0bf)]
58
- - Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`b343119`](https://github.com/eea/volto-group-block/commit/b3431196931fd568476fa8bf6fbc508e086229ae)]
59
71
  - test(Jenkins): Run tests and cypress with latest canary @plone/volto [Alin Voinea - [`2f42e7c`](https://github.com/eea/volto-group-block/commit/2f42e7c19a1da5a9c6a883cb4f101e8fa224ff94)]
60
- - Add Sonarqube tag using cca-frontend addons list [EEA Jenkins - [`73afcc2`](https://github.com/eea/volto-group-block/commit/73afcc2f417797cedaa78cceefb007001d6c2406)]
61
- - yarn 3 [Alin Voinea - [`3c00ccc`](https://github.com/eea/volto-group-block/commit/3c00ccc7110bbf12a4d268182313418fb46b1a5d)]
62
- - Add Sonarqube tag using demo-kitkat-frontend addons list [EEA Jenkins - [`9b9662b`](https://github.com/eea/volto-group-block/commit/9b9662bda1da70ba0c3a7b4b05cebf130ed89e9e)]
63
72
  ### [5.0.1](https://github.com/eea/volto-group-block/compare/5.0.0...5.0.1) - 16 November 2022
64
73
 
65
74
  #### :nail_care: Enhancements
@@ -76,8 +85,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
76
85
 
77
86
  - Prepare 5.0.0 release [Miu Razvan - [`88c0ddd`](https://github.com/eea/volto-group-block/commit/88c0ddd569aeda7ee34d1eadea6a087f4e7dc257)]
78
87
  - Update dependencies [Alin Voinea - [`c8405af`](https://github.com/eea/volto-group-block/commit/c8405afb830cdf62e7877bf30b619933519e1d71)]
79
- - Add Sonarqube tag using marine-frontend addons list [EEA Jenkins - [`18e26c6`](https://github.com/eea/volto-group-block/commit/18e26c6939706d572ab8574e9b1826b9abc76314)]
80
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`8ed6d21`](https://github.com/eea/volto-group-block/commit/8ed6d21d8489911cc4cb471e3f8823c35f4adc50)]
81
88
  ### [4.3.8](https://github.com/eea/volto-group-block/compare/4.3.7...4.3.8) - 26 August 2022
82
89
 
83
90
  ### [4.3.7](https://github.com/eea/volto-group-block/compare/4.3.6...4.3.7) - 22 August 2022
@@ -90,9 +97,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
90
97
 
91
98
  #### :hammer_and_wrench: Others
92
99
 
93
- - Add Sonarqube tag using circularity-frontend addons list [EEA Jenkins - [`4e73f8b`](https://github.com/eea/volto-group-block/commit/4e73f8be3c73559557efadc410cb56abc055d82d)]
94
- - Add Sonarqube tag using clms-frontend addons list [EEA Jenkins - [`3040335`](https://github.com/eea/volto-group-block/commit/3040335002c63b50208c95918413bc958150e7a9)]
95
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`386f730`](https://github.com/eea/volto-group-block/commit/386f730ed65f73fe1468b9b77351c97fb70edcc5)]
96
100
  ### [4.3.5](https://github.com/eea/volto-group-block/compare/4.3.4...4.3.5) - 4 January 2022
97
101
 
98
102
  ### [4.3.4](https://github.com/eea/volto-group-block/compare/4.3.3...4.3.4) - 3 January 2022
@@ -101,23 +105,15 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
101
105
 
102
106
  #### :hammer_and_wrench: Others
103
107
 
104
- - Add Sonarqube tag using freshwater-frontend addons list [EEA Jenkins - [`3e62d79`](https://github.com/eea/volto-group-block/commit/3e62d79a7ed37d10d623bc845d43e1144f8080f7)]
105
108
  ### [4.3.2](https://github.com/eea/volto-group-block/compare/4.3.1...4.3.2) - 10 December 2021
106
109
 
107
110
  #### :hammer_and_wrench: Others
108
111
 
109
112
  - Refs #142010 - Optimize Volto-addons gitflow pipelines [valentinab25 - [`bc36cf5`](https://github.com/eea/volto-group-block/commit/bc36cf58c39e2b43c2fbf5189df6ddefc1260857)]
110
- - Add Sonarqube tag using industry-frontend addons list [EEA Jenkins - [`8038e78`](https://github.com/eea/volto-group-block/commit/8038e783c1e8ddd71e21f72070fdfa8e7e098993)]
111
- - Add Sonarqube tag using clms-frontend addons list [EEA Jenkins - [`daccdbc`](https://github.com/eea/volto-group-block/commit/daccdbc733e47be7d6536eb67f8f2eea038dc94b)]
112
113
  ### [4.3.1](https://github.com/eea/volto-group-block/compare/4.3.0...4.3.1) - 11 October 2021
113
114
 
114
115
  #### :hammer_and_wrench: Others
115
116
 
116
- - Add Sonarqube tag using bise-frontend addons list [EEA Jenkins - [`b0092e4`](https://github.com/eea/volto-group-block/commit/b0092e4f78a1a0184e22e32bb9806cd57417dfb2)]
117
- - Add Sonarqube tag using sustainability-frontend addons list [EEA Jenkins - [`ff8889c`](https://github.com/eea/volto-group-block/commit/ff8889cb7b0761b1df43b201984ce40b14e1561b)]
118
- - Add Sonarqube tag using climate-energy-frontend addons list [EEA Jenkins - [`0375c28`](https://github.com/eea/volto-group-block/commit/0375c28ed1ffe9186a4790b454795c0ca8039f72)]
119
- - Add Sonarqube tag using ims-frontend addons list [EEA Jenkins - [`c392190`](https://github.com/eea/volto-group-block/commit/c392190f044f5d9397bd2fb8c3d6a357f84960d0)]
120
- - Add Sonarqube tag using frontend addons list [EEA Jenkins - [`9694501`](https://github.com/eea/volto-group-block/commit/9694501141e6780eba89464d36406e3c93629fd8)]
121
117
  ### [4.3.0](https://github.com/eea/volto-group-block/compare/4.2.3...4.3.0) - 24 June 2021
122
118
 
123
119
  #### :hammer_and_wrench: Others
@@ -233,7 +229,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
233
229
  - Release 1.0.0 [Alin Voinea - [`b6ef873`](https://github.com/eea/volto-group-block/commit/b6ef873cb6f61e17db66fdd4de1d9d4902a66fc6)]
234
230
  - Update package meta info [Alin Voinea - [`143b7d4`](https://github.com/eea/volto-group-block/commit/143b7d44438d7afa5e346a9d21a85352df4e925f)]
235
231
  - Add Jenkinkins pipeline [Alin Voinea - [`866a4e1`](https://github.com/eea/volto-group-block/commit/866a4e14ea1eb8f5adb01222e576e5ab6dc73a70)]
236
- - yarn prettier [Alin Voinea - [`e3fe0a3`](https://github.com/eea/volto-group-block/commit/e3fe0a36b89878769341b45198d6c9e2f2584d15)]
237
232
  ### [0.1.3](https://github.com/eea/volto-group-block/compare/0.1.2...0.1.3) - 9 November 2020
238
233
 
239
234
  #### :hammer_and_wrench: Others
@@ -273,5 +268,4 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
273
268
  - Render meta block [Alin Voinea - [`0d44560`](https://github.com/eea/volto-group-block/commit/0d4456011ca56454068a54c610250b02df4ccb3b)]
274
269
  - Implement meta block allowedBlocks settings [Alin Voinea - [`f24feb1`](https://github.com/eea/volto-group-block/commit/f24feb1a1751f04841c21c7cd52a517fb02074ba)]
275
270
  - Edit meta block [Alin Voinea - [`236d291`](https://github.com/eea/volto-group-block/commit/236d29156fa835a7aa54eecdb4f120de0d64b271)]
276
- - yarn bootstrap [Alin Voinea - [`e009dfb`](https://github.com/eea/volto-group-block/commit/e009dfb6b9b74d101a6722f0982a5359fc522b6b)]
277
271
  - Initial commit [Alin Voinea - [`6a7b0de`](https://github.com/eea/volto-group-block/commit/6a7b0deb8f873d1462fd6a9c61edfc1562b3aace)]
@@ -1,11 +1,12 @@
1
1
  version: "3"
2
2
  services:
3
3
  backend:
4
- image: plone/plone-backend:${PLONE_VERSION:-6}
4
+ image: eeacms/plone-backend
5
5
  ports:
6
6
  - "8080:8080"
7
7
  environment:
8
8
  SITE: "Plone"
9
+ PROFILES: "eea.kitkat:testing"
9
10
 
10
11
  frontend:
11
12
  build:
@@ -23,6 +24,9 @@ services:
23
24
  volumes:
24
25
  - ./:/app/src/addons/${ADDON_PATH}
25
26
  environment:
27
+ CI: "true"
28
+ NODE_ENV: "development"
29
+ RAZZLE_JEST_CONFIG: "src/addons/${ADDON_PATH}/jest-addon.config.js"
26
30
  RAZZLE_INTERNAL_API_PATH: "http://backend:8080/Plone"
27
31
  RAZZLE_DEV_PROXY_API_PATH: "http://backend:8080/Plone"
28
32
  HOST: "0.0.0.0"
@@ -11,4 +11,12 @@ msgstr ""
11
11
  "Content-Transfer-Encoding: \n"
12
12
  "Plural-Forms: \n"
13
13
 
14
+ #: components/manage/Blocks/Group/EditBlockWrapper
15
+ # defaultMessage: Unknown Block {block}
16
+ msgid "Unknown Block"
17
+ msgstr ""
14
18
 
19
+ #: components/manage/Blocks/Group/EditBlockWrapper
20
+ # defaultMessage: delete
21
+ msgid "delete"
22
+ msgstr ""
@@ -0,0 +1,22 @@
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: \n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: \n"
6
+ "PO-Revision-Date: \n"
7
+ "Last-Translator: \n"
8
+ "Language: \n"
9
+ "Language-Team: \n"
10
+ "Content-Type: \n"
11
+ "Content-Transfer-Encoding: \n"
12
+ "Plural-Forms: \n"
13
+
14
+ #: components/manage/Blocks/Group/EditBlockWrapper
15
+ # defaultMessage: Unknown Block {block}
16
+ msgid "Unknown Block"
17
+ msgstr ""
18
+
19
+ #: components/manage/Blocks/Group/EditBlockWrapper
20
+ # defaultMessage: delete
21
+ msgid "delete"
22
+ msgstr ""
@@ -11,4 +11,12 @@ msgstr ""
11
11
  "Content-Transfer-Encoding: \n"
12
12
  "Plural-Forms: \n"
13
13
 
14
+ #: components/manage/Blocks/Group/EditBlockWrapper
15
+ # defaultMessage: Unknown Block {block}
16
+ msgid "Unknown Block"
17
+ msgstr ""
14
18
 
19
+ #: components/manage/Blocks/Group/EditBlockWrapper
20
+ # defaultMessage: delete
21
+ msgid "delete"
22
+ msgstr ""
@@ -11,4 +11,12 @@ msgstr ""
11
11
  "Content-Transfer-Encoding: \n"
12
12
  "Plural-Forms: \n"
13
13
 
14
+ #: components/manage/Blocks/Group/EditBlockWrapper
15
+ # defaultMessage: Unknown Block {block}
16
+ msgid "Unknown Block"
17
+ msgstr ""
14
18
 
19
+ #: components/manage/Blocks/Group/EditBlockWrapper
20
+ # defaultMessage: delete
21
+ msgid "delete"
22
+ msgstr ""
package/locales/volto.pot CHANGED
@@ -1,7 +1,7 @@
1
1
  msgid ""
2
2
  msgstr ""
3
3
  "Project-Id-Version: Plone\n"
4
- "POT-Creation-Date: 2023-06-28T10:48:22.678Z\n"
4
+ "POT-Creation-Date: 2023-08-29T17:38:01.779Z\n"
5
5
  "Last-Translator: Plone i18n <plone-i18n@lists.sourceforge.net>\n"
6
6
  "Language-Team: Plone i18n <plone-i18n@lists.sourceforge.net>\n"
7
7
  "MIME-Version: 1.0\n"
@@ -13,4 +13,12 @@ msgstr ""
13
13
  "Preferred-Encodings: utf-8\n"
14
14
  "Domain: volto\n"
15
15
 
16
+ #: components/manage/Blocks/Group/EditBlockWrapper
17
+ # defaultMessage: Unknown Block {block}
18
+ msgid "Unknown Block"
19
+ msgstr ""
16
20
 
21
+ #: components/manage/Blocks/Group/EditBlockWrapper
22
+ # defaultMessage: delete
23
+ msgid "delete"
24
+ msgstr ""
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-group-block",
3
- "version": "6.2.1",
3
+ "version": "6.3.0",
4
4
  "description": "volto-group-block: Volto block to be used to group other blocks",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -1,3 +1,4 @@
1
- export GroupBlockEdit from './manage/Blocks/Group/Edit';
2
- export GroupBlockView from './manage/Blocks/Group/View';
3
- export GroupBlockLayout from './manage/Blocks/Group/LayoutSchema';
1
+ export { default as GroupBlockDefaultBody } from './manage/Blocks/Group/DefaultBody';
2
+ export { default as GroupBlockEdit } from './manage/Blocks/Group/Edit';
3
+ export { default as GroupBlockView } from './manage/Blocks/Group/View';
4
+ export { default as GroupBlockLayout } from './manage/Blocks/Group/LayoutSchema';
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { GroupBlockDefaultBody } from '@eeacms/volto-group-block/components';
4
+
5
+ const Body = (props) => {
6
+ const { variation } = props;
7
+
8
+ const BodyComponent = variation?.template || GroupBlockDefaultBody;
9
+
10
+ return <BodyComponent {...props} />;
11
+ };
12
+
13
+ Body.propTypes = {
14
+ variation: PropTypes.objectOf(PropTypes.any).isRequired,
15
+ };
16
+
17
+ export default Body;
@@ -0,0 +1,105 @@
1
+ import { Button } from 'semantic-ui-react';
2
+ import { BlocksForm, Icon, RenderBlocks } from '@plone/volto/components';
3
+ import EditBlockWrapper from './EditBlockWrapper';
4
+
5
+ import helpSVG from '@plone/volto/icons/help.svg';
6
+
7
+ const GroupBlockDefaultBody = (props) => {
8
+ const {
9
+ block,
10
+ data,
11
+ onChangeBlock,
12
+ onChangeField,
13
+ pathname,
14
+ selected,
15
+ selectedBlock,
16
+ onSelectBlock,
17
+ setSelectedBlock,
18
+ manage,
19
+ childBlocksForm,
20
+ multiSelected,
21
+ formDescription,
22
+ isEditMode,
23
+ } = props;
24
+ const metadata = props.metadata || props.properties;
25
+ const blockState = {};
26
+
27
+ // Get editing instructions from block settings or props
28
+ let instructions = data?.instructions?.data || data?.instructions;
29
+ if (!instructions || instructions === '<p><br/></p>') {
30
+ instructions = formDescription;
31
+ }
32
+ return isEditMode ? (
33
+ <BlocksForm
34
+ metadata={metadata}
35
+ properties={childBlocksForm}
36
+ manage={manage}
37
+ selectedBlock={selected ? selectedBlock : null}
38
+ allowedBlocks={data.allowedBlocks}
39
+ title={data.placeholder}
40
+ description={instructions}
41
+ onSelectBlock={(id, l, e) => {
42
+ const isMultipleSelection = e
43
+ ? e.shiftKey || e.ctrlKey || e.metaKey
44
+ : false;
45
+ onSelectBlock(id, isMultipleSelection, e, selectedBlock);
46
+ }}
47
+ onChangeFormData={(newFormData) => {
48
+ onChangeBlock(block, {
49
+ ...data,
50
+ data: newFormData,
51
+ });
52
+ }}
53
+ onChangeField={(id, value) => {
54
+ if (['blocks', 'blocks_layout'].indexOf(id) > -1) {
55
+ blockState[id] = value;
56
+ onChangeBlock(block, {
57
+ ...data,
58
+ data: {
59
+ ...data.data,
60
+ ...blockState,
61
+ },
62
+ });
63
+ } else {
64
+ onChangeField(id, value);
65
+ }
66
+ }}
67
+ pathname={pathname}
68
+ >
69
+ {({ draginfo }, editBlock, blockProps) => (
70
+ <EditBlockWrapper
71
+ draginfo={draginfo}
72
+ blockProps={blockProps}
73
+ disabled={data.disableInnerButtons}
74
+ extraControls={
75
+ <>
76
+ {instructions && (
77
+ <>
78
+ <Button
79
+ icon
80
+ basic
81
+ title="Section help"
82
+ onClick={() => {
83
+ setSelectedBlock();
84
+ const tab = manage ? 0 : 1;
85
+ props.setSidebarTab(tab);
86
+ }}
87
+ >
88
+ <Icon name={helpSVG} className="" size="19px" />
89
+ </Button>
90
+ </>
91
+ )}
92
+ </>
93
+ }
94
+ multiSelected={multiSelected.includes(blockProps.block)}
95
+ >
96
+ {editBlock}
97
+ </EditBlockWrapper>
98
+ )}
99
+ </BlocksForm>
100
+ ) : (
101
+ <RenderBlocks {...props} metadata={metadata} content={data?.data || {}} />
102
+ );
103
+ };
104
+
105
+ export default GroupBlockDefaultBody;
@@ -1,46 +1,35 @@
1
1
  import React, { useState, useCallback } from 'react';
2
2
  import { isEmpty, without } from 'lodash';
3
+ import {
4
+ emptyBlocksForm,
5
+ withBlockExtensions,
6
+ getBlocksLayoutFieldname,
7
+ } from '@plone/volto/helpers';
8
+ import BodyComponent from './Body';
9
+
3
10
  import config from '@plone/volto/registry';
4
11
  import {
5
- BlocksForm,
6
12
  SidebarPortal,
7
- Icon,
8
13
  BlockDataForm,
9
14
  BlocksToolbar,
10
15
  } from '@plone/volto/components';
11
- import {
12
- emptyBlocksForm,
13
- getBlocksLayoutFieldname,
14
- } from '@plone/volto/helpers';
15
16
  import PropTypes from 'prop-types';
16
- import { Button, Segment } from 'semantic-ui-react';
17
- import EditBlockWrapper from './EditBlockWrapper';
17
+ import { Segment } from 'semantic-ui-react';
18
18
  import EditSchema from './EditSchema';
19
+
19
20
  import CounterComponent from './CounterComponent';
20
- import helpSVG from '@plone/volto/icons/help.svg';
21
21
  import './editor.less';
22
22
 
23
23
  const Edit = (props) => {
24
- const {
25
- block,
26
- data,
27
- onChangeBlock,
28
- onChangeField,
29
- pathname,
30
- selected,
31
- manage,
32
- formDescription,
33
- } = props;
34
- const metadata = props.metadata || props.properties;
24
+ const { block, data, onChangeBlock, selected, formDescription } = props;
35
25
  const [multiSelected, setMultiSelected] = useState([]);
36
26
  const data_blocks = data?.data?.blocks;
37
- const properties = isEmpty(data_blocks) ? emptyBlocksForm() : data.data;
27
+ const childBlocksForm = isEmpty(data_blocks) ? emptyBlocksForm() : data.data;
38
28
 
39
29
  const [selectedBlock, setSelectedBlock] = useState(
40
- properties.blocks_layout.items[0],
30
+ childBlocksForm.blocks_layout.items[0],
41
31
  );
42
32
 
43
- const blockState = {};
44
33
  const handleKeyDown = (
45
34
  e,
46
35
  index,
@@ -131,15 +120,15 @@ const Edit = (props) => {
131
120
  React.useEffect(() => {
132
121
  if (
133
122
  isEmpty(data_blocks) &&
134
- properties.blocks_layout.items[0] !== selectedBlock
123
+ childBlocksForm.blocks_layout.items[0] !== selectedBlock
135
124
  ) {
136
- setSelectedBlock(properties.blocks_layout.items[0]);
125
+ setSelectedBlock(childBlocksForm.blocks_layout.items[0]);
137
126
  onChangeBlock(block, {
138
127
  ...data,
139
- data: properties,
128
+ data: childBlocksForm,
140
129
  });
141
130
  }
142
- }, [onChangeBlock, properties, selectedBlock, block, data, data_blocks]);
131
+ }, [onChangeBlock, childBlocksForm, selectedBlock, block, data, data_blocks]);
143
132
 
144
133
  // Get editing instructions from block settings or props
145
134
  let instructions = data?.instructions?.data || data?.instructions;
@@ -167,6 +156,16 @@ const Edit = (props) => {
167
156
  >
168
157
  {data.title || 'Section'}
169
158
  </legend>
159
+ <BodyComponent
160
+ {...props}
161
+ isEditMode={true}
162
+ selectedBlock={selectedBlock}
163
+ setSelectedBlock={setSelectedBlock}
164
+ multiSelected={multiSelected}
165
+ setMultiSelected={setMultiSelected}
166
+ onSelectBlock={onSelectBlock}
167
+ childBlocksForm={childBlocksForm}
168
+ />
170
169
  {selected ? (
171
170
  <BlocksToolbar
172
171
  selectedBlock={Object.keys(selectedBlock || {})[0]}
@@ -189,74 +188,6 @@ const Edit = (props) => {
189
188
  ) : (
190
189
  ''
191
190
  )}
192
- <BlocksForm
193
- metadata={metadata}
194
- properties={properties}
195
- manage={manage}
196
- selectedBlock={selected ? selectedBlock : null}
197
- allowedBlocks={data.allowedBlocks}
198
- title={data.placeholder}
199
- description={instructions}
200
- onSelectBlock={(id, l, e) => {
201
- const isMultipleSelection = e
202
- ? e.shiftKey || e.ctrlKey || e.metaKey
203
- : false;
204
- onSelectBlock(id, isMultipleSelection, e, selectedBlock);
205
- }}
206
- onChangeFormData={(newFormData) => {
207
- onChangeBlock(block, {
208
- ...data,
209
- data: newFormData,
210
- });
211
- }}
212
- onChangeField={(id, value) => {
213
- if (['blocks', 'blocks_layout'].indexOf(id) > -1) {
214
- blockState[id] = value;
215
- onChangeBlock(block, {
216
- ...data,
217
- data: {
218
- ...data.data,
219
- ...blockState,
220
- },
221
- });
222
- } else {
223
- onChangeField(id, value);
224
- }
225
- }}
226
- pathname={pathname}
227
- >
228
- {({ draginfo }, editBlock, blockProps) => (
229
- <EditBlockWrapper
230
- draginfo={draginfo}
231
- blockProps={blockProps}
232
- disabled={data.disableInnerButtons}
233
- extraControls={
234
- <>
235
- {instructions && (
236
- <>
237
- <Button
238
- icon
239
- basic
240
- title="Section help"
241
- onClick={() => {
242
- setSelectedBlock();
243
- const tab = manage ? 0 : 1;
244
- props.setSidebarTab(tab);
245
- }}
246
- >
247
- <Icon name={helpSVG} className="" size="19px" />
248
- </Button>
249
- </>
250
- )}
251
- </>
252
- }
253
- multiSelected={multiSelected.includes(blockProps.block)}
254
- >
255
- {editBlock}
256
- </EditBlockWrapper>
257
- )}
258
- </BlocksForm>
259
-
260
191
  {props.data.maxChars && (
261
192
  <CounterComponent {...props} setSelectedBlock={setSelectedBlock} />
262
193
  )}
@@ -293,4 +224,4 @@ Edit.propTypes = {
293
224
  manage: PropTypes.bool.isRequired,
294
225
  };
295
226
 
296
- export default Edit;
227
+ export default withBlockExtensions(Edit);
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import Edit from './Edit';
2
+ import { default as Edit } from './Edit';
3
3
  import configureStore from 'redux-mock-store';
4
4
  import { Provider } from 'react-intl-redux';
5
5
  import thunk from 'redux-thunk';
@@ -15,6 +15,21 @@ const store = mockStore({
15
15
  },
16
16
  });
17
17
 
18
+ jest.mock('@plone/volto/components', () => ({
19
+ BlocksForm: jest.fn(() => <div className="blocks-form">RenderBlocks</div>),
20
+ Icon: () => <div>Icon</div>,
21
+ SidebarPortal: () => <div>SidebarPortal</div>,
22
+ BlocksToolbar: () => <div>BlocksToolbar</div>,
23
+ BlockDataForm: () => <div>BlockDataForm</div>,
24
+ RenderBlocks: jest.fn(() => <div>RenderBlocks</div>),
25
+ }));
26
+
27
+ jest.mock('@plone/volto/helpers', () => ({
28
+ withBlockExtensions: jest.fn((Component) => Component),
29
+ emptyBlocksForm: jest.fn(),
30
+ getBlocksLayoutFieldname: jest.fn(),
31
+ }));
32
+
18
33
  describe('Edit', () => {
19
34
  const onChangeBlock = jest.fn();
20
35
  const onChangeField = jest.fn();
@@ -41,6 +56,7 @@ describe('Edit', () => {
41
56
  pathname: '/',
42
57
  selected: true,
43
58
  manage: true,
59
+ variation: {},
44
60
  };
45
61
 
46
62
  it('should render without crashing', () => {
@@ -101,6 +117,7 @@ describe('Edit', () => {
101
117
  pathname: '/',
102
118
  selected: true,
103
119
  manage: true,
120
+ variation: {},
104
121
  };
105
122
  const mockOnFocusPreviousBlock = jest.fn();
106
123
  const mockOnFocusNextBlock = jest.fn();
@@ -163,6 +180,7 @@ describe('Edit', () => {
163
180
  pathname: '/',
164
181
  selected: true,
165
182
  manage: true,
183
+ variation: {},
166
184
  };
167
185
  const mockOnFocusPreviousBlock = jest.fn();
168
186
  const mockOnFocusNextBlock = jest.fn();
@@ -1,9 +1,9 @@
1
1
  import React from 'react';
2
- import { RenderBlocks } from '@plone/volto/components';
2
+ import { withBlockExtensions } from '@plone/volto/helpers';
3
+ import BodyComponent from './Body';
3
4
 
4
5
  const View = (props) => {
5
6
  const { data } = props;
6
- const metadata = props.metadata || props.properties;
7
7
  const CustomTag = `${data.as || 'div'}`;
8
8
  const customId = data?.title
9
9
  ?.toLowerCase()
@@ -12,9 +12,9 @@ const View = (props) => {
12
12
  ?.replace(/\s+/gi, '-');
13
13
  return (
14
14
  <CustomTag id={customId}>
15
- <RenderBlocks {...props} metadata={metadata} content={data?.data || {}} />
15
+ <BodyComponent {...props} />
16
16
  </CustomTag>
17
17
  );
18
18
  };
19
19
 
20
- export default View;
20
+ export default withBlockExtensions(View);
@@ -7,6 +7,11 @@ import '@testing-library/jest-dom/extend-expect';
7
7
 
8
8
  jest.mock('@plone/volto/components', () => ({
9
9
  RenderBlocks: jest.fn(() => <div>RenderBlocks</div>),
10
+ BodyComponent: () => <div>BodyComponent</div>,
11
+ }));
12
+
13
+ jest.mock('@plone/volto/helpers', () => ({
14
+ withBlockExtensions: jest.fn((Component) => Component),
10
15
  }));
11
16
 
12
17
  describe('View', () => {
@@ -15,6 +20,7 @@ describe('View', () => {
15
20
  data: {},
16
21
  metadata: {},
17
22
  properties: {},
23
+ variation: {},
18
24
  };
19
25
  const component = renderer.create(<View {...props} />);
20
26
 
@@ -24,9 +30,12 @@ describe('View', () => {
24
30
 
25
31
  it('renders with default tag and without crashing', () => {
26
32
  const props = {
27
- data: {},
33
+ data: {
34
+ variation: {},
35
+ },
28
36
  metadata: {},
29
37
  properties: {},
38
+ variation: {},
30
39
  };
31
40
  const { container } = render(<View {...props} />);
32
41
  expect(container.querySelector('div')).toBeInTheDocument();
@@ -40,6 +49,7 @@ describe('View', () => {
40
49
  data: { key: 'value' },
41
50
  },
42
51
  properties: {},
52
+ variation: {},
43
53
  };
44
54
  const { container } = render(<View {...props} />);
45
55
  expect(container.querySelector('section')).toBeInTheDocument();
@@ -55,6 +65,7 @@ describe('View', () => {
55
65
  },
56
66
  metadata: { meta: 'data' },
57
67
  properties: { prop: 'erty' },
68
+ variation: {},
58
69
  };
59
70
  render(<View {...props} />);
60
71
  expect(RenderBlocks).toHaveBeenCalledWith(
package/src/index.js CHANGED
@@ -1,6 +1,10 @@
1
1
  import { getBlocks } from '@plone/volto/helpers';
2
- import { GroupBlockEdit, GroupBlockView, GroupBlockLayout } from './components';
3
-
2
+ import {
3
+ GroupBlockEdit,
4
+ GroupBlockView,
5
+ GroupBlockLayout,
6
+ GroupBlockDefaultBody,
7
+ } from './components';
4
8
  import codeSVG from '@plone/volto/icons/row.svg';
5
9
 
6
10
  const applyConfig = (config) => {
@@ -45,6 +49,14 @@ const applyConfig = (config) => {
45
49
  addPermission: [],
46
50
  view: [],
47
51
  },
52
+ variations: [
53
+ {
54
+ id: 'default',
55
+ isDefault: true,
56
+ title: 'Default',
57
+ template: GroupBlockDefaultBody,
58
+ },
59
+ ],
48
60
  tocEntries: (block = {}, tocData) => {
49
61
  // integration with volto-block-toc
50
62
  const headlines = tocData.levels || ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];