@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.
- package/.changelog.draft +12 -12
- package/.yarn/install-state.gz +0 -0
- package/CHANGELOG.md +31 -0
- package/locales/ca/LC_MESSAGES/volto.po +94 -3
- package/locales/ca.json +1 -1
- package/locales/de/LC_MESSAGES/volto.po +94 -3
- package/locales/de.json +1 -1
- package/locales/en/LC_MESSAGES/volto.po +93 -2
- package/locales/en.json +1 -1
- package/locales/es/LC_MESSAGES/volto.po +94 -3
- package/locales/es.json +1 -1
- package/locales/eu/LC_MESSAGES/volto.po +94 -3
- package/locales/eu.json +1 -1
- package/locales/fi/LC_MESSAGES/volto.po +94 -3
- package/locales/fi.json +1 -1
- package/locales/fr/LC_MESSAGES/volto.po +94 -3
- package/locales/fr.json +1 -1
- package/locales/it/LC_MESSAGES/volto.po +94 -3
- package/locales/it.json +1 -1
- package/locales/ja/LC_MESSAGES/volto.po +94 -3
- package/locales/ja.json +1 -1
- package/locales/nl/LC_MESSAGES/volto.po +94 -3
- package/locales/nl.json +1 -1
- package/locales/pt/LC_MESSAGES/volto.po +94 -3
- package/locales/pt.json +1 -1
- package/locales/pt_BR/LC_MESSAGES/volto.po +94 -3
- package/locales/pt_BR.json +1 -1
- package/locales/ro/LC_MESSAGES/volto.po +94 -3
- package/locales/ro.json +1 -1
- package/locales/volto.pot +94 -3
- package/locales/zh_CN/LC_MESSAGES/volto.po +94 -3
- package/locales/zh_CN.json +1 -1
- package/package.json +1 -1
- package/packages/volto-slate/package.json +1 -1
- package/packages/volto-slate/src/blocks/Text/DefaultTextBlockEditor.jsx +8 -3
- package/packages/volto-slate/src/blocks/Text/extensions/withDeserializers.js +3 -1
- package/packages/volto-slate/src/editor/plugins/StyleMenu/StyleMenu.jsx +14 -4
- package/src/components/manage/Blocks/HeroImageLeft/Edit.jsx +6 -1
- package/src/components/manage/Blocks/Image/Edit.jsx +11 -7
- package/src/components/manage/Contents/Contents.jsx +5 -1
- package/src/components/manage/Contents/ContentsUploadModal.jsx +10 -5
- package/src/components/manage/Form/Form.jsx +5 -3
- package/src/components/manage/History/History.jsx +11 -1
- package/src/components/manage/Preferences/ChangePassword.jsx +2 -2
- package/src/components/manage/Sharing/Sharing.jsx +5 -1
- package/src/components/manage/Toast/Toast.jsx +1 -1
- package/src/components/manage/Widgets/ColorPickerWidget.jsx +6 -1
- package/src/components/manage/Widgets/FileWidget.jsx +2 -1
- package/src/components/theme/NotFound/NotFound.jsx +55 -41
- package/src/components/theme/PasswordReset/PasswordReset.jsx +6 -3
- package/src/components/theme/View/NewsItemView.jsx +10 -5
- package/src/components/theme/View/RenderBlocks.jsx +7 -1
- package/src/config/index.js +1 -0
- package/src/helpers/Api/Api.js +1 -1
- package/src/helpers/Extensions/withBlockSchemaEnhancer.js +15 -11
- package/src/helpers/Extensions/withBlockSchemaEnhancer.test.js +145 -0
- package/src/helpers/FormValidation/FormValidation.js +30 -1
- package/src/helpers/FormValidation/FormValidation.test.js +32 -0
- package/src/helpers/MessageLabels/MessageLabels.js +76 -0
- package/src/helpers/index.js +3 -1
- 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
|
});
|
package/src/helpers/index.js
CHANGED
|
@@ -72,7 +72,9 @@ export {
|
|
|
72
72
|
|
|
73
73
|
export langmap from './LanguageMap/LanguageMap';
|
|
74
74
|
export Helmet from './Helmet/Helmet';
|
|
75
|
-
export FormValidation
|
|
75
|
+
export FormValidation, {
|
|
76
|
+
validateFileUploadSize,
|
|
77
|
+
} from './FormValidation/FormValidation';
|
|
76
78
|
export {
|
|
77
79
|
difference,
|
|
78
80
|
getColor,
|