@plone/volto 16.20.7 → 16.21.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 (61) hide show
  1. package/.changelog.draft +12 -12
  2. package/.yarn/install-state.gz +0 -0
  3. package/CHANGELOG.md +31 -0
  4. package/locales/ca/LC_MESSAGES/volto.po +94 -3
  5. package/locales/ca.json +1 -1
  6. package/locales/de/LC_MESSAGES/volto.po +94 -3
  7. package/locales/de.json +1 -1
  8. package/locales/en/LC_MESSAGES/volto.po +93 -2
  9. package/locales/en.json +1 -1
  10. package/locales/es/LC_MESSAGES/volto.po +94 -3
  11. package/locales/es.json +1 -1
  12. package/locales/eu/LC_MESSAGES/volto.po +94 -3
  13. package/locales/eu.json +1 -1
  14. package/locales/fi/LC_MESSAGES/volto.po +94 -3
  15. package/locales/fi.json +1 -1
  16. package/locales/fr/LC_MESSAGES/volto.po +94 -3
  17. package/locales/fr.json +1 -1
  18. package/locales/it/LC_MESSAGES/volto.po +94 -3
  19. package/locales/it.json +1 -1
  20. package/locales/ja/LC_MESSAGES/volto.po +94 -3
  21. package/locales/ja.json +1 -1
  22. package/locales/nl/LC_MESSAGES/volto.po +94 -3
  23. package/locales/nl.json +1 -1
  24. package/locales/pt/LC_MESSAGES/volto.po +94 -3
  25. package/locales/pt.json +1 -1
  26. package/locales/pt_BR/LC_MESSAGES/volto.po +94 -3
  27. package/locales/pt_BR.json +1 -1
  28. package/locales/ro/LC_MESSAGES/volto.po +94 -3
  29. package/locales/ro.json +1 -1
  30. package/locales/volto.pot +94 -3
  31. package/locales/zh_CN/LC_MESSAGES/volto.po +94 -3
  32. package/locales/zh_CN.json +1 -1
  33. package/package.json +1 -1
  34. package/packages/volto-slate/package.json +1 -1
  35. package/packages/volto-slate/src/blocks/Text/DefaultTextBlockEditor.jsx +8 -3
  36. package/packages/volto-slate/src/blocks/Text/extensions/withDeserializers.js +3 -1
  37. package/packages/volto-slate/src/editor/plugins/StyleMenu/StyleMenu.jsx +14 -4
  38. package/src/components/manage/Blocks/HeroImageLeft/Edit.jsx +6 -1
  39. package/src/components/manage/Blocks/Image/Edit.jsx +11 -7
  40. package/src/components/manage/Contents/Contents.jsx +5 -1
  41. package/src/components/manage/Contents/ContentsUploadModal.jsx +10 -5
  42. package/src/components/manage/Form/Form.jsx +5 -3
  43. package/src/components/manage/History/History.jsx +11 -1
  44. package/src/components/manage/Preferences/ChangePassword.jsx +2 -2
  45. package/src/components/manage/Sharing/Sharing.jsx +5 -1
  46. package/src/components/manage/Toast/Toast.jsx +1 -1
  47. package/src/components/manage/Widgets/ColorPickerWidget.jsx +6 -1
  48. package/src/components/manage/Widgets/FileWidget.jsx +2 -1
  49. package/src/components/theme/NotFound/NotFound.jsx +55 -41
  50. package/src/components/theme/PasswordReset/PasswordReset.jsx +6 -3
  51. package/src/components/theme/View/NewsItemView.jsx +10 -5
  52. package/src/components/theme/View/RenderBlocks.jsx +7 -1
  53. package/src/config/index.js +1 -0
  54. package/src/helpers/Api/Api.js +1 -1
  55. package/src/helpers/Extensions/withBlockSchemaEnhancer.js +15 -11
  56. package/src/helpers/Extensions/withBlockSchemaEnhancer.test.js +145 -0
  57. package/src/helpers/FormValidation/FormValidation.js +30 -1
  58. package/src/helpers/FormValidation/FormValidation.test.js +32 -0
  59. package/src/helpers/MessageLabels/MessageLabels.js +76 -0
  60. package/src/helpers/index.js +3 -1
  61. package/theme/themes/pastanaga/extras/contents.less +1 -0
@@ -1,5 +1,8 @@
1
1
  import { map, uniq, keys, intersection, isEmpty } from 'lodash';
2
2
  import { messages } from '../MessageLabels/MessageLabels';
3
+ import config from '@plone/volto/registry';
4
+ import { toast } from 'react-toastify';
5
+ import Toast from '@plone/volto/components/manage/Toast/Toast';
3
6
 
4
7
  /**
5
8
  * Will return the intl message if invalid
@@ -203,7 +206,7 @@ const validateRequiredFields = (
203
206
  const type = schema.properties[requiredField]?.type;
204
207
  const widget = schema.properties[requiredField]?.widget;
205
208
 
206
- let isEmpty = !formData[requiredField];
209
+ let isEmpty = !formData[requiredField] && formData[requiredField] !== 0;
207
210
  if (!isEmpty) {
208
211
  if (type === 'array') {
209
212
  isEmpty = formData[requiredField]
@@ -369,3 +372,29 @@ class FormValidation {
369
372
  }
370
373
 
371
374
  export default FormValidation;
375
+
376
+ /**
377
+ * Check if a file upload is within the maximum size limit.
378
+ * @param {File} file
379
+ * @param {Function} intlFunc
380
+ * @returns {Boolean}
381
+ */
382
+ export const validateFileUploadSize = (file, intlFunc) => {
383
+ const isValid =
384
+ !config.settings.maxFileUploadSize ||
385
+ file.size <= config.settings.maxFileUploadSize;
386
+ if (!isValid) {
387
+ toast.error(
388
+ <Toast
389
+ error
390
+ title={intlFunc(messages.error)}
391
+ content={intlFunc(messages.fileTooLarge, {
392
+ limit: `${Math.floor(
393
+ config.settings.maxFileUploadSize / 1024 / 1024,
394
+ )}MB`,
395
+ })}
396
+ />,
397
+ );
398
+ }
399
+ return isValid;
400
+ };
@@ -66,6 +66,38 @@ describe('FormValidation', () => {
66
66
  });
67
67
  });
68
68
 
69
+ it('do not treat 0 as missing required value', () => {
70
+ let newSchema = {
71
+ ...schema,
72
+ properties: {
73
+ ...schema.properties,
74
+ age: {
75
+ title: 'age',
76
+ type: 'integer',
77
+ widget: 'number',
78
+ description: '',
79
+ },
80
+ },
81
+ required: ['age'],
82
+ };
83
+ expect(
84
+ FormValidation.validateFieldsPerFieldset({
85
+ schema: newSchema,
86
+ formData: { username: 'test username', age: null },
87
+ formatMessage,
88
+ }),
89
+ ).toEqual({
90
+ age: [messages.required.defaultMessage],
91
+ });
92
+ expect(
93
+ FormValidation.validateFieldsPerFieldset({
94
+ schema: newSchema,
95
+ formData: { username: 'test username', age: 0 },
96
+ formatMessage,
97
+ }),
98
+ ).toEqual({});
99
+ });
100
+
69
101
  it('validates incorrect email', () => {
70
102
  expect(
71
103
  FormValidation.validateFieldsPerFieldset({
@@ -260,4 +260,80 @@ export const messages = defineMessages({
260
260
  id: 'Show groups of users below',
261
261
  defaultMessage: 'Show groups of users below',
262
262
  },
263
+ inspectRelations: {
264
+ id: 'Inspect relations',
265
+ defaultMessage: 'Inspect relations',
266
+ },
267
+ relations: {
268
+ id: 'Relations',
269
+ defaultMessage: 'Relations',
270
+ },
271
+ fixRelations: {
272
+ id: 'Fix relations',
273
+ defaultMessage: 'Fix relations',
274
+ },
275
+ searchRelationSource: {
276
+ id: 'Search sources by title or path',
277
+ defaultMessage: 'Search sources by title or path',
278
+ },
279
+ searchRelationTarget: {
280
+ id: 'Search targets by title or path',
281
+ defaultMessage: 'Search targets by title or path',
282
+ },
283
+ createOrDeleteRelationsToTarget: {
284
+ id: 'Create or delete relations to target',
285
+ defaultMessage: 'Create or delete relations to target',
286
+ },
287
+ relationName: {
288
+ id: 'Relation name',
289
+ defaultMessage: 'relation',
290
+ },
291
+ selectRelation: {
292
+ id: 'Select relation',
293
+ defaultMessage: 'Select relation',
294
+ },
295
+ norelationfound: {
296
+ id: 'No relation found',
297
+ defaultMessage: 'No relation found',
298
+ },
299
+ toomanyrelationsfound: {
300
+ id: 'Many relations found. Please search.',
301
+ defaultMessage: 'Many relations found. Please search.',
302
+ },
303
+ rebuildRelations: {
304
+ id: 'rebuild relations',
305
+ defaultMessage: 'rebuild relations',
306
+ },
307
+ flushAndRebuildRelations: {
308
+ id: 'flush intIds and rebuild relations',
309
+ defaultMessage: 'flush intIds and rebuild relations',
310
+ },
311
+ addPotentialTargetsPath: {
312
+ id: 'target path',
313
+ defaultMessage: 'target path',
314
+ },
315
+ addPotentialSourcesPath: {
316
+ id: 'sources path',
317
+ defaultMessage: 'sources path',
318
+ },
319
+ relationsUpdated: {
320
+ id: 'Relations updated',
321
+ defaultMessage: 'Relations updated',
322
+ },
323
+ select: {
324
+ id: 'Select',
325
+ defaultMessage: 'Select',
326
+ },
327
+ selected: {
328
+ id: 'Selected',
329
+ defaultMessage: 'Selected',
330
+ },
331
+ filter: {
332
+ id: 'Filter',
333
+ defaultMessage: 'Filter',
334
+ },
335
+ fileTooLarge: {
336
+ id: 'fileTooLarge',
337
+ defaultMessage: 'This website does not accept files larger than {limit}',
338
+ },
263
339
  });
@@ -72,7 +72,9 @@ export {
72
72
 
73
73
  export langmap from './LanguageMap/LanguageMap';
74
74
  export Helmet from './Helmet/Helmet';
75
- export FormValidation from './FormValidation/FormValidation';
75
+ export FormValidation, {
76
+ validateFileUploadSize,
77
+ } from './FormValidation/FormValidation';
76
78
  export {
77
79
  difference,
78
80
  getColor,
@@ -94,6 +94,7 @@
94
94
 
95
95
  .contents-table-wrapper {
96
96
  width: 100%;
97
+ overflow-x: auto;
97
98
 
98
99
  .ui.attached.table {
99
100
  width: 100%;