@commercetools-frontend/react-notifications 20.10.3 → 20.12.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/dist/commercetools-frontend-react-notifications.cjs.dev.js +83 -87
- package/dist/commercetools-frontend-react-notifications.cjs.prod.js +67 -71
- package/dist/commercetools-frontend-react-notifications.esm.js +35 -39
- package/dist/declarations/src/components/notifications-list/selectors.d.ts +9 -3
- package/dist/declarations/src/version.d.ts +1 -1
- package/package.json +9 -13
|
@@ -59,8 +59,8 @@ var Spacings__default = /*#__PURE__*/_interopDefault(Spacings);
|
|
|
59
59
|
var _sliceInstanceProperty__default = /*#__PURE__*/_interopDefault(_sliceInstanceProperty);
|
|
60
60
|
var isNumber__default = /*#__PURE__*/_interopDefault(isNumber);
|
|
61
61
|
|
|
62
|
-
// NOTE: This string will be replaced
|
|
63
|
-
var version =
|
|
62
|
+
// NOTE: This string will be replaced on build time with the package version.
|
|
63
|
+
var version = "20.12.0";
|
|
64
64
|
|
|
65
65
|
var Context = /*#__PURE__*/react.createContext(function () {
|
|
66
66
|
return null;
|
|
@@ -74,8 +74,8 @@ function NotificationProviderForCustomComponent(props) {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
NotificationProviderForCustomComponent.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
77
|
-
mapNotificationToComponent: _pt__default[
|
|
78
|
-
children: _pt__default[
|
|
77
|
+
mapNotificationToComponent: _pt__default["default"].func.isRequired,
|
|
78
|
+
children: _pt__default["default"].node.isRequired
|
|
79
79
|
} : {};
|
|
80
80
|
NotificationProviderForCustomComponent.displayName = 'NotificationProviderForCustomComponent';
|
|
81
81
|
var useCustomNotificationComponent = function useCustomNotificationComponent() {
|
|
@@ -83,8 +83,8 @@ var useCustomNotificationComponent = function useCustomNotificationComponent() {
|
|
|
83
83
|
}; // Exports
|
|
84
84
|
|
|
85
85
|
function filterDataAttributes(obj) {
|
|
86
|
-
return omitBy__default[
|
|
87
|
-
return !_startsWithInstanceProperty__default[
|
|
86
|
+
return omitBy__default["default"](obj, function (_value, key) {
|
|
87
|
+
return !_startsWithInstanceProperty__default["default"](key).call(key, 'data-');
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
90
|
|
|
@@ -152,9 +152,9 @@ var getStylesForNotification = function getStylesForNotification(props) {
|
|
|
152
152
|
}
|
|
153
153
|
};
|
|
154
154
|
|
|
155
|
-
function ownKeys$4(object, enumerableOnly) { var keys = _Object$keys__default[
|
|
155
|
+
function ownKeys$4(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); if (enumerableOnly) { symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
156
156
|
|
|
157
|
-
function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context; _forEachInstanceProperty__default[
|
|
157
|
+
function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context; _forEachInstanceProperty__default["default"](_context = ownKeys$4(Object(source), true)).call(_context, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors__default["default"]) { _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)); } else { var _context2; _forEachInstanceProperty__default["default"](_context2 = ownKeys$4(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } } return target; }
|
|
158
158
|
|
|
159
159
|
var NotificationIcon = function NotificationIcon(props) {
|
|
160
160
|
if (props.type === constants.NOTIFICATION_KINDS_SIDE.error) return jsxRuntime.jsx(icons.ErrorIcon, {
|
|
@@ -172,8 +172,8 @@ var NotificationIcon = function NotificationIcon(props) {
|
|
|
172
172
|
};
|
|
173
173
|
|
|
174
174
|
NotificationIcon.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
175
|
-
type: _pt__default[
|
|
176
|
-
color: _pt__default[
|
|
175
|
+
type: _pt__default["default"].any.isRequired,
|
|
176
|
+
color: _pt__default["default"].oneOf(['error', 'warning', 'info', 'solid', 'neutral60', 'surface', 'primary', 'primary40']).isRequired
|
|
177
177
|
} : {};
|
|
178
178
|
NotificationIcon.displayName = 'NotificationIcon';
|
|
179
179
|
var defaultProps$1 = {
|
|
@@ -189,7 +189,7 @@ var Notification = function Notification(props) {
|
|
|
189
189
|
css: getStylesForContent(props),
|
|
190
190
|
children: props.children
|
|
191
191
|
}), props.onCloseClick ? jsxRuntime.jsx("div", {
|
|
192
|
-
children: jsxRuntime.jsx(IconButton__default[
|
|
192
|
+
children: jsxRuntime.jsx(IconButton__default["default"], {
|
|
193
193
|
label: intl.formatMessage(messages.hideNotification),
|
|
194
194
|
onClick: props.onCloseClick,
|
|
195
195
|
icon: jsxRuntime.jsx(icons.CloseBoldIcon, {}),
|
|
@@ -206,11 +206,11 @@ var Notification = function Notification(props) {
|
|
|
206
206
|
};
|
|
207
207
|
|
|
208
208
|
Notification.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
209
|
-
domain: _pt__default[
|
|
210
|
-
type: _pt__default[
|
|
211
|
-
fixed: _pt__default[
|
|
212
|
-
onCloseClick: _pt__default[
|
|
213
|
-
children: _pt__default[
|
|
209
|
+
domain: _pt__default["default"].any.isRequired,
|
|
210
|
+
type: _pt__default["default"].any.isRequired,
|
|
211
|
+
fixed: _pt__default["default"].bool.isRequired,
|
|
212
|
+
onCloseClick: _pt__default["default"].func,
|
|
213
|
+
children: _pt__default["default"].node.isRequired
|
|
214
214
|
} : {};
|
|
215
215
|
Notification.displayName = 'Notification';
|
|
216
216
|
Notification.defaultProps = defaultProps$1;
|
|
@@ -225,8 +225,8 @@ var GenericNotification = function GenericNotification(props) {
|
|
|
225
225
|
};
|
|
226
226
|
|
|
227
227
|
GenericNotification.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
228
|
-
notification: _pt__default[
|
|
229
|
-
dismiss: _pt__default[
|
|
228
|
+
notification: _pt__default["default"].any.isRequired,
|
|
229
|
+
dismiss: _pt__default["default"].func.isRequired
|
|
230
230
|
} : {};
|
|
231
231
|
GenericNotification.displayName = 'GenericNotification';
|
|
232
232
|
|
|
@@ -371,9 +371,9 @@ var apiErrorMessages = reactIntl.defineMessages({
|
|
|
371
371
|
}
|
|
372
372
|
});
|
|
373
373
|
|
|
374
|
-
function ownKeys$3(object, enumerableOnly) { var keys = _Object$keys__default[
|
|
374
|
+
function ownKeys$3(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); if (enumerableOnly) { symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
375
375
|
|
|
376
|
-
function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context6; _forEachInstanceProperty__default[
|
|
376
|
+
function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context6; _forEachInstanceProperty__default["default"](_context6 = ownKeys$3(Object(source), true)).call(_context6, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors__default["default"]) { _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)); } else { var _context7; _forEachInstanceProperty__default["default"](_context7 = ownKeys$3(Object(source))).call(_context7, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } } return target; }
|
|
377
377
|
var regexInvalidOperationRequiredAttribute = /Required attribute '(.*)' cannot be removed/;
|
|
378
378
|
|
|
379
379
|
// The values passed to the Intl message must be a map of scalar values.
|
|
@@ -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`.
|
|
@@ -424,12 +425,12 @@ var FormattedErrorMessage = function FormattedErrorMessage(props) {
|
|
|
424
425
|
}
|
|
425
426
|
|
|
426
427
|
return jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
427
|
-
children: _filterInstanceProperty__default[
|
|
428
|
+
children: _filterInstanceProperty__default["default"](_context2 = [props.error.message, props.error.detailedErrorMessage && "(".concat(props.error.detailedErrorMessage, ")")]).call(_context2, Boolean).join(' ')
|
|
428
429
|
});
|
|
429
430
|
};
|
|
430
431
|
|
|
431
432
|
FormattedErrorMessage.propTypes = {
|
|
432
|
-
error: _pt__default[
|
|
433
|
+
error: _pt__default["default"].any.isRequired
|
|
433
434
|
};
|
|
434
435
|
FormattedErrorMessage.displayName = 'FormattedErrorMessage';
|
|
435
436
|
|
|
@@ -448,12 +449,14 @@ var ApiErrorMessage = function ApiErrorMessage(props) {
|
|
|
448
449
|
};
|
|
449
450
|
|
|
450
451
|
ApiErrorMessage.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
451
|
-
error: _pt__default[
|
|
452
|
+
error: _pt__default["default"].any.isRequired
|
|
452
453
|
} : {};
|
|
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
|
-
if (has__default[
|
|
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
|
|
|
@@ -519,8 +522,11 @@ var ApiErrorNotification = function ApiErrorNotification(props) {
|
|
|
519
522
|
domain: props.notification.domain,
|
|
520
523
|
onCloseClick: props.dismiss,
|
|
521
524
|
children: jsxRuntime.jsx("ul", {
|
|
522
|
-
children: _valuesInstanceProperty__default[
|
|
523
|
-
var
|
|
525
|
+
children: _valuesInstanceProperty__default["default"](props.notification) && _mapInstanceProperty__default["default"](_context = _valuesInstanceProperty__default["default"](props.notification).errors).call(_context, function (error, idx) {
|
|
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
|
/**
|
|
@@ -544,33 +550,33 @@ var ApiErrorNotification = function ApiErrorNotification(props) {
|
|
|
544
550
|
};
|
|
545
551
|
|
|
546
552
|
ApiErrorNotification.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
547
|
-
notification: _pt__default[
|
|
548
|
-
dismiss: _pt__default[
|
|
553
|
+
notification: _pt__default["default"].any.isRequired,
|
|
554
|
+
dismiss: _pt__default["default"].func.isRequired
|
|
549
555
|
} : {};
|
|
550
556
|
ApiErrorNotification.displayName = 'ApiErrorNotification';
|
|
551
557
|
|
|
552
|
-
function ownKeys$2(object, enumerableOnly) { var keys = _Object$keys__default[
|
|
558
|
+
function ownKeys$2(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); if (enumerableOnly) { symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
553
559
|
|
|
554
|
-
function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context; _forEachInstanceProperty__default[
|
|
560
|
+
function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context; _forEachInstanceProperty__default["default"](_context = ownKeys$2(Object(source), true)).call(_context, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors__default["default"]) { _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)); } else { var _context2; _forEachInstanceProperty__default["default"](_context2 = ownKeys$2(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } } return target; }
|
|
555
561
|
|
|
556
562
|
var UnexpectedErrorNotification = function UnexpectedErrorNotification(props) {
|
|
557
563
|
return jsxRuntime.jsx(Notification, {
|
|
558
564
|
type: "error",
|
|
559
565
|
domain: props.notification.domain,
|
|
560
566
|
onCloseClick: props.dismiss,
|
|
561
|
-
children: jsxRuntime.jsxs(Spacings__default[
|
|
567
|
+
children: jsxRuntime.jsxs(Spacings__default["default"].Stack, {
|
|
562
568
|
children: [jsxRuntime.jsx("div", {
|
|
563
569
|
children: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$2({}, apiErrorMessages.General))
|
|
564
|
-
}), _valuesInstanceProperty__default[
|
|
565
|
-
children: "ID (".concat(_valuesInstanceProperty__default[
|
|
570
|
+
}), _valuesInstanceProperty__default["default"](props.notification) && _valuesInstanceProperty__default["default"](props.notification).errorId && jsxRuntime.jsx("div", {
|
|
571
|
+
children: "ID (".concat(_valuesInstanceProperty__default["default"](props.notification).errorId, ")")
|
|
566
572
|
})]
|
|
567
573
|
})
|
|
568
574
|
});
|
|
569
575
|
};
|
|
570
576
|
|
|
571
577
|
UnexpectedErrorNotification.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
572
|
-
notification: _pt__default[
|
|
573
|
-
dismiss: _pt__default[
|
|
578
|
+
notification: _pt__default["default"].any.isRequired,
|
|
579
|
+
dismiss: _pt__default["default"].func.isRequired
|
|
574
580
|
} : {};
|
|
575
581
|
UnexpectedErrorNotification.displayName = 'UnexpectedErrorNotification';
|
|
576
582
|
|
|
@@ -580,32 +586,22 @@ var selectNotifications = function selectNotifications(state) {
|
|
|
580
586
|
return state.notifications;
|
|
581
587
|
};
|
|
582
588
|
var selectGlobalNotifications = reselect.createSelector(selectNotifications, function (notifications) {
|
|
583
|
-
var _context
|
|
584
|
-
|
|
585
|
-
return (
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
).call(_context, 0, 1)
|
|
590
|
-
);
|
|
589
|
+
var _context;
|
|
590
|
+
|
|
591
|
+
return _sliceInstanceProperty__default["default"](_context = _filterInstanceProperty__default["default"](notifications).call(notifications, function (notification) {
|
|
592
|
+
return notification.domain === constants.NOTIFICATION_DOMAINS.GLOBAL;
|
|
593
|
+
}) // Return only 1 at a time
|
|
594
|
+
).call(_context, 0, 1);
|
|
591
595
|
});
|
|
592
596
|
var selectPageNotifications = reselect.createSelector(selectNotifications, function (notifications) {
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
_filterInstanceProperty__default['default'](_context3 = notifications).call(_context3, function (notification) {
|
|
597
|
-
return notification.domain === constants.NOTIFICATION_DOMAINS.PAGE;
|
|
598
|
-
})
|
|
599
|
-
);
|
|
597
|
+
return _filterInstanceProperty__default["default"](notifications).call(notifications, function (notification) {
|
|
598
|
+
return notification.domain === constants.NOTIFICATION_DOMAINS.PAGE;
|
|
599
|
+
});
|
|
600
600
|
});
|
|
601
601
|
var selectSideNotifications = reselect.createSelector(selectNotifications, function (notifications) {
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
_filterInstanceProperty__default['default'](_context4 = notifications).call(_context4, function (notification) {
|
|
606
|
-
return notification.domain === constants.NOTIFICATION_DOMAINS.SIDE;
|
|
607
|
-
})
|
|
608
|
-
);
|
|
602
|
+
return _filterInstanceProperty__default["default"](notifications).call(notifications, function (notification) {
|
|
603
|
+
return notification.domain === constants.NOTIFICATION_DOMAINS.SIDE;
|
|
604
|
+
});
|
|
609
605
|
});
|
|
610
606
|
|
|
611
607
|
var getStyles = function getStyles(props) {
|
|
@@ -632,9 +628,9 @@ var _excluded = ["values"],
|
|
|
632
628
|
_excluded4 = ["text"],
|
|
633
629
|
_excluded5 = ["text"];
|
|
634
630
|
|
|
635
|
-
function ownKeys$1(object, enumerableOnly) { var keys = _Object$keys__default[
|
|
631
|
+
function ownKeys$1(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); if (enumerableOnly) { symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
636
632
|
|
|
637
|
-
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context; _forEachInstanceProperty__default[
|
|
633
|
+
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context; _forEachInstanceProperty__default["default"](_context = ownKeys$1(Object(source), true)).call(_context, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors__default["default"]) { _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)); } else { var _context2; _forEachInstanceProperty__default["default"](_context2 = ownKeys$1(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } } return target; }
|
|
638
634
|
|
|
639
635
|
var NotificationsListGlobal = function NotificationsListGlobal(props) {
|
|
640
636
|
var dispatch = reactRedux.useDispatch();
|
|
@@ -642,7 +638,7 @@ var NotificationsListGlobal = function NotificationsListGlobal(props) {
|
|
|
642
638
|
var notifications$1 = reactRedux.useSelector(selectGlobalNotifications);
|
|
643
639
|
return jsxRuntime.jsx("div", {
|
|
644
640
|
css: getStyles(props),
|
|
645
|
-
children: _mapInstanceProperty__default[
|
|
641
|
+
children: _mapInstanceProperty__default["default"](notifications$1).call(notifications$1, function (notification) {
|
|
646
642
|
// 1. Check if there is a custom notification component first
|
|
647
643
|
var CustomNotificationComponent = mapCustomNotificationToComponent(notification);
|
|
648
644
|
|
|
@@ -661,7 +657,7 @@ var NotificationsListGlobal = function NotificationsListGlobal(props) {
|
|
|
661
657
|
case constants.NOTIFICATION_KINDS_GLOBAL.info:
|
|
662
658
|
case constants.NOTIFICATION_KINDS_GLOBAL.success:
|
|
663
659
|
{
|
|
664
|
-
_valuesInstanceProperty__default[
|
|
660
|
+
_valuesInstanceProperty__default["default"](notification);
|
|
665
661
|
var genericNotification = _objectWithoutProperties(notification, _excluded);
|
|
666
662
|
|
|
667
663
|
return jsxRuntime.jsx(GenericNotification, {
|
|
@@ -707,7 +703,7 @@ var NotificationsListPage = function NotificationsListPage(props) {
|
|
|
707
703
|
var notifications$1 = reactRedux.useSelector(selectPageNotifications);
|
|
708
704
|
return jsxRuntime.jsx("div", {
|
|
709
705
|
css: getStyles(props),
|
|
710
|
-
children: _mapInstanceProperty__default[
|
|
706
|
+
children: _mapInstanceProperty__default["default"](notifications$1).call(notifications$1, function (notification) {
|
|
711
707
|
// 1. Check if there is a custom notification component first
|
|
712
708
|
var CustomNotificationComponent = mapCustomNotificationToComponent(notification);
|
|
713
709
|
|
|
@@ -726,7 +722,7 @@ var NotificationsListPage = function NotificationsListPage(props) {
|
|
|
726
722
|
case constants.NOTIFICATION_KINDS_PAGE.info:
|
|
727
723
|
case constants.NOTIFICATION_KINDS_PAGE.success:
|
|
728
724
|
{
|
|
729
|
-
_valuesInstanceProperty__default[
|
|
725
|
+
_valuesInstanceProperty__default["default"](notification);
|
|
730
726
|
var genericNotification = _objectWithoutProperties(notification, _excluded3);
|
|
731
727
|
|
|
732
728
|
return jsxRuntime.jsx(GenericNotification, {
|
|
@@ -759,7 +755,7 @@ var NotificationsListPage = function NotificationsListPage(props) {
|
|
|
759
755
|
|
|
760
756
|
return jsxRuntime.jsx(UnexpectedErrorNotification, {
|
|
761
757
|
notification: _objectSpread$1(_objectSpread$1({}, _errorNotification), {}, {
|
|
762
|
-
values: _valuesInstanceProperty__default[
|
|
758
|
+
values: _valuesInstanceProperty__default["default"](notification)
|
|
763
759
|
}),
|
|
764
760
|
dismiss: function dismiss() {
|
|
765
761
|
dispatch(notifications.removeNotification(notification.id));
|
|
@@ -780,7 +776,7 @@ var NotificationsListSide = function NotificationsListSide(props) {
|
|
|
780
776
|
var notifications$1 = reactRedux.useSelector(selectSideNotifications);
|
|
781
777
|
return jsxRuntime.jsx("div", {
|
|
782
778
|
css: getStyles(props),
|
|
783
|
-
children: _mapInstanceProperty__default[
|
|
779
|
+
children: _mapInstanceProperty__default["default"](notifications$1).call(notifications$1, function (notification) {
|
|
784
780
|
// 1. Check if there is a custom notification component first
|
|
785
781
|
var CustomNotificationComponent = mapCustomNotificationToComponent(notification);
|
|
786
782
|
|
|
@@ -830,9 +826,9 @@ var NotificationsList = function NotificationsList(props) {
|
|
|
830
826
|
|
|
831
827
|
NotificationsList.displayName = 'NotificationsList';
|
|
832
828
|
|
|
833
|
-
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default[
|
|
829
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); if (enumerableOnly) { symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
834
830
|
|
|
835
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context; _forEachInstanceProperty__default[
|
|
831
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context; _forEachInstanceProperty__default["default"](_context = ownKeys(Object(source), true)).call(_context, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors__default["default"]) { _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)); } else { var _context2; _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } } return target; }
|
|
836
832
|
var defaultProps = {
|
|
837
833
|
domain: constants.NOTIFICATION_DOMAINS.SIDE,
|
|
838
834
|
kind: constants.NOTIFICATION_KINDS_SIDE.success
|
|
@@ -846,7 +842,7 @@ var Notifier = function Notifier(props) {
|
|
|
846
842
|
domain: props.domain,
|
|
847
843
|
kind: props.kind,
|
|
848
844
|
text: props.text
|
|
849
|
-
}, isNumber__default[
|
|
845
|
+
}, isNumber__default["default"](props.dismissAfter) ? _objectSpread(_objectSpread({}, props.meta), {}, {
|
|
850
846
|
dismissAfter: props.dismissAfter
|
|
851
847
|
}) : props.meta);
|
|
852
848
|
return function () {
|
|
@@ -859,11 +855,11 @@ var Notifier = function Notifier(props) {
|
|
|
859
855
|
};
|
|
860
856
|
|
|
861
857
|
Notifier.propTypes = {
|
|
862
|
-
domain: _pt__default[
|
|
863
|
-
kind: _pt__default[
|
|
864
|
-
text: _pt__default[
|
|
865
|
-
meta: _pt__default[
|
|
866
|
-
dismissAfter: _pt__default[
|
|
858
|
+
domain: _pt__default["default"].any.isRequired,
|
|
859
|
+
kind: _pt__default["default"].any.isRequired,
|
|
860
|
+
text: _pt__default["default"].string,
|
|
861
|
+
meta: _pt__default["default"].objectOf(_pt__default["default"].any),
|
|
862
|
+
dismissAfter: _pt__default["default"].number
|
|
867
863
|
};
|
|
868
864
|
Notifier.displayName = 'Notifier';
|
|
869
865
|
Notifier.defaultProps = defaultProps;
|
|
@@ -59,8 +59,8 @@ var Spacings__default = /*#__PURE__*/_interopDefault(Spacings);
|
|
|
59
59
|
var _sliceInstanceProperty__default = /*#__PURE__*/_interopDefault(_sliceInstanceProperty);
|
|
60
60
|
var isNumber__default = /*#__PURE__*/_interopDefault(isNumber);
|
|
61
61
|
|
|
62
|
-
// NOTE: This string will be replaced
|
|
63
|
-
var version =
|
|
62
|
+
// NOTE: This string will be replaced on build time with the package version.
|
|
63
|
+
var version = "20.12.0";
|
|
64
64
|
|
|
65
65
|
var Context = /*#__PURE__*/react.createContext(function () {
|
|
66
66
|
return null;
|
|
@@ -80,8 +80,8 @@ var useCustomNotificationComponent = function useCustomNotificationComponent() {
|
|
|
80
80
|
}; // Exports
|
|
81
81
|
|
|
82
82
|
function filterDataAttributes(obj) {
|
|
83
|
-
return omitBy__default[
|
|
84
|
-
return !_startsWithInstanceProperty__default[
|
|
83
|
+
return omitBy__default["default"](obj, function (_value, key) {
|
|
84
|
+
return !_startsWithInstanceProperty__default["default"](key).call(key, 'data-');
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
87
|
|
|
@@ -149,9 +149,9 @@ var getStylesForNotification = function getStylesForNotification(props) {
|
|
|
149
149
|
}
|
|
150
150
|
};
|
|
151
151
|
|
|
152
|
-
function ownKeys$4(object, enumerableOnly) { var keys = _Object$keys__default[
|
|
152
|
+
function ownKeys$4(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); if (enumerableOnly) { symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
153
153
|
|
|
154
|
-
function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context; _forEachInstanceProperty__default[
|
|
154
|
+
function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context; _forEachInstanceProperty__default["default"](_context = ownKeys$4(Object(source), true)).call(_context, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors__default["default"]) { _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)); } else { var _context2; _forEachInstanceProperty__default["default"](_context2 = ownKeys$4(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } } return target; }
|
|
155
155
|
|
|
156
156
|
var NotificationIcon = function NotificationIcon(props) {
|
|
157
157
|
if (props.type === constants.NOTIFICATION_KINDS_SIDE.error) return jsxRuntime.jsx(icons.ErrorIcon, {
|
|
@@ -183,7 +183,7 @@ var Notification = function Notification(props) {
|
|
|
183
183
|
css: getStylesForContent(props),
|
|
184
184
|
children: props.children
|
|
185
185
|
}), props.onCloseClick ? jsxRuntime.jsx("div", {
|
|
186
|
-
children: jsxRuntime.jsx(IconButton__default[
|
|
186
|
+
children: jsxRuntime.jsx(IconButton__default["default"], {
|
|
187
187
|
label: intl.formatMessage(messages.hideNotification),
|
|
188
188
|
onClick: props.onCloseClick,
|
|
189
189
|
icon: jsxRuntime.jsx(icons.CloseBoldIcon, {}),
|
|
@@ -356,9 +356,9 @@ var apiErrorMessages = reactIntl.defineMessages({
|
|
|
356
356
|
}
|
|
357
357
|
});
|
|
358
358
|
|
|
359
|
-
function ownKeys$3(object, enumerableOnly) { var keys = _Object$keys__default[
|
|
359
|
+
function ownKeys$3(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); if (enumerableOnly) { symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
360
360
|
|
|
361
|
-
function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context6; _forEachInstanceProperty__default[
|
|
361
|
+
function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context6; _forEachInstanceProperty__default["default"](_context6 = ownKeys$3(Object(source), true)).call(_context6, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors__default["default"]) { _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)); } else { var _context7; _forEachInstanceProperty__default["default"](_context7 = ownKeys$3(Object(source))).call(_context7, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } } return target; }
|
|
362
362
|
var regexInvalidOperationRequiredAttribute = /Required attribute '(.*)' cannot be removed/;
|
|
363
363
|
|
|
364
364
|
// The values passed to the Intl message must be a map of scalar values.
|
|
@@ -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`.
|
|
@@ -409,12 +410,12 @@ var FormattedErrorMessage = function FormattedErrorMessage(props) {
|
|
|
409
410
|
}
|
|
410
411
|
|
|
411
412
|
return jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
412
|
-
children: _filterInstanceProperty__default[
|
|
413
|
+
children: _filterInstanceProperty__default["default"](_context2 = [props.error.message, props.error.detailedErrorMessage && "(".concat(props.error.detailedErrorMessage, ")")]).call(_context2, Boolean).join(' ')
|
|
413
414
|
});
|
|
414
415
|
};
|
|
415
416
|
|
|
416
417
|
FormattedErrorMessage.propTypes = {
|
|
417
|
-
error: _pt__default[
|
|
418
|
+
error: _pt__default["default"].any.isRequired
|
|
418
419
|
};
|
|
419
420
|
FormattedErrorMessage.displayName = 'FormattedErrorMessage';
|
|
420
421
|
|
|
@@ -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
|
-
if (has__default[
|
|
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
|
|
|
@@ -502,8 +505,11 @@ var ApiErrorNotification = function ApiErrorNotification(props) {
|
|
|
502
505
|
domain: props.notification.domain,
|
|
503
506
|
onCloseClick: props.dismiss,
|
|
504
507
|
children: jsxRuntime.jsx("ul", {
|
|
505
|
-
children: _valuesInstanceProperty__default[
|
|
506
|
-
var
|
|
508
|
+
children: _valuesInstanceProperty__default["default"](props.notification) && _mapInstanceProperty__default["default"](_context = _valuesInstanceProperty__default["default"](props.notification).errors).call(_context, function (error, idx) {
|
|
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
|
/**
|
|
@@ -529,20 +535,20 @@ var ApiErrorNotification = function ApiErrorNotification(props) {
|
|
|
529
535
|
ApiErrorNotification.propTypes = {};
|
|
530
536
|
ApiErrorNotification.displayName = 'ApiErrorNotification';
|
|
531
537
|
|
|
532
|
-
function ownKeys$2(object, enumerableOnly) { var keys = _Object$keys__default[
|
|
538
|
+
function ownKeys$2(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); if (enumerableOnly) { symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
533
539
|
|
|
534
|
-
function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context; _forEachInstanceProperty__default[
|
|
540
|
+
function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context; _forEachInstanceProperty__default["default"](_context = ownKeys$2(Object(source), true)).call(_context, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors__default["default"]) { _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)); } else { var _context2; _forEachInstanceProperty__default["default"](_context2 = ownKeys$2(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } } return target; }
|
|
535
541
|
|
|
536
542
|
var UnexpectedErrorNotification = function UnexpectedErrorNotification(props) {
|
|
537
543
|
return jsxRuntime.jsx(Notification, {
|
|
538
544
|
type: "error",
|
|
539
545
|
domain: props.notification.domain,
|
|
540
546
|
onCloseClick: props.dismiss,
|
|
541
|
-
children: jsxRuntime.jsxs(Spacings__default[
|
|
547
|
+
children: jsxRuntime.jsxs(Spacings__default["default"].Stack, {
|
|
542
548
|
children: [jsxRuntime.jsx("div", {
|
|
543
549
|
children: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$2({}, apiErrorMessages.General))
|
|
544
|
-
}), _valuesInstanceProperty__default[
|
|
545
|
-
children: "ID (".concat(_valuesInstanceProperty__default[
|
|
550
|
+
}), _valuesInstanceProperty__default["default"](props.notification) && _valuesInstanceProperty__default["default"](props.notification).errorId && jsxRuntime.jsx("div", {
|
|
551
|
+
children: "ID (".concat(_valuesInstanceProperty__default["default"](props.notification).errorId, ")")
|
|
546
552
|
})]
|
|
547
553
|
})
|
|
548
554
|
});
|
|
@@ -557,32 +563,22 @@ var selectNotifications = function selectNotifications(state) {
|
|
|
557
563
|
return state.notifications;
|
|
558
564
|
};
|
|
559
565
|
var selectGlobalNotifications = reselect.createSelector(selectNotifications, function (notifications) {
|
|
560
|
-
var _context
|
|
561
|
-
|
|
562
|
-
return (
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
).call(_context, 0, 1)
|
|
567
|
-
);
|
|
566
|
+
var _context;
|
|
567
|
+
|
|
568
|
+
return _sliceInstanceProperty__default["default"](_context = _filterInstanceProperty__default["default"](notifications).call(notifications, function (notification) {
|
|
569
|
+
return notification.domain === constants.NOTIFICATION_DOMAINS.GLOBAL;
|
|
570
|
+
}) // Return only 1 at a time
|
|
571
|
+
).call(_context, 0, 1);
|
|
568
572
|
});
|
|
569
573
|
var selectPageNotifications = reselect.createSelector(selectNotifications, function (notifications) {
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
_filterInstanceProperty__default['default'](_context3 = notifications).call(_context3, function (notification) {
|
|
574
|
-
return notification.domain === constants.NOTIFICATION_DOMAINS.PAGE;
|
|
575
|
-
})
|
|
576
|
-
);
|
|
574
|
+
return _filterInstanceProperty__default["default"](notifications).call(notifications, function (notification) {
|
|
575
|
+
return notification.domain === constants.NOTIFICATION_DOMAINS.PAGE;
|
|
576
|
+
});
|
|
577
577
|
});
|
|
578
578
|
var selectSideNotifications = reselect.createSelector(selectNotifications, function (notifications) {
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
_filterInstanceProperty__default['default'](_context4 = notifications).call(_context4, function (notification) {
|
|
583
|
-
return notification.domain === constants.NOTIFICATION_DOMAINS.SIDE;
|
|
584
|
-
})
|
|
585
|
-
);
|
|
579
|
+
return _filterInstanceProperty__default["default"](notifications).call(notifications, function (notification) {
|
|
580
|
+
return notification.domain === constants.NOTIFICATION_DOMAINS.SIDE;
|
|
581
|
+
});
|
|
586
582
|
});
|
|
587
583
|
|
|
588
584
|
var getStyles = function getStyles(props) {
|
|
@@ -609,9 +605,9 @@ var _excluded = ["values"],
|
|
|
609
605
|
_excluded4 = ["text"],
|
|
610
606
|
_excluded5 = ["text"];
|
|
611
607
|
|
|
612
|
-
function ownKeys$1(object, enumerableOnly) { var keys = _Object$keys__default[
|
|
608
|
+
function ownKeys$1(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); if (enumerableOnly) { symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
613
609
|
|
|
614
|
-
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context; _forEachInstanceProperty__default[
|
|
610
|
+
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context; _forEachInstanceProperty__default["default"](_context = ownKeys$1(Object(source), true)).call(_context, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors__default["default"]) { _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)); } else { var _context2; _forEachInstanceProperty__default["default"](_context2 = ownKeys$1(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } } return target; }
|
|
615
611
|
|
|
616
612
|
var NotificationsListGlobal = function NotificationsListGlobal(props) {
|
|
617
613
|
var dispatch = reactRedux.useDispatch();
|
|
@@ -619,7 +615,7 @@ var NotificationsListGlobal = function NotificationsListGlobal(props) {
|
|
|
619
615
|
var notifications$1 = reactRedux.useSelector(selectGlobalNotifications);
|
|
620
616
|
return jsxRuntime.jsx("div", {
|
|
621
617
|
css: getStyles(props),
|
|
622
|
-
children: _mapInstanceProperty__default[
|
|
618
|
+
children: _mapInstanceProperty__default["default"](notifications$1).call(notifications$1, function (notification) {
|
|
623
619
|
// 1. Check if there is a custom notification component first
|
|
624
620
|
var CustomNotificationComponent = mapCustomNotificationToComponent(notification);
|
|
625
621
|
|
|
@@ -638,7 +634,7 @@ var NotificationsListGlobal = function NotificationsListGlobal(props) {
|
|
|
638
634
|
case constants.NOTIFICATION_KINDS_GLOBAL.info:
|
|
639
635
|
case constants.NOTIFICATION_KINDS_GLOBAL.success:
|
|
640
636
|
{
|
|
641
|
-
_valuesInstanceProperty__default[
|
|
637
|
+
_valuesInstanceProperty__default["default"](notification);
|
|
642
638
|
var genericNotification = _objectWithoutProperties(notification, _excluded);
|
|
643
639
|
|
|
644
640
|
return jsxRuntime.jsx(GenericNotification, {
|
|
@@ -678,7 +674,7 @@ var NotificationsListPage = function NotificationsListPage(props) {
|
|
|
678
674
|
var notifications$1 = reactRedux.useSelector(selectPageNotifications);
|
|
679
675
|
return jsxRuntime.jsx("div", {
|
|
680
676
|
css: getStyles(props),
|
|
681
|
-
children: _mapInstanceProperty__default[
|
|
677
|
+
children: _mapInstanceProperty__default["default"](notifications$1).call(notifications$1, function (notification) {
|
|
682
678
|
// 1. Check if there is a custom notification component first
|
|
683
679
|
var CustomNotificationComponent = mapCustomNotificationToComponent(notification);
|
|
684
680
|
|
|
@@ -697,7 +693,7 @@ var NotificationsListPage = function NotificationsListPage(props) {
|
|
|
697
693
|
case constants.NOTIFICATION_KINDS_PAGE.info:
|
|
698
694
|
case constants.NOTIFICATION_KINDS_PAGE.success:
|
|
699
695
|
{
|
|
700
|
-
_valuesInstanceProperty__default[
|
|
696
|
+
_valuesInstanceProperty__default["default"](notification);
|
|
701
697
|
var genericNotification = _objectWithoutProperties(notification, _excluded3);
|
|
702
698
|
|
|
703
699
|
return jsxRuntime.jsx(GenericNotification, {
|
|
@@ -730,7 +726,7 @@ var NotificationsListPage = function NotificationsListPage(props) {
|
|
|
730
726
|
|
|
731
727
|
return jsxRuntime.jsx(UnexpectedErrorNotification, {
|
|
732
728
|
notification: _objectSpread$1(_objectSpread$1({}, _errorNotification), {}, {
|
|
733
|
-
values: _valuesInstanceProperty__default[
|
|
729
|
+
values: _valuesInstanceProperty__default["default"](notification)
|
|
734
730
|
}),
|
|
735
731
|
dismiss: function dismiss() {
|
|
736
732
|
dispatch(notifications.removeNotification(notification.id));
|
|
@@ -751,7 +747,7 @@ var NotificationsListSide = function NotificationsListSide(props) {
|
|
|
751
747
|
var notifications$1 = reactRedux.useSelector(selectSideNotifications);
|
|
752
748
|
return jsxRuntime.jsx("div", {
|
|
753
749
|
css: getStyles(props),
|
|
754
|
-
children: _mapInstanceProperty__default[
|
|
750
|
+
children: _mapInstanceProperty__default["default"](notifications$1).call(notifications$1, function (notification) {
|
|
755
751
|
// 1. Check if there is a custom notification component first
|
|
756
752
|
var CustomNotificationComponent = mapCustomNotificationToComponent(notification);
|
|
757
753
|
|
|
@@ -801,9 +797,9 @@ var NotificationsList = function NotificationsList(props) {
|
|
|
801
797
|
|
|
802
798
|
NotificationsList.displayName = 'NotificationsList';
|
|
803
799
|
|
|
804
|
-
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default[
|
|
800
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); if (enumerableOnly) { symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
805
801
|
|
|
806
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context; _forEachInstanceProperty__default[
|
|
802
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context; _forEachInstanceProperty__default["default"](_context = ownKeys(Object(source), true)).call(_context, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors__default["default"]) { _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)); } else { var _context2; _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } } return target; }
|
|
807
803
|
var defaultProps = {
|
|
808
804
|
domain: constants.NOTIFICATION_DOMAINS.SIDE,
|
|
809
805
|
kind: constants.NOTIFICATION_KINDS_SIDE.success
|
|
@@ -817,7 +813,7 @@ var Notifier = function Notifier(props) {
|
|
|
817
813
|
domain: props.domain,
|
|
818
814
|
kind: props.kind,
|
|
819
815
|
text: props.text
|
|
820
|
-
}, isNumber__default[
|
|
816
|
+
}, isNumber__default["default"](props.dismissAfter) ? _objectSpread(_objectSpread({}, props.meta), {}, {
|
|
821
817
|
dismissAfter: props.dismissAfter
|
|
822
818
|
}) : props.meta);
|
|
823
819
|
return function () {
|
|
@@ -830,11 +826,11 @@ var Notifier = function Notifier(props) {
|
|
|
830
826
|
};
|
|
831
827
|
|
|
832
828
|
Notifier.propTypes = {
|
|
833
|
-
domain: _pt__default[
|
|
834
|
-
kind: _pt__default[
|
|
835
|
-
text: _pt__default[
|
|
836
|
-
meta: _pt__default[
|
|
837
|
-
dismissAfter: _pt__default[
|
|
829
|
+
domain: _pt__default["default"].any.isRequired,
|
|
830
|
+
kind: _pt__default["default"].any.isRequired,
|
|
831
|
+
text: _pt__default["default"].string,
|
|
832
|
+
meta: _pt__default["default"].objectOf(_pt__default["default"].any),
|
|
833
|
+
dismissAfter: _pt__default["default"].number
|
|
838
834
|
};
|
|
839
835
|
Notifier.displayName = 'Notifier';
|
|
840
836
|
Notifier.defaultProps = defaultProps;
|
|
@@ -33,8 +33,8 @@ import { createSelector } from 'reselect';
|
|
|
33
33
|
import isNumber from 'lodash/isNumber';
|
|
34
34
|
import { useShowNotification } from '@commercetools-frontend/actions-global';
|
|
35
35
|
|
|
36
|
-
// NOTE: This string will be replaced
|
|
37
|
-
var version =
|
|
36
|
+
// NOTE: This string will be replaced on build time with the package version.
|
|
37
|
+
var version = "20.12.0";
|
|
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
|
/**
|
|
@@ -554,32 +560,22 @@ var selectNotifications = function selectNotifications(state) {
|
|
|
554
560
|
return state.notifications;
|
|
555
561
|
};
|
|
556
562
|
var selectGlobalNotifications = createSelector(selectNotifications, function (notifications) {
|
|
557
|
-
var _context
|
|
558
|
-
|
|
559
|
-
return (
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
).call(_context, 0, 1)
|
|
564
|
-
);
|
|
563
|
+
var _context;
|
|
564
|
+
|
|
565
|
+
return _sliceInstanceProperty(_context = _filterInstanceProperty(notifications).call(notifications, function (notification) {
|
|
566
|
+
return notification.domain === NOTIFICATION_DOMAINS.GLOBAL;
|
|
567
|
+
}) // Return only 1 at a time
|
|
568
|
+
).call(_context, 0, 1);
|
|
565
569
|
});
|
|
566
570
|
var selectPageNotifications = createSelector(selectNotifications, function (notifications) {
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
_filterInstanceProperty(_context3 = notifications).call(_context3, function (notification) {
|
|
571
|
-
return notification.domain === NOTIFICATION_DOMAINS.PAGE;
|
|
572
|
-
})
|
|
573
|
-
);
|
|
571
|
+
return _filterInstanceProperty(notifications).call(notifications, function (notification) {
|
|
572
|
+
return notification.domain === NOTIFICATION_DOMAINS.PAGE;
|
|
573
|
+
});
|
|
574
574
|
});
|
|
575
575
|
var selectSideNotifications = createSelector(selectNotifications, function (notifications) {
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
_filterInstanceProperty(_context4 = notifications).call(_context4, function (notification) {
|
|
580
|
-
return notification.domain === NOTIFICATION_DOMAINS.SIDE;
|
|
581
|
-
})
|
|
582
|
-
);
|
|
576
|
+
return _filterInstanceProperty(notifications).call(notifications, function (notification) {
|
|
577
|
+
return notification.domain === NOTIFICATION_DOMAINS.SIDE;
|
|
578
|
+
});
|
|
583
579
|
});
|
|
584
580
|
|
|
585
581
|
var getStyles = function getStyles(props) {
|
|
@@ -1,6 +1,12 @@
|
|
|
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: import("reselect").OutputSelector<TAppState, TAppNotificationGlobal[], (
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
export declare const selectGlobalNotifications: import("reselect").OutputSelector<[(state: TAppState) => (TAppNotificationGlobal | TAppNotificationPage | TAppNotificationSide)[]], TAppNotificationGlobal[], never, ((args_0: (TAppNotificationGlobal | TAppNotificationPage | TAppNotificationSide)[], ...args_1: unknown[]) => TAppNotificationGlobal[]) & ((...args: any[]) => any) & {
|
|
5
|
+
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
|
+
clearCache: () => void;
|
|
9
|
+
}>;
|
|
10
|
+
export declare const selectSideNotifications: import("reselect").OutputSelector<[(state: TAppState) => (TAppNotificationGlobal | TAppNotificationPage | TAppNotificationSide)[]], TAppNotificationSide[], never, ((args_0: (TAppNotificationGlobal | TAppNotificationPage | TAppNotificationSide)[], ...args_1: unknown[]) => TAppNotificationSide[]) & ((...args: any[]) => any) & {
|
|
11
|
+
clearCache: () => void;
|
|
12
|
+
}>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "
|
|
1
|
+
declare const _default: "__@APPLICATION_KIT_PACKAGE/VERSION_OF_RELEASE__";
|
|
2
2
|
export default _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-frontend/react-notifications",
|
|
3
|
-
"version": "20.
|
|
3
|
+
"version": "20.12.0",
|
|
4
4
|
"description": "React bindings for @commercetools-frontend/notifications",
|
|
5
5
|
"bugs": "https://github.com/commercetools/merchant-center-application-kit/issues",
|
|
6
6
|
"repository": {
|
|
@@ -11,28 +11,24 @@
|
|
|
11
11
|
"homepage": "https://docs.commercetools.com/custom-applications",
|
|
12
12
|
"keywords": ["javascript", "frontend", "react", "toolkit"],
|
|
13
13
|
"license": "MIT",
|
|
14
|
-
"private": false,
|
|
15
14
|
"publishConfig": {
|
|
16
15
|
"access": "public"
|
|
17
16
|
},
|
|
18
17
|
"main": "dist/commercetools-frontend-react-notifications.cjs.js",
|
|
19
18
|
"module": "dist/commercetools-frontend-react-notifications.esm.js",
|
|
20
19
|
"files": ["dist", "package.json", "LICENSE", "README.md"],
|
|
21
|
-
"scripts": {
|
|
22
|
-
"prepare": "./../../scripts/version.js replace"
|
|
23
|
-
},
|
|
24
20
|
"dependencies": {
|
|
25
21
|
"@babel/runtime": "7.15.4",
|
|
26
22
|
"@babel/runtime-corejs3": "7.15.4",
|
|
27
|
-
"@commercetools-frontend/actions-global": "20.
|
|
28
|
-
"@commercetools-frontend/constants": "20.
|
|
29
|
-
"@commercetools-frontend/notifications": "20.10.
|
|
30
|
-
"@commercetools-frontend/sentry": "20.
|
|
23
|
+
"@commercetools-frontend/actions-global": "20.12.0",
|
|
24
|
+
"@commercetools-frontend/constants": "20.12.0",
|
|
25
|
+
"@commercetools-frontend/notifications": "20.10.6",
|
|
26
|
+
"@commercetools-frontend/sentry": "20.12.0",
|
|
31
27
|
"@commercetools-uikit/design-system": "^12.2.2",
|
|
32
28
|
"@commercetools-uikit/icon-button": "^12.2.2",
|
|
33
29
|
"@commercetools-uikit/icons": "^12.2.2",
|
|
34
30
|
"@commercetools-uikit/spacings": "^12.2.2",
|
|
35
|
-
"@emotion/react": "11.
|
|
31
|
+
"@emotion/react": "11.5.0",
|
|
36
32
|
"@emotion/styled": "11.3.0",
|
|
37
33
|
"@types/history": "4.7.9",
|
|
38
34
|
"@types/lodash": "^4.14.167",
|
|
@@ -46,14 +42,14 @@
|
|
|
46
42
|
"moment": "^2.29.1",
|
|
47
43
|
"moment-timezone": "^0.5.32",
|
|
48
44
|
"prop-types": "15.7.2",
|
|
49
|
-
"reselect": "4.
|
|
45
|
+
"reselect": "4.1.0"
|
|
50
46
|
},
|
|
51
47
|
"devDependencies": {
|
|
52
48
|
"@testing-library/react": "12.1.2",
|
|
53
49
|
"react": "17.0.2",
|
|
54
50
|
"react-dom": "17.0.2",
|
|
55
|
-
"react-intl": "5.
|
|
56
|
-
"react-redux": "7.2.
|
|
51
|
+
"react-intl": "5.21.0",
|
|
52
|
+
"react-redux": "7.2.6",
|
|
57
53
|
"react-router-dom": "5.3.0"
|
|
58
54
|
},
|
|
59
55
|
"peerDependencies": {
|