@commercetools-frontend-extensions/export-resources-modal 0.0.0-canary-20240507102123 → 0.0.0-canary-20240508124931
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-extensions-export-resources-modal.cjs.dev.js +99 -62
- package/dist/commercetools-frontend-extensions-export-resources-modal.cjs.prod.js +99 -62
- package/dist/commercetools-frontend-extensions-export-resources-modal.esm.js +98 -61
- package/dist/de-a34c5dd4.cjs.dev.js +6 -0
- package/dist/de-cd6c45d3.esm.js +4 -0
- package/dist/de-d954fe3d.cjs.prod.js +6 -0
- package/dist/en-3a9aa2d4.esm.js +4 -0
- package/dist/en-6b3694f6.cjs.dev.js +6 -0
- package/dist/en-c7757448.cjs.prod.js +6 -0
- package/dist/es-042343bd.cjs.prod.js +6 -0
- package/dist/es-8b3ecab1.cjs.dev.js +6 -0
- package/dist/es-e544023d.esm.js +4 -0
- package/dist/fr-FR-9d9081ee.esm.js +4 -0
- package/dist/fr-FR-e7126fcc.cjs.dev.js +6 -0
- package/dist/fr-FR-fce1ca96.cjs.prod.js +6 -0
- package/dist/ja-37632763.cjs.prod.js +6 -0
- package/dist/ja-73c088a7.esm.js +4 -0
- package/dist/ja-9bd5f452.cjs.dev.js +6 -0
- package/dist/pt-BR-b37d730b.esm.js +4 -0
- package/dist/pt-BR-ea6b3251.cjs.dev.js +6 -0
- package/dist/pt-BR-ec2a1a11.cjs.prod.js +6 -0
- package/dist/zh-CN-4780d88e.esm.js +4 -0
- package/dist/zh-CN-52baa549.cjs.prod.js +6 -0
- package/dist/zh-CN-d4bc6d26.cjs.dev.js +6 -0
- package/package.json +12 -4
|
@@ -11,13 +11,13 @@ var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-
|
|
|
11
11
|
var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
|
|
12
12
|
var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
|
|
13
13
|
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
14
|
+
var reactIntl = require('react-intl');
|
|
15
|
+
var applicationShellConnectors = require('@commercetools-frontend/application-shell-connectors');
|
|
14
16
|
var uiKit = require('@commercetools-frontend/ui-kit');
|
|
15
17
|
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
16
18
|
require('@commercetools-uikit/design-system');
|
|
17
|
-
var reactIntl = require('react-intl');
|
|
18
19
|
var _valuesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/values');
|
|
19
20
|
var applicationComponents = require('@commercetools-frontend/application-components');
|
|
20
|
-
var applicationShellConnectors = require('@commercetools-frontend/application-shell-connectors');
|
|
21
21
|
var _Reflect$construct = require('@babel/runtime-corejs3/core-js-stable/reflect/construct');
|
|
22
22
|
var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
|
|
23
23
|
var _classCallCheck = require('@babel/runtime-corejs3/helpers/classCallCheck');
|
|
@@ -39,6 +39,7 @@ var _Set = require('@babel/runtime-corejs3/core-js-stable/set');
|
|
|
39
39
|
var _sortInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/sort');
|
|
40
40
|
require('@babel/runtime-corejs3/core-js-stable/instance/starts-with');
|
|
41
41
|
var _indexOfInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/index-of');
|
|
42
|
+
var shared = require('@commercetools-local/shared');
|
|
42
43
|
var sdk = require('@commercetools-frontend/sdk');
|
|
43
44
|
var actionsGlobal = require('@commercetools-frontend/actions-global');
|
|
44
45
|
var constants = require('@commercetools-frontend/constants');
|
|
@@ -53,6 +54,8 @@ var react = require('@emotion/react');
|
|
|
53
54
|
var get = require('lodash/get');
|
|
54
55
|
var PropTypes = require('prop-types');
|
|
55
56
|
var formik = require('formik');
|
|
57
|
+
var sentry = require('@commercetools-frontend/sentry');
|
|
58
|
+
var i18n = require('@commercetools-frontend/i18n');
|
|
56
59
|
|
|
57
60
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
58
61
|
|
|
@@ -219,21 +222,6 @@ var messages = reactIntl.defineMessages({
|
|
|
219
222
|
description: 'Label for "Field definitions" link',
|
|
220
223
|
defaultMessage: 'Field definitions'
|
|
221
224
|
},
|
|
222
|
-
allGeneralFields: {
|
|
223
|
-
id: 'ExportResourcesModal.allGeneralFields',
|
|
224
|
-
description: 'Label for "All general fields" checkbox',
|
|
225
|
-
defaultMessage: 'All general fields'
|
|
226
|
-
},
|
|
227
|
-
allCustomFields: {
|
|
228
|
-
id: 'ExportResourcesModal.allCustomFields',
|
|
229
|
-
description: 'Label for "All custom fields" checkbox',
|
|
230
|
-
defaultMessage: 'All custom fields'
|
|
231
|
-
},
|
|
232
|
-
customTypeKeyAndTypeId: {
|
|
233
|
-
id: 'ExportResourcesModal.customTypeKeyAndTypeId',
|
|
234
|
-
description: 'Label for "Custom type key and typeId" checkbox',
|
|
235
|
-
defaultMessage: 'Custom type key and typeId'
|
|
236
|
-
},
|
|
237
225
|
unexpectedError: {
|
|
238
226
|
id: 'ExportResourcesModal.unexpectedError',
|
|
239
227
|
description: 'Generic notification message when starting export process fails',
|
|
@@ -323,11 +311,11 @@ const FIELD_DEFINITIONS_URLS = {
|
|
|
323
311
|
category: 'https://docs.commercetools.com/merchant-center/import-categories#supported-headers-and-values'
|
|
324
312
|
};
|
|
325
313
|
|
|
326
|
-
function _createSuper$
|
|
327
|
-
function _isNativeReflectConstruct$
|
|
314
|
+
function _createSuper$2(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$2(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct__default["default"](Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
315
|
+
function _isNativeReflectConstruct$2() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$2 = function () { return !!t; })(); }
|
|
328
316
|
let UnexpectedExportTypeError = /*#__PURE__*/function (_Error) {
|
|
329
317
|
_inherits(UnexpectedExportTypeError, _Error);
|
|
330
|
-
var _super = _createSuper$
|
|
318
|
+
var _super = _createSuper$2(UnexpectedExportTypeError);
|
|
331
319
|
function UnexpectedExportTypeError(exportType) {
|
|
332
320
|
var _this;
|
|
333
321
|
_classCallCheck(this, UnexpectedExportTypeError);
|
|
@@ -338,11 +326,11 @@ let UnexpectedExportTypeError = /*#__PURE__*/function (_Error) {
|
|
|
338
326
|
return _createClass(UnexpectedExportTypeError);
|
|
339
327
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
340
328
|
|
|
341
|
-
function _createSuper$
|
|
342
|
-
function _isNativeReflectConstruct$
|
|
329
|
+
function _createSuper$1(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct__default["default"](Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
330
|
+
function _isNativeReflectConstruct$1() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$1 = function () { return !!t; })(); }
|
|
343
331
|
let MissingExportResourceProviderError = /*#__PURE__*/function (_Error) {
|
|
344
332
|
_inherits(MissingExportResourceProviderError, _Error);
|
|
345
|
-
var _super = _createSuper$
|
|
333
|
+
var _super = _createSuper$1(MissingExportResourceProviderError);
|
|
346
334
|
function MissingExportResourceProviderError() {
|
|
347
335
|
var _this;
|
|
348
336
|
_classCallCheck(this, MissingExportResourceProviderError);
|
|
@@ -353,11 +341,11 @@ let MissingExportResourceProviderError = /*#__PURE__*/function (_Error) {
|
|
|
353
341
|
return _createClass(MissingExportResourceProviderError);
|
|
354
342
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
355
343
|
|
|
356
|
-
function _createSuper
|
|
357
|
-
function _isNativeReflectConstruct
|
|
344
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct__default["default"](Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
345
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); }
|
|
358
346
|
let UnexpectedExportOperationStateError = /*#__PURE__*/function (_Error) {
|
|
359
347
|
_inherits(UnexpectedExportOperationStateError, _Error);
|
|
360
|
-
var _super = _createSuper
|
|
348
|
+
var _super = _createSuper(UnexpectedExportOperationStateError);
|
|
361
349
|
function UnexpectedExportOperationStateError(state) {
|
|
362
350
|
var _this;
|
|
363
351
|
_classCallCheck(this, UnexpectedExportOperationStateError);
|
|
@@ -368,36 +356,6 @@ let UnexpectedExportOperationStateError = /*#__PURE__*/function (_Error) {
|
|
|
368
356
|
return _createClass(UnexpectedExportOperationStateError);
|
|
369
357
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
370
358
|
|
|
371
|
-
function _createSuper$1(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct__default["default"](Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
372
|
-
function _isNativeReflectConstruct$1() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$1 = function () { return !!t; })(); }
|
|
373
|
-
let UnexpectedResourceTypeError = /*#__PURE__*/function (_Error) {
|
|
374
|
-
_inherits(UnexpectedResourceTypeError, _Error);
|
|
375
|
-
var _super = _createSuper$1(UnexpectedResourceTypeError);
|
|
376
|
-
function UnexpectedResourceTypeError(resourceType) {
|
|
377
|
-
var _this;
|
|
378
|
-
_classCallCheck(this, UnexpectedResourceTypeError);
|
|
379
|
-
_this = _super.call(this, "Unexpected resource type: ".concat(resourceType));
|
|
380
|
-
_this.name = 'UnexpectedResourceTypeError';
|
|
381
|
-
return _this;
|
|
382
|
-
}
|
|
383
|
-
return _createClass(UnexpectedResourceTypeError);
|
|
384
|
-
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
385
|
-
|
|
386
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct__default["default"](Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
387
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); }
|
|
388
|
-
let InvalidResponseError = /*#__PURE__*/function (_Error) {
|
|
389
|
-
_inherits(InvalidResponseError, _Error);
|
|
390
|
-
var _super = _createSuper(InvalidResponseError);
|
|
391
|
-
function InvalidResponseError(message) {
|
|
392
|
-
var _this;
|
|
393
|
-
_classCallCheck(this, InvalidResponseError);
|
|
394
|
-
_this = _super.call(this, message);
|
|
395
|
-
_this.name = 'InvalidResponseError';
|
|
396
|
-
return _this;
|
|
397
|
-
}
|
|
398
|
-
return _createClass(InvalidResponseError);
|
|
399
|
-
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
400
|
-
|
|
401
359
|
function useExportResourcesContext() {
|
|
402
360
|
const context = React.useContext(ExportResourcesContext);
|
|
403
361
|
if (!context) {
|
|
@@ -470,7 +428,7 @@ function resourceTypeToDisplayName(_ref) {
|
|
|
470
428
|
displayName = isPlural ? 'Discount codes' : 'Discount code';
|
|
471
429
|
break;
|
|
472
430
|
default:
|
|
473
|
-
throw UnexpectedResourceTypeError(resourceType);
|
|
431
|
+
throw shared.UnexpectedResourceTypeError(resourceType);
|
|
474
432
|
}
|
|
475
433
|
return isUpperCase ? displayName : displayName.toLowerCase();
|
|
476
434
|
}
|
|
@@ -665,7 +623,7 @@ async function createExportOperation(_ref) {
|
|
|
665
623
|
filters
|
|
666
624
|
}
|
|
667
625
|
}));
|
|
668
|
-
if (!response.state) throw new InvalidResponseError('Invalid response');
|
|
626
|
+
if (!response.state) throw new shared.InvalidResponseError('Invalid response');
|
|
669
627
|
return response;
|
|
670
628
|
}
|
|
671
629
|
|
|
@@ -1235,13 +1193,92 @@ const CurrentStep = () => {
|
|
|
1235
1193
|
return steps[currentStep] || null;
|
|
1236
1194
|
};
|
|
1237
1195
|
|
|
1196
|
+
const loadMessages = locale => {
|
|
1197
|
+
const intlLocale = i18n.mapLocaleToIntlLocale(locale);
|
|
1198
|
+
switch (intlLocale) {
|
|
1199
|
+
case 'de':
|
|
1200
|
+
return Promise.resolve().then(function () { return require( /* webpackChunkName: "export-resources-modal-i18n-de" */'./de-a34c5dd4.cjs.dev.js'); });
|
|
1201
|
+
case 'es':
|
|
1202
|
+
return Promise.resolve().then(function () { return require( /* webpackChunkName: "export-resources-modal-i18n-es" */'./es-8b3ecab1.cjs.dev.js'); });
|
|
1203
|
+
case 'fr-FR':
|
|
1204
|
+
return Promise.resolve().then(function () { return require( /* webpackChunkName: "export-resources-modal-i18n-fr-FR" */'./fr-FR-e7126fcc.cjs.dev.js'); });
|
|
1205
|
+
case 'zh-CN':
|
|
1206
|
+
return Promise.resolve().then(function () { return require( /* webpackChunkName: "export-resources-modal-i18n-zh-CN" */'./zh-CN-d4bc6d26.cjs.dev.js'); });
|
|
1207
|
+
case 'ja':
|
|
1208
|
+
return Promise.resolve().then(function () { return require( /* webpackChunkName: "export-resources-modal-i18n-ja" */'./ja-9bd5f452.cjs.dev.js'); });
|
|
1209
|
+
case 'pt-BR':
|
|
1210
|
+
return Promise.resolve().then(function () { return require( /* webpackChunkName: "change-history-i18n-pt-BR" */'./pt-BR-ea6b3251.cjs.dev.js'); });
|
|
1211
|
+
default:
|
|
1212
|
+
return Promise.resolve().then(function () { return require( /* webpackChunkName: "export-resources-modal-i18n-en" */'./en-6b3694f6.cjs.dev.js'); });
|
|
1213
|
+
}
|
|
1214
|
+
};
|
|
1215
|
+
|
|
1216
|
+
// eslint-disable-next-line import/prefer-default-export
|
|
1217
|
+
const loadI18n = async locale => {
|
|
1218
|
+
try {
|
|
1219
|
+
const messages = await loadMessages(locale);
|
|
1220
|
+
return messages.default || messages;
|
|
1221
|
+
} catch (error) {
|
|
1222
|
+
// eslint-disable-next-line no-console
|
|
1223
|
+
console.warn("Something went wrong while loading the export-resources-modal messages for ".concat(locale), error);
|
|
1224
|
+
sentry.reportErrorToSentry(new Error("Something went wrong while loading the export-resources-modal messages for ".concat(locale)), {
|
|
1225
|
+
extra: error
|
|
1226
|
+
});
|
|
1227
|
+
return {};
|
|
1228
|
+
}
|
|
1229
|
+
};
|
|
1230
|
+
|
|
1231
|
+
const useAsyncIntlMessages = (locale, loader) => {
|
|
1232
|
+
const _useState = React.useState({
|
|
1233
|
+
isLoading: true,
|
|
1234
|
+
messages: undefined,
|
|
1235
|
+
error: undefined
|
|
1236
|
+
}),
|
|
1237
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1238
|
+
state = _useState2[0],
|
|
1239
|
+
setState = _useState2[1];
|
|
1240
|
+
React.useEffect(() => {
|
|
1241
|
+
let _isUnmounting = false;
|
|
1242
|
+
async function load() {
|
|
1243
|
+
try {
|
|
1244
|
+
if (!_isUnmounting) {
|
|
1245
|
+
const messages = await loader(locale);
|
|
1246
|
+
setState({
|
|
1247
|
+
isLoading: false,
|
|
1248
|
+
messages
|
|
1249
|
+
});
|
|
1250
|
+
}
|
|
1251
|
+
} catch (error) {
|
|
1252
|
+
setState({
|
|
1253
|
+
isLoading: false,
|
|
1254
|
+
error
|
|
1255
|
+
});
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
if (locale) load();
|
|
1259
|
+
return () => {
|
|
1260
|
+
_isUnmounting = true;
|
|
1261
|
+
};
|
|
1262
|
+
}, [locale, loader]);
|
|
1263
|
+
return state;
|
|
1264
|
+
};
|
|
1265
|
+
|
|
1238
1266
|
function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1239
1267
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
1240
1268
|
const ExportResourcesModal = props => {
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1269
|
+
const _useApplicationContex = applicationShellConnectors.useApplicationContext(context => ({
|
|
1270
|
+
locale: context.user && context.user.locale
|
|
1271
|
+
})),
|
|
1272
|
+
locale = _useApplicationContex.locale;
|
|
1273
|
+
const messages = useAsyncIntlMessages('en', loadI18n);
|
|
1274
|
+
if (!props.isOpen || messages.isLoading) return null;
|
|
1275
|
+
return jsxRuntime.jsx(reactIntl.IntlProvider, {
|
|
1276
|
+
locale: locale,
|
|
1277
|
+
messages: messages.messages,
|
|
1278
|
+
children: jsxRuntime.jsx(ExportResourcesProvider, _objectSpread(_objectSpread({}, props), {}, {
|
|
1279
|
+
children: jsxRuntime.jsx(CurrentStep, {})
|
|
1280
|
+
}))
|
|
1281
|
+
});
|
|
1245
1282
|
};
|
|
1246
1283
|
ExportResourcesModal.displayName = 'ExportResourcesModal';
|
|
1247
1284
|
ExportResourcesModal.defaultProps = {
|
|
@@ -11,13 +11,13 @@ var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-
|
|
|
11
11
|
var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
|
|
12
12
|
var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
|
|
13
13
|
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
14
|
+
var reactIntl = require('react-intl');
|
|
15
|
+
var applicationShellConnectors = require('@commercetools-frontend/application-shell-connectors');
|
|
14
16
|
var uiKit = require('@commercetools-frontend/ui-kit');
|
|
15
17
|
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
16
18
|
require('@commercetools-uikit/design-system');
|
|
17
|
-
var reactIntl = require('react-intl');
|
|
18
19
|
var _valuesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/values');
|
|
19
20
|
var applicationComponents = require('@commercetools-frontend/application-components');
|
|
20
|
-
var applicationShellConnectors = require('@commercetools-frontend/application-shell-connectors');
|
|
21
21
|
var _Reflect$construct = require('@babel/runtime-corejs3/core-js-stable/reflect/construct');
|
|
22
22
|
var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
|
|
23
23
|
var _classCallCheck = require('@babel/runtime-corejs3/helpers/classCallCheck');
|
|
@@ -39,6 +39,7 @@ var _Set = require('@babel/runtime-corejs3/core-js-stable/set');
|
|
|
39
39
|
var _sortInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/sort');
|
|
40
40
|
require('@babel/runtime-corejs3/core-js-stable/instance/starts-with');
|
|
41
41
|
var _indexOfInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/index-of');
|
|
42
|
+
var shared = require('@commercetools-local/shared');
|
|
42
43
|
var sdk = require('@commercetools-frontend/sdk');
|
|
43
44
|
var actionsGlobal = require('@commercetools-frontend/actions-global');
|
|
44
45
|
var constants = require('@commercetools-frontend/constants');
|
|
@@ -53,6 +54,8 @@ var react = require('@emotion/react');
|
|
|
53
54
|
var get = require('lodash/get');
|
|
54
55
|
require('prop-types');
|
|
55
56
|
var formik = require('formik');
|
|
57
|
+
var sentry = require('@commercetools-frontend/sentry');
|
|
58
|
+
var i18n = require('@commercetools-frontend/i18n');
|
|
56
59
|
|
|
57
60
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
58
61
|
|
|
@@ -218,21 +221,6 @@ var messages = reactIntl.defineMessages({
|
|
|
218
221
|
description: 'Label for "Field definitions" link',
|
|
219
222
|
defaultMessage: 'Field definitions'
|
|
220
223
|
},
|
|
221
|
-
allGeneralFields: {
|
|
222
|
-
id: 'ExportResourcesModal.allGeneralFields',
|
|
223
|
-
description: 'Label for "All general fields" checkbox',
|
|
224
|
-
defaultMessage: 'All general fields'
|
|
225
|
-
},
|
|
226
|
-
allCustomFields: {
|
|
227
|
-
id: 'ExportResourcesModal.allCustomFields',
|
|
228
|
-
description: 'Label for "All custom fields" checkbox',
|
|
229
|
-
defaultMessage: 'All custom fields'
|
|
230
|
-
},
|
|
231
|
-
customTypeKeyAndTypeId: {
|
|
232
|
-
id: 'ExportResourcesModal.customTypeKeyAndTypeId',
|
|
233
|
-
description: 'Label for "Custom type key and typeId" checkbox',
|
|
234
|
-
defaultMessage: 'Custom type key and typeId'
|
|
235
|
-
},
|
|
236
224
|
unexpectedError: {
|
|
237
225
|
id: 'ExportResourcesModal.unexpectedError',
|
|
238
226
|
description: 'Generic notification message when starting export process fails',
|
|
@@ -322,11 +310,11 @@ const FIELD_DEFINITIONS_URLS = {
|
|
|
322
310
|
category: 'https://docs.commercetools.com/merchant-center/import-categories#supported-headers-and-values'
|
|
323
311
|
};
|
|
324
312
|
|
|
325
|
-
function _createSuper$
|
|
326
|
-
function _isNativeReflectConstruct$
|
|
313
|
+
function _createSuper$2(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$2(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct__default["default"](Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
314
|
+
function _isNativeReflectConstruct$2() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$2 = function () { return !!t; })(); }
|
|
327
315
|
let UnexpectedExportTypeError = /*#__PURE__*/function (_Error) {
|
|
328
316
|
_inherits(UnexpectedExportTypeError, _Error);
|
|
329
|
-
var _super = _createSuper$
|
|
317
|
+
var _super = _createSuper$2(UnexpectedExportTypeError);
|
|
330
318
|
function UnexpectedExportTypeError(exportType) {
|
|
331
319
|
var _this;
|
|
332
320
|
_classCallCheck(this, UnexpectedExportTypeError);
|
|
@@ -337,11 +325,11 @@ let UnexpectedExportTypeError = /*#__PURE__*/function (_Error) {
|
|
|
337
325
|
return _createClass(UnexpectedExportTypeError);
|
|
338
326
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
339
327
|
|
|
340
|
-
function _createSuper$
|
|
341
|
-
function _isNativeReflectConstruct$
|
|
328
|
+
function _createSuper$1(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct__default["default"](Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
329
|
+
function _isNativeReflectConstruct$1() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$1 = function () { return !!t; })(); }
|
|
342
330
|
let MissingExportResourceProviderError = /*#__PURE__*/function (_Error) {
|
|
343
331
|
_inherits(MissingExportResourceProviderError, _Error);
|
|
344
|
-
var _super = _createSuper$
|
|
332
|
+
var _super = _createSuper$1(MissingExportResourceProviderError);
|
|
345
333
|
function MissingExportResourceProviderError() {
|
|
346
334
|
var _this;
|
|
347
335
|
_classCallCheck(this, MissingExportResourceProviderError);
|
|
@@ -352,11 +340,11 @@ let MissingExportResourceProviderError = /*#__PURE__*/function (_Error) {
|
|
|
352
340
|
return _createClass(MissingExportResourceProviderError);
|
|
353
341
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
354
342
|
|
|
355
|
-
function _createSuper
|
|
356
|
-
function _isNativeReflectConstruct
|
|
343
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct__default["default"](Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
344
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); }
|
|
357
345
|
let UnexpectedExportOperationStateError = /*#__PURE__*/function (_Error) {
|
|
358
346
|
_inherits(UnexpectedExportOperationStateError, _Error);
|
|
359
|
-
var _super = _createSuper
|
|
347
|
+
var _super = _createSuper(UnexpectedExportOperationStateError);
|
|
360
348
|
function UnexpectedExportOperationStateError(state) {
|
|
361
349
|
var _this;
|
|
362
350
|
_classCallCheck(this, UnexpectedExportOperationStateError);
|
|
@@ -367,36 +355,6 @@ let UnexpectedExportOperationStateError = /*#__PURE__*/function (_Error) {
|
|
|
367
355
|
return _createClass(UnexpectedExportOperationStateError);
|
|
368
356
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
369
357
|
|
|
370
|
-
function _createSuper$1(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct__default["default"](Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
371
|
-
function _isNativeReflectConstruct$1() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$1 = function () { return !!t; })(); }
|
|
372
|
-
let UnexpectedResourceTypeError = /*#__PURE__*/function (_Error) {
|
|
373
|
-
_inherits(UnexpectedResourceTypeError, _Error);
|
|
374
|
-
var _super = _createSuper$1(UnexpectedResourceTypeError);
|
|
375
|
-
function UnexpectedResourceTypeError(resourceType) {
|
|
376
|
-
var _this;
|
|
377
|
-
_classCallCheck(this, UnexpectedResourceTypeError);
|
|
378
|
-
_this = _super.call(this, "Unexpected resource type: ".concat(resourceType));
|
|
379
|
-
_this.name = 'UnexpectedResourceTypeError';
|
|
380
|
-
return _this;
|
|
381
|
-
}
|
|
382
|
-
return _createClass(UnexpectedResourceTypeError);
|
|
383
|
-
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
384
|
-
|
|
385
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct__default["default"](Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
386
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); }
|
|
387
|
-
let InvalidResponseError = /*#__PURE__*/function (_Error) {
|
|
388
|
-
_inherits(InvalidResponseError, _Error);
|
|
389
|
-
var _super = _createSuper(InvalidResponseError);
|
|
390
|
-
function InvalidResponseError(message) {
|
|
391
|
-
var _this;
|
|
392
|
-
_classCallCheck(this, InvalidResponseError);
|
|
393
|
-
_this = _super.call(this, message);
|
|
394
|
-
_this.name = 'InvalidResponseError';
|
|
395
|
-
return _this;
|
|
396
|
-
}
|
|
397
|
-
return _createClass(InvalidResponseError);
|
|
398
|
-
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
399
|
-
|
|
400
358
|
function useExportResourcesContext() {
|
|
401
359
|
const context = React.useContext(ExportResourcesContext);
|
|
402
360
|
if (!context) {
|
|
@@ -469,7 +427,7 @@ function resourceTypeToDisplayName(_ref) {
|
|
|
469
427
|
displayName = isPlural ? 'Discount codes' : 'Discount code';
|
|
470
428
|
break;
|
|
471
429
|
default:
|
|
472
|
-
throw UnexpectedResourceTypeError(resourceType);
|
|
430
|
+
throw shared.UnexpectedResourceTypeError(resourceType);
|
|
473
431
|
}
|
|
474
432
|
return isUpperCase ? displayName : displayName.toLowerCase();
|
|
475
433
|
}
|
|
@@ -664,7 +622,7 @@ async function createExportOperation(_ref) {
|
|
|
664
622
|
filters
|
|
665
623
|
}
|
|
666
624
|
}));
|
|
667
|
-
if (!response.state) throw new InvalidResponseError('Invalid response');
|
|
625
|
+
if (!response.state) throw new shared.InvalidResponseError('Invalid response');
|
|
668
626
|
return response;
|
|
669
627
|
}
|
|
670
628
|
|
|
@@ -1218,13 +1176,92 @@ const CurrentStep = () => {
|
|
|
1218
1176
|
return steps[currentStep] || null;
|
|
1219
1177
|
};
|
|
1220
1178
|
|
|
1179
|
+
const loadMessages = locale => {
|
|
1180
|
+
const intlLocale = i18n.mapLocaleToIntlLocale(locale);
|
|
1181
|
+
switch (intlLocale) {
|
|
1182
|
+
case 'de':
|
|
1183
|
+
return Promise.resolve().then(function () { return require( /* webpackChunkName: "export-resources-modal-i18n-de" */'./de-d954fe3d.cjs.prod.js'); });
|
|
1184
|
+
case 'es':
|
|
1185
|
+
return Promise.resolve().then(function () { return require( /* webpackChunkName: "export-resources-modal-i18n-es" */'./es-042343bd.cjs.prod.js'); });
|
|
1186
|
+
case 'fr-FR':
|
|
1187
|
+
return Promise.resolve().then(function () { return require( /* webpackChunkName: "export-resources-modal-i18n-fr-FR" */'./fr-FR-fce1ca96.cjs.prod.js'); });
|
|
1188
|
+
case 'zh-CN':
|
|
1189
|
+
return Promise.resolve().then(function () { return require( /* webpackChunkName: "export-resources-modal-i18n-zh-CN" */'./zh-CN-52baa549.cjs.prod.js'); });
|
|
1190
|
+
case 'ja':
|
|
1191
|
+
return Promise.resolve().then(function () { return require( /* webpackChunkName: "export-resources-modal-i18n-ja" */'./ja-37632763.cjs.prod.js'); });
|
|
1192
|
+
case 'pt-BR':
|
|
1193
|
+
return Promise.resolve().then(function () { return require( /* webpackChunkName: "change-history-i18n-pt-BR" */'./pt-BR-ec2a1a11.cjs.prod.js'); });
|
|
1194
|
+
default:
|
|
1195
|
+
return Promise.resolve().then(function () { return require( /* webpackChunkName: "export-resources-modal-i18n-en" */'./en-c7757448.cjs.prod.js'); });
|
|
1196
|
+
}
|
|
1197
|
+
};
|
|
1198
|
+
|
|
1199
|
+
// eslint-disable-next-line import/prefer-default-export
|
|
1200
|
+
const loadI18n = async locale => {
|
|
1201
|
+
try {
|
|
1202
|
+
const messages = await loadMessages(locale);
|
|
1203
|
+
return messages.default || messages;
|
|
1204
|
+
} catch (error) {
|
|
1205
|
+
// eslint-disable-next-line no-console
|
|
1206
|
+
console.warn("Something went wrong while loading the export-resources-modal messages for ".concat(locale), error);
|
|
1207
|
+
sentry.reportErrorToSentry(new Error("Something went wrong while loading the export-resources-modal messages for ".concat(locale)), {
|
|
1208
|
+
extra: error
|
|
1209
|
+
});
|
|
1210
|
+
return {};
|
|
1211
|
+
}
|
|
1212
|
+
};
|
|
1213
|
+
|
|
1214
|
+
const useAsyncIntlMessages = (locale, loader) => {
|
|
1215
|
+
const _useState = React.useState({
|
|
1216
|
+
isLoading: true,
|
|
1217
|
+
messages: undefined,
|
|
1218
|
+
error: undefined
|
|
1219
|
+
}),
|
|
1220
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1221
|
+
state = _useState2[0],
|
|
1222
|
+
setState = _useState2[1];
|
|
1223
|
+
React.useEffect(() => {
|
|
1224
|
+
let _isUnmounting = false;
|
|
1225
|
+
async function load() {
|
|
1226
|
+
try {
|
|
1227
|
+
if (!_isUnmounting) {
|
|
1228
|
+
const messages = await loader(locale);
|
|
1229
|
+
setState({
|
|
1230
|
+
isLoading: false,
|
|
1231
|
+
messages
|
|
1232
|
+
});
|
|
1233
|
+
}
|
|
1234
|
+
} catch (error) {
|
|
1235
|
+
setState({
|
|
1236
|
+
isLoading: false,
|
|
1237
|
+
error
|
|
1238
|
+
});
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
if (locale) load();
|
|
1242
|
+
return () => {
|
|
1243
|
+
_isUnmounting = true;
|
|
1244
|
+
};
|
|
1245
|
+
}, [locale, loader]);
|
|
1246
|
+
return state;
|
|
1247
|
+
};
|
|
1248
|
+
|
|
1221
1249
|
function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1222
1250
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
1223
1251
|
const ExportResourcesModal = props => {
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1252
|
+
const _useApplicationContex = applicationShellConnectors.useApplicationContext(context => ({
|
|
1253
|
+
locale: context.user && context.user.locale
|
|
1254
|
+
})),
|
|
1255
|
+
locale = _useApplicationContex.locale;
|
|
1256
|
+
const messages = useAsyncIntlMessages('en', loadI18n);
|
|
1257
|
+
if (!props.isOpen || messages.isLoading) return null;
|
|
1258
|
+
return jsxRuntime.jsx(reactIntl.IntlProvider, {
|
|
1259
|
+
locale: locale,
|
|
1260
|
+
messages: messages.messages,
|
|
1261
|
+
children: jsxRuntime.jsx(ExportResourcesProvider, _objectSpread(_objectSpread({}, props), {}, {
|
|
1262
|
+
children: jsxRuntime.jsx(CurrentStep, {})
|
|
1263
|
+
}))
|
|
1264
|
+
});
|
|
1228
1265
|
};
|
|
1229
1266
|
ExportResourcesModal.displayName = 'ExportResourcesModal';
|
|
1230
1267
|
ExportResourcesModal.defaultProps = {
|
|
@@ -7,13 +7,13 @@ import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js-st
|
|
|
7
7
|
import _Object$defineProperties from '@babel/runtime-corejs3/core-js-stable/object/define-properties';
|
|
8
8
|
import _Object$defineProperty from '@babel/runtime-corejs3/core-js-stable/object/define-property';
|
|
9
9
|
import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
|
|
10
|
+
import { defineMessages, FormattedMessage, useIntl, IntlProvider } from 'react-intl';
|
|
11
|
+
import { useApplicationContext } from '@commercetools-frontend/application-shell-connectors';
|
|
10
12
|
import { Text, TextInput, Link, Spacings, ExportIcon, SelectField, TextField, CheckboxInput, Card, designTokens, SearchTextInput, Grid } from '@commercetools-frontend/ui-kit';
|
|
11
13
|
import { jsx, jsxs, Fragment } from '@emotion/react/jsx-runtime';
|
|
12
14
|
import '@commercetools-uikit/design-system';
|
|
13
|
-
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
|
14
15
|
import _valuesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/values';
|
|
15
16
|
import { FormDialog } from '@commercetools-frontend/application-components';
|
|
16
|
-
import { useApplicationContext } from '@commercetools-frontend/application-shell-connectors';
|
|
17
17
|
import _Reflect$construct from '@babel/runtime-corejs3/core-js-stable/reflect/construct';
|
|
18
18
|
import _createClass from '@babel/runtime-corejs3/helpers/esm/createClass';
|
|
19
19
|
import _classCallCheck from '@babel/runtime-corejs3/helpers/esm/classCallCheck';
|
|
@@ -21,7 +21,7 @@ import _inherits from '@babel/runtime-corejs3/helpers/esm/inherits';
|
|
|
21
21
|
import _possibleConstructorReturn from '@babel/runtime-corejs3/helpers/esm/possibleConstructorReturn';
|
|
22
22
|
import _getPrototypeOf from '@babel/runtime-corejs3/helpers/esm/getPrototypeOf';
|
|
23
23
|
import _wrapNativeSuper from '@babel/runtime-corejs3/helpers/esm/wrapNativeSuper';
|
|
24
|
-
import React, { useContext, createContext } from 'react';
|
|
24
|
+
import React, { useContext, createContext, useState, useEffect } from 'react';
|
|
25
25
|
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/esm/objectWithoutProperties';
|
|
26
26
|
import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/map';
|
|
27
27
|
import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
|
|
@@ -35,6 +35,7 @@ import _Set from '@babel/runtime-corejs3/core-js-stable/set';
|
|
|
35
35
|
import _sortInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/sort';
|
|
36
36
|
import '@babel/runtime-corejs3/core-js-stable/instance/starts-with';
|
|
37
37
|
import _indexOfInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/index-of';
|
|
38
|
+
import { UnexpectedResourceTypeError, InvalidResponseError } from '@commercetools-local/shared';
|
|
38
39
|
import { actions, useAsyncDispatch } from '@commercetools-frontend/sdk';
|
|
39
40
|
import { useShowNotification } from '@commercetools-frontend/actions-global';
|
|
40
41
|
import { MC_API_PROXY_TARGETS, DOMAINS } from '@commercetools-frontend/constants';
|
|
@@ -49,6 +50,8 @@ import { css } from '@emotion/react';
|
|
|
49
50
|
import get from 'lodash/get';
|
|
50
51
|
import PropTypes from 'prop-types';
|
|
51
52
|
import { useFormik } from 'formik';
|
|
53
|
+
import { reportErrorToSentry } from '@commercetools-frontend/sentry';
|
|
54
|
+
import { mapLocaleToIntlLocale } from '@commercetools-frontend/i18n';
|
|
52
55
|
|
|
53
56
|
function getBold(msg) {
|
|
54
57
|
return jsx(Text.Body, {
|
|
@@ -182,21 +185,6 @@ var messages = defineMessages({
|
|
|
182
185
|
description: 'Label for "Field definitions" link',
|
|
183
186
|
defaultMessage: 'Field definitions'
|
|
184
187
|
},
|
|
185
|
-
allGeneralFields: {
|
|
186
|
-
id: 'ExportResourcesModal.allGeneralFields',
|
|
187
|
-
description: 'Label for "All general fields" checkbox',
|
|
188
|
-
defaultMessage: 'All general fields'
|
|
189
|
-
},
|
|
190
|
-
allCustomFields: {
|
|
191
|
-
id: 'ExportResourcesModal.allCustomFields',
|
|
192
|
-
description: 'Label for "All custom fields" checkbox',
|
|
193
|
-
defaultMessage: 'All custom fields'
|
|
194
|
-
},
|
|
195
|
-
customTypeKeyAndTypeId: {
|
|
196
|
-
id: 'ExportResourcesModal.customTypeKeyAndTypeId',
|
|
197
|
-
description: 'Label for "Custom type key and typeId" checkbox',
|
|
198
|
-
defaultMessage: 'Custom type key and typeId'
|
|
199
|
-
},
|
|
200
188
|
unexpectedError: {
|
|
201
189
|
id: 'ExportResourcesModal.unexpectedError',
|
|
202
190
|
description: 'Generic notification message when starting export process fails',
|
|
@@ -286,11 +274,11 @@ const FIELD_DEFINITIONS_URLS = {
|
|
|
286
274
|
category: 'https://docs.commercetools.com/merchant-center/import-categories#supported-headers-and-values'
|
|
287
275
|
};
|
|
288
276
|
|
|
289
|
-
function _createSuper$
|
|
290
|
-
function _isNativeReflectConstruct$
|
|
277
|
+
function _createSuper$2(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$2(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
278
|
+
function _isNativeReflectConstruct$2() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$2 = function () { return !!t; })(); }
|
|
291
279
|
let UnexpectedExportTypeError = /*#__PURE__*/function (_Error) {
|
|
292
280
|
_inherits(UnexpectedExportTypeError, _Error);
|
|
293
|
-
var _super = _createSuper$
|
|
281
|
+
var _super = _createSuper$2(UnexpectedExportTypeError);
|
|
294
282
|
function UnexpectedExportTypeError(exportType) {
|
|
295
283
|
var _this;
|
|
296
284
|
_classCallCheck(this, UnexpectedExportTypeError);
|
|
@@ -301,11 +289,11 @@ let UnexpectedExportTypeError = /*#__PURE__*/function (_Error) {
|
|
|
301
289
|
return _createClass(UnexpectedExportTypeError);
|
|
302
290
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
303
291
|
|
|
304
|
-
function _createSuper$
|
|
305
|
-
function _isNativeReflectConstruct$
|
|
292
|
+
function _createSuper$1(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
293
|
+
function _isNativeReflectConstruct$1() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$1 = function () { return !!t; })(); }
|
|
306
294
|
let MissingExportResourceProviderError = /*#__PURE__*/function (_Error) {
|
|
307
295
|
_inherits(MissingExportResourceProviderError, _Error);
|
|
308
|
-
var _super = _createSuper$
|
|
296
|
+
var _super = _createSuper$1(MissingExportResourceProviderError);
|
|
309
297
|
function MissingExportResourceProviderError() {
|
|
310
298
|
var _this;
|
|
311
299
|
_classCallCheck(this, MissingExportResourceProviderError);
|
|
@@ -316,11 +304,11 @@ let MissingExportResourceProviderError = /*#__PURE__*/function (_Error) {
|
|
|
316
304
|
return _createClass(MissingExportResourceProviderError);
|
|
317
305
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
318
306
|
|
|
319
|
-
function _createSuper
|
|
320
|
-
function _isNativeReflectConstruct
|
|
307
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
308
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); }
|
|
321
309
|
let UnexpectedExportOperationStateError = /*#__PURE__*/function (_Error) {
|
|
322
310
|
_inherits(UnexpectedExportOperationStateError, _Error);
|
|
323
|
-
var _super = _createSuper
|
|
311
|
+
var _super = _createSuper(UnexpectedExportOperationStateError);
|
|
324
312
|
function UnexpectedExportOperationStateError(state) {
|
|
325
313
|
var _this;
|
|
326
314
|
_classCallCheck(this, UnexpectedExportOperationStateError);
|
|
@@ -331,36 +319,6 @@ let UnexpectedExportOperationStateError = /*#__PURE__*/function (_Error) {
|
|
|
331
319
|
return _createClass(UnexpectedExportOperationStateError);
|
|
332
320
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
333
321
|
|
|
334
|
-
function _createSuper$1(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
335
|
-
function _isNativeReflectConstruct$1() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$1 = function () { return !!t; })(); }
|
|
336
|
-
let UnexpectedResourceTypeError = /*#__PURE__*/function (_Error) {
|
|
337
|
-
_inherits(UnexpectedResourceTypeError, _Error);
|
|
338
|
-
var _super = _createSuper$1(UnexpectedResourceTypeError);
|
|
339
|
-
function UnexpectedResourceTypeError(resourceType) {
|
|
340
|
-
var _this;
|
|
341
|
-
_classCallCheck(this, UnexpectedResourceTypeError);
|
|
342
|
-
_this = _super.call(this, "Unexpected resource type: ".concat(resourceType));
|
|
343
|
-
_this.name = 'UnexpectedResourceTypeError';
|
|
344
|
-
return _this;
|
|
345
|
-
}
|
|
346
|
-
return _createClass(UnexpectedResourceTypeError);
|
|
347
|
-
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
348
|
-
|
|
349
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
350
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); }
|
|
351
|
-
let InvalidResponseError = /*#__PURE__*/function (_Error) {
|
|
352
|
-
_inherits(InvalidResponseError, _Error);
|
|
353
|
-
var _super = _createSuper(InvalidResponseError);
|
|
354
|
-
function InvalidResponseError(message) {
|
|
355
|
-
var _this;
|
|
356
|
-
_classCallCheck(this, InvalidResponseError);
|
|
357
|
-
_this = _super.call(this, message);
|
|
358
|
-
_this.name = 'InvalidResponseError';
|
|
359
|
-
return _this;
|
|
360
|
-
}
|
|
361
|
-
return _createClass(InvalidResponseError);
|
|
362
|
-
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
363
|
-
|
|
364
322
|
function useExportResourcesContext() {
|
|
365
323
|
const context = useContext(ExportResourcesContext);
|
|
366
324
|
if (!context) {
|
|
@@ -1198,13 +1156,92 @@ const CurrentStep = () => {
|
|
|
1198
1156
|
return steps[currentStep] || null;
|
|
1199
1157
|
};
|
|
1200
1158
|
|
|
1159
|
+
const loadMessages = locale => {
|
|
1160
|
+
const intlLocale = mapLocaleToIntlLocale(locale);
|
|
1161
|
+
switch (intlLocale) {
|
|
1162
|
+
case 'de':
|
|
1163
|
+
return import( /* webpackChunkName: "export-resources-modal-i18n-de" */'./de-cd6c45d3.esm.js');
|
|
1164
|
+
case 'es':
|
|
1165
|
+
return import( /* webpackChunkName: "export-resources-modal-i18n-es" */'./es-e544023d.esm.js');
|
|
1166
|
+
case 'fr-FR':
|
|
1167
|
+
return import( /* webpackChunkName: "export-resources-modal-i18n-fr-FR" */'./fr-FR-9d9081ee.esm.js');
|
|
1168
|
+
case 'zh-CN':
|
|
1169
|
+
return import( /* webpackChunkName: "export-resources-modal-i18n-zh-CN" */'./zh-CN-4780d88e.esm.js');
|
|
1170
|
+
case 'ja':
|
|
1171
|
+
return import( /* webpackChunkName: "export-resources-modal-i18n-ja" */'./ja-73c088a7.esm.js');
|
|
1172
|
+
case 'pt-BR':
|
|
1173
|
+
return import( /* webpackChunkName: "change-history-i18n-pt-BR" */'./pt-BR-b37d730b.esm.js');
|
|
1174
|
+
default:
|
|
1175
|
+
return import( /* webpackChunkName: "export-resources-modal-i18n-en" */'./en-3a9aa2d4.esm.js');
|
|
1176
|
+
}
|
|
1177
|
+
};
|
|
1178
|
+
|
|
1179
|
+
// eslint-disable-next-line import/prefer-default-export
|
|
1180
|
+
const loadI18n = async locale => {
|
|
1181
|
+
try {
|
|
1182
|
+
const messages = await loadMessages(locale);
|
|
1183
|
+
return messages.default || messages;
|
|
1184
|
+
} catch (error) {
|
|
1185
|
+
// eslint-disable-next-line no-console
|
|
1186
|
+
console.warn("Something went wrong while loading the export-resources-modal messages for ".concat(locale), error);
|
|
1187
|
+
reportErrorToSentry(new Error("Something went wrong while loading the export-resources-modal messages for ".concat(locale)), {
|
|
1188
|
+
extra: error
|
|
1189
|
+
});
|
|
1190
|
+
return {};
|
|
1191
|
+
}
|
|
1192
|
+
};
|
|
1193
|
+
|
|
1194
|
+
const useAsyncIntlMessages = (locale, loader) => {
|
|
1195
|
+
const _useState = useState({
|
|
1196
|
+
isLoading: true,
|
|
1197
|
+
messages: undefined,
|
|
1198
|
+
error: undefined
|
|
1199
|
+
}),
|
|
1200
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1201
|
+
state = _useState2[0],
|
|
1202
|
+
setState = _useState2[1];
|
|
1203
|
+
useEffect(() => {
|
|
1204
|
+
let _isUnmounting = false;
|
|
1205
|
+
async function load() {
|
|
1206
|
+
try {
|
|
1207
|
+
if (!_isUnmounting) {
|
|
1208
|
+
const messages = await loader(locale);
|
|
1209
|
+
setState({
|
|
1210
|
+
isLoading: false,
|
|
1211
|
+
messages
|
|
1212
|
+
});
|
|
1213
|
+
}
|
|
1214
|
+
} catch (error) {
|
|
1215
|
+
setState({
|
|
1216
|
+
isLoading: false,
|
|
1217
|
+
error
|
|
1218
|
+
});
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
if (locale) load();
|
|
1222
|
+
return () => {
|
|
1223
|
+
_isUnmounting = true;
|
|
1224
|
+
};
|
|
1225
|
+
}, [locale, loader]);
|
|
1226
|
+
return state;
|
|
1227
|
+
};
|
|
1228
|
+
|
|
1201
1229
|
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1202
1230
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1203
1231
|
const ExportResourcesModal = props => {
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1232
|
+
const _useApplicationContex = useApplicationContext(context => ({
|
|
1233
|
+
locale: context.user && context.user.locale
|
|
1234
|
+
})),
|
|
1235
|
+
locale = _useApplicationContex.locale;
|
|
1236
|
+
const messages = useAsyncIntlMessages('en', loadI18n);
|
|
1237
|
+
if (!props.isOpen || messages.isLoading) return null;
|
|
1238
|
+
return jsx(IntlProvider, {
|
|
1239
|
+
locale: locale,
|
|
1240
|
+
messages: messages.messages,
|
|
1241
|
+
children: jsx(ExportResourcesProvider, _objectSpread(_objectSpread({}, props), {}, {
|
|
1242
|
+
children: jsx(CurrentStep, {})
|
|
1243
|
+
}))
|
|
1244
|
+
});
|
|
1208
1245
|
};
|
|
1209
1246
|
ExportResourcesModal.displayName = 'ExportResourcesModal';
|
|
1210
1247
|
ExportResourcesModal.defaultProps = {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-frontend-extensions/export-resources-modal",
|
|
3
3
|
"description": "Shared export modal for exporting resources",
|
|
4
|
-
"version": "0.0.0-canary-
|
|
4
|
+
"version": "0.0.0-canary-20240508124931",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"omit-empty-es": "^1.1.3",
|
|
29
29
|
"prop-types": "15.8.1",
|
|
30
30
|
"react": "17.0.2",
|
|
31
|
-
"
|
|
31
|
+
"@commercetools-local/shared": "1.0.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@commercetools-frontend/actions-global": "22.25.1",
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"@commercetools-frontend/application-shell": "22.25.1",
|
|
37
37
|
"@commercetools-frontend/application-shell-connectors": "22.25.1",
|
|
38
38
|
"@commercetools-frontend/constants": "22.25.1",
|
|
39
|
+
"@commercetools-frontend/i18n": "22.25.1",
|
|
39
40
|
"@commercetools-frontend/jest-preset-mc-app": "22.25.1",
|
|
40
41
|
"@commercetools-frontend/sdk": "22.25.1",
|
|
41
42
|
"@commercetools-frontend/sentry": "22.25.1",
|
|
@@ -45,6 +46,9 @@
|
|
|
45
46
|
"@types/jest": "29.5.12",
|
|
46
47
|
"@types/testing-library__jest-dom": "^5.14.5",
|
|
47
48
|
"msw": "1.3.3",
|
|
49
|
+
"react-intl": "6.6.6",
|
|
50
|
+
"react-redux": "7.2.9",
|
|
51
|
+
"redux": "4.2.1",
|
|
48
52
|
"rimraf": "5.0.5"
|
|
49
53
|
},
|
|
50
54
|
"peerDependencies": {
|
|
@@ -53,11 +57,15 @@
|
|
|
53
57
|
"@commercetools-frontend/application-shell": "22.x",
|
|
54
58
|
"@commercetools-frontend/application-shell-connectors": "22.x",
|
|
55
59
|
"@commercetools-frontend/constants": "22.x",
|
|
60
|
+
"@commercetools-frontend/i18n": "22.x",
|
|
56
61
|
"@commercetools-frontend/jest-preset-mc-app": "22.x",
|
|
57
62
|
"@commercetools-frontend/sdk": "22.x",
|
|
58
63
|
"@commercetools-frontend/sentry": "22.x",
|
|
59
64
|
"@commercetools-frontend/ui-kit": "17.x || 18.x || 19.x",
|
|
60
|
-
"@commercetools-uikit/design-system": "17.x || 18.x || 19.x"
|
|
65
|
+
"@commercetools-uikit/design-system": "17.x || 18.x || 19.x",
|
|
66
|
+
"react-intl": "6.x",
|
|
67
|
+
"react-redux": "7.x",
|
|
68
|
+
"redux": "4.x"
|
|
61
69
|
},
|
|
62
70
|
"scripts": {
|
|
63
71
|
"build": "rimraf dist && preconstruct build",
|
|
@@ -65,7 +73,7 @@
|
|
|
65
73
|
"test:watch": "jest --config jest.test.config.js --watch",
|
|
66
74
|
"build:bundles": "pnpm build",
|
|
67
75
|
"build:watch": "preconstruct watch",
|
|
68
|
-
"extract-intl": "formatjs extract --format transifex --out-file $(pwd)/src/i18n/data/core.json 'src
|
|
76
|
+
"extract-intl": "formatjs extract --format transifex --out-file $(pwd)/src/i18n/data/core.json 'src/**/(*.)?messages.(js|ts)'",
|
|
69
77
|
"typecheck": "tsc --noEmit"
|
|
70
78
|
}
|
|
71
79
|
}
|