@commercetools-frontend/react-notifications 20.10.6 → 20.12.3
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/dist/commercetools-frontend-react-notifications.cjs.dev.js +22 -16
- package/dist/commercetools-frontend-react-notifications.cjs.prod.js +22 -16
- package/dist/commercetools-frontend-react-notifications.esm.js +22 -16
- package/dist/declarations/src/components/notifications-list/selectors.d.ts +18 -6
- package/package.json +23 -23
|
@@ -60,7 +60,7 @@ var _sliceInstanceProperty__default = /*#__PURE__*/_interopDefault(_sliceInstanc
|
|
|
60
60
|
var isNumber__default = /*#__PURE__*/_interopDefault(isNumber);
|
|
61
61
|
|
|
62
62
|
// NOTE: This string will be replaced on build time with the package version.
|
|
63
|
-
var version = "20.
|
|
63
|
+
var version = "20.12.3";
|
|
64
64
|
|
|
65
65
|
var Context = /*#__PURE__*/react.createContext(function () {
|
|
66
66
|
return null;
|
|
@@ -396,11 +396,12 @@ var hasErrorCodeAMatchingMessage = function hasErrorCodeAMatchingMessage(errorCo
|
|
|
396
396
|
};
|
|
397
397
|
|
|
398
398
|
var FormattedErrorMessage = function FormattedErrorMessage(props) {
|
|
399
|
-
var _context2;
|
|
399
|
+
var _props$error$extensio, _props$error$extensio2, _context2;
|
|
400
400
|
|
|
401
401
|
var intl = reactIntl.useIntl(); // Attempt to map the error by code
|
|
402
402
|
|
|
403
|
-
var
|
|
403
|
+
var extensionErrorCode = (_props$error$extensio = (_props$error$extensio2 = props.error.extensions) === null || _props$error$extensio2 === void 0 ? void 0 : _props$error$extensio2.code) !== null && _props$error$extensio !== void 0 ? _props$error$extensio : props.error.code;
|
|
404
|
+
var messageCode = extensionErrorCode && hasErrorCodeAMatchingMessage(extensionErrorCode) ? apiErrorMessages[extensionErrorCode] : undefined;
|
|
404
405
|
react.useEffect(function () {
|
|
405
406
|
if (!messageCode) {
|
|
406
407
|
var _context;
|
|
@@ -408,13 +409,13 @@ var FormattedErrorMessage = function FormattedErrorMessage(props) {
|
|
|
408
409
|
// This error is not mapped / translated yet,
|
|
409
410
|
// we log, report it to sentry and show the original error, unless `error.code` is `invalid_scope`
|
|
410
411
|
// which an error code emitted for expired project(s)
|
|
411
|
-
if (
|
|
412
|
+
if (extensionErrorCode !== 'invalid_scope' && !_includesInstanceProperty__default["default"](_context = props.error.message).call(_context, 'has expired')) {
|
|
412
413
|
sentry.reportErrorToSentry(new Error('Unmapped error'), {
|
|
413
414
|
extra: props.error
|
|
414
415
|
});
|
|
415
416
|
}
|
|
416
417
|
}
|
|
417
|
-
}, [messageCode, props.error]);
|
|
418
|
+
}, [extensionErrorCode, messageCode, props.error]);
|
|
418
419
|
|
|
419
420
|
if (messageCode) {
|
|
420
421
|
// The `error` object might contain extra fields for the specific `code`.
|
|
@@ -453,7 +454,9 @@ ApiErrorMessage.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
453
454
|
ApiErrorMessage.displayName = 'ApiErrorMessage';
|
|
454
455
|
|
|
455
456
|
function getSpecialFormattedMessageByErrorCode(error, intl) {
|
|
456
|
-
var _context3, _context4, _context5;
|
|
457
|
+
var _error$extensions$cod, _error$extensions, _context3, _context4, _context5;
|
|
458
|
+
|
|
459
|
+
var extensionErrorCode = (_error$extensions$cod = (_error$extensions = error.extensions) === null || _error$extensions === void 0 ? void 0 : _error$extensions.code) !== null && _error$extensions$cod !== void 0 ? _error$extensions$cod : error.code;
|
|
457
460
|
|
|
458
461
|
if (error.errorByExtension) {
|
|
459
462
|
var extensionMessage;
|
|
@@ -465,26 +468,26 @@ function getSpecialFormattedMessageByErrorCode(error, intl) {
|
|
|
465
468
|
return extensionMessage || error.message;
|
|
466
469
|
}
|
|
467
470
|
|
|
468
|
-
if (!
|
|
471
|
+
if (!extensionErrorCode || extensionErrorCode === 'InvalidInput') return intl.formatMessage(apiErrorMessages.General); // TODO: this is a temporary solution until we have proper pages about 403
|
|
469
472
|
|
|
470
|
-
if (
|
|
471
|
-
if (
|
|
473
|
+
if (extensionErrorCode === 'insufficient_scope') return intl.formatMessage(apiErrorMessages.Forbidden);
|
|
474
|
+
if (extensionErrorCode === 'DuplicateField' && error.field === 'slug') return intl.formatMessage(apiErrorMessages.DuplicateSlug, {
|
|
472
475
|
slugValue: error.duplicateValue
|
|
473
476
|
}); // Try to match the error with a custom error message
|
|
474
477
|
|
|
475
478
|
if (has__default["default"](error, 'invalidValue') && has__default["default"](error.invalidValue, 'overlappingPrices')) return intl.formatMessage(apiErrorMessages.OverlappingPrices);
|
|
476
479
|
|
|
477
|
-
if (
|
|
480
|
+
if (extensionErrorCode === 'InvalidOperation' && _includesInstanceProperty__default["default"](_context3 = error.message).call(_context3, 'validFrom') && _includesInstanceProperty__default["default"](_context4 = error.message).call(_context4, 'validUntil')) {
|
|
478
481
|
return intl.formatMessage(apiErrorMessages.InvalidDateRange, {
|
|
479
482
|
field: 'validFrom'
|
|
480
483
|
});
|
|
481
484
|
}
|
|
482
485
|
|
|
483
|
-
if (
|
|
486
|
+
if (extensionErrorCode === 'InvalidOperation' && _includesInstanceProperty__default["default"](_context5 = error.message).call(_context5, 'Duplicate tax rate for')) {
|
|
484
487
|
return intl.formatMessage(apiErrorMessages.TaxCategoryDuplicateCountry);
|
|
485
488
|
}
|
|
486
489
|
|
|
487
|
-
if (
|
|
490
|
+
if (extensionErrorCode === 'InvalidOperation' && regexInvalidOperationRequiredAttribute.test(error.message)) {
|
|
488
491
|
var attrName = error.message.replace(regexInvalidOperationRequiredAttribute, '$1');
|
|
489
492
|
return intl.formatMessage(apiErrorMessages.RequiredField, {
|
|
490
493
|
field: attrName
|
|
@@ -494,17 +497,17 @@ function getSpecialFormattedMessageByErrorCode(error, intl) {
|
|
|
494
497
|
// errors. We should investigate this further.
|
|
495
498
|
|
|
496
499
|
|
|
497
|
-
if (
|
|
500
|
+
if (extensionErrorCode === 'InvalidField' && error.field === 'price' && has__default["default"](error, 'invalidValue') && has__default["default"](error.invalidValue, 'validFrom') && has__default["default"](error.invalidValue, 'validUntil')) return intl.formatMessage(apiErrorMessages.InvalidDateRange, {
|
|
498
501
|
field: error.field
|
|
499
502
|
});
|
|
500
503
|
|
|
501
|
-
if (
|
|
504
|
+
if (extensionErrorCode === 'DuplicateAttributeValue' && error.attribute) {
|
|
502
505
|
return intl.formatMessage(apiErrorMessages.DuplicateAttributeValue, {
|
|
503
506
|
name: error.attribute.name
|
|
504
507
|
});
|
|
505
508
|
}
|
|
506
509
|
|
|
507
|
-
if (
|
|
510
|
+
if (extensionErrorCode === 'MaxResourceLimitExceeded') {
|
|
508
511
|
return intl.formatMessage(apiErrorMessages.MaxResourceLimitExceeded);
|
|
509
512
|
}
|
|
510
513
|
|
|
@@ -520,7 +523,10 @@ var ApiErrorNotification = function ApiErrorNotification(props) {
|
|
|
520
523
|
onCloseClick: props.dismiss,
|
|
521
524
|
children: jsxRuntime.jsx("ul", {
|
|
522
525
|
children: _valuesInstanceProperty__default["default"](props.notification) && _mapInstanceProperty__default["default"](_context = _valuesInstanceProperty__default["default"](props.notification).errors).call(_context, function (error, idx) {
|
|
523
|
-
var
|
|
526
|
+
var _error$extensions$cod, _error$extensions;
|
|
527
|
+
|
|
528
|
+
var extensionErrorCode = (_error$extensions$cod = (_error$extensions = error.extensions) === null || _error$extensions === void 0 ? void 0 : _error$extensions.code) !== null && _error$extensions$cod !== void 0 ? _error$extensions$cod : error.code;
|
|
529
|
+
var shouldLogErrorToConsole = !extensionErrorCode && process.env.NODE_ENV === 'development';
|
|
524
530
|
|
|
525
531
|
if (shouldLogErrorToConsole) {
|
|
526
532
|
/**
|
|
@@ -60,7 +60,7 @@ var _sliceInstanceProperty__default = /*#__PURE__*/_interopDefault(_sliceInstanc
|
|
|
60
60
|
var isNumber__default = /*#__PURE__*/_interopDefault(isNumber);
|
|
61
61
|
|
|
62
62
|
// NOTE: This string will be replaced on build time with the package version.
|
|
63
|
-
var version = "20.
|
|
63
|
+
var version = "20.12.3";
|
|
64
64
|
|
|
65
65
|
var Context = /*#__PURE__*/react.createContext(function () {
|
|
66
66
|
return null;
|
|
@@ -381,11 +381,12 @@ var hasErrorCodeAMatchingMessage = function hasErrorCodeAMatchingMessage(errorCo
|
|
|
381
381
|
};
|
|
382
382
|
|
|
383
383
|
var FormattedErrorMessage = function FormattedErrorMessage(props) {
|
|
384
|
-
var _context2;
|
|
384
|
+
var _props$error$extensio, _props$error$extensio2, _context2;
|
|
385
385
|
|
|
386
386
|
var intl = reactIntl.useIntl(); // Attempt to map the error by code
|
|
387
387
|
|
|
388
|
-
var
|
|
388
|
+
var extensionErrorCode = (_props$error$extensio = (_props$error$extensio2 = props.error.extensions) === null || _props$error$extensio2 === void 0 ? void 0 : _props$error$extensio2.code) !== null && _props$error$extensio !== void 0 ? _props$error$extensio : props.error.code;
|
|
389
|
+
var messageCode = extensionErrorCode && hasErrorCodeAMatchingMessage(extensionErrorCode) ? apiErrorMessages[extensionErrorCode] : undefined;
|
|
389
390
|
react.useEffect(function () {
|
|
390
391
|
if (!messageCode) {
|
|
391
392
|
var _context;
|
|
@@ -393,13 +394,13 @@ var FormattedErrorMessage = function FormattedErrorMessage(props) {
|
|
|
393
394
|
// This error is not mapped / translated yet,
|
|
394
395
|
// we log, report it to sentry and show the original error, unless `error.code` is `invalid_scope`
|
|
395
396
|
// which an error code emitted for expired project(s)
|
|
396
|
-
if (
|
|
397
|
+
if (extensionErrorCode !== 'invalid_scope' && !_includesInstanceProperty__default["default"](_context = props.error.message).call(_context, 'has expired')) {
|
|
397
398
|
sentry.reportErrorToSentry(new Error('Unmapped error'), {
|
|
398
399
|
extra: props.error
|
|
399
400
|
});
|
|
400
401
|
}
|
|
401
402
|
}
|
|
402
|
-
}, [messageCode, props.error]);
|
|
403
|
+
}, [extensionErrorCode, messageCode, props.error]);
|
|
403
404
|
|
|
404
405
|
if (messageCode) {
|
|
405
406
|
// The `error` object might contain extra fields for the specific `code`.
|
|
@@ -436,7 +437,9 @@ ApiErrorMessage.propTypes = {};
|
|
|
436
437
|
ApiErrorMessage.displayName = 'ApiErrorMessage';
|
|
437
438
|
|
|
438
439
|
function getSpecialFormattedMessageByErrorCode(error, intl) {
|
|
439
|
-
var _context3, _context4, _context5;
|
|
440
|
+
var _error$extensions$cod, _error$extensions, _context3, _context4, _context5;
|
|
441
|
+
|
|
442
|
+
var extensionErrorCode = (_error$extensions$cod = (_error$extensions = error.extensions) === null || _error$extensions === void 0 ? void 0 : _error$extensions.code) !== null && _error$extensions$cod !== void 0 ? _error$extensions$cod : error.code;
|
|
440
443
|
|
|
441
444
|
if (error.errorByExtension) {
|
|
442
445
|
var extensionMessage;
|
|
@@ -448,26 +451,26 @@ function getSpecialFormattedMessageByErrorCode(error, intl) {
|
|
|
448
451
|
return extensionMessage || error.message;
|
|
449
452
|
}
|
|
450
453
|
|
|
451
|
-
if (!
|
|
454
|
+
if (!extensionErrorCode || extensionErrorCode === 'InvalidInput') return intl.formatMessage(apiErrorMessages.General); // TODO: this is a temporary solution until we have proper pages about 403
|
|
452
455
|
|
|
453
|
-
if (
|
|
454
|
-
if (
|
|
456
|
+
if (extensionErrorCode === 'insufficient_scope') return intl.formatMessage(apiErrorMessages.Forbidden);
|
|
457
|
+
if (extensionErrorCode === 'DuplicateField' && error.field === 'slug') return intl.formatMessage(apiErrorMessages.DuplicateSlug, {
|
|
455
458
|
slugValue: error.duplicateValue
|
|
456
459
|
}); // Try to match the error with a custom error message
|
|
457
460
|
|
|
458
461
|
if (has__default["default"](error, 'invalidValue') && has__default["default"](error.invalidValue, 'overlappingPrices')) return intl.formatMessage(apiErrorMessages.OverlappingPrices);
|
|
459
462
|
|
|
460
|
-
if (
|
|
463
|
+
if (extensionErrorCode === 'InvalidOperation' && _includesInstanceProperty__default["default"](_context3 = error.message).call(_context3, 'validFrom') && _includesInstanceProperty__default["default"](_context4 = error.message).call(_context4, 'validUntil')) {
|
|
461
464
|
return intl.formatMessage(apiErrorMessages.InvalidDateRange, {
|
|
462
465
|
field: 'validFrom'
|
|
463
466
|
});
|
|
464
467
|
}
|
|
465
468
|
|
|
466
|
-
if (
|
|
469
|
+
if (extensionErrorCode === 'InvalidOperation' && _includesInstanceProperty__default["default"](_context5 = error.message).call(_context5, 'Duplicate tax rate for')) {
|
|
467
470
|
return intl.formatMessage(apiErrorMessages.TaxCategoryDuplicateCountry);
|
|
468
471
|
}
|
|
469
472
|
|
|
470
|
-
if (
|
|
473
|
+
if (extensionErrorCode === 'InvalidOperation' && regexInvalidOperationRequiredAttribute.test(error.message)) {
|
|
471
474
|
var attrName = error.message.replace(regexInvalidOperationRequiredAttribute, '$1');
|
|
472
475
|
return intl.formatMessage(apiErrorMessages.RequiredField, {
|
|
473
476
|
field: attrName
|
|
@@ -477,17 +480,17 @@ function getSpecialFormattedMessageByErrorCode(error, intl) {
|
|
|
477
480
|
// errors. We should investigate this further.
|
|
478
481
|
|
|
479
482
|
|
|
480
|
-
if (
|
|
483
|
+
if (extensionErrorCode === 'InvalidField' && error.field === 'price' && has__default["default"](error, 'invalidValue') && has__default["default"](error.invalidValue, 'validFrom') && has__default["default"](error.invalidValue, 'validUntil')) return intl.formatMessage(apiErrorMessages.InvalidDateRange, {
|
|
481
484
|
field: error.field
|
|
482
485
|
});
|
|
483
486
|
|
|
484
|
-
if (
|
|
487
|
+
if (extensionErrorCode === 'DuplicateAttributeValue' && error.attribute) {
|
|
485
488
|
return intl.formatMessage(apiErrorMessages.DuplicateAttributeValue, {
|
|
486
489
|
name: error.attribute.name
|
|
487
490
|
});
|
|
488
491
|
}
|
|
489
492
|
|
|
490
|
-
if (
|
|
493
|
+
if (extensionErrorCode === 'MaxResourceLimitExceeded') {
|
|
491
494
|
return intl.formatMessage(apiErrorMessages.MaxResourceLimitExceeded);
|
|
492
495
|
}
|
|
493
496
|
|
|
@@ -503,7 +506,10 @@ var ApiErrorNotification = function ApiErrorNotification(props) {
|
|
|
503
506
|
onCloseClick: props.dismiss,
|
|
504
507
|
children: jsxRuntime.jsx("ul", {
|
|
505
508
|
children: _valuesInstanceProperty__default["default"](props.notification) && _mapInstanceProperty__default["default"](_context = _valuesInstanceProperty__default["default"](props.notification).errors).call(_context, function (error, idx) {
|
|
506
|
-
var
|
|
509
|
+
var _error$extensions$cod, _error$extensions;
|
|
510
|
+
|
|
511
|
+
var extensionErrorCode = (_error$extensions$cod = (_error$extensions = error.extensions) === null || _error$extensions === void 0 ? void 0 : _error$extensions.code) !== null && _error$extensions$cod !== void 0 ? _error$extensions$cod : error.code;
|
|
512
|
+
var shouldLogErrorToConsole = !extensionErrorCode && "production" === 'development';
|
|
507
513
|
|
|
508
514
|
if (shouldLogErrorToConsole) {
|
|
509
515
|
/**
|
|
@@ -34,7 +34,7 @@ import isNumber from 'lodash/isNumber';
|
|
|
34
34
|
import { useShowNotification } from '@commercetools-frontend/actions-global';
|
|
35
35
|
|
|
36
36
|
// NOTE: This string will be replaced on build time with the package version.
|
|
37
|
-
var version = "20.
|
|
37
|
+
var version = "20.12.3";
|
|
38
38
|
|
|
39
39
|
var Context = /*#__PURE__*/createContext(function () {
|
|
40
40
|
return null;
|
|
@@ -370,11 +370,12 @@ var hasErrorCodeAMatchingMessage = function hasErrorCodeAMatchingMessage(errorCo
|
|
|
370
370
|
};
|
|
371
371
|
|
|
372
372
|
var FormattedErrorMessage = function FormattedErrorMessage(props) {
|
|
373
|
-
var _context2;
|
|
373
|
+
var _props$error$extensio, _props$error$extensio2, _context2;
|
|
374
374
|
|
|
375
375
|
var intl = useIntl(); // Attempt to map the error by code
|
|
376
376
|
|
|
377
|
-
var
|
|
377
|
+
var extensionErrorCode = (_props$error$extensio = (_props$error$extensio2 = props.error.extensions) === null || _props$error$extensio2 === void 0 ? void 0 : _props$error$extensio2.code) !== null && _props$error$extensio !== void 0 ? _props$error$extensio : props.error.code;
|
|
378
|
+
var messageCode = extensionErrorCode && hasErrorCodeAMatchingMessage(extensionErrorCode) ? apiErrorMessages[extensionErrorCode] : undefined;
|
|
378
379
|
useEffect(function () {
|
|
379
380
|
if (!messageCode) {
|
|
380
381
|
var _context;
|
|
@@ -382,13 +383,13 @@ var FormattedErrorMessage = function FormattedErrorMessage(props) {
|
|
|
382
383
|
// This error is not mapped / translated yet,
|
|
383
384
|
// we log, report it to sentry and show the original error, unless `error.code` is `invalid_scope`
|
|
384
385
|
// which an error code emitted for expired project(s)
|
|
385
|
-
if (
|
|
386
|
+
if (extensionErrorCode !== 'invalid_scope' && !_includesInstanceProperty(_context = props.error.message).call(_context, 'has expired')) {
|
|
386
387
|
reportErrorToSentry(new Error('Unmapped error'), {
|
|
387
388
|
extra: props.error
|
|
388
389
|
});
|
|
389
390
|
}
|
|
390
391
|
}
|
|
391
|
-
}, [messageCode, props.error]);
|
|
392
|
+
}, [extensionErrorCode, messageCode, props.error]);
|
|
392
393
|
|
|
393
394
|
if (messageCode) {
|
|
394
395
|
// The `error` object might contain extra fields for the specific `code`.
|
|
@@ -427,7 +428,9 @@ ApiErrorMessage.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
427
428
|
ApiErrorMessage.displayName = 'ApiErrorMessage';
|
|
428
429
|
|
|
429
430
|
function getSpecialFormattedMessageByErrorCode(error, intl) {
|
|
430
|
-
var _context3, _context4, _context5;
|
|
431
|
+
var _error$extensions$cod, _error$extensions, _context3, _context4, _context5;
|
|
432
|
+
|
|
433
|
+
var extensionErrorCode = (_error$extensions$cod = (_error$extensions = error.extensions) === null || _error$extensions === void 0 ? void 0 : _error$extensions.code) !== null && _error$extensions$cod !== void 0 ? _error$extensions$cod : error.code;
|
|
431
434
|
|
|
432
435
|
if (error.errorByExtension) {
|
|
433
436
|
var extensionMessage;
|
|
@@ -439,26 +442,26 @@ function getSpecialFormattedMessageByErrorCode(error, intl) {
|
|
|
439
442
|
return extensionMessage || error.message;
|
|
440
443
|
}
|
|
441
444
|
|
|
442
|
-
if (!
|
|
445
|
+
if (!extensionErrorCode || extensionErrorCode === 'InvalidInput') return intl.formatMessage(apiErrorMessages.General); // TODO: this is a temporary solution until we have proper pages about 403
|
|
443
446
|
|
|
444
|
-
if (
|
|
445
|
-
if (
|
|
447
|
+
if (extensionErrorCode === 'insufficient_scope') return intl.formatMessage(apiErrorMessages.Forbidden);
|
|
448
|
+
if (extensionErrorCode === 'DuplicateField' && error.field === 'slug') return intl.formatMessage(apiErrorMessages.DuplicateSlug, {
|
|
446
449
|
slugValue: error.duplicateValue
|
|
447
450
|
}); // Try to match the error with a custom error message
|
|
448
451
|
|
|
449
452
|
if (has(error, 'invalidValue') && has(error.invalidValue, 'overlappingPrices')) return intl.formatMessage(apiErrorMessages.OverlappingPrices);
|
|
450
453
|
|
|
451
|
-
if (
|
|
454
|
+
if (extensionErrorCode === 'InvalidOperation' && _includesInstanceProperty(_context3 = error.message).call(_context3, 'validFrom') && _includesInstanceProperty(_context4 = error.message).call(_context4, 'validUntil')) {
|
|
452
455
|
return intl.formatMessage(apiErrorMessages.InvalidDateRange, {
|
|
453
456
|
field: 'validFrom'
|
|
454
457
|
});
|
|
455
458
|
}
|
|
456
459
|
|
|
457
|
-
if (
|
|
460
|
+
if (extensionErrorCode === 'InvalidOperation' && _includesInstanceProperty(_context5 = error.message).call(_context5, 'Duplicate tax rate for')) {
|
|
458
461
|
return intl.formatMessage(apiErrorMessages.TaxCategoryDuplicateCountry);
|
|
459
462
|
}
|
|
460
463
|
|
|
461
|
-
if (
|
|
464
|
+
if (extensionErrorCode === 'InvalidOperation' && regexInvalidOperationRequiredAttribute.test(error.message)) {
|
|
462
465
|
var attrName = error.message.replace(regexInvalidOperationRequiredAttribute, '$1');
|
|
463
466
|
return intl.formatMessage(apiErrorMessages.RequiredField, {
|
|
464
467
|
field: attrName
|
|
@@ -468,17 +471,17 @@ function getSpecialFormattedMessageByErrorCode(error, intl) {
|
|
|
468
471
|
// errors. We should investigate this further.
|
|
469
472
|
|
|
470
473
|
|
|
471
|
-
if (
|
|
474
|
+
if (extensionErrorCode === 'InvalidField' && error.field === 'price' && has(error, 'invalidValue') && has(error.invalidValue, 'validFrom') && has(error.invalidValue, 'validUntil')) return intl.formatMessage(apiErrorMessages.InvalidDateRange, {
|
|
472
475
|
field: error.field
|
|
473
476
|
});
|
|
474
477
|
|
|
475
|
-
if (
|
|
478
|
+
if (extensionErrorCode === 'DuplicateAttributeValue' && error.attribute) {
|
|
476
479
|
return intl.formatMessage(apiErrorMessages.DuplicateAttributeValue, {
|
|
477
480
|
name: error.attribute.name
|
|
478
481
|
});
|
|
479
482
|
}
|
|
480
483
|
|
|
481
|
-
if (
|
|
484
|
+
if (extensionErrorCode === 'MaxResourceLimitExceeded') {
|
|
482
485
|
return intl.formatMessage(apiErrorMessages.MaxResourceLimitExceeded);
|
|
483
486
|
}
|
|
484
487
|
|
|
@@ -494,7 +497,10 @@ var ApiErrorNotification = function ApiErrorNotification(props) {
|
|
|
494
497
|
onCloseClick: props.dismiss,
|
|
495
498
|
children: jsx("ul", {
|
|
496
499
|
children: _valuesInstanceProperty(props.notification) && _mapInstanceProperty(_context = _valuesInstanceProperty(props.notification).errors).call(_context, function (error, idx) {
|
|
497
|
-
var
|
|
500
|
+
var _error$extensions$cod, _error$extensions;
|
|
501
|
+
|
|
502
|
+
var extensionErrorCode = (_error$extensions$cod = (_error$extensions = error.extensions) === null || _error$extensions === void 0 ? void 0 : _error$extensions.code) !== null && _error$extensions$cod !== void 0 ? _error$extensions$cod : error.code;
|
|
503
|
+
var shouldLogErrorToConsole = !extensionErrorCode && process.env.NODE_ENV === 'development';
|
|
498
504
|
|
|
499
505
|
if (shouldLogErrorToConsole) {
|
|
500
506
|
/**
|
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
import type { TAppNotificationGlobal, TAppNotificationPage, TAppNotificationSide } from '@commercetools-frontend/constants';
|
|
2
2
|
import type { TAppState } from './types';
|
|
3
3
|
export declare const selectNotifications: (state: TAppState) => (TAppNotificationGlobal | TAppNotificationPage | TAppNotificationSide)[];
|
|
4
|
-
export declare const selectGlobalNotifications:
|
|
4
|
+
export declare const selectGlobalNotifications: ((state: {
|
|
5
|
+
notifications: (TAppNotificationGlobal | TAppNotificationPage | TAppNotificationSide)[];
|
|
6
|
+
}) => TAppNotificationGlobal[]) & import("reselect").OutputSelectorFields<(args_0: (TAppNotificationGlobal | TAppNotificationPage | TAppNotificationSide)[]) => TAppNotificationGlobal[] & {
|
|
5
7
|
clearCache: () => void;
|
|
6
|
-
}
|
|
7
|
-
export declare const selectPageNotifications: import("reselect").OutputSelector<[(state: TAppState) => (TAppNotificationGlobal | TAppNotificationPage | TAppNotificationSide)[]], TAppNotificationPage[], never, ((args_0: (TAppNotificationGlobal | TAppNotificationPage | TAppNotificationSide)[], ...args_1: unknown[]) => TAppNotificationPage[]) & ((...args: any[]) => any) & {
|
|
8
|
+
}> & {
|
|
8
9
|
clearCache: () => void;
|
|
9
|
-
}
|
|
10
|
-
export declare const
|
|
10
|
+
};
|
|
11
|
+
export declare const selectPageNotifications: ((state: {
|
|
12
|
+
notifications: (TAppNotificationGlobal | TAppNotificationPage | TAppNotificationSide)[];
|
|
13
|
+
}) => TAppNotificationPage[]) & import("reselect").OutputSelectorFields<(args_0: (TAppNotificationGlobal | TAppNotificationPage | TAppNotificationSide)[]) => TAppNotificationPage[] & {
|
|
11
14
|
clearCache: () => void;
|
|
12
|
-
}
|
|
15
|
+
}> & {
|
|
16
|
+
clearCache: () => void;
|
|
17
|
+
};
|
|
18
|
+
export declare const selectSideNotifications: ((state: {
|
|
19
|
+
notifications: (TAppNotificationGlobal | TAppNotificationPage | TAppNotificationSide)[];
|
|
20
|
+
}) => TAppNotificationSide[]) & import("reselect").OutputSelectorFields<(args_0: (TAppNotificationGlobal | TAppNotificationPage | TAppNotificationSide)[]) => TAppNotificationSide[] & {
|
|
21
|
+
clearCache: () => void;
|
|
22
|
+
}> & {
|
|
23
|
+
clearCache: () => void;
|
|
24
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-frontend/react-notifications",
|
|
3
|
-
"version": "20.
|
|
3
|
+
"version": "20.12.3",
|
|
4
4
|
"description": "React bindings for @commercetools-frontend/notifications",
|
|
5
5
|
"bugs": "https://github.com/commercetools/merchant-center-application-kit/issues",
|
|
6
6
|
"repository": {
|
|
@@ -18,37 +18,37 @@
|
|
|
18
18
|
"module": "dist/commercetools-frontend-react-notifications.esm.js",
|
|
19
19
|
"files": ["dist", "package.json", "LICENSE", "README.md"],
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@babel/runtime": "7.
|
|
22
|
-
"@babel/runtime-corejs3": "7.
|
|
23
|
-
"@commercetools-frontend/actions-global": "20.
|
|
24
|
-
"@commercetools-frontend/constants": "20.
|
|
25
|
-
"@commercetools-frontend/notifications": "20.
|
|
26
|
-
"@commercetools-frontend/sentry": "20.
|
|
27
|
-
"@commercetools-uikit/design-system": "^12.2.
|
|
28
|
-
"@commercetools-uikit/icon-button": "^12.2.
|
|
29
|
-
"@commercetools-uikit/icons": "^12.2.
|
|
30
|
-
"@commercetools-uikit/spacings": "^12.2.
|
|
31
|
-
"@emotion/react": "11.
|
|
32
|
-
"@emotion/styled": "11.
|
|
21
|
+
"@babel/runtime": "7.16.5",
|
|
22
|
+
"@babel/runtime-corejs3": "7.16.5",
|
|
23
|
+
"@commercetools-frontend/actions-global": "20.12.3",
|
|
24
|
+
"@commercetools-frontend/constants": "20.12.3",
|
|
25
|
+
"@commercetools-frontend/notifications": "20.12.3",
|
|
26
|
+
"@commercetools-frontend/sentry": "20.12.3",
|
|
27
|
+
"@commercetools-uikit/design-system": "^12.2.9",
|
|
28
|
+
"@commercetools-uikit/icon-button": "^12.2.9",
|
|
29
|
+
"@commercetools-uikit/icons": "^12.2.9",
|
|
30
|
+
"@commercetools-uikit/spacings": "^12.2.9",
|
|
31
|
+
"@emotion/react": "11.7.1",
|
|
32
|
+
"@emotion/styled": "11.6.0",
|
|
33
33
|
"@types/history": "4.7.9",
|
|
34
|
-
"@types/lodash": "^4.14.
|
|
35
|
-
"@types/prop-types": "^15.7.
|
|
36
|
-
"@types/react": "^17.0.
|
|
37
|
-
"@types/react-dom": "^17.0.
|
|
38
|
-
"@types/react-redux": "^7.1.
|
|
39
|
-
"@types/react-router": "^5.1.
|
|
40
|
-
"@types/react-router-dom": "^5.
|
|
34
|
+
"@types/lodash": "^4.14.178",
|
|
35
|
+
"@types/prop-types": "^15.7.4",
|
|
36
|
+
"@types/react": "^17.0.37",
|
|
37
|
+
"@types/react-dom": "^17.0.11",
|
|
38
|
+
"@types/react-redux": "^7.1.20",
|
|
39
|
+
"@types/react-router": "^5.1.17",
|
|
40
|
+
"@types/react-router-dom": "^5.3.2",
|
|
41
41
|
"lodash": "4.17.21",
|
|
42
42
|
"moment": "^2.29.1",
|
|
43
|
-
"moment-timezone": "^0.5.
|
|
43
|
+
"moment-timezone": "^0.5.34",
|
|
44
44
|
"prop-types": "15.7.2",
|
|
45
|
-
"reselect": "4.1.
|
|
45
|
+
"reselect": "4.1.5"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@testing-library/react": "12.1.2",
|
|
49
49
|
"react": "17.0.2",
|
|
50
50
|
"react-dom": "17.0.2",
|
|
51
|
-
"react-intl": "5.
|
|
51
|
+
"react-intl": "5.23.0",
|
|
52
52
|
"react-redux": "7.2.6",
|
|
53
53
|
"react-router-dom": "5.3.0"
|
|
54
54
|
},
|