@plone/volto 16.28.1 → 16.30.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.
Files changed (26) hide show
  1. package/.changelog.draft +3 -4
  2. package/.yarn/install-state.gz +0 -0
  3. package/CHANGELOG.md +12 -0
  4. package/package.json +1 -1
  5. package/packages/volto-slate/news/5517.feature +1 -0
  6. package/packages/volto-slate/package.json +1 -1
  7. package/packages/volto-slate/src/blocks/Text/DefaultTextBlockEditor.jsx +4 -0
  8. package/src/components/manage/Add/Add.jsx +6 -0
  9. package/src/components/manage/BlockChooser/BlockChooser.jsx +3 -1
  10. package/src/components/manage/BlockChooser/BlockChooserButton.jsx +5 -0
  11. package/src/components/manage/Blocks/Block/BlocksForm.jsx +4 -0
  12. package/src/components/manage/Blocks/Block/DefaultEdit.jsx +3 -1
  13. package/src/components/manage/Blocks/Block/EditBlockWrapper.jsx +5 -0
  14. package/src/components/manage/Blocks/Block/Settings.jsx +10 -1
  15. package/src/components/manage/Blocks/HeroImageLeft/Data.jsx +3 -1
  16. package/src/components/manage/Blocks/Image/ImageSidebar.jsx +3 -1
  17. package/src/components/manage/Blocks/Listing/ListingData.jsx +10 -1
  18. package/src/components/manage/Blocks/Maps/MapsSidebar.jsx +3 -1
  19. package/src/components/manage/Blocks/Search/SearchBlockEdit.jsx +4 -0
  20. package/src/components/manage/Blocks/Teaser/Data.jsx +10 -1
  21. package/src/components/manage/Blocks/ToC/Edit.jsx +2 -0
  22. package/src/components/manage/Blocks/Video/VideoSidebar.jsx +3 -1
  23. package/src/components/manage/Edit/Edit.jsx +1 -0
  24. package/src/components/manage/Form/Form.jsx +9 -1
  25. package/src/helpers/Blocks/Blocks.js +11 -2
  26. package/src/helpers/Extensions/withBlockSchemaEnhancer.js +20 -9
package/.changelog.draft CHANGED
@@ -1,8 +1,7 @@
1
- ## 16.28.1 (2023-12-04)
1
+ ## 16.30.0 (2023-12-13)
2
2
 
3
- ### Bugfix
3
+ ### Feature
4
4
 
5
- - Adjust DNS resolution to prefer IPv4 addresses when both IPv4 and IPv6 are resolved. @davisagli [#5261](https://github.com/plone/volto/issues/5261)
6
- - Fix the right order of parameters in normalizeExternalData.js @dobri1408 [#5475](https://github.com/plone/volto/issues/5475)
5
+ - Added `navRoot` and `contentType` to `restricted` key in blocks configuration. @sneridagh [#5517](https://github.com/plone/volto/issues/5517)
7
6
 
8
7
 
Binary file
package/CHANGELOG.md CHANGED
@@ -8,6 +8,18 @@
8
8
 
9
9
  <!-- towncrier release notes start -->
10
10
 
11
+ ## 16.30.0 (2023-12-13)
12
+
13
+ ### Feature
14
+
15
+ - Added `navRoot` and `contentType` to `restricted` key in blocks configuration. @sneridagh [#5517](https://github.com/plone/volto/issues/5517)
16
+
17
+ ## 16.29.0 (2023-12-07)
18
+
19
+ ### Feature
20
+
21
+ - Added conditional variations support. @sneridagh @robgietema [#5424](https://github.com/plone/volto/issues/5424)
22
+
11
23
  ## 16.28.1 (2023-12-04)
12
24
 
13
25
  ### Bugfix
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  }
10
10
  ],
11
11
  "license": "MIT",
12
- "version": "16.28.1",
12
+ "version": "16.30.0",
13
13
  "repository": {
14
14
  "type": "git",
15
15
  "url": "git@github.com:plone/volto.git"
@@ -0,0 +1 @@
1
+ Added `navRoot` and `contentType` to `restricted` key in blocks configuration. @sneridagh
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plone/volto-slate",
3
- "version": "16.28.1",
3
+ "version": "16.30.0",
4
4
  "description": "Slate.js integration with Volto",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -70,6 +70,8 @@ export const DefaultTextBlockEditor = (props) => {
70
70
  allowedBlocks,
71
71
  formTitle,
72
72
  formDescription,
73
+ navRoot,
74
+ contentType,
73
75
  } = props;
74
76
 
75
77
  const { slate } = config.settings;
@@ -267,6 +269,8 @@ export const DefaultTextBlockEditor = (props) => {
267
269
  blocksConfig={blocksConfig}
268
270
  size="24px"
269
271
  properties={properties}
272
+ navRoot={navRoot}
273
+ contentType={contentType}
270
274
  />
271
275
  )}
272
276
 
@@ -316,6 +316,9 @@ class Add extends Component {
316
316
  <Form
317
317
  ref={this.form}
318
318
  key="translated-or-new-content-form"
319
+ navRoot={
320
+ this.props.content?.['@components']?.navroot?.navroot || {}
321
+ }
319
322
  schema={this.props.schema}
320
323
  type={this.props.type}
321
324
  formData={{
@@ -335,6 +338,9 @@ class Add extends Component {
335
338
  // Copy the Language Independent Fields values from the to-be translated content
336
339
  // into the default values of the translated content Add form.
337
340
  ...lifData(),
341
+ parent: {
342
+ '@id': this.props.content?.['@id'] || '',
343
+ },
338
344
  }}
339
345
  requestError={this.state.error}
340
346
  onSubmit={this.onSubmit}
@@ -31,6 +31,8 @@ const BlockChooser = ({
31
31
  blocksConfig = config.blocks.blocksConfig,
32
32
  blockChooserRef,
33
33
  properties = {},
34
+ navRoot,
35
+ contentType,
34
36
  }) => {
35
37
  const intl = useIntl();
36
38
  const hasAllowedBlocks = !isEmpty(allowedBlocks);
@@ -55,7 +57,7 @@ const BlockChooser = ({
55
57
  // depending on this function, given properties (current present blocks) and the
56
58
  // block being evaluated
57
59
  return typeof item.restricted === 'function'
58
- ? !item.restricted({ properties, block: item })
60
+ ? !item.restricted({ properties, block: item, navRoot, contentType })
59
61
  : !item.restricted;
60
62
  }
61
63
  }
@@ -52,7 +52,10 @@ const BlockChooserButton = (props) => {
52
52
  blocksConfig,
53
53
  buttonComponent,
54
54
  properties,
55
+ navRoot,
56
+ contentType,
55
57
  } = props;
58
+
56
59
  const { disableNewBlocks } = data;
57
60
  const [addNewBlockOpened, setAddNewBlockOpened] = React.useState(false);
58
61
 
@@ -110,6 +113,8 @@ const BlockChooserButton = (props) => {
110
113
  properties={properties}
111
114
  showRestricted={showRestricted}
112
115
  ref={blockChooserRef}
116
+ navRoot={navRoot}
117
+ contentType={contentType}
113
118
  />
114
119
  )}
115
120
  </>
@@ -28,6 +28,8 @@ const BlocksForm = (props) => {
28
28
  pathname,
29
29
  onChangeField,
30
30
  properties,
31
+ type,
32
+ navRoot,
31
33
  onChangeFormData,
32
34
  selectedBlock,
33
35
  multiSelected,
@@ -244,6 +246,8 @@ const BlocksForm = (props) => {
244
246
  pathname,
245
247
  metadata,
246
248
  properties,
249
+ contentType: type,
250
+ navRoot,
247
251
  blocksConfig,
248
252
  selected: selectedBlock === childId,
249
253
  multiSelected: multiSelected?.includes(childId),
@@ -7,7 +7,7 @@ import DefaultBlockView from './DefaultView';
7
7
 
8
8
  const DefaultBlockEdit = (props) => {
9
9
  const { blocksConfig = config.blocks.blocksConfig } = props;
10
- const { data, onChangeBlock, block, selected } = props;
10
+ const { data, onChangeBlock, block, selected, navRoot, contentType } = props;
11
11
  const intl = useIntl();
12
12
  const blockSchema = blocksConfig?.[data['@type']]?.blockSchema;
13
13
  const schema =
@@ -32,6 +32,8 @@ const DefaultBlockEdit = (props) => {
32
32
  });
33
33
  }}
34
34
  formData={data}
35
+ navRoot={navRoot}
36
+ contentType={contentType}
35
37
  />
36
38
  </SidebarPortal>
37
39
  ) : (
@@ -47,7 +47,10 @@ const EditBlockWrapper = (props) => {
47
47
  editable,
48
48
  properties,
49
49
  showBlockChooser,
50
+ navRoot,
51
+ contentType,
50
52
  } = blockProps;
53
+
51
54
  const visible = selected && !hideHandler(data);
52
55
 
53
56
  const required = isBoolean(data.required)
@@ -107,6 +110,8 @@ const EditBlockWrapper = (props) => {
107
110
  blocksConfig={blocksConfig}
108
111
  size="24px"
109
112
  properties={properties}
113
+ navRoot={navRoot}
114
+ contentType={contentType}
110
115
  />
111
116
  )}
112
117
  </div>
@@ -3,7 +3,14 @@ import PropTypes from 'prop-types';
3
3
  import { injectIntl } from 'react-intl';
4
4
  import BlockDataForm from '@plone/volto/components/manage/Form/BlockDataForm';
5
5
 
6
- const Settings = ({ data, block, onChangeBlock, schema }) => {
6
+ const Settings = ({
7
+ data,
8
+ block,
9
+ onChangeBlock,
10
+ schema,
11
+ navRoot,
12
+ contentType,
13
+ }) => {
7
14
  return (
8
15
  <BlockDataForm
9
16
  schema={schema}
@@ -17,6 +24,8 @@ const Settings = ({ data, block, onChangeBlock, schema }) => {
17
24
  onChangeBlock={onChangeBlock}
18
25
  formData={data}
19
26
  applySchemaEnhancers={false}
27
+ navRoot={navRoot}
28
+ contentType={contentType}
20
29
  />
21
30
  );
22
31
  };
@@ -4,7 +4,7 @@ import schemaHero from './schema.js';
4
4
  import { BlockDataForm } from '@plone/volto/components';
5
5
 
6
6
  const HeroImageLeftBlockData = (props) => {
7
- const { block, data, onChangeBlock } = props;
7
+ const { block, data, onChangeBlock, navRoot, contentType } = props;
8
8
  const intl = useIntl();
9
9
  const schema = schemaHero({ ...props, intl });
10
10
  return (
@@ -20,6 +20,8 @@ const HeroImageLeftBlockData = (props) => {
20
20
  onChangeBlock={onChangeBlock}
21
21
  formData={data}
22
22
  block={block}
23
+ navRoot={navRoot}
24
+ contentType={contentType}
23
25
  />
24
26
  );
25
27
  };
@@ -8,7 +8,7 @@ import { ImageSchema } from './schema';
8
8
  import imageSVG from '@plone/volto/icons/image.svg';
9
9
 
10
10
  const ImageSidebar = (props) => {
11
- const { data, block, onChangeBlock } = props;
11
+ const { data, block, onChangeBlock, navRoot, contentType } = props;
12
12
  const intl = useIntl();
13
13
  const schema = ImageSchema({ formData: data, intl });
14
14
  return (
@@ -55,6 +55,8 @@ const ImageSidebar = (props) => {
55
55
  onChangeBlock={onChangeBlock}
56
56
  formData={data}
57
57
  block={block}
58
+ navRoot={navRoot}
59
+ contentType={contentType}
58
60
  />
59
61
  </>
60
62
  );
@@ -4,7 +4,14 @@ import { useIntl } from 'react-intl';
4
4
  import { BlockDataForm } from '@plone/volto/components';
5
5
 
6
6
  const ListingData = (props) => {
7
- const { data, block, blocksConfig, onChangeBlock } = props;
7
+ const {
8
+ data,
9
+ block,
10
+ blocksConfig,
11
+ onChangeBlock,
12
+ navRoot,
13
+ contentType,
14
+ } = props;
8
15
  const intl = useIntl();
9
16
  const schema = blocksConfig.listing.blockSchema({
10
17
  ...props,
@@ -25,6 +32,8 @@ const ListingData = (props) => {
25
32
  formData={data}
26
33
  blocksConfig={blocksConfig}
27
34
  block={block}
35
+ navRoot={navRoot}
36
+ contentType={contentType}
28
37
  />
29
38
  );
30
39
  };
@@ -18,7 +18,7 @@ const messages = defineMessages({
18
18
  });
19
19
 
20
20
  const MapsSidebar = (props) => {
21
- const { data, block, onChangeBlock } = props;
21
+ const { data, block, onChangeBlock, navRoot, contentType } = props;
22
22
  const intl = useIntl();
23
23
  const schema = MapsSchema({ ...props, intl });
24
24
 
@@ -42,6 +42,8 @@ const MapsSidebar = (props) => {
42
42
  onChangeBlock={onChangeBlock}
43
43
  formData={data}
44
44
  block={block}
45
+ navRoot={navRoot}
46
+ contentType={contentType}
45
47
  />
46
48
  )}
47
49
  </>
@@ -26,6 +26,8 @@ const SearchBlockEdit = (props) => {
26
26
  data,
27
27
  selected,
28
28
  intl,
29
+ navRoot,
30
+ contentType,
29
31
  onTriggerSearch,
30
32
  querystring = {},
31
33
  } = props;
@@ -83,6 +85,8 @@ const SearchBlockEdit = (props) => {
83
85
  }}
84
86
  onChangeBlock={onChangeBlock}
85
87
  formData={data}
88
+ navRoot={navRoot}
89
+ contentType={contentType}
86
90
  />
87
91
  </SidebarPortal>
88
92
  </>
@@ -14,7 +14,14 @@ const messages = defineMessages({
14
14
  });
15
15
 
16
16
  const TeaserData = (props) => {
17
- const { block, blocksConfig, data, onChangeBlock } = props;
17
+ const {
18
+ block,
19
+ blocksConfig,
20
+ data,
21
+ onChangeBlock,
22
+ navRoot,
23
+ contentType,
24
+ } = props;
18
25
  const intl = useIntl();
19
26
 
20
27
  const reset = () => {
@@ -64,6 +71,8 @@ const TeaserData = (props) => {
64
71
  block={block}
65
72
  blocksConfig={blocksConfig}
66
73
  headerActions={HeaderActions}
74
+ navRoot={navRoot}
75
+ contentType={contentType}
67
76
  />
68
77
  );
69
78
  };
@@ -27,6 +27,8 @@ class Edit extends Component {
27
27
  onChangeBlock={this.props.onChangeBlock}
28
28
  formData={this.props.data}
29
29
  block={this.props.block}
30
+ navRoot={this.props.navRoot}
31
+ contentType={this.props.contentType}
30
32
  />
31
33
  </SidebarPortal>
32
34
  </>
@@ -18,7 +18,7 @@ const messages = defineMessages({
18
18
  });
19
19
 
20
20
  const VideoSidebar = (props) => {
21
- const { data, block, onChangeBlock } = props;
21
+ const { data, block, onChangeBlock, navRoot, contentType } = props;
22
22
  const intl = useIntl();
23
23
  const schema = VideoBlockSchema({ ...props, intl });
24
24
 
@@ -42,6 +42,8 @@ const VideoSidebar = (props) => {
42
42
  onChangeBlock={onChangeBlock}
43
43
  formData={data}
44
44
  block={block}
45
+ navRoot={navRoot}
46
+ contentType={contentType}
45
47
  />
46
48
  )}
47
49
  </>
@@ -286,6 +286,7 @@ class Edit extends Component {
286
286
  <Form
287
287
  isEditForm
288
288
  ref={this.form}
289
+ navRoot={this.props.content?.['@components']?.navroot?.navroot || {}}
289
290
  schema={this.props.schema}
290
291
  type={this.props.content?.['@type']}
291
292
  formData={this.props.content}
@@ -542,7 +542,13 @@ class Form extends Component {
542
542
  */
543
543
  render() {
544
544
  const { settings } = config;
545
- const { schema: originalSchema, onCancel, onSubmit } = this.props;
545
+ const {
546
+ schema: originalSchema,
547
+ onCancel,
548
+ onSubmit,
549
+ navRoot,
550
+ type,
551
+ } = this.props;
546
552
  const { formData } = this.state;
547
553
  const schema = this.removeBlocksLayoutFields(originalSchema);
548
554
  const Container =
@@ -591,6 +597,8 @@ class Form extends Component {
591
597
  onChangeField={this.onChangeField}
592
598
  onSelectBlock={this.onSelectBlock}
593
599
  properties={formData}
600
+ navRoot={navRoot}
601
+ type={type}
594
602
  pathname={this.props.pathname}
595
603
  selectedBlock={this.state.selected}
596
604
  multiSelected={this.state.multiSelected}
@@ -425,7 +425,10 @@ export function applySchemaDefaults({ data = {}, schema, intl }) {
425
425
  * @param {Object} params An object with data, intl and anything else
426
426
  * @return {Object} Derived data, with the defaults extracted from the schema
427
427
  */
428
- export function applyBlockDefaults({ data, intl, ...rest }, blocksConfig) {
428
+ export function applyBlockDefaults(
429
+ { data, intl, navRoot, contentType, ...rest },
430
+ blocksConfig,
431
+ ) {
429
432
  // We pay attention to not break on a missing (invalid) block.
430
433
  const block_type = data?.['@type'];
431
434
  const { blockSchema } =
@@ -436,7 +439,13 @@ export function applyBlockDefaults({ data, intl, ...rest }, blocksConfig) {
436
439
  typeof blockSchema === 'function'
437
440
  ? blockSchema({ data, intl, ...rest })
438
441
  : blockSchema;
439
- schema = applySchemaEnhancer({ schema, formData: data, intl });
442
+ schema = applySchemaEnhancer({
443
+ schema,
444
+ formData: data,
445
+ intl,
446
+ navRoot,
447
+ contentType,
448
+ });
440
449
 
441
450
  return applySchemaDefaults({ data, schema, intl });
442
451
  }
@@ -201,6 +201,8 @@ export const applySchemaEnhancer = ({
201
201
  formData,
202
202
  intl,
203
203
  blocksConfig = config.blocks.blocksConfig,
204
+ navRoot,
205
+ contentType,
204
206
  }) => {
205
207
  let schema, schemaEnhancer;
206
208
 
@@ -217,6 +219,8 @@ export const applySchemaEnhancer = ({
217
219
  schema: cloneDeepSchema(originalSchema),
218
220
  formData,
219
221
  intl,
222
+ navRoot,
223
+ contentType,
220
224
  });
221
225
  return schema || originalSchema;
222
226
  }
@@ -232,12 +236,15 @@ export const applySchemaEnhancer = ({
232
236
  schema: cloneDeepSchema(originalSchema),
233
237
  formData,
234
238
  intl,
239
+ navRoot,
240
+ contentType,
235
241
  })
236
242
  : cloneDeepSchema(originalSchema);
237
243
 
238
244
  // Finalize the schema with a schemaEnhancer in the block config;
239
245
  schemaEnhancer = blocksConfig?.[blockType]?.schemaEnhancer;
240
- if (schemaEnhancer) schema = schemaEnhancer({ schema, formData, intl });
246
+ if (schemaEnhancer)
247
+ schema = schemaEnhancer({ schema, formData, intl, navRoot, contentType });
241
248
 
242
249
  return schema || originalSchema;
243
250
  };
@@ -250,7 +257,7 @@ export const applySchemaEnhancer = ({
250
257
  * - adds the variation selection input (as a choice widget)
251
258
  */
252
259
  export const withVariationSchemaEnhancer = (FormComponent) => (props) => {
253
- const { formData, schema: originalSchema } = props;
260
+ const { formData, schema: originalSchema, navRoot, contentType } = props;
254
261
  const intl = useIntl();
255
262
 
256
263
  const blocksConfig = getBlocksConfig(props);
@@ -258,15 +265,10 @@ export const withVariationSchemaEnhancer = (FormComponent) => (props) => {
258
265
  const blockType = formData['@type'];
259
266
  const variations = blocksConfig[blockType]?.variations || [];
260
267
 
261
- let schema = applySchemaEnhancer({
262
- schema: originalSchema,
263
- formData,
264
- intl,
265
- blocksConfig,
266
- });
268
+ let schema = cloneDeepSchema(originalSchema);
267
269
 
268
270
  if (variations.length > 1) {
269
- addExtensionFieldToSchema({
271
+ schema = addExtensionFieldToSchema({
270
272
  schema,
271
273
  name: 'variation',
272
274
  items: variations,
@@ -276,6 +278,15 @@ export const withVariationSchemaEnhancer = (FormComponent) => (props) => {
276
278
  });
277
279
  }
278
280
 
281
+ schema = applySchemaEnhancer({
282
+ schema,
283
+ formData,
284
+ intl,
285
+ blocksConfig,
286
+ navRoot,
287
+ contentType,
288
+ });
289
+
279
290
  return <FormComponent {...props} schema={schema} />;
280
291
  };
281
292