@commercetools-frontend/react-notifications 22.2.1 → 22.3.1
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 +68 -168
- package/dist/commercetools-frontend-react-notifications.cjs.prod.js +61 -160
- package/dist/commercetools-frontend-react-notifications.esm.js +69 -168
- package/dist/declarations/src/components/map-notification-to-component/map-notification-to-component.d.ts +1 -1
- package/dist/declarations/src/components/notification/notification.d.ts +1 -1
- package/dist/declarations/src/components/notification/notification.styles.d.ts +5 -5
- package/dist/declarations/src/components/notification-kinds/api-error/api-error.d.ts +1 -1
- package/dist/declarations/src/components/notification-kinds/api-error-message/api-error-message.d.ts +13 -10
- package/dist/declarations/src/components/notification-kinds/generic/generic.d.ts +1 -1
- package/dist/declarations/src/components/notification-kinds/unexpected-error/unexpected-error.d.ts +1 -1
- package/dist/declarations/src/components/notifications-list/notifications-list.d.ts +1 -1
- package/dist/declarations/src/components/notifications-list/notifications-list.styles.d.ts +1 -1
- package/package.json +25 -12
|
@@ -16,9 +16,7 @@ var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/obje
|
|
|
16
16
|
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
17
17
|
var reactIntl = require('react-intl');
|
|
18
18
|
var constants = require('@commercetools-frontend/constants');
|
|
19
|
-
var designSystem = require('@commercetools-uikit/design-system');
|
|
20
19
|
var hooks = require('@commercetools-uikit/hooks');
|
|
21
|
-
var IconButton = require('@commercetools-uikit/icon-button');
|
|
22
20
|
var icons = require('@commercetools-uikit/icons');
|
|
23
21
|
var SecondaryIconButton = require('@commercetools-uikit/secondary-icon-button');
|
|
24
22
|
var utils = require('@commercetools-uikit/utils');
|
|
@@ -26,6 +24,7 @@ var _startsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable
|
|
|
26
24
|
var omitBy = require('lodash/omitBy');
|
|
27
25
|
var _taggedTemplateLiteral = require('@babel/runtime-corejs3/helpers/taggedTemplateLiteral');
|
|
28
26
|
var react$1 = require('@emotion/react');
|
|
27
|
+
var designSystem = require('@commercetools-uikit/design-system');
|
|
29
28
|
var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
|
|
30
29
|
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
31
30
|
var _valuesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/values');
|
|
@@ -51,7 +50,6 @@ var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachIns
|
|
|
51
50
|
var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
|
|
52
51
|
var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
|
|
53
52
|
var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
|
|
54
|
-
var IconButton__default = /*#__PURE__*/_interopDefault(IconButton);
|
|
55
53
|
var SecondaryIconButton__default = /*#__PURE__*/_interopDefault(SecondaryIconButton);
|
|
56
54
|
var _startsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_startsWithInstanceProperty);
|
|
57
55
|
var omitBy__default = /*#__PURE__*/_interopDefault(omitBy);
|
|
@@ -64,20 +62,18 @@ var _sliceInstanceProperty__default = /*#__PURE__*/_interopDefault(_sliceInstanc
|
|
|
64
62
|
var isNumber__default = /*#__PURE__*/_interopDefault(isNumber);
|
|
65
63
|
|
|
66
64
|
// NOTE: This string will be replaced on build time with the package version.
|
|
67
|
-
var version = "22.
|
|
65
|
+
var version = "22.3.1";
|
|
68
66
|
|
|
69
67
|
const Context = /*#__PURE__*/react.createContext(() => null);
|
|
70
|
-
|
|
71
68
|
function NotificationProviderForCustomComponent(props) {
|
|
72
69
|
return jsxRuntime.jsx(Context.Provider, {
|
|
73
70
|
value: props.mapNotificationToComponent,
|
|
74
71
|
children: props.children
|
|
75
72
|
});
|
|
76
73
|
}
|
|
77
|
-
|
|
78
74
|
NotificationProviderForCustomComponent.propTypes = {};
|
|
79
75
|
NotificationProviderForCustomComponent.displayName = 'NotificationProviderForCustomComponent';
|
|
80
|
-
const useCustomNotificationComponent = () => react.useContext(Context);
|
|
76
|
+
const useCustomNotificationComponent = () => react.useContext(Context);
|
|
81
77
|
|
|
82
78
|
function filterDataAttributes(obj) {
|
|
83
79
|
return omitBy__default["default"](obj, (_value, key) => !_startsWithInstanceProperty__default["default"](key).call(key, 'data-'));
|
|
@@ -92,144 +88,104 @@ var messages = reactIntl.defineMessages({
|
|
|
92
88
|
});
|
|
93
89
|
|
|
94
90
|
var _templateObject, _templateObject2;
|
|
95
|
-
|
|
96
91
|
const getColorByType = value => {
|
|
97
92
|
switch (value) {
|
|
98
93
|
case constants.NOTIFICATION_KINDS_SIDE.success:
|
|
99
94
|
return designSystem.designTokens.colorPrimary;
|
|
100
|
-
|
|
101
95
|
case constants.NOTIFICATION_KINDS_SIDE.info:
|
|
102
96
|
return designSystem.designTokens.colorInfo;
|
|
103
|
-
|
|
104
97
|
case constants.NOTIFICATION_KINDS_SIDE.error:
|
|
105
98
|
return designSystem.designTokens.colorError;
|
|
106
|
-
|
|
107
99
|
case constants.NOTIFICATION_KINDS_SIDE.warning:
|
|
108
100
|
return designSystem.designTokens.colorWarning;
|
|
109
|
-
|
|
110
101
|
default:
|
|
111
102
|
return 'transparent';
|
|
112
103
|
}
|
|
113
104
|
};
|
|
114
|
-
|
|
115
105
|
const getBorderColor = notificationKind => {
|
|
116
106
|
switch (notificationKind) {
|
|
117
107
|
case constants.NOTIFICATION_KINDS_SIDE.success:
|
|
118
108
|
return designSystem.designTokens.colorPrimary85;
|
|
119
|
-
|
|
120
109
|
case constants.NOTIFICATION_KINDS_SIDE.info:
|
|
121
110
|
return designSystem.designTokens.colorInfo85;
|
|
122
|
-
|
|
123
111
|
case constants.NOTIFICATION_KINDS_SIDE.error:
|
|
124
112
|
return designSystem.designTokens.colorError85;
|
|
125
|
-
|
|
126
113
|
case constants.NOTIFICATION_KINDS_SIDE.warning:
|
|
127
114
|
return designSystem.designTokens.colorWarning85;
|
|
128
|
-
|
|
129
115
|
default:
|
|
130
116
|
return 'transparent';
|
|
131
117
|
}
|
|
132
118
|
};
|
|
133
|
-
|
|
134
119
|
const showNotificationAnimation = react$1.keyframes(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n 0% {\n max-height: 0;\n padding-top: 0;\n padding-bottom: 0;\n overflow: hidden;\n }\n 100% {\n max-height: 200px;\n }\n"])));
|
|
135
120
|
const showNotificationSideAnimation = react$1.keyframes(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n 0% {\n transform: translateX(50px);\n }\n 100% {\n transform: translateX(0);\n }\n"])));
|
|
136
|
-
|
|
137
121
|
const getStylesForNotificationIcon = props => /*#__PURE__*/react$1.css("display:flex;align-items:center;justify-content:center;position:absolute;left:0;top:0;width:48px;height:100%;color:", designSystem.designTokens.colorSurface, ";border-radius:3px 0 0 3px;background:", getColorByType(props.type), ";" + ("" ), "" );
|
|
138
|
-
|
|
139
|
-
const getStylesForCloseIcon = props => /*#__PURE__*/react$1.css("display:flex;justify-content:center;", props.isNewTheme ? '& svg { width: 16px; height: 16px; }' : '', " ", props.isNewTheme && props.domain !== constants.NOTIFICATION_DOMAINS.SIDE ? '& svg { fill: ' + designSystem.designTokens.colorSurface + '; }' : '', ";" + ("" ), "" );
|
|
140
|
-
|
|
122
|
+
const getStylesForCloseIcon = props => /*#__PURE__*/react$1.css("display:flex;justify-content:center;& svg{width:16px;height:16px;}", props.domain !== constants.NOTIFICATION_DOMAINS.SIDE ? '& svg { fill: ' + designSystem.designTokens.colorSurface + '; }' : '', ";" + ("" ), "" );
|
|
141
123
|
const getStylesForContent = props => {
|
|
142
124
|
const fontColor = props.domain === constants.NOTIFICATION_DOMAINS.SIDE ? designSystem.designTokens.colorSolid : designSystem.designTokens.colorSurface;
|
|
143
|
-
return /*#__PURE__*/react$1.css("flex-basis:100%;flex-grow:1;padding:0 "
|
|
125
|
+
return /*#__PURE__*/react$1.css("flex-basis:100%;flex-grow:1;padding:", "0 ".concat(designSystem.designTokens.spacingM), ";margin:0;font-size:", props.domain === constants.NOTIFICATION_DOMAINS.SIDE ? '1rem' : 'inherit', ";color:", fontColor, ";p{color:", fontColor, ";}ul{padding:0;margin:0;list-style:none;}" + ("" ), "" );
|
|
144
126
|
};
|
|
145
|
-
|
|
146
127
|
const getStylesForNotification = props => {
|
|
147
128
|
const baseStyles = /*#__PURE__*/react$1.css("position:relative;display:flex;align-items:center;padding:", designSystem.designTokens.spacingM, ";color:", designSystem.designTokens.colorSurface, ";" + ("" ), "" );
|
|
148
129
|
const pageStyles = /*#__PURE__*/react$1.css(baseStyles, ";animation:", showNotificationAnimation, " 0.3s forwards;text-align:center;background-color:", props.fixed ? 'transparent' : getColorByType(props.type), ";>*+*{margin-left:", designSystem.designTokens.spacingS, ";}" + ("" ), "" );
|
|
149
|
-
|
|
150
130
|
switch (props.domain) {
|
|
151
131
|
case constants.NOTIFICATION_DOMAINS.GLOBAL:
|
|
152
132
|
return /*#__PURE__*/react$1.css(pageStyles, ";background-color:", getColorByType(props.type), ";" + ("" ), "" );
|
|
153
|
-
|
|
154
133
|
case constants.NOTIFICATION_DOMAINS.PAGE:
|
|
155
134
|
return pageStyles;
|
|
156
|
-
|
|
157
135
|
case constants.NOTIFICATION_DOMAINS.SIDE:
|
|
158
136
|
{
|
|
159
|
-
const sideStyles = /*#__PURE__*/react$1.css(baseStyles, ";animation:", showNotificationAnimation, " 0.3s forwards;padding:", designSystem.designTokens.spacingM, " ", designSystem.designTokens.spacingM, " ", designSystem.designTokens.spacingM, " 50px!important;text-align:left;background:", designSystem.designTokens.colorSurface, ";border:1px solid ",
|
|
137
|
+
const sideStyles = /*#__PURE__*/react$1.css(baseStyles, ";animation:", showNotificationAnimation, " 0.3s forwards;padding:", designSystem.designTokens.spacingM, " ", designSystem.designTokens.spacingM, " ", designSystem.designTokens.spacingM, " 50px!important;text-align:left;background:", designSystem.designTokens.colorSurface, ";border:1px solid ", getBorderColor(props.type), ";box-shadow:0px 2px 5px 0px rgba(0, 0, 0, 0.15);border-radius:", designSystem.designTokens.borderRadius6, ";word-break:break-word;hyphens:auto;" + ("" ), "" );
|
|
160
138
|
if (props.fixed) return sideStyles;
|
|
161
139
|
return /*#__PURE__*/react$1.css(sideStyles, ";animation:", showNotificationSideAnimation, " 0.3s forwards;position:relative;z-index:10000;margin-top:", designSystem.designTokens.spacingL, "!important;right:", designSystem.designTokens.spacingXl, ";float:right;clear:both;max-width:50%;" + ("" ), "" );
|
|
162
140
|
}
|
|
163
|
-
|
|
164
141
|
default:
|
|
165
142
|
return /*#__PURE__*/react$1.css("" , "" );
|
|
166
143
|
}
|
|
167
144
|
};
|
|
168
145
|
|
|
169
146
|
function ownKeys$4(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); 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; }
|
|
170
|
-
|
|
171
147
|
function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$4(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _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; }
|
|
172
148
|
const sequentialId = utils.createSequentialId('notification-');
|
|
173
|
-
|
|
174
149
|
const NotificationIcon = props => {
|
|
175
150
|
if (props.type === constants.NOTIFICATION_KINDS_SIDE.error) {
|
|
176
151
|
return jsxRuntime.jsx(icons.ErrorIcon, {
|
|
177
152
|
color: props.color
|
|
178
153
|
});
|
|
179
154
|
}
|
|
180
|
-
|
|
181
155
|
if (props.type === constants.NOTIFICATION_KINDS_SIDE.info) {
|
|
182
|
-
return
|
|
183
|
-
color: props.color
|
|
184
|
-
}) : jsxRuntime.jsx(icons.InfoIcon, {
|
|
156
|
+
return jsxRuntime.jsx(icons.InformationIcon, {
|
|
185
157
|
color: props.color
|
|
186
158
|
});
|
|
187
159
|
}
|
|
188
|
-
|
|
189
160
|
if (props.type === constants.NOTIFICATION_KINDS_SIDE.warning) {
|
|
190
161
|
return jsxRuntime.jsx(icons.WarningIcon, {
|
|
191
162
|
color: props.color
|
|
192
163
|
});
|
|
193
164
|
}
|
|
194
|
-
|
|
195
165
|
return jsxRuntime.jsx(icons.CheckBoldIcon, {
|
|
196
166
|
color: props.color
|
|
197
167
|
});
|
|
198
168
|
};
|
|
199
|
-
|
|
200
169
|
NotificationIcon.propTypes = {};
|
|
201
170
|
NotificationIcon.displayName = 'NotificationIcon';
|
|
202
171
|
const defaultProps$1 = {
|
|
203
172
|
fixed: false
|
|
204
173
|
};
|
|
205
|
-
|
|
206
174
|
const Notification = props => {
|
|
207
175
|
const intl = reactIntl.useIntl();
|
|
208
176
|
const id = hooks.useFieldId(undefined, sequentialId);
|
|
209
|
-
|
|
210
|
-
const _useTheme = designSystem.useTheme(),
|
|
211
|
-
isNewTheme = _useTheme.isNewTheme,
|
|
212
|
-
themedValue = _useTheme.themedValue;
|
|
213
|
-
|
|
214
|
-
const Button = themedValue(IconButton__default["default"], SecondaryIconButton__default["default"]);
|
|
215
177
|
return jsxRuntime.jsxs("div", _objectSpread$4(_objectSpread$4({
|
|
216
178
|
role: "alertdialog",
|
|
217
179
|
"aria-describedby": id,
|
|
218
|
-
css: getStylesForNotification(
|
|
219
|
-
isNewTheme
|
|
220
|
-
}))
|
|
180
|
+
css: getStylesForNotification(props)
|
|
221
181
|
}, filterDataAttributes(props)), {}, {
|
|
222
182
|
children: [jsxRuntime.jsx("div", {
|
|
223
183
|
id: id,
|
|
224
|
-
css: getStylesForContent(
|
|
225
|
-
isNewTheme
|
|
226
|
-
})),
|
|
184
|
+
css: getStylesForContent(props),
|
|
227
185
|
children: props.children
|
|
228
186
|
}), props.onCloseClick ? jsxRuntime.jsx("div", {
|
|
229
|
-
css: getStylesForCloseIcon(
|
|
230
|
-
|
|
231
|
-
})),
|
|
232
|
-
children: jsxRuntime.jsx(Button, {
|
|
187
|
+
css: getStylesForCloseIcon(props),
|
|
188
|
+
children: jsxRuntime.jsx(SecondaryIconButton__default["default"], {
|
|
233
189
|
label: intl.formatMessage(messages.hideNotification),
|
|
234
190
|
onClick: props.onCloseClick,
|
|
235
191
|
icon: jsxRuntime.jsx(icons.CloseBoldIcon, {}),
|
|
@@ -239,13 +195,11 @@ const Notification = props => {
|
|
|
239
195
|
css: getStylesForNotificationIcon(props),
|
|
240
196
|
children: jsxRuntime.jsx(NotificationIcon, {
|
|
241
197
|
type: props.type,
|
|
242
|
-
color: "surface"
|
|
243
|
-
isNewTheme: isNewTheme
|
|
198
|
+
color: "surface"
|
|
244
199
|
})
|
|
245
200
|
}) : null]
|
|
246
201
|
}));
|
|
247
202
|
};
|
|
248
|
-
|
|
249
203
|
Notification.propTypes = {};
|
|
250
204
|
Notification.displayName = 'Notification';
|
|
251
205
|
Notification.defaultProps = defaultProps$1;
|
|
@@ -392,38 +346,43 @@ var apiErrorMessages = reactIntl.defineMessages({
|
|
|
392
346
|
});
|
|
393
347
|
|
|
394
348
|
function ownKeys$3(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); 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; }
|
|
395
|
-
|
|
396
349
|
function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var _context6, _context7; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context6 = ownKeys$3(Object(source), !0)).call(_context6, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _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; }
|
|
397
350
|
const regexInvalidOperationRequiredAttribute = /Required attribute '(.*)' cannot be removed/;
|
|
398
351
|
|
|
352
|
+
// `error` fields for REST errors
|
|
353
|
+
// `error.extensions` fields for GraphQL errors
|
|
399
354
|
// The values passed to the Intl message must be a map of scalar values.
|
|
400
355
|
// Some of the message values are already mapped in the `getSpecialFormattedMessageByErrorCode`
|
|
401
356
|
// function. Here we map other possible error properties that can be
|
|
402
357
|
// used in the message.
|
|
403
358
|
const mapErrorFieldsToMessageValues = error => {
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
359
|
+
var _error$extensions, _error$extensions2;
|
|
360
|
+
const errorField = ((_error$extensions = error.extensions) === null || _error$extensions === void 0 ? void 0 : _error$extensions.field) || error.field;
|
|
361
|
+
if (errorField) {
|
|
362
|
+
return {
|
|
363
|
+
field: errorField
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
const errorReferencedBy = ((_error$extensions2 = error.extensions) === null || _error$extensions2 === void 0 ? void 0 : _error$extensions2.referencedBy) || error.referencedBy;
|
|
367
|
+
if (errorReferencedBy) {
|
|
368
|
+
return {
|
|
369
|
+
referencedBy: errorReferencedBy
|
|
370
|
+
};
|
|
371
|
+
}
|
|
410
372
|
return {};
|
|
411
|
-
};
|
|
412
|
-
|
|
373
|
+
};
|
|
413
374
|
|
|
375
|
+
// Type-guard validation for error code to be included in the message object keys.
|
|
414
376
|
const hasErrorCodeAMatchingMessage = errorCode => errorCode in apiErrorMessages;
|
|
415
|
-
|
|
416
377
|
const FormattedErrorMessage = props => {
|
|
417
378
|
var _props$error$extensio, _props$error$extensio2, _context2;
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
379
|
+
const intl = reactIntl.useIntl();
|
|
380
|
+
// Attempt to map the error by code
|
|
421
381
|
const 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;
|
|
422
382
|
const messageCode = extensionErrorCode && hasErrorCodeAMatchingMessage(extensionErrorCode) ? apiErrorMessages[extensionErrorCode] : undefined;
|
|
423
383
|
react.useEffect(() => {
|
|
424
384
|
if (!messageCode) {
|
|
425
385
|
var _context;
|
|
426
|
-
|
|
427
386
|
// This error is not mapped / translated yet,
|
|
428
387
|
// we log, report it to sentry and show the original error, unless `error.code` is `invalid_scope`
|
|
429
388
|
// which an error code emitted for expired project(s)
|
|
@@ -434,115 +393,99 @@ const FormattedErrorMessage = props => {
|
|
|
434
393
|
}
|
|
435
394
|
}
|
|
436
395
|
}, [extensionErrorCode, messageCode, props.error]);
|
|
437
|
-
|
|
438
396
|
if (messageCode) {
|
|
439
397
|
// The `error` object might contain extra fields for the specific `code`.
|
|
440
398
|
return jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
441
399
|
children: intl.formatMessage(messageCode, mapErrorFieldsToMessageValues(props.error))
|
|
442
400
|
});
|
|
443
401
|
}
|
|
444
|
-
|
|
445
402
|
return jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
446
403
|
children: _filterInstanceProperty__default["default"](_context2 = [props.error.message, props.error.detailedErrorMessage && "(".concat(props.error.detailedErrorMessage, ")")]).call(_context2, Boolean).join(' ')
|
|
447
404
|
});
|
|
448
405
|
};
|
|
449
|
-
|
|
450
406
|
FormattedErrorMessage.propTypes = {
|
|
451
407
|
error: _pt__default["default"].any.isRequired
|
|
452
408
|
};
|
|
453
409
|
FormattedErrorMessage.displayName = 'FormattedErrorMessage';
|
|
454
|
-
|
|
455
410
|
const ApiErrorMessage = props => {
|
|
456
|
-
const intl = reactIntl.useIntl();
|
|
411
|
+
const intl = reactIntl.useIntl();
|
|
457
412
|
|
|
413
|
+
// Attempt to map the error to a specific error message
|
|
458
414
|
const specialFormattedMessage = getSpecialFormattedMessageByErrorCode(props.error, intl);
|
|
459
|
-
|
|
460
415
|
if (specialFormattedMessage) {
|
|
461
416
|
return jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
462
417
|
children: specialFormattedMessage
|
|
463
418
|
});
|
|
464
419
|
}
|
|
465
|
-
|
|
466
420
|
return jsxRuntime.jsx(FormattedErrorMessage, _objectSpread$3({}, props));
|
|
467
421
|
};
|
|
468
|
-
|
|
469
422
|
ApiErrorMessage.propTypes = {};
|
|
470
423
|
ApiErrorMessage.displayName = 'ApiErrorMessage';
|
|
471
|
-
|
|
472
424
|
function getSpecialFormattedMessageByErrorCode(error, intl) {
|
|
473
|
-
var _error$extensions$cod, _error$
|
|
474
|
-
|
|
475
|
-
const 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;
|
|
476
|
-
|
|
425
|
+
var _error$extensions$cod, _error$extensions3, _context3, _context4, _context5;
|
|
426
|
+
const extensionErrorCode = (_error$extensions$cod = (_error$extensions3 = error.extensions) === null || _error$extensions3 === void 0 ? void 0 : _error$extensions3.code) !== null && _error$extensions$cod !== void 0 ? _error$extensions$cod : error.code;
|
|
477
427
|
if (error.errorByExtension) {
|
|
478
428
|
let extensionMessage;
|
|
479
|
-
|
|
480
429
|
if (error.localizedMessage) {
|
|
481
430
|
extensionMessage = error.localizedMessage[intl.locale];
|
|
482
431
|
}
|
|
483
|
-
|
|
484
432
|
return extensionMessage || error.message;
|
|
485
433
|
}
|
|
434
|
+
if (!extensionErrorCode || extensionErrorCode === 'InvalidInput') return intl.formatMessage(apiErrorMessages.General);
|
|
486
435
|
|
|
487
|
-
|
|
488
|
-
|
|
436
|
+
// TODO: this is a temporary solution until we have proper pages about 403
|
|
489
437
|
if (extensionErrorCode === 'insufficient_scope') return intl.formatMessage(apiErrorMessages.Forbidden);
|
|
490
|
-
|
|
491
438
|
if (extensionErrorCode === 'DuplicateField') {
|
|
492
|
-
|
|
439
|
+
var _error$extensions4, _error$extensions5;
|
|
440
|
+
const errorField = ((_error$extensions4 = error.extensions) === null || _error$extensions4 === void 0 ? void 0 : _error$extensions4.field) || error.field;
|
|
441
|
+
const errorDuplicateValue = ((_error$extensions5 = error.extensions) === null || _error$extensions5 === void 0 ? void 0 : _error$extensions5.duplicateValue) || error.duplicateValue;
|
|
442
|
+
if (errorField === 'slug') {
|
|
493
443
|
return intl.formatMessage(apiErrorMessages.DuplicateSlug, {
|
|
494
|
-
slugValue:
|
|
444
|
+
slugValue: errorDuplicateValue
|
|
495
445
|
});
|
|
496
446
|
} else {
|
|
497
447
|
return intl.formatMessage(apiErrorMessages.DuplicateField, {
|
|
498
|
-
field:
|
|
448
|
+
field: errorField
|
|
499
449
|
});
|
|
500
450
|
}
|
|
501
|
-
}
|
|
502
|
-
|
|
451
|
+
}
|
|
503
452
|
|
|
453
|
+
// Try to match the error with a custom error message
|
|
504
454
|
if (has__default["default"](error, 'invalidValue') && has__default["default"](error.invalidValue, 'overlappingPrices')) return intl.formatMessage(apiErrorMessages.OverlappingPrices);
|
|
505
|
-
|
|
506
455
|
if (extensionErrorCode === 'InvalidOperation' && _includesInstanceProperty__default["default"](_context3 = error.message).call(_context3, 'validFrom') && _includesInstanceProperty__default["default"](_context4 = error.message).call(_context4, 'validUntil')) {
|
|
507
456
|
return intl.formatMessage(apiErrorMessages.InvalidDateRange, {
|
|
508
457
|
field: 'validFrom'
|
|
509
458
|
});
|
|
510
459
|
}
|
|
511
|
-
|
|
512
460
|
if (extensionErrorCode === 'InvalidOperation' && _includesInstanceProperty__default["default"](_context5 = error.message).call(_context5, 'Duplicate tax rate for')) {
|
|
513
461
|
return intl.formatMessage(apiErrorMessages.TaxCategoryDuplicateCountry);
|
|
514
462
|
}
|
|
515
|
-
|
|
516
463
|
if (extensionErrorCode === 'InvalidOperation' && regexInvalidOperationRequiredAttribute.test(error.message)) {
|
|
517
464
|
const attrName = error.message.replace(regexInvalidOperationRequiredAttribute, '$1');
|
|
518
465
|
return intl.formatMessage(apiErrorMessages.RequiredField, {
|
|
519
466
|
field: attrName
|
|
520
467
|
});
|
|
521
|
-
}
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
// TODO: A concern has be raised that we can't accurately distinguish
|
|
522
471
|
// this error (invalid start / end dates with prices) from other price
|
|
523
472
|
// errors. We should investigate this further.
|
|
524
|
-
|
|
525
|
-
|
|
526
473
|
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, {
|
|
527
474
|
field: error.field
|
|
528
475
|
});
|
|
529
|
-
|
|
530
476
|
if (extensionErrorCode === 'DuplicateAttributeValue' && error.attribute) {
|
|
531
477
|
return intl.formatMessage(apiErrorMessages.DuplicateAttributeValue, {
|
|
532
478
|
name: error.attribute.name
|
|
533
479
|
});
|
|
534
480
|
}
|
|
535
|
-
|
|
536
481
|
if (extensionErrorCode === 'MaxResourceLimitExceeded') {
|
|
537
482
|
return intl.formatMessage(apiErrorMessages.MaxResourceLimitExceeded);
|
|
538
483
|
}
|
|
539
|
-
|
|
540
484
|
return;
|
|
541
485
|
}
|
|
542
486
|
|
|
543
487
|
const ApiErrorNotification = props => {
|
|
544
488
|
var _context;
|
|
545
|
-
|
|
546
489
|
return jsxRuntime.jsx(Notification, {
|
|
547
490
|
type: "error",
|
|
548
491
|
domain: props.notification.domain,
|
|
@@ -550,10 +493,8 @@ const ApiErrorNotification = props => {
|
|
|
550
493
|
children: jsxRuntime.jsx("ul", {
|
|
551
494
|
children: _valuesInstanceProperty__default["default"](props.notification) && _mapInstanceProperty__default["default"](_context = _valuesInstanceProperty__default["default"](props.notification).errors).call(_context, (error, idx) => {
|
|
552
495
|
var _error$extensions$cod, _error$extensions;
|
|
553
|
-
|
|
554
496
|
const 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;
|
|
555
497
|
const shouldLogErrorToConsole = !extensionErrorCode && "production" === 'development';
|
|
556
|
-
|
|
557
498
|
if (shouldLogErrorToConsole) {
|
|
558
499
|
/**
|
|
559
500
|
* NOTE: This is an API error which usually contains
|
|
@@ -564,7 +505,6 @@ const ApiErrorNotification = props => {
|
|
|
564
505
|
// eslint-disable-next-line no-console
|
|
565
506
|
console.error('Unknown API error', error);
|
|
566
507
|
}
|
|
567
|
-
|
|
568
508
|
return jsxRuntime.jsx("li", {
|
|
569
509
|
children: jsxRuntime.jsx(ApiErrorMessage, {
|
|
570
510
|
error: error
|
|
@@ -574,7 +514,6 @@ const ApiErrorNotification = props => {
|
|
|
574
514
|
})
|
|
575
515
|
});
|
|
576
516
|
};
|
|
577
|
-
|
|
578
517
|
ApiErrorNotification.propTypes = {};
|
|
579
518
|
ApiErrorNotification.displayName = 'ApiErrorNotification';
|
|
580
519
|
|
|
@@ -584,14 +523,11 @@ const GenericNotification = props => jsxRuntime.jsx(Notification, {
|
|
|
584
523
|
onCloseClick: props.dismiss,
|
|
585
524
|
children: props.notification.text
|
|
586
525
|
});
|
|
587
|
-
|
|
588
526
|
GenericNotification.propTypes = {};
|
|
589
527
|
GenericNotification.displayName = 'GenericNotification';
|
|
590
528
|
|
|
591
529
|
function ownKeys$2(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); 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; }
|
|
592
|
-
|
|
593
530
|
function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$2(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _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; }
|
|
594
|
-
|
|
595
531
|
const UnexpectedErrorNotification = props => jsxRuntime.jsx(Notification, {
|
|
596
532
|
type: "error",
|
|
597
533
|
domain: props.notification.domain,
|
|
@@ -604,23 +540,18 @@ const UnexpectedErrorNotification = props => jsxRuntime.jsx(Notification, {
|
|
|
604
540
|
})]
|
|
605
541
|
})
|
|
606
542
|
});
|
|
607
|
-
|
|
608
543
|
UnexpectedErrorNotification.propTypes = {};
|
|
609
544
|
UnexpectedErrorNotification.displayName = 'UnexpectedErrorNotification';
|
|
610
545
|
|
|
611
546
|
const getStyles = props => {
|
|
612
547
|
const baseStyles = /*#__PURE__*/react$1.css("color:", designSystem.customProperties.colorSurface, ";position:relative;width:100%;z-index:19999;" + ("" ), "" );
|
|
613
|
-
|
|
614
548
|
switch (props.domain) {
|
|
615
549
|
case constants.NOTIFICATION_DOMAINS.GLOBAL:
|
|
616
550
|
return /*#__PURE__*/react$1.css(baseStyles, ";text-align:center;width:100%!important;" + ("" ), "" );
|
|
617
|
-
|
|
618
551
|
case constants.NOTIFICATION_DOMAINS.PAGE:
|
|
619
552
|
return /*#__PURE__*/react$1.css(baseStyles, ";" + ("" ), "" );
|
|
620
|
-
|
|
621
553
|
case constants.NOTIFICATION_DOMAINS.SIDE:
|
|
622
554
|
return /*#__PURE__*/react$1.css(baseStyles, ";position:absolute;text-align:left;height:0;overflow:visible;" + ("" ), "" );
|
|
623
|
-
|
|
624
555
|
default:
|
|
625
556
|
return /*#__PURE__*/react$1.css("" , "" );
|
|
626
557
|
}
|
|
@@ -631,23 +562,20 @@ const getStyles = props => {
|
|
|
631
562
|
const selectNotifications = state => state.notifications;
|
|
632
563
|
const selectGlobalNotifications = reselect.createSelector(selectNotifications, notifications => {
|
|
633
564
|
var _context;
|
|
634
|
-
|
|
635
|
-
|
|
565
|
+
return _sliceInstanceProperty__default["default"](_context = _filterInstanceProperty__default["default"](notifications).call(notifications, notification => notification.domain === constants.NOTIFICATION_DOMAINS.GLOBAL)
|
|
566
|
+
// Return only 1 at a time
|
|
636
567
|
).call(_context, 0, 1);
|
|
637
568
|
});
|
|
638
569
|
const selectPageNotifications = reselect.createSelector(selectNotifications, notifications => _filterInstanceProperty__default["default"](notifications).call(notifications, notification => notification.domain === constants.NOTIFICATION_DOMAINS.PAGE));
|
|
639
570
|
const selectSideNotifications = reselect.createSelector(selectNotifications, notifications => _filterInstanceProperty__default["default"](notifications).call(notifications, notification => notification.domain === constants.NOTIFICATION_DOMAINS.SIDE));
|
|
640
571
|
|
|
641
572
|
const _excluded = ["values"],
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
573
|
+
_excluded2 = ["text"],
|
|
574
|
+
_excluded3 = ["values"],
|
|
575
|
+
_excluded4 = ["text"],
|
|
576
|
+
_excluded5 = ["text"];
|
|
647
577
|
function ownKeys$1(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); 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; }
|
|
648
|
-
|
|
649
578
|
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$1(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _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; }
|
|
650
|
-
|
|
651
579
|
const NotificationsListGlobal = props => {
|
|
652
580
|
const dispatch = reactRedux.useDispatch();
|
|
653
581
|
const mapCustomNotificationToComponent = useCustomNotificationComponent();
|
|
@@ -658,7 +586,6 @@ const NotificationsListGlobal = props => {
|
|
|
658
586
|
children: _mapInstanceProperty__default["default"](notifications$1).call(notifications$1, notification => {
|
|
659
587
|
// 1. Check if there is a custom notification component first
|
|
660
588
|
const CustomNotificationComponent = mapCustomNotificationToComponent(notification);
|
|
661
|
-
|
|
662
589
|
if (CustomNotificationComponent) {
|
|
663
590
|
return jsxRuntime.jsx(CustomNotificationComponent, {
|
|
664
591
|
notification: notification,
|
|
@@ -667,7 +594,6 @@ const NotificationsListGlobal = props => {
|
|
|
667
594
|
}
|
|
668
595
|
}, notification.id);
|
|
669
596
|
}
|
|
670
|
-
|
|
671
597
|
switch (notification.kind) {
|
|
672
598
|
case constants.NOTIFICATION_KINDS_GLOBAL.error:
|
|
673
599
|
case constants.NOTIFICATION_KINDS_GLOBAL.warning:
|
|
@@ -675,8 +601,7 @@ const NotificationsListGlobal = props => {
|
|
|
675
601
|
case constants.NOTIFICATION_KINDS_GLOBAL.success:
|
|
676
602
|
{
|
|
677
603
|
_valuesInstanceProperty__default["default"](notification);
|
|
678
|
-
|
|
679
|
-
|
|
604
|
+
const genericNotification = _objectWithoutProperties(notification, _excluded);
|
|
680
605
|
return jsxRuntime.jsx(GenericNotification, {
|
|
681
606
|
notification: genericNotification,
|
|
682
607
|
dismiss: () => {
|
|
@@ -684,12 +609,10 @@ const NotificationsListGlobal = props => {
|
|
|
684
609
|
}
|
|
685
610
|
}, notification.id);
|
|
686
611
|
}
|
|
687
|
-
|
|
688
612
|
case constants.NOTIFICATION_KINDS_GLOBAL['unexpected-error']:
|
|
689
613
|
{
|
|
690
614
|
notification.text;
|
|
691
|
-
|
|
692
|
-
|
|
615
|
+
const errorNotification = _objectWithoutProperties(notification, _excluded2);
|
|
693
616
|
return jsxRuntime.jsx(UnexpectedErrorNotification, {
|
|
694
617
|
notification: errorNotification,
|
|
695
618
|
dismiss: () => {
|
|
@@ -697,17 +620,14 @@ const NotificationsListGlobal = props => {
|
|
|
697
620
|
}
|
|
698
621
|
}, notification.id);
|
|
699
622
|
}
|
|
700
|
-
|
|
701
623
|
default:
|
|
702
624
|
{
|
|
703
|
-
|
|
704
625
|
return null;
|
|
705
626
|
}
|
|
706
627
|
}
|
|
707
628
|
})
|
|
708
629
|
});
|
|
709
630
|
};
|
|
710
|
-
|
|
711
631
|
const NotificationsListPage = props => {
|
|
712
632
|
const dispatch = reactRedux.useDispatch();
|
|
713
633
|
const mapCustomNotificationToComponent = useCustomNotificationComponent();
|
|
@@ -718,7 +638,6 @@ const NotificationsListPage = props => {
|
|
|
718
638
|
children: _mapInstanceProperty__default["default"](notifications$1).call(notifications$1, notification => {
|
|
719
639
|
// 1. Check if there is a custom notification component first
|
|
720
640
|
const CustomNotificationComponent = mapCustomNotificationToComponent(notification);
|
|
721
|
-
|
|
722
641
|
if (CustomNotificationComponent) {
|
|
723
642
|
return jsxRuntime.jsx(CustomNotificationComponent, {
|
|
724
643
|
notification: notification,
|
|
@@ -727,7 +646,6 @@ const NotificationsListPage = props => {
|
|
|
727
646
|
}
|
|
728
647
|
}, notification.id);
|
|
729
648
|
}
|
|
730
|
-
|
|
731
649
|
switch (notification.kind) {
|
|
732
650
|
case constants.NOTIFICATION_KINDS_PAGE.error:
|
|
733
651
|
case constants.NOTIFICATION_KINDS_PAGE.warning:
|
|
@@ -735,8 +653,7 @@ const NotificationsListPage = props => {
|
|
|
735
653
|
case constants.NOTIFICATION_KINDS_PAGE.success:
|
|
736
654
|
{
|
|
737
655
|
_valuesInstanceProperty__default["default"](notification);
|
|
738
|
-
|
|
739
|
-
|
|
656
|
+
const genericNotification = _objectWithoutProperties(notification, _excluded3);
|
|
740
657
|
return jsxRuntime.jsx(GenericNotification, {
|
|
741
658
|
notification: _objectSpread$1(_objectSpread$1({}, genericNotification), {}, {
|
|
742
659
|
kind: notification.kind
|
|
@@ -746,12 +663,10 @@ const NotificationsListPage = props => {
|
|
|
746
663
|
}
|
|
747
664
|
}, notification.id);
|
|
748
665
|
}
|
|
749
|
-
|
|
750
666
|
case constants.NOTIFICATION_KINDS_PAGE['api-error']:
|
|
751
667
|
{
|
|
752
668
|
notification.text;
|
|
753
|
-
|
|
754
|
-
|
|
669
|
+
const errorNotification = _objectWithoutProperties(notification, _excluded4);
|
|
755
670
|
return jsxRuntime.jsx(ApiErrorNotification, {
|
|
756
671
|
notification: errorNotification,
|
|
757
672
|
dismiss: () => {
|
|
@@ -759,12 +674,10 @@ const NotificationsListPage = props => {
|
|
|
759
674
|
}
|
|
760
675
|
}, notification.id);
|
|
761
676
|
}
|
|
762
|
-
|
|
763
677
|
case constants.NOTIFICATION_KINDS_PAGE['unexpected-error']:
|
|
764
678
|
{
|
|
765
679
|
notification.text;
|
|
766
|
-
|
|
767
|
-
|
|
680
|
+
const errorNotification = _objectWithoutProperties(notification, _excluded5);
|
|
768
681
|
return jsxRuntime.jsx(UnexpectedErrorNotification, {
|
|
769
682
|
notification: _objectSpread$1(_objectSpread$1({}, errorNotification), {}, {
|
|
770
683
|
values: _valuesInstanceProperty__default["default"](notification)
|
|
@@ -774,14 +687,12 @@ const NotificationsListPage = props => {
|
|
|
774
687
|
}
|
|
775
688
|
}, notification.id);
|
|
776
689
|
}
|
|
777
|
-
|
|
778
690
|
default:
|
|
779
691
|
return null;
|
|
780
692
|
}
|
|
781
693
|
})
|
|
782
694
|
});
|
|
783
695
|
};
|
|
784
|
-
|
|
785
696
|
const NotificationsListSide = props => {
|
|
786
697
|
const dispatch = reactRedux.useDispatch();
|
|
787
698
|
const mapCustomNotificationToComponent = useCustomNotificationComponent();
|
|
@@ -792,7 +703,6 @@ const NotificationsListSide = props => {
|
|
|
792
703
|
children: _mapInstanceProperty__default["default"](notifications$1).call(notifications$1, notification => {
|
|
793
704
|
// 1. Check if there is a custom notification component first
|
|
794
705
|
const CustomNotificationComponent = mapCustomNotificationToComponent(notification);
|
|
795
|
-
|
|
796
706
|
if (CustomNotificationComponent) {
|
|
797
707
|
return jsxRuntime.jsx(CustomNotificationComponent, {
|
|
798
708
|
notification: notification,
|
|
@@ -801,7 +711,6 @@ const NotificationsListSide = props => {
|
|
|
801
711
|
}
|
|
802
712
|
}, notification.id);
|
|
803
713
|
}
|
|
804
|
-
|
|
805
714
|
switch (notification.kind) {
|
|
806
715
|
case constants.NOTIFICATION_KINDS_SIDE.error:
|
|
807
716
|
case constants.NOTIFICATION_KINDS_SIDE.warning:
|
|
@@ -813,40 +722,32 @@ const NotificationsListSide = props => {
|
|
|
813
722
|
dispatch(notifications.removeNotification(notification.id));
|
|
814
723
|
}
|
|
815
724
|
}, notification.id);
|
|
816
|
-
|
|
817
725
|
default:
|
|
818
726
|
return null;
|
|
819
727
|
}
|
|
820
728
|
})
|
|
821
729
|
});
|
|
822
730
|
};
|
|
823
|
-
|
|
824
731
|
const NotificationsList = props => {
|
|
825
732
|
switch (props.domain) {
|
|
826
733
|
case constants.NOTIFICATION_DOMAINS.GLOBAL:
|
|
827
734
|
return jsxRuntime.jsx(NotificationsListGlobal, _objectSpread$1({}, props));
|
|
828
|
-
|
|
829
735
|
case constants.NOTIFICATION_DOMAINS.PAGE:
|
|
830
736
|
return jsxRuntime.jsx(NotificationsListPage, _objectSpread$1({}, props));
|
|
831
|
-
|
|
832
737
|
case constants.NOTIFICATION_DOMAINS.SIDE:
|
|
833
738
|
return jsxRuntime.jsx(NotificationsListSide, _objectSpread$1({}, props));
|
|
834
|
-
|
|
835
739
|
default:
|
|
836
740
|
return null;
|
|
837
741
|
}
|
|
838
742
|
};
|
|
839
|
-
|
|
840
743
|
NotificationsList.displayName = 'NotificationsList';
|
|
841
744
|
|
|
842
745
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); 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; }
|
|
843
|
-
|
|
844
746
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _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; }
|
|
845
747
|
const defaultProps = {
|
|
846
748
|
domain: constants.NOTIFICATION_DOMAINS.SIDE,
|
|
847
749
|
kind: constants.NOTIFICATION_KINDS_SIDE.success
|
|
848
750
|
};
|
|
849
|
-
|
|
850
751
|
const Notifier = props => {
|
|
851
752
|
const showNotification = actionsGlobal.useShowNotification();
|
|
852
753
|
react.useEffect(() => {
|
|
@@ -860,12 +761,12 @@ const Notifier = props => {
|
|
|
860
761
|
return () => {
|
|
861
762
|
// Remove notification when component "unmounts"
|
|
862
763
|
notification.dismiss && notification.dismiss();
|
|
863
|
-
};
|
|
764
|
+
};
|
|
765
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
864
766
|
}, []); // We want to run this only once, when the component mounts the first time. Therefore we need to pass an empty array, even though the eslint rule shows a warning.
|
|
865
767
|
|
|
866
768
|
return null;
|
|
867
769
|
};
|
|
868
|
-
|
|
869
770
|
Notifier.propTypes = {
|
|
870
771
|
domain: _pt__default["default"].any.isRequired,
|
|
871
772
|
kind: _pt__default["default"].any.isRequired,
|