@commercetools-frontend-extensions/export-resources-modal 4.1.2 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/dist/commercetools-frontend-extensions-export-resources-modal.cjs.dev.js +88 -76
  2. package/dist/commercetools-frontend-extensions-export-resources-modal.cjs.prod.js +85 -73
  3. package/dist/commercetools-frontend-extensions-export-resources-modal.esm.js +87 -75
  4. package/dist/{de-d2b26aa9.cjs.dev.js → de-2a6234a5.cjs.dev.js} +22 -30
  5. package/dist/{de-d3199184.cjs.prod.js → de-4316954a.cjs.prod.js} +22 -30
  6. package/dist/{de-39735288.esm.js → de-9c23a6d0.esm.js} +22 -30
  7. package/dist/declarations/src/@constants/exportable-resources.d.ts +1 -0
  8. package/dist/declarations/src/@constants/index.d.ts +1 -0
  9. package/dist/declarations/src/@constants/resource-type-messages.d.ts +2 -0
  10. package/dist/declarations/src/@constants/urls.d.ts +2 -3
  11. package/dist/declarations/src/@types/export-resources-modal-shape.d.ts +4 -4
  12. package/dist/declarations/src/@types/index.d.ts +1 -0
  13. package/dist/declarations/src/@types/resource-type.d.ts +7 -0
  14. package/dist/{en-d27c9cc6.cjs.dev.js → en-3ff78dd6.cjs.prod.js} +22 -30
  15. package/dist/{en-9154a09c.cjs.prod.js → en-824a97a4.cjs.dev.js} +22 -30
  16. package/dist/{en-e9679129.esm.js → en-918b9076.esm.js} +22 -30
  17. package/dist/{es-8a6a2dee.cjs.dev.js → es-2adfbcfc.cjs.dev.js} +24 -32
  18. package/dist/{es-9dd22c84.esm.js → es-96a36990.esm.js} +24 -32
  19. package/dist/{es-85b30e13.cjs.prod.js → es-b80ca82c.cjs.prod.js} +24 -32
  20. package/dist/{fr-FR-832b636d.cjs.prod.js → fr-FR-6c989046.cjs.prod.js} +24 -32
  21. package/dist/{fr-FR-2f22db42.esm.js → fr-FR-8589dc5c.esm.js} +24 -32
  22. package/dist/{fr-FR-75b735ea.cjs.dev.js → fr-FR-d36cb786.cjs.dev.js} +24 -32
  23. package/dist/{pt-BR-f1e9f28a.cjs.dev.js → pt-BR-6dc77a9e.cjs.dev.js} +23 -31
  24. package/dist/{pt-BR-62408d52.esm.js → pt-BR-aef7dfa4.esm.js} +23 -31
  25. package/dist/{pt-BR-11e4c627.cjs.prod.js → pt-BR-b8807555.cjs.prod.js} +23 -31
  26. package/dist/{zh-CN-896408dc.cjs.dev.js → zh-CN-086bca26.cjs.dev.js} +23 -31
  27. package/dist/{zh-CN-35db5160.esm.js → zh-CN-b9eaf9b3.esm.js} +23 -31
  28. package/dist/{zh-CN-42d4a424.cjs.prod.js → zh-CN-e961895b.cjs.prod.js} +23 -31
  29. package/package.json +24 -24
@@ -26,7 +26,6 @@ var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
26
26
  var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
27
27
  var _wrapNativeSuper = require('@babel/runtime-corejs3/helpers/wrapNativeSuper');
28
28
  var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
29
- var moment = require('moment');
30
29
  var _someInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/some');
31
30
  var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
32
31
  var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
@@ -36,6 +35,7 @@ var _Array$isArray = require('@babel/runtime-corejs3/core-js-stable/array/is-arr
36
35
  var _Set = require('@babel/runtime-corejs3/core-js-stable/set');
37
36
  var _sortInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/sort');
38
37
  var _indexOfInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/index-of');
38
+ var moment = require('moment');
39
39
  var experimentalComponents = require('@commercetools-frontend/experimental-components');
40
40
  var sdk = require('@commercetools-frontend/sdk');
41
41
  var actionsGlobal = require('@commercetools-frontend/actions-global');
@@ -65,7 +65,6 @@ var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defin
65
65
  var _valuesInstanceProperty__default = /*#__PURE__*/_interopDefault(_valuesInstanceProperty);
66
66
  var React__default = /*#__PURE__*/_interopDefault(React);
67
67
  var _Reflect$construct__default = /*#__PURE__*/_interopDefault(_Reflect$construct);
68
- var moment__default = /*#__PURE__*/_interopDefault(moment);
69
68
  var _someInstanceProperty__default = /*#__PURE__*/_interopDefault(_someInstanceProperty);
70
69
  var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInstanceProperty);
71
70
  var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
@@ -75,6 +74,7 @@ var _Array$isArray__default = /*#__PURE__*/_interopDefault(_Array$isArray);
75
74
  var _Set__default = /*#__PURE__*/_interopDefault(_Set);
76
75
  var _sortInstanceProperty__default = /*#__PURE__*/_interopDefault(_sortInstanceProperty);
77
76
  var _indexOfInstanceProperty__default = /*#__PURE__*/_interopDefault(_indexOfInstanceProperty);
77
+ var moment__default = /*#__PURE__*/_interopDefault(moment);
78
78
  var _styled__default = /*#__PURE__*/_interopDefault(_styled);
79
79
  var _everyInstanceProperty__default = /*#__PURE__*/_interopDefault(_everyInstanceProperty);
80
80
  var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
@@ -95,10 +95,20 @@ function getNewLine() {
95
95
  }
96
96
 
97
97
  var messages = reactIntl.defineMessages({
98
- modalTitle: {
99
- id: 'ExportResourcesModal.modalTitle',
100
- description: 'Label for the modal title',
101
- defaultMessage: 'Export {resourceType}'
98
+ 'modalTitle.category': {
99
+ id: 'ExportResourcesModal.modalTitle.category',
100
+ description: 'Label for the categories modal title',
101
+ defaultMessage: 'Export categories'
102
+ },
103
+ 'modalTitle.product': {
104
+ id: 'ExportResourcesModal.modalTitle.product',
105
+ description: 'Label for the products modal title',
106
+ defaultMessage: 'Export products'
107
+ },
108
+ 'modalTitle.inventory-entry': {
109
+ id: 'ExportResourcesModal.modalTitle.inventoryEntry',
110
+ description: 'Label for the inventories modal title',
111
+ defaultMessage: 'Export inventories'
102
112
  },
103
113
  outputFormat: {
104
114
  id: 'ExportResourcesModal.outputFormat',
@@ -115,36 +125,6 @@ var messages = reactIntl.defineMessages({
115
125
  description: 'Locale',
116
126
  defaultMessage: 'Locale'
117
127
  },
118
- exportSelection: {
119
- id: 'ExportResourcesModal.exportSelection',
120
- description: 'Export selection',
121
- defaultMessage: 'Export selection'
122
- },
123
- exportAllResources: {
124
- id: 'ExportResourcesModal.exportAllResources',
125
- description: 'Export All selection',
126
- defaultMessage: 'Export all {resourceType} ({count})'
127
- },
128
- exportOnlySelectedResources: {
129
- id: 'ExportResourcesModal.exportOnlySelectedResources',
130
- description: 'Export only selected resources',
131
- defaultMessage: 'Export selected {resourceType} ({count})'
132
- },
133
- exportAllMessage: {
134
- id: 'ExportResourcesModal.exportAllMessage',
135
- description: 'All resources will be exported',
136
- defaultMessage: 'All <b>{count}</b> {resourceType} will be exported.'
137
- },
138
- exportMatchingMessage: {
139
- id: 'ExportResourcesModal.exportMatchingMessage',
140
- description: 'resources will be exported',
141
- defaultMessage: '<b>{count}</b> {resourceType} will be exported.'
142
- },
143
- exportSelectedMessage: {
144
- id: 'ExportResourcesModal.exportSelectedMessage',
145
- description: 'resources are selected and will be exported',
146
- defaultMessage: '<b>{count}</b> {resourceType} are selected and will be exported.'
147
- },
148
128
  exportBasedOnMyViewsMessage: {
149
129
  id: 'ExportResourcesModal.exportBasedOnMyViewsMessage',
150
130
  description: 'Select Export setttings based on my views',
@@ -249,16 +229,36 @@ var messages = reactIntl.defineMessages({
249
229
  description: 'Label for Export Scope',
250
230
  defaultMessage: 'Scope'
251
231
  },
252
- exportScopeAll: {
253
- id: 'ExportResourcesModal.exportScopeAll',
254
- description: 'Label for Export All',
232
+ exportScopeAllCategories: {
233
+ id: 'ExportResourcesModal.exportScopeAllCategories',
234
+ description: 'Label for Export All categories',
255
235
  defaultMessage: 'Export all: {total} categories'
256
236
  },
257
- exportScopeSelected: {
258
- id: 'ExportResourcesModal.exportScopeSelected',
259
- description: 'Label for Export Selected',
237
+ exportScopeSelectedCategories: {
238
+ id: 'ExportResourcesModal.exportScopeSelectedCategories',
239
+ description: 'Label for Export Selected categories',
260
240
  defaultMessage: 'Export selected: {total} categories'
261
241
  },
242
+ exportScopeAllProducts: {
243
+ id: 'ExportResourcesModal.exportScopeAllProducts',
244
+ description: 'Label for Export All products',
245
+ defaultMessage: 'Export all: {total} products'
246
+ },
247
+ exportScopeSelectedProducts: {
248
+ id: 'ExportResourcesModal.exportScopeSelectedProducts',
249
+ description: 'Label for Export Selected products',
250
+ defaultMessage: 'Export selected: {total} products'
251
+ },
252
+ exportScopeAllInventories: {
253
+ id: 'ExportResourcesModal.exportScopeAllInventories',
254
+ description: 'Label for Export All inventories',
255
+ defaultMessage: 'Export all: {total} inventories'
256
+ },
257
+ exportScopeSelectedInventories: {
258
+ id: 'ExportResourcesModal.exportScopeSelectedInventories',
259
+ description: 'Label for Export Selected inventories',
260
+ defaultMessage: 'Export selected: {total} inventories'
261
+ },
262
262
  exportScopeSelectedWithoutCount: {
263
263
  id: 'ExportResourcesModal.exportScopeSelectedWithoutCount',
264
264
  description: 'Label for Export Selected without count',
@@ -418,7 +418,9 @@ const EXPORT_TYPES = {
418
418
  const EXPORTABLE_RESOURCES = {
419
419
  CATEGORY: 'category',
420
420
  PRODUCT: 'product',
421
- DISCOUNT_CODE: 'discountCode'
421
+ // TODO: remove this and its usage
422
+ DISCOUNT_CODE: 'discountCode',
423
+ INVENTORY_ENTRY: 'inventory-entry'
422
424
  };
423
425
 
424
426
  const OUTPUT_FORMATS = {
@@ -434,15 +436,33 @@ const OUTPUT_FORMAT_OPTIONS = [{
434
436
  }];
435
437
 
436
438
  const FIELD_DEFINITIONS_URLS = {
437
- category: 'https://docs.commercetools.com/merchant-center/import-categories#supported-headers-and-values'
439
+ category: 'https://docs.commercetools.com/merchant-center/import-categories#supported-headers-and-values',
440
+ product: 'https://docs.commercetools.com/merchant-center/import-products#supported-headers-and-values',
441
+ 'inventory-entry': 'https://docs.commercetools.com/merchant-center/import-inventory#supported-headers-and-values'
442
+ };
443
+
444
+ const resourceTypeMessages = {
445
+ category: {
446
+ exportScopeAll: messages.exportScopeAllCategories,
447
+ exportScopeSelected: messages.exportScopeSelectedCategories
448
+ },
449
+ product: {
450
+ exportScopeAll: messages.exportScopeAllProducts,
451
+ exportScopeSelected: messages.exportScopeSelectedProducts
452
+ },
453
+ 'inventory-entry': {
454
+ exportScopeAll: messages.exportScopeAllInventories,
455
+ exportScopeSelected: messages.exportScopeSelectedInventories
456
+ }
438
457
  };
439
458
 
440
- function resourceTypeToDisplayName(_ref) {
459
+ function resourceTypeToFileName(_ref) {
441
460
  let resourceType = _ref.resourceType,
442
461
  _ref$isUpperCase = _ref.isUpperCase,
443
462
  isUpperCase = _ref$isUpperCase === void 0 ? false : _ref$isUpperCase,
444
463
  _ref$isPlural = _ref.isPlural,
445
464
  isPlural = _ref$isPlural === void 0 ? false : _ref$isPlural;
465
+ const todayFormatted = moment__default["default"]().format('DD-MM-YY_HH-mm');
446
466
  let displayName;
447
467
  switch (resourceType) {
448
468
  case EXPORTABLE_RESOURCES.CATEGORY:
@@ -454,10 +474,14 @@ function resourceTypeToDisplayName(_ref) {
454
474
  case EXPORTABLE_RESOURCES.DISCOUNT_CODE:
455
475
  displayName = isPlural ? 'Discount codes' : 'Discount code';
456
476
  break;
477
+ case EXPORTABLE_RESOURCES.INVENTORY_ENTRY:
478
+ displayName = isPlural ? 'Inventories' : 'Inventory';
479
+ break;
457
480
  default:
458
481
  throw new UnexpectedResourceTypeError(resourceType);
459
482
  }
460
- return isUpperCase ? displayName : displayName.toLowerCase();
483
+ const result = isUpperCase ? displayName : displayName.toLowerCase();
484
+ return `${result}_Export_${todayFormatted}`;
461
485
  }
462
486
  function mapLocalesToOptions(locales) {
463
487
  return _mapInstanceProperty__default["default"](locales).call(locales, locale => ({
@@ -569,7 +593,6 @@ const updateFieldGroupWithAdditionalFieldExtensions = groups => {
569
593
  };
570
594
 
571
595
  const useInitialValues = props => {
572
- const todayFormatted = moment__default["default"]().format('DD-MM-YY_HH-mm');
573
596
  const _useApplicationContex = applicationShellConnectors.useApplicationContext(applicationContext => ({
574
597
  locale: applicationContext.dataLocale
575
598
  })),
@@ -585,15 +608,15 @@ const useInitialValues = props => {
585
608
  const groups = updateFieldGroupsWithIsCheckedValue(props.fieldGroups, cachedSelectedGroups[props.resourceType] || {});
586
609
  return {
587
610
  outputFormat: props.outputFormat,
588
- fileName: `${resourceTypeToDisplayName({
611
+ fileName: `${resourceTypeToFileName({
589
612
  resourceType: props.resourceType,
590
613
  isUpperCase: true,
591
614
  isPlural: true
592
- })}_Export_${todayFormatted}`,
615
+ })}`,
593
616
  locales: [locale],
594
617
  groups: updateFieldGroupWithAdditionalFieldExtensions(groups)
595
618
  };
596
- }, [props.fieldGroups, props.outputFormat, props.resourceType, cachedSelectedGroups, todayFormatted, locale]);
619
+ }, [props.fieldGroups, props.outputFormat, props.resourceType, cachedSelectedGroups, locale]);
597
620
  };
598
621
 
599
622
  async function createExportOperation(_ref) {
@@ -710,7 +733,8 @@ function ExportScopeSection() {
710
733
  exportType = _useExportResourcesCo.exportType,
711
734
  totalResourcesCount = _useExportResourcesCo.totalResourcesCount,
712
735
  originalSelectedResourceIds = _useExportResourcesCo.originalSelectedResourceIds,
713
- onScopeChange = _useExportResourcesCo.onScopeChange;
736
+ onScopeChange = _useExportResourcesCo.onScopeChange,
737
+ resourceType = _useExportResourcesCo.resourceType;
714
738
  return jsxRuntime.jsx(uiKit.Spacings.Stack, {
715
739
  scale: "m",
716
740
  children: jsxRuntime.jsxs(uiKit.RadioInput.Group, {
@@ -725,7 +749,7 @@ function ExportScopeSection() {
725
749
  children: [jsxRuntime.jsx(uiKit.RadioInput.Option, {
726
750
  value: EXPORT_TYPES.ALL,
727
751
  children: jsxRuntime.jsx(uiKit.Text.Body, {
728
- intlMessage: _objectSpread$3(_objectSpread$3({}, messages.exportScopeAll), {}, {
752
+ intlMessage: _objectSpread$3(_objectSpread$3({}, resourceTypeMessages[resourceType].exportScopeAll), {}, {
729
753
  values: {
730
754
  total: new Intl.NumberFormat().format(totalResourcesCount)
731
755
  }
@@ -736,7 +760,7 @@ function ExportScopeSection() {
736
760
  isDisabled: !originalSelectedResourceIds?.length,
737
761
  children: jsxRuntime.jsx(uiKit.Text.Body, {
738
762
  tone: !originalSelectedResourceIds?.length ? 'tertiary' : undefined,
739
- intlMessage: originalSelectedResourceIds?.length ? _objectSpread$3(_objectSpread$3({}, messages.exportScopeSelected), {}, {
763
+ intlMessage: originalSelectedResourceIds?.length ? _objectSpread$3(_objectSpread$3({}, resourceTypeMessages[resourceType].exportScopeSelected), {}, {
740
764
  values: {
741
765
  total: new Intl.NumberFormat().format(originalSelectedResourceIds?.length ?? 0)
742
766
  }
@@ -753,10 +777,6 @@ const ExportFileSettingsStep = () => {
753
777
  formik = _useExportResourcesCo.formik,
754
778
  resourceType = _useExportResourcesCo.resourceType,
755
779
  onClose = _useExportResourcesCo.onClose;
756
- const resourceTypePlural = resourceTypeToDisplayName({
757
- resourceType: resourceType,
758
- isPlural: true
759
- });
760
780
  const _useApplicationContex = applicationShellConnectors.useApplicationContext(applicationContext => ({
761
781
  locale: applicationContext.dataLocale,
762
782
  locales: applicationContext.project?.languages || []
@@ -766,9 +786,7 @@ const ExportFileSettingsStep = () => {
766
786
  const areAllLocalesChecked = _valuesInstanceProperty__default["default"](formik).locales.length === locales.length;
767
787
  return jsxRuntime.jsx(applicationComponents.FormDialog, {
768
788
  isOpen: true,
769
- title: intl.formatMessage(messages.modalTitle, {
770
- resourceType: resourceTypePlural
771
- }),
789
+ title: intl.formatMessage(messages[`modalTitle.${resourceType}`]),
772
790
  labelPrimary: intl.formatMessage(messages.continue),
773
791
  onPrimaryButtonClick: formik.submitForm,
774
792
  isPrimaryButtonDisabled: !formik.isValid,
@@ -1044,10 +1062,6 @@ const ExportFieldsSelectionStep = () => {
1044
1062
  setCurrentStep = _useExportResourcesCo.setCurrentStep,
1045
1063
  resourceType = _useExportResourcesCo.resourceType,
1046
1064
  onClose = _useExportResourcesCo.onClose;
1047
- const resourceTypePlural = resourceTypeToDisplayName({
1048
- resourceType: resourceType,
1049
- isPlural: true
1050
- });
1051
1065
  React__default["default"].useEffect(() => {
1052
1066
  var _context3;
1053
1067
  formik.validateForm();
@@ -1106,9 +1120,7 @@ const ExportFieldsSelectionStep = () => {
1106
1120
  };
1107
1121
  return jsxRuntime.jsx(applicationComponents.FormDialog, {
1108
1122
  isOpen: true,
1109
- title: intl.formatMessage(messages.modalTitle, {
1110
- resourceType: resourceTypePlural
1111
- }),
1123
+ title: intl.formatMessage(messages[`modalTitle.${resourceType}`]),
1112
1124
  labelPrimary: intl.formatMessage(messages.startExport),
1113
1125
  onPrimaryButtonClick: formik.submitForm,
1114
1126
  isPrimaryButtonDisabled: !formik.isValid,
@@ -1236,19 +1248,19 @@ const getChunkImport = locale => {
1236
1248
  const intlLocale = i18n.mapLocaleToIntlLocale(locale);
1237
1249
  switch (intlLocale) {
1238
1250
  case 'de':
1239
- return Promise.resolve().then(function () { return require( /* webpackChunkName: "export-resources-modal-i18n-de" */'./de-d3199184.cjs.prod.js'); });
1251
+ return Promise.resolve().then(function () { return require( /* webpackChunkName: "export-resources-modal-i18n-de" */'./de-4316954a.cjs.prod.js'); });
1240
1252
  case 'es':
1241
- return Promise.resolve().then(function () { return require( /* webpackChunkName: "export-resources-modal-i18n-es" */'./es-85b30e13.cjs.prod.js'); });
1253
+ return Promise.resolve().then(function () { return require( /* webpackChunkName: "export-resources-modal-i18n-es" */'./es-b80ca82c.cjs.prod.js'); });
1242
1254
  case 'fr-FR':
1243
- return Promise.resolve().then(function () { return require( /* webpackChunkName: "export-resources-modal-i18n-fr-FR" */'./fr-FR-832b636d.cjs.prod.js'); });
1255
+ return Promise.resolve().then(function () { return require( /* webpackChunkName: "export-resources-modal-i18n-fr-FR" */'./fr-FR-6c989046.cjs.prod.js'); });
1244
1256
  case 'zh-CN':
1245
- return Promise.resolve().then(function () { return require( /* webpackChunkName: "export-resources-modal-i18n-zh-CN" */'./zh-CN-42d4a424.cjs.prod.js'); });
1257
+ return Promise.resolve().then(function () { return require( /* webpackChunkName: "export-resources-modal-i18n-zh-CN" */'./zh-CN-e961895b.cjs.prod.js'); });
1246
1258
  case 'ja':
1247
1259
  return Promise.resolve().then(function () { return require( /* webpackChunkName: "export-resources-modal-i18n-ja" */'./ja-37632763.cjs.prod.js'); });
1248
1260
  case 'pt-BR':
1249
- return Promise.resolve().then(function () { return require( /* webpackChunkName: "change-history-i18n-pt-BR" */'./pt-BR-11e4c627.cjs.prod.js'); });
1261
+ return Promise.resolve().then(function () { return require( /* webpackChunkName: "change-history-i18n-pt-BR" */'./pt-BR-b8807555.cjs.prod.js'); });
1250
1262
  default:
1251
- return Promise.resolve().then(function () { return require( /* webpackChunkName: "export-resources-modal-i18n-en" */'./en-9154a09c.cjs.prod.js'); });
1263
+ return Promise.resolve().then(function () { return require( /* webpackChunkName: "export-resources-modal-i18n-en" */'./en-3ff78dd6.cjs.prod.js'); });
1252
1264
  }
1253
1265
  };
1254
1266
  const loadMessages = async locale => {