@commercetools-frontend/actions-global 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.
|
@@ -39,19 +39,19 @@ var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defin
|
|
|
39
39
|
var isNumber__default = /*#__PURE__*/_interopDefault(isNumber);
|
|
40
40
|
|
|
41
41
|
// NOTE: This string will be replaced on build time with the package version.
|
|
42
|
-
var version = "22.
|
|
42
|
+
var version = "22.3.1";
|
|
43
43
|
|
|
44
44
|
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; }
|
|
45
|
-
|
|
46
45
|
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context2 = ownKeys$1(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context3 = ownKeys$1(Object(source))).call(_context3, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
47
46
|
function showNotification(notification) {
|
|
48
47
|
let meta = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
49
48
|
if (process.env.NODE_ENV !== 'production') if (notification.domain) {
|
|
50
49
|
var _context;
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
if (!_includesInstanceProperty__default["default"](_context = _Object$values__default["default"](constants.NOTIFICATION_DOMAINS)).call(_context, notification.domain))
|
|
51
|
+
// eslint-disable-next-line no-console
|
|
53
52
|
console.warn("Unknown notification domain \"".concat(notification.domain, "\""), notification);
|
|
54
|
-
}
|
|
53
|
+
}
|
|
54
|
+
// eslint-disable-next-line no-console
|
|
55
55
|
else console.warn('Notification is missing domain', notification);
|
|
56
56
|
let dismissAfter = meta.dismissAfter;
|
|
57
57
|
if (!isNumber__default["default"](dismissAfter)) dismissAfter = notification.kind === constants.NOTIFICATION_KINDS_SIDE.success ? 5000 : 0;
|
|
@@ -78,8 +78,7 @@ function showApiErrorNotification(_ref) {
|
|
|
78
78
|
|
|
79
79
|
function showUnexpectedErrorNotification() {
|
|
80
80
|
let _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
errorId = _ref.errorId;
|
|
83
82
|
return showNotification({
|
|
84
83
|
id: 0,
|
|
85
84
|
domain: constants.DOMAINS.PAGE,
|
|
@@ -95,31 +94,30 @@ function showUnexpectedErrorNotification() {
|
|
|
95
94
|
function isApiError(error) {
|
|
96
95
|
return error.body !== undefined;
|
|
97
96
|
}
|
|
98
|
-
|
|
99
97
|
function handleActionError(error) {
|
|
100
98
|
return dispatch => {
|
|
101
99
|
// On production we send the errors to Sentry.
|
|
102
100
|
// eslint-disable-next-line no-console
|
|
103
101
|
if (window.app.env !== 'production') console.error(error, error instanceof Error && error.stack);
|
|
104
|
-
|
|
105
102
|
if (!isApiError(error)) {
|
|
106
103
|
const errorId = sentry.reportErrorToSentry(error);
|
|
107
104
|
return dispatch(showUnexpectedErrorNotification({
|
|
108
105
|
errorId
|
|
109
106
|
}));
|
|
110
|
-
}
|
|
111
|
-
|
|
107
|
+
}
|
|
112
108
|
|
|
109
|
+
// When unauthorized, log the user out.
|
|
113
110
|
if (error.statusCode === constants.STATUS_CODES.UNAUTHORIZED) {
|
|
114
111
|
history__default["default"].push("/logout?reason=".concat(constants.LOGOUT_REASONS.UNAUTHORIZED));
|
|
115
|
-
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// We need to do the return, because if not we see an error notification
|
|
116
115
|
// The error is handled with the handleUnavailableResource HoC to show the PageNotFound component
|
|
117
116
|
// when the api returns 404
|
|
118
|
-
|
|
119
|
-
|
|
120
117
|
if (error.statusCode === constants.STATUS_CODES.NOT_FOUND) return null;
|
|
121
118
|
return dispatch(showApiErrorNotification({
|
|
122
|
-
errors: error.body.errors || [
|
|
119
|
+
errors: error.body.errors || [
|
|
120
|
+
// Pass a fallback error so that our error components can handle it
|
|
123
121
|
{
|
|
124
122
|
message: error.body.message
|
|
125
123
|
}]
|
|
@@ -134,9 +132,45 @@ function hideAllPageNotifications() {
|
|
|
134
132
|
}
|
|
135
133
|
|
|
136
134
|
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; }
|
|
137
|
-
|
|
138
135
|
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; }
|
|
139
136
|
|
|
137
|
+
/**
|
|
138
|
+
* Dispatch a notification.
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* const showSuccessNotification = useShowNotification();
|
|
142
|
+
* showSuccessNotification({
|
|
143
|
+
* domain: NOTIFICATION_DOMAINS.SIDE,
|
|
144
|
+
* kind: NOTIFICATION_KINDS_SIDE.success,
|
|
145
|
+
* text: "All good!",
|
|
146
|
+
* });
|
|
147
|
+
*/
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Dispatch a notification.
|
|
151
|
+
*
|
|
152
|
+
* @deprecated: Avoid passing the notification options here.
|
|
153
|
+
* Instead define them in the notification function itself.
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* Bad:
|
|
157
|
+
* const showSuccessNotification = useShowNotification({
|
|
158
|
+
* domain: NOTIFICATION_DOMAINS.SIDE,
|
|
159
|
+
* kind: NOTIFICATION_KINDS_SIDE.success,
|
|
160
|
+
* });
|
|
161
|
+
* showSuccessNotification({
|
|
162
|
+
* text: "All good!",
|
|
163
|
+
* });
|
|
164
|
+
*
|
|
165
|
+
* Good:
|
|
166
|
+
* const showSuccessNotification = useShowNotification();
|
|
167
|
+
* showSuccessNotification({
|
|
168
|
+
* domain: NOTIFICATION_DOMAINS.SIDE,
|
|
169
|
+
* kind: NOTIFICATION_KINDS_SIDE.success,
|
|
170
|
+
* text: "All good!",
|
|
171
|
+
* });
|
|
172
|
+
*/
|
|
173
|
+
|
|
140
174
|
function useShowNotification(notificationFragment) {
|
|
141
175
|
const dispatch = reactRedux.useDispatch();
|
|
142
176
|
return react.useCallback((content, meta) => {
|
|
@@ -164,7 +198,6 @@ function useShowApiErrorNotification() {
|
|
|
164
198
|
* const showUnexpectedErrorNotification = useShowUnexpectedErrorNotification();
|
|
165
199
|
* showUnexpectedErrorNotification({ errors });
|
|
166
200
|
*/
|
|
167
|
-
|
|
168
201
|
function useShowUnexpectedErrorNotification() {
|
|
169
202
|
const dispatch = reactRedux.useDispatch();
|
|
170
203
|
return react.useCallback(options => dispatch(showUnexpectedErrorNotification(options)), [dispatch]);
|
|
@@ -37,10 +37,9 @@ var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defin
|
|
|
37
37
|
var isNumber__default = /*#__PURE__*/_interopDefault(isNumber);
|
|
38
38
|
|
|
39
39
|
// NOTE: This string will be replaced on build time with the package version.
|
|
40
|
-
var version = "22.
|
|
40
|
+
var version = "22.3.1";
|
|
41
41
|
|
|
42
42
|
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; }
|
|
43
|
-
|
|
44
43
|
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context2 = ownKeys$1(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context3 = ownKeys$1(Object(source))).call(_context3, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
45
44
|
function showNotification(notification) {
|
|
46
45
|
let meta = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -69,8 +68,7 @@ function showApiErrorNotification(_ref) {
|
|
|
69
68
|
|
|
70
69
|
function showUnexpectedErrorNotification() {
|
|
71
70
|
let _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
errorId = _ref.errorId;
|
|
74
72
|
return showNotification({
|
|
75
73
|
id: 0,
|
|
76
74
|
domain: constants.DOMAINS.PAGE,
|
|
@@ -86,31 +84,30 @@ function showUnexpectedErrorNotification() {
|
|
|
86
84
|
function isApiError(error) {
|
|
87
85
|
return error.body !== undefined;
|
|
88
86
|
}
|
|
89
|
-
|
|
90
87
|
function handleActionError(error) {
|
|
91
88
|
return dispatch => {
|
|
92
89
|
// On production we send the errors to Sentry.
|
|
93
90
|
// eslint-disable-next-line no-console
|
|
94
91
|
if (window.app.env !== 'production') console.error(error, error instanceof Error && error.stack);
|
|
95
|
-
|
|
96
92
|
if (!isApiError(error)) {
|
|
97
93
|
const errorId = sentry.reportErrorToSentry(error);
|
|
98
94
|
return dispatch(showUnexpectedErrorNotification({
|
|
99
95
|
errorId
|
|
100
96
|
}));
|
|
101
|
-
}
|
|
102
|
-
|
|
97
|
+
}
|
|
103
98
|
|
|
99
|
+
// When unauthorized, log the user out.
|
|
104
100
|
if (error.statusCode === constants.STATUS_CODES.UNAUTHORIZED) {
|
|
105
101
|
history__default["default"].push("/logout?reason=".concat(constants.LOGOUT_REASONS.UNAUTHORIZED));
|
|
106
|
-
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// We need to do the return, because if not we see an error notification
|
|
107
105
|
// The error is handled with the handleUnavailableResource HoC to show the PageNotFound component
|
|
108
106
|
// when the api returns 404
|
|
109
|
-
|
|
110
|
-
|
|
111
107
|
if (error.statusCode === constants.STATUS_CODES.NOT_FOUND) return null;
|
|
112
108
|
return dispatch(showApiErrorNotification({
|
|
113
|
-
errors: error.body.errors || [
|
|
109
|
+
errors: error.body.errors || [
|
|
110
|
+
// Pass a fallback error so that our error components can handle it
|
|
114
111
|
{
|
|
115
112
|
message: error.body.message
|
|
116
113
|
}]
|
|
@@ -125,9 +122,45 @@ function hideAllPageNotifications() {
|
|
|
125
122
|
}
|
|
126
123
|
|
|
127
124
|
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; }
|
|
128
|
-
|
|
129
125
|
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; }
|
|
130
126
|
|
|
127
|
+
/**
|
|
128
|
+
* Dispatch a notification.
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* const showSuccessNotification = useShowNotification();
|
|
132
|
+
* showSuccessNotification({
|
|
133
|
+
* domain: NOTIFICATION_DOMAINS.SIDE,
|
|
134
|
+
* kind: NOTIFICATION_KINDS_SIDE.success,
|
|
135
|
+
* text: "All good!",
|
|
136
|
+
* });
|
|
137
|
+
*/
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Dispatch a notification.
|
|
141
|
+
*
|
|
142
|
+
* @deprecated: Avoid passing the notification options here.
|
|
143
|
+
* Instead define them in the notification function itself.
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* Bad:
|
|
147
|
+
* const showSuccessNotification = useShowNotification({
|
|
148
|
+
* domain: NOTIFICATION_DOMAINS.SIDE,
|
|
149
|
+
* kind: NOTIFICATION_KINDS_SIDE.success,
|
|
150
|
+
* });
|
|
151
|
+
* showSuccessNotification({
|
|
152
|
+
* text: "All good!",
|
|
153
|
+
* });
|
|
154
|
+
*
|
|
155
|
+
* Good:
|
|
156
|
+
* const showSuccessNotification = useShowNotification();
|
|
157
|
+
* showSuccessNotification({
|
|
158
|
+
* domain: NOTIFICATION_DOMAINS.SIDE,
|
|
159
|
+
* kind: NOTIFICATION_KINDS_SIDE.success,
|
|
160
|
+
* text: "All good!",
|
|
161
|
+
* });
|
|
162
|
+
*/
|
|
163
|
+
|
|
131
164
|
function useShowNotification(notificationFragment) {
|
|
132
165
|
const dispatch = reactRedux.useDispatch();
|
|
133
166
|
return react.useCallback((content, meta) => {
|
|
@@ -155,7 +188,6 @@ function useShowApiErrorNotification() {
|
|
|
155
188
|
* const showUnexpectedErrorNotification = useShowUnexpectedErrorNotification();
|
|
156
189
|
* showUnexpectedErrorNotification({ errors });
|
|
157
190
|
*/
|
|
158
|
-
|
|
159
191
|
function useShowUnexpectedErrorNotification() {
|
|
160
192
|
const dispatch = reactRedux.useDispatch();
|
|
161
193
|
return react.useCallback(options => dispatch(showUnexpectedErrorNotification(options)), [dispatch]);
|
|
@@ -19,19 +19,19 @@ import { useCallback } from 'react';
|
|
|
19
19
|
import { useDispatch } from 'react-redux';
|
|
20
20
|
|
|
21
21
|
// NOTE: This string will be replaced on build time with the package version.
|
|
22
|
-
var version = "22.
|
|
22
|
+
var version = "22.3.1";
|
|
23
23
|
|
|
24
24
|
function ownKeys$1(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
25
|
-
|
|
26
25
|
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context2 = ownKeys$1(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context3 = ownKeys$1(Object(source))).call(_context3, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
27
26
|
function showNotification(notification) {
|
|
28
27
|
let meta = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
29
28
|
if (process.env.NODE_ENV !== 'production') if (notification.domain) {
|
|
30
29
|
var _context;
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
if (!_includesInstanceProperty(_context = _Object$values(NOTIFICATION_DOMAINS)).call(_context, notification.domain))
|
|
31
|
+
// eslint-disable-next-line no-console
|
|
33
32
|
console.warn("Unknown notification domain \"".concat(notification.domain, "\""), notification);
|
|
34
|
-
}
|
|
33
|
+
}
|
|
34
|
+
// eslint-disable-next-line no-console
|
|
35
35
|
else console.warn('Notification is missing domain', notification);
|
|
36
36
|
let dismissAfter = meta.dismissAfter;
|
|
37
37
|
if (!isNumber(dismissAfter)) dismissAfter = notification.kind === NOTIFICATION_KINDS_SIDE.success ? 5000 : 0;
|
|
@@ -58,8 +58,7 @@ function showApiErrorNotification(_ref) {
|
|
|
58
58
|
|
|
59
59
|
function showUnexpectedErrorNotification() {
|
|
60
60
|
let _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
errorId = _ref.errorId;
|
|
63
62
|
return showNotification({
|
|
64
63
|
id: 0,
|
|
65
64
|
domain: DOMAINS.PAGE,
|
|
@@ -75,31 +74,30 @@ function showUnexpectedErrorNotification() {
|
|
|
75
74
|
function isApiError(error) {
|
|
76
75
|
return error.body !== undefined;
|
|
77
76
|
}
|
|
78
|
-
|
|
79
77
|
function handleActionError(error) {
|
|
80
78
|
return dispatch => {
|
|
81
79
|
// On production we send the errors to Sentry.
|
|
82
80
|
// eslint-disable-next-line no-console
|
|
83
81
|
if (window.app.env !== 'production') console.error(error, error instanceof Error && error.stack);
|
|
84
|
-
|
|
85
82
|
if (!isApiError(error)) {
|
|
86
83
|
const errorId = reportErrorToSentry(error);
|
|
87
84
|
return dispatch(showUnexpectedErrorNotification({
|
|
88
85
|
errorId
|
|
89
86
|
}));
|
|
90
|
-
}
|
|
91
|
-
|
|
87
|
+
}
|
|
92
88
|
|
|
89
|
+
// When unauthorized, log the user out.
|
|
93
90
|
if (error.statusCode === STATUS_CODES.UNAUTHORIZED) {
|
|
94
91
|
history.push("/logout?reason=".concat(LOGOUT_REASONS.UNAUTHORIZED));
|
|
95
|
-
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// We need to do the return, because if not we see an error notification
|
|
96
95
|
// The error is handled with the handleUnavailableResource HoC to show the PageNotFound component
|
|
97
96
|
// when the api returns 404
|
|
98
|
-
|
|
99
|
-
|
|
100
97
|
if (error.statusCode === STATUS_CODES.NOT_FOUND) return null;
|
|
101
98
|
return dispatch(showApiErrorNotification({
|
|
102
|
-
errors: error.body.errors || [
|
|
99
|
+
errors: error.body.errors || [
|
|
100
|
+
// Pass a fallback error so that our error components can handle it
|
|
103
101
|
{
|
|
104
102
|
message: error.body.message
|
|
105
103
|
}]
|
|
@@ -114,9 +112,45 @@ function hideAllPageNotifications() {
|
|
|
114
112
|
}
|
|
115
113
|
|
|
116
114
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
117
|
-
|
|
118
115
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
119
116
|
|
|
117
|
+
/**
|
|
118
|
+
* Dispatch a notification.
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* const showSuccessNotification = useShowNotification();
|
|
122
|
+
* showSuccessNotification({
|
|
123
|
+
* domain: NOTIFICATION_DOMAINS.SIDE,
|
|
124
|
+
* kind: NOTIFICATION_KINDS_SIDE.success,
|
|
125
|
+
* text: "All good!",
|
|
126
|
+
* });
|
|
127
|
+
*/
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Dispatch a notification.
|
|
131
|
+
*
|
|
132
|
+
* @deprecated: Avoid passing the notification options here.
|
|
133
|
+
* Instead define them in the notification function itself.
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* Bad:
|
|
137
|
+
* const showSuccessNotification = useShowNotification({
|
|
138
|
+
* domain: NOTIFICATION_DOMAINS.SIDE,
|
|
139
|
+
* kind: NOTIFICATION_KINDS_SIDE.success,
|
|
140
|
+
* });
|
|
141
|
+
* showSuccessNotification({
|
|
142
|
+
* text: "All good!",
|
|
143
|
+
* });
|
|
144
|
+
*
|
|
145
|
+
* Good:
|
|
146
|
+
* const showSuccessNotification = useShowNotification();
|
|
147
|
+
* showSuccessNotification({
|
|
148
|
+
* domain: NOTIFICATION_DOMAINS.SIDE,
|
|
149
|
+
* kind: NOTIFICATION_KINDS_SIDE.success,
|
|
150
|
+
* text: "All good!",
|
|
151
|
+
* });
|
|
152
|
+
*/
|
|
153
|
+
|
|
120
154
|
function useShowNotification(notificationFragment) {
|
|
121
155
|
const dispatch = useDispatch();
|
|
122
156
|
return useCallback((content, meta) => {
|
|
@@ -144,7 +178,6 @@ function useShowApiErrorNotification() {
|
|
|
144
178
|
* const showUnexpectedErrorNotification = useShowUnexpectedErrorNotification();
|
|
145
179
|
* showUnexpectedErrorNotification({ errors });
|
|
146
180
|
*/
|
|
147
|
-
|
|
148
181
|
function useShowUnexpectedErrorNotification() {
|
|
149
182
|
const dispatch = useDispatch();
|
|
150
183
|
return useCallback(options => dispatch(showUnexpectedErrorNotification(options)), [dispatch]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-frontend/actions-global",
|
|
3
|
-
"version": "22.
|
|
3
|
+
"version": "22.3.1",
|
|
4
4
|
"description": "Global redux actions for a MC application",
|
|
5
5
|
"bugs": "https://github.com/commercetools/merchant-center-application-kit/issues",
|
|
6
6
|
"repository": {
|
|
@@ -9,21 +9,31 @@
|
|
|
9
9
|
"directory": "packages/actions-global"
|
|
10
10
|
},
|
|
11
11
|
"homepage": "https://docs.commercetools.com/custom-applications",
|
|
12
|
-
"keywords": [
|
|
12
|
+
"keywords": [
|
|
13
|
+
"javascript",
|
|
14
|
+
"frontend",
|
|
15
|
+
"react",
|
|
16
|
+
"toolkit"
|
|
17
|
+
],
|
|
13
18
|
"license": "MIT",
|
|
14
19
|
"publishConfig": {
|
|
15
20
|
"access": "public"
|
|
16
21
|
},
|
|
17
22
|
"main": "dist/commercetools-frontend-actions-global.cjs.js",
|
|
18
23
|
"module": "dist/commercetools-frontend-actions-global.esm.js",
|
|
19
|
-
"files": [
|
|
24
|
+
"files": [
|
|
25
|
+
"dist",
|
|
26
|
+
"package.json",
|
|
27
|
+
"LICENSE",
|
|
28
|
+
"README.md"
|
|
29
|
+
],
|
|
20
30
|
"dependencies": {
|
|
21
31
|
"@babel/runtime": "^7.20.13",
|
|
22
32
|
"@babel/runtime-corejs3": "^7.20.13",
|
|
23
|
-
"@commercetools-frontend/browser-history": "22.
|
|
24
|
-
"@commercetools-frontend/constants": "22.
|
|
25
|
-
"@commercetools-frontend/notifications": "22.
|
|
26
|
-
"@commercetools-frontend/sentry": "22.
|
|
33
|
+
"@commercetools-frontend/browser-history": "22.3.1",
|
|
34
|
+
"@commercetools-frontend/constants": "22.3.1",
|
|
35
|
+
"@commercetools-frontend/notifications": "22.3.1",
|
|
36
|
+
"@commercetools-frontend/sentry": "22.3.1",
|
|
27
37
|
"@types/lodash": "^4.14.191",
|
|
28
38
|
"@types/react": "^17.0.53",
|
|
29
39
|
"@types/react-redux": "^7.1.25",
|
|
@@ -31,6 +41,9 @@
|
|
|
31
41
|
"redux-thunk": "2.4.2"
|
|
32
42
|
},
|
|
33
43
|
"devDependencies": {
|
|
44
|
+
"@testing-library/react-hooks": "8.0.1",
|
|
45
|
+
"@types/jest": "^29.5.1",
|
|
46
|
+
"jest": "29.5.0",
|
|
34
47
|
"react": "17.0.2",
|
|
35
48
|
"react-redux": "7.2.9",
|
|
36
49
|
"redux": "4.2.1"
|
|
@@ -40,4 +53,4 @@
|
|
|
40
53
|
"react-redux": "7.x",
|
|
41
54
|
"redux": "4.x"
|
|
42
55
|
}
|
|
43
|
-
}
|
|
56
|
+
}
|