@commercetools-frontend-extensions/delete-resources-modal 1.7.5 → 2.0.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.
@@ -29,7 +29,6 @@ var _possibleConstructorReturn = require('@babel/runtime-corejs3/helpers/possibl
29
29
  var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
30
30
  var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
31
31
  var _wrapNativeSuper = require('@babel/runtime-corejs3/helpers/wrapNativeSuper');
32
- var applicationShell = require('@commercetools-frontend/application-shell');
33
32
  var sentry = require('@commercetools-frontend/sentry');
34
33
  var _sliceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/slice');
35
34
  require('@emotion/react');
@@ -49,17 +48,17 @@ var React__default = /*#__PURE__*/_interopDefault(React);
49
48
  var _Reflect$construct__default = /*#__PURE__*/_interopDefault(_Reflect$construct);
50
49
  var _sliceInstanceProperty__default = /*#__PURE__*/_interopDefault(_sliceInstanceProperty);
51
50
 
52
- function ownKeys$7(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; }
53
- function _objectSpread$7(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$7(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$7(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
51
+ function ownKeys$6(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; }
52
+ function _objectSpread$6(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$6(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$6(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
54
53
  function reducer(state, action) {
55
- if (action.type === 'setCurrentStep') return _objectSpread$7(_objectSpread$7({}, state), {}, {
54
+ if (action.type === 'setCurrentStep') return _objectSpread$6(_objectSpread$6({}, state), {}, {
56
55
  currentStep: action.currentStep,
57
56
  progress: 0
58
57
  });
59
- if (action.type === 'setContainerKey') return _objectSpread$7(_objectSpread$7({}, state), {}, {
58
+ if (action.type === 'setContainerKey') return _objectSpread$6(_objectSpread$6({}, state), {}, {
60
59
  containerKey: action.containerKey
61
60
  });
62
- if (action.type === 'cancelImport') return _objectSpread$7(_objectSpread$7({}, state), {}, {
61
+ if (action.type === 'cancelImport') return _objectSpread$6(_objectSpread$6({}, state), {}, {
63
62
  currentStep: 'upload',
64
63
  containerKey: undefined,
65
64
  droppedFile: undefined,
@@ -69,7 +68,7 @@ function reducer(state, action) {
69
68
  validationProcessed: undefined,
70
69
  isValidating: false
71
70
  });
72
- if (action.type === 'uploadNewFile') return _objectSpread$7(_objectSpread$7({}, state), {}, {
71
+ if (action.type === 'uploadNewFile') return _objectSpread$6(_objectSpread$6({}, state), {}, {
73
72
  currentStep: 'upload',
74
73
  containerKey: undefined,
75
74
  droppedFile: undefined,
@@ -80,37 +79,37 @@ function reducer(state, action) {
80
79
  isValidating: false
81
80
  });
82
81
  if (action.type === 'setDroppedFile') {
83
- return _objectSpread$7(_objectSpread$7({}, state), {}, {
82
+ return _objectSpread$6(_objectSpread$6({}, state), {}, {
84
83
  droppedFile: action.droppedFile
85
84
  });
86
85
  }
87
86
  if (action.type === 'setAbortController') {
88
- return _objectSpread$7(_objectSpread$7({}, state), {}, {
87
+ return _objectSpread$6(_objectSpread$6({}, state), {}, {
89
88
  abortController: action.abortController
90
89
  });
91
90
  }
92
91
  if (action.type === 'setProgress') {
93
- return _objectSpread$7(_objectSpread$7({}, state), {}, {
92
+ return _objectSpread$6(_objectSpread$6({}, state), {}, {
94
93
  progress: action.progress
95
94
  });
96
95
  }
97
96
  if (action.type === 'setUploadFileResponse') {
98
- return _objectSpread$7(_objectSpread$7({}, state), {}, {
97
+ return _objectSpread$6(_objectSpread$6({}, state), {}, {
99
98
  uploadFileResponse: action.uploadFileResponse
100
99
  });
101
100
  }
102
101
  if (action.type === 'setFileUploadErrors') {
103
- return _objectSpread$7(_objectSpread$7({}, state), {}, {
102
+ return _objectSpread$6(_objectSpread$6({}, state), {}, {
104
103
  fileUploadErrors: action.fileUploadErrors
105
104
  });
106
105
  }
107
106
  if (action.type === 'setJobId') {
108
- return _objectSpread$7(_objectSpread$7({}, state), {}, {
107
+ return _objectSpread$6(_objectSpread$6({}, state), {}, {
109
108
  jobId: action.jobId
110
109
  });
111
110
  }
112
111
  if (action.type === 'setValidationProgress') {
113
- return _objectSpread$7(_objectSpread$7({}, state), {}, {
112
+ return _objectSpread$6(_objectSpread$6({}, state), {}, {
114
113
  validationProcessed: action.processed,
115
114
  isValidating: action.isValidating
116
115
  });
@@ -465,22 +464,6 @@ var messages$4 = reactIntl.defineMessages({
465
464
  }
466
465
  });
467
466
 
468
- function ownKeys$6(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; }
469
- function _objectSpread$6(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$6(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$6(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
470
- const FILE_IMPORT_JOB_FLOW = 'fileImportJobFlow';
471
- const DEFAULT_SHORT_LIVED_FLAGS = {
472
- [FILE_IMPORT_JOB_FLOW]: false
473
- };
474
- const DEFAULT_LONG_LIVED_FLAGS = {};
475
- _objectSpread$6(_objectSpread$6({}, DEFAULT_SHORT_LIVED_FLAGS), DEFAULT_LONG_LIVED_FLAGS);
476
-
477
- const DOCUMENTATION_LINKS = {
478
- product: 'https://docs.commercetools.com/merchant-center/product-list#bulk-delete-via-csv-import'
479
- };
480
- const TEMPLATE_DOWNLOAD_LINKS = {
481
- product: 'https://docs.commercetools.com/merchant-center/downloads/product_delete_import_template.csv'
482
- };
483
-
484
467
  const useUpload = () => {
485
468
  const intl = reactIntl.useIntl();
486
469
  const _useApplicationContex = applicationShellConnectors.useApplicationContext(context => ({
@@ -492,25 +475,21 @@ const useUpload = () => {
492
475
  state = _useDeleteResourcesCo.state,
493
476
  actions = _useDeleteResourcesCo.actions;
494
477
  const showNotification = actionsGlobal.useShowNotification();
495
- const isFileImportJobFlowEnabled = applicationShell.useFeatureToggle(FILE_IMPORT_JOB_FLOW);
496
478
  const _useFileUpload = operations.useFileUpload({
497
- projectKey: projectKey,
498
- useJobBasedFlow: isFileImportJobFlowEnabled
479
+ projectKey: projectKey
499
480
  }),
500
481
  upload = _useFileUpload.upload;
501
482
  const isFileValid = async file => {
502
483
  const errors = [];
503
- const maxFileSizeMB = isFileImportJobFlowEnabled ? operations.IMPORT_MAX_FILE_SIZE_MB : operations.IMPORT_LEGACY_MAX_FILE_SIZE_MB;
504
- const maxItemCount = isFileImportJobFlowEnabled ? operations.IMPORT_MAX_ITEM_COUNT : operations.IMPORT_LEGACY_MAX_ROW_COUNT;
505
484
  const rowCount = await operations.getRowCount(file);
506
485
  if (rowCount < 1) errors.push({
507
486
  title: intl.formatMessage(messages$4.dropAreaNotEnoughRowsTitle),
508
487
  description: intl.formatMessage(messages$4.dropAreaNotEnoughRowsDescription)
509
488
  });
510
- if (file.size > operations.toBytes(maxFileSizeMB)) errors.push({
489
+ if (file.size > operations.toBytes(operations.IMPORT_MAX_FILE_SIZE_MB)) errors.push({
511
490
  title: intl.formatMessage(messages$4.fileSizeExceededTitle),
512
491
  description: intl.formatMessage(messages$4.fileSizeExceededDescription, {
513
- fileSizeLimit: intl.formatNumber(maxFileSizeMB)
492
+ fileSizeLimit: intl.formatNumber(operations.IMPORT_MAX_FILE_SIZE_MB)
514
493
  })
515
494
  });
516
495
  if (!(await operations.hasSingleKeyColumn(file))) {
@@ -519,10 +498,10 @@ const useUpload = () => {
519
498
  description: intl.formatMessage(messages$4.csvFormatErrorDescription)
520
499
  });
521
500
  }
522
- if (rowCount > maxItemCount) errors.push({
501
+ if (rowCount > operations.IMPORT_MAX_ITEM_COUNT) errors.push({
523
502
  title: intl.formatMessage(messages$4.rowLimitExceededTitle),
524
503
  description: intl.formatMessage(messages$4.rowLimitExceededDescription, {
525
- rowLimit: intl.formatNumber(maxItemCount)
504
+ rowLimit: intl.formatNumber(operations.IMPORT_MAX_ITEM_COUNT)
526
505
  })
527
506
  });
528
507
  if (errors.length > 0) {
@@ -869,6 +848,13 @@ var messages$3 = reactIntl.defineMessages({
869
848
  }
870
849
  });
871
850
 
851
+ const DOCUMENTATION_LINKS = {
852
+ product: 'https://docs.commercetools.com/merchant-center/product-list#bulk-delete-via-csv-import'
853
+ };
854
+ const TEMPLATE_DOWNLOAD_LINKS = {
855
+ product: 'https://docs.commercetools.com/merchant-center/downloads/product_delete_import_template.csv'
856
+ };
857
+
872
858
  function resourceTypeToMessage(resourceType) {
873
859
  const resourceTypeMap = {
874
860
  category: sharedMessages.category,
@@ -926,11 +912,8 @@ const Instructions = () => {
926
912
  const intl = reactIntl.useIntl();
927
913
  const _useDeleteResourcesCo = useDeleteResourcesContext(),
928
914
  resourceType = _useDeleteResourcesCo.resourceType;
929
- const isFileImportJobFlowEnabled = applicationShell.useFeatureToggle(FILE_IMPORT_JOB_FLOW);
930
915
  const documentTemplateLink = TEMPLATE_DOWNLOAD_LINKS[resourceType];
931
916
  const documentationLink = DOCUMENTATION_LINKS[resourceType];
932
- const maxFileSizeMB = isFileImportJobFlowEnabled ? operations.IMPORT_MAX_FILE_SIZE_MB : operations.IMPORT_LEGACY_MAX_FILE_SIZE_MB;
933
- const maxItemCount = isFileImportJobFlowEnabled ? operations.IMPORT_MAX_ITEM_COUNT : operations.IMPORT_LEGACY_MAX_ROW_COUNT;
934
917
  return jsxRuntime.jsxs(uiKit.Spacings.Stack, {
935
918
  scale: "m",
936
919
  children: [jsxRuntime.jsxs(uiKit.Text.Body, {
@@ -944,8 +927,8 @@ const Instructions = () => {
944
927
  }), jsxRuntime.jsx(uiKit.Text.Body, {
945
928
  intlMessage: _objectSpread$5(_objectSpread$5({}, messages$3.fileUploadInstructionForMaxFileSize), {}, {
946
929
  values: {
947
- maxFileSize: intl.formatNumber(maxFileSizeMB),
948
- maxRowCount: intl.formatNumber(maxItemCount),
930
+ maxFileSize: intl.formatNumber(operations.IMPORT_MAX_FILE_SIZE_MB),
931
+ maxRowCount: intl.formatNumber(operations.IMPORT_MAX_ITEM_COUNT),
949
932
  csvTemplateLink: msg => jsxRuntime.jsx(uiKit.Link, {
950
933
  tone: "secondary",
951
934
  isExternal: true,
@@ -29,7 +29,6 @@ var _possibleConstructorReturn = require('@babel/runtime-corejs3/helpers/possibl
29
29
  var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
30
30
  var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
31
31
  var _wrapNativeSuper = require('@babel/runtime-corejs3/helpers/wrapNativeSuper');
32
- var applicationShell = require('@commercetools-frontend/application-shell');
33
32
  var sentry = require('@commercetools-frontend/sentry');
34
33
  var _sliceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/slice');
35
34
  require('@emotion/react');
@@ -49,17 +48,17 @@ var React__default = /*#__PURE__*/_interopDefault(React);
49
48
  var _Reflect$construct__default = /*#__PURE__*/_interopDefault(_Reflect$construct);
50
49
  var _sliceInstanceProperty__default = /*#__PURE__*/_interopDefault(_sliceInstanceProperty);
51
50
 
52
- function ownKeys$7(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; }
53
- function _objectSpread$7(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$7(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$7(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
51
+ function ownKeys$6(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; }
52
+ function _objectSpread$6(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$6(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$6(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
54
53
  function reducer(state, action) {
55
- if (action.type === 'setCurrentStep') return _objectSpread$7(_objectSpread$7({}, state), {}, {
54
+ if (action.type === 'setCurrentStep') return _objectSpread$6(_objectSpread$6({}, state), {}, {
56
55
  currentStep: action.currentStep,
57
56
  progress: 0
58
57
  });
59
- if (action.type === 'setContainerKey') return _objectSpread$7(_objectSpread$7({}, state), {}, {
58
+ if (action.type === 'setContainerKey') return _objectSpread$6(_objectSpread$6({}, state), {}, {
60
59
  containerKey: action.containerKey
61
60
  });
62
- if (action.type === 'cancelImport') return _objectSpread$7(_objectSpread$7({}, state), {}, {
61
+ if (action.type === 'cancelImport') return _objectSpread$6(_objectSpread$6({}, state), {}, {
63
62
  currentStep: 'upload',
64
63
  containerKey: undefined,
65
64
  droppedFile: undefined,
@@ -69,7 +68,7 @@ function reducer(state, action) {
69
68
  validationProcessed: undefined,
70
69
  isValidating: false
71
70
  });
72
- if (action.type === 'uploadNewFile') return _objectSpread$7(_objectSpread$7({}, state), {}, {
71
+ if (action.type === 'uploadNewFile') return _objectSpread$6(_objectSpread$6({}, state), {}, {
73
72
  currentStep: 'upload',
74
73
  containerKey: undefined,
75
74
  droppedFile: undefined,
@@ -80,37 +79,37 @@ function reducer(state, action) {
80
79
  isValidating: false
81
80
  });
82
81
  if (action.type === 'setDroppedFile') {
83
- return _objectSpread$7(_objectSpread$7({}, state), {}, {
82
+ return _objectSpread$6(_objectSpread$6({}, state), {}, {
84
83
  droppedFile: action.droppedFile
85
84
  });
86
85
  }
87
86
  if (action.type === 'setAbortController') {
88
- return _objectSpread$7(_objectSpread$7({}, state), {}, {
87
+ return _objectSpread$6(_objectSpread$6({}, state), {}, {
89
88
  abortController: action.abortController
90
89
  });
91
90
  }
92
91
  if (action.type === 'setProgress') {
93
- return _objectSpread$7(_objectSpread$7({}, state), {}, {
92
+ return _objectSpread$6(_objectSpread$6({}, state), {}, {
94
93
  progress: action.progress
95
94
  });
96
95
  }
97
96
  if (action.type === 'setUploadFileResponse') {
98
- return _objectSpread$7(_objectSpread$7({}, state), {}, {
97
+ return _objectSpread$6(_objectSpread$6({}, state), {}, {
99
98
  uploadFileResponse: action.uploadFileResponse
100
99
  });
101
100
  }
102
101
  if (action.type === 'setFileUploadErrors') {
103
- return _objectSpread$7(_objectSpread$7({}, state), {}, {
102
+ return _objectSpread$6(_objectSpread$6({}, state), {}, {
104
103
  fileUploadErrors: action.fileUploadErrors
105
104
  });
106
105
  }
107
106
  if (action.type === 'setJobId') {
108
- return _objectSpread$7(_objectSpread$7({}, state), {}, {
107
+ return _objectSpread$6(_objectSpread$6({}, state), {}, {
109
108
  jobId: action.jobId
110
109
  });
111
110
  }
112
111
  if (action.type === 'setValidationProgress') {
113
- return _objectSpread$7(_objectSpread$7({}, state), {}, {
112
+ return _objectSpread$6(_objectSpread$6({}, state), {}, {
114
113
  validationProcessed: action.processed,
115
114
  isValidating: action.isValidating
116
115
  });
@@ -465,22 +464,6 @@ var messages$4 = reactIntl.defineMessages({
465
464
  }
466
465
  });
467
466
 
468
- function ownKeys$6(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; }
469
- function _objectSpread$6(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$6(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$6(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
470
- const FILE_IMPORT_JOB_FLOW = 'fileImportJobFlow';
471
- const DEFAULT_SHORT_LIVED_FLAGS = {
472
- [FILE_IMPORT_JOB_FLOW]: false
473
- };
474
- const DEFAULT_LONG_LIVED_FLAGS = {};
475
- _objectSpread$6(_objectSpread$6({}, DEFAULT_SHORT_LIVED_FLAGS), DEFAULT_LONG_LIVED_FLAGS);
476
-
477
- const DOCUMENTATION_LINKS = {
478
- product: 'https://docs.commercetools.com/merchant-center/product-list#bulk-delete-via-csv-import'
479
- };
480
- const TEMPLATE_DOWNLOAD_LINKS = {
481
- product: 'https://docs.commercetools.com/merchant-center/downloads/product_delete_import_template.csv'
482
- };
483
-
484
467
  const useUpload = () => {
485
468
  const intl = reactIntl.useIntl();
486
469
  const _useApplicationContex = applicationShellConnectors.useApplicationContext(context => ({
@@ -492,25 +475,21 @@ const useUpload = () => {
492
475
  state = _useDeleteResourcesCo.state,
493
476
  actions = _useDeleteResourcesCo.actions;
494
477
  const showNotification = actionsGlobal.useShowNotification();
495
- const isFileImportJobFlowEnabled = applicationShell.useFeatureToggle(FILE_IMPORT_JOB_FLOW);
496
478
  const _useFileUpload = operations.useFileUpload({
497
- projectKey: projectKey,
498
- useJobBasedFlow: isFileImportJobFlowEnabled
479
+ projectKey: projectKey
499
480
  }),
500
481
  upload = _useFileUpload.upload;
501
482
  const isFileValid = async file => {
502
483
  const errors = [];
503
- const maxFileSizeMB = isFileImportJobFlowEnabled ? operations.IMPORT_MAX_FILE_SIZE_MB : operations.IMPORT_LEGACY_MAX_FILE_SIZE_MB;
504
- const maxItemCount = isFileImportJobFlowEnabled ? operations.IMPORT_MAX_ITEM_COUNT : operations.IMPORT_LEGACY_MAX_ROW_COUNT;
505
484
  const rowCount = await operations.getRowCount(file);
506
485
  if (rowCount < 1) errors.push({
507
486
  title: intl.formatMessage(messages$4.dropAreaNotEnoughRowsTitle),
508
487
  description: intl.formatMessage(messages$4.dropAreaNotEnoughRowsDescription)
509
488
  });
510
- if (file.size > operations.toBytes(maxFileSizeMB)) errors.push({
489
+ if (file.size > operations.toBytes(operations.IMPORT_MAX_FILE_SIZE_MB)) errors.push({
511
490
  title: intl.formatMessage(messages$4.fileSizeExceededTitle),
512
491
  description: intl.formatMessage(messages$4.fileSizeExceededDescription, {
513
- fileSizeLimit: intl.formatNumber(maxFileSizeMB)
492
+ fileSizeLimit: intl.formatNumber(operations.IMPORT_MAX_FILE_SIZE_MB)
514
493
  })
515
494
  });
516
495
  if (!(await operations.hasSingleKeyColumn(file))) {
@@ -519,10 +498,10 @@ const useUpload = () => {
519
498
  description: intl.formatMessage(messages$4.csvFormatErrorDescription)
520
499
  });
521
500
  }
522
- if (rowCount > maxItemCount) errors.push({
501
+ if (rowCount > operations.IMPORT_MAX_ITEM_COUNT) errors.push({
523
502
  title: intl.formatMessage(messages$4.rowLimitExceededTitle),
524
503
  description: intl.formatMessage(messages$4.rowLimitExceededDescription, {
525
- rowLimit: intl.formatNumber(maxItemCount)
504
+ rowLimit: intl.formatNumber(operations.IMPORT_MAX_ITEM_COUNT)
526
505
  })
527
506
  });
528
507
  if (errors.length > 0) {
@@ -869,6 +848,13 @@ var messages$3 = reactIntl.defineMessages({
869
848
  }
870
849
  });
871
850
 
851
+ const DOCUMENTATION_LINKS = {
852
+ product: 'https://docs.commercetools.com/merchant-center/product-list#bulk-delete-via-csv-import'
853
+ };
854
+ const TEMPLATE_DOWNLOAD_LINKS = {
855
+ product: 'https://docs.commercetools.com/merchant-center/downloads/product_delete_import_template.csv'
856
+ };
857
+
872
858
  function resourceTypeToMessage(resourceType) {
873
859
  const resourceTypeMap = {
874
860
  category: sharedMessages.category,
@@ -926,11 +912,8 @@ const Instructions = () => {
926
912
  const intl = reactIntl.useIntl();
927
913
  const _useDeleteResourcesCo = useDeleteResourcesContext(),
928
914
  resourceType = _useDeleteResourcesCo.resourceType;
929
- const isFileImportJobFlowEnabled = applicationShell.useFeatureToggle(FILE_IMPORT_JOB_FLOW);
930
915
  const documentTemplateLink = TEMPLATE_DOWNLOAD_LINKS[resourceType];
931
916
  const documentationLink = DOCUMENTATION_LINKS[resourceType];
932
- const maxFileSizeMB = isFileImportJobFlowEnabled ? operations.IMPORT_MAX_FILE_SIZE_MB : operations.IMPORT_LEGACY_MAX_FILE_SIZE_MB;
933
- const maxItemCount = isFileImportJobFlowEnabled ? operations.IMPORT_MAX_ITEM_COUNT : operations.IMPORT_LEGACY_MAX_ROW_COUNT;
934
917
  return jsxRuntime.jsxs(uiKit.Spacings.Stack, {
935
918
  scale: "m",
936
919
  children: [jsxRuntime.jsxs(uiKit.Text.Body, {
@@ -944,8 +927,8 @@ const Instructions = () => {
944
927
  }), jsxRuntime.jsx(uiKit.Text.Body, {
945
928
  intlMessage: _objectSpread$5(_objectSpread$5({}, messages$3.fileUploadInstructionForMaxFileSize), {}, {
946
929
  values: {
947
- maxFileSize: intl.formatNumber(maxFileSizeMB),
948
- maxRowCount: intl.formatNumber(maxItemCount),
930
+ maxFileSize: intl.formatNumber(operations.IMPORT_MAX_FILE_SIZE_MB),
931
+ maxRowCount: intl.formatNumber(operations.IMPORT_MAX_ITEM_COUNT),
949
932
  csvTemplateLink: msg => jsxRuntime.jsx(uiKit.Link, {
950
933
  tone: "secondary",
951
934
  isExternal: true,
@@ -11,7 +11,7 @@ import { defineMessages, useIntl, FormattedMessage, IntlProvider } from 'react-i
11
11
  import { useApplicationContext } from '@commercetools-frontend/application-shell-connectors';
12
12
  import _slicedToArray from '@babel/runtime-corejs3/helpers/esm/slicedToArray';
13
13
  import React, { useContext, useState, useEffect } from 'react';
14
- import { deleteImportContainer, EnabledDropArea, FileDroppedArea, ActiveDragDropArea, useFileUpload, getRowCount, toBytes, hasSingleKeyColumn, isAbortError, HttpError, PollingTimeoutError, IMPORT_MAX_FILE_SIZE_MB, IMPORT_LEGACY_MAX_FILE_SIZE_MB, IMPORT_MAX_ITEM_COUNT, IMPORT_LEGACY_MAX_ROW_COUNT, FileDropArea as FileDropArea$1, UploadingModal, mapFileUploadErrorsToUploadFileErrorRows, processFileImportJob, processUploadedFile } from '@commercetools-frontend-extensions/operations';
14
+ import { deleteImportContainer, EnabledDropArea, FileDroppedArea, ActiveDragDropArea, useFileUpload, getRowCount, toBytes, IMPORT_MAX_FILE_SIZE_MB, hasSingleKeyColumn, IMPORT_MAX_ITEM_COUNT, isAbortError, HttpError, PollingTimeoutError, FileDropArea as FileDropArea$1, UploadingModal, mapFileUploadErrorsToUploadFileErrorRows, processFileImportJob, processUploadedFile } from '@commercetools-frontend-extensions/operations';
15
15
  import { jsx, jsxs } from '@emotion/react/jsx-runtime';
16
16
  import { FormDialog, InfoDialog } from '@commercetools-frontend/application-components';
17
17
  import { Masking } from '@commercetools-frontend/fullstory';
@@ -25,23 +25,22 @@ import _possibleConstructorReturn from '@babel/runtime-corejs3/helpers/esm/possi
25
25
  import _getPrototypeOf from '@babel/runtime-corejs3/helpers/esm/getPrototypeOf';
26
26
  import _inherits from '@babel/runtime-corejs3/helpers/esm/inherits';
27
27
  import _wrapNativeSuper from '@babel/runtime-corejs3/helpers/esm/wrapNativeSuper';
28
- import { useFeatureToggle } from '@commercetools-frontend/application-shell';
29
28
  import { reportErrorToSentry } from '@commercetools-frontend/sentry';
30
29
  import _sliceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/slice';
31
30
  import '@emotion/react';
32
31
  import { parseChunkImport, mapLocaleToIntlLocale } from '@commercetools-frontend/i18n';
33
32
 
34
- function ownKeys$7(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; }
35
- function _objectSpread$7(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys$7(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys$7(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
33
+ function ownKeys$6(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; }
34
+ function _objectSpread$6(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys$6(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys$6(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
36
35
  function reducer(state, action) {
37
- if (action.type === 'setCurrentStep') return _objectSpread$7(_objectSpread$7({}, state), {}, {
36
+ if (action.type === 'setCurrentStep') return _objectSpread$6(_objectSpread$6({}, state), {}, {
38
37
  currentStep: action.currentStep,
39
38
  progress: 0
40
39
  });
41
- if (action.type === 'setContainerKey') return _objectSpread$7(_objectSpread$7({}, state), {}, {
40
+ if (action.type === 'setContainerKey') return _objectSpread$6(_objectSpread$6({}, state), {}, {
42
41
  containerKey: action.containerKey
43
42
  });
44
- if (action.type === 'cancelImport') return _objectSpread$7(_objectSpread$7({}, state), {}, {
43
+ if (action.type === 'cancelImport') return _objectSpread$6(_objectSpread$6({}, state), {}, {
45
44
  currentStep: 'upload',
46
45
  containerKey: undefined,
47
46
  droppedFile: undefined,
@@ -51,7 +50,7 @@ function reducer(state, action) {
51
50
  validationProcessed: undefined,
52
51
  isValidating: false
53
52
  });
54
- if (action.type === 'uploadNewFile') return _objectSpread$7(_objectSpread$7({}, state), {}, {
53
+ if (action.type === 'uploadNewFile') return _objectSpread$6(_objectSpread$6({}, state), {}, {
55
54
  currentStep: 'upload',
56
55
  containerKey: undefined,
57
56
  droppedFile: undefined,
@@ -62,37 +61,37 @@ function reducer(state, action) {
62
61
  isValidating: false
63
62
  });
64
63
  if (action.type === 'setDroppedFile') {
65
- return _objectSpread$7(_objectSpread$7({}, state), {}, {
64
+ return _objectSpread$6(_objectSpread$6({}, state), {}, {
66
65
  droppedFile: action.droppedFile
67
66
  });
68
67
  }
69
68
  if (action.type === 'setAbortController') {
70
- return _objectSpread$7(_objectSpread$7({}, state), {}, {
69
+ return _objectSpread$6(_objectSpread$6({}, state), {}, {
71
70
  abortController: action.abortController
72
71
  });
73
72
  }
74
73
  if (action.type === 'setProgress') {
75
- return _objectSpread$7(_objectSpread$7({}, state), {}, {
74
+ return _objectSpread$6(_objectSpread$6({}, state), {}, {
76
75
  progress: action.progress
77
76
  });
78
77
  }
79
78
  if (action.type === 'setUploadFileResponse') {
80
- return _objectSpread$7(_objectSpread$7({}, state), {}, {
79
+ return _objectSpread$6(_objectSpread$6({}, state), {}, {
81
80
  uploadFileResponse: action.uploadFileResponse
82
81
  });
83
82
  }
84
83
  if (action.type === 'setFileUploadErrors') {
85
- return _objectSpread$7(_objectSpread$7({}, state), {}, {
84
+ return _objectSpread$6(_objectSpread$6({}, state), {}, {
86
85
  fileUploadErrors: action.fileUploadErrors
87
86
  });
88
87
  }
89
88
  if (action.type === 'setJobId') {
90
- return _objectSpread$7(_objectSpread$7({}, state), {}, {
89
+ return _objectSpread$6(_objectSpread$6({}, state), {}, {
91
90
  jobId: action.jobId
92
91
  });
93
92
  }
94
93
  if (action.type === 'setValidationProgress') {
95
- return _objectSpread$7(_objectSpread$7({}, state), {}, {
94
+ return _objectSpread$6(_objectSpread$6({}, state), {}, {
96
95
  validationProcessed: action.processed,
97
96
  isValidating: action.isValidating
98
97
  });
@@ -447,22 +446,6 @@ var messages$4 = defineMessages({
447
446
  }
448
447
  });
449
448
 
450
- function ownKeys$6(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; }
451
- function _objectSpread$6(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys$6(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys$6(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
452
- const FILE_IMPORT_JOB_FLOW = 'fileImportJobFlow';
453
- const DEFAULT_SHORT_LIVED_FLAGS = {
454
- [FILE_IMPORT_JOB_FLOW]: false
455
- };
456
- const DEFAULT_LONG_LIVED_FLAGS = {};
457
- _objectSpread$6(_objectSpread$6({}, DEFAULT_SHORT_LIVED_FLAGS), DEFAULT_LONG_LIVED_FLAGS);
458
-
459
- const DOCUMENTATION_LINKS = {
460
- product: 'https://docs.commercetools.com/merchant-center/product-list#bulk-delete-via-csv-import'
461
- };
462
- const TEMPLATE_DOWNLOAD_LINKS = {
463
- product: 'https://docs.commercetools.com/merchant-center/downloads/product_delete_import_template.csv'
464
- };
465
-
466
449
  const useUpload = () => {
467
450
  const intl = useIntl();
468
451
  const _useApplicationContex = useApplicationContext(context => ({
@@ -474,25 +457,21 @@ const useUpload = () => {
474
457
  state = _useDeleteResourcesCo.state,
475
458
  actions = _useDeleteResourcesCo.actions;
476
459
  const showNotification = useShowNotification();
477
- const isFileImportJobFlowEnabled = useFeatureToggle(FILE_IMPORT_JOB_FLOW);
478
460
  const _useFileUpload = useFileUpload({
479
- projectKey: projectKey,
480
- useJobBasedFlow: isFileImportJobFlowEnabled
461
+ projectKey: projectKey
481
462
  }),
482
463
  upload = _useFileUpload.upload;
483
464
  const isFileValid = async file => {
484
465
  const errors = [];
485
- const maxFileSizeMB = isFileImportJobFlowEnabled ? IMPORT_MAX_FILE_SIZE_MB : IMPORT_LEGACY_MAX_FILE_SIZE_MB;
486
- const maxItemCount = isFileImportJobFlowEnabled ? IMPORT_MAX_ITEM_COUNT : IMPORT_LEGACY_MAX_ROW_COUNT;
487
466
  const rowCount = await getRowCount(file);
488
467
  if (rowCount < 1) errors.push({
489
468
  title: intl.formatMessage(messages$4.dropAreaNotEnoughRowsTitle),
490
469
  description: intl.formatMessage(messages$4.dropAreaNotEnoughRowsDescription)
491
470
  });
492
- if (file.size > toBytes(maxFileSizeMB)) errors.push({
471
+ if (file.size > toBytes(IMPORT_MAX_FILE_SIZE_MB)) errors.push({
493
472
  title: intl.formatMessage(messages$4.fileSizeExceededTitle),
494
473
  description: intl.formatMessage(messages$4.fileSizeExceededDescription, {
495
- fileSizeLimit: intl.formatNumber(maxFileSizeMB)
474
+ fileSizeLimit: intl.formatNumber(IMPORT_MAX_FILE_SIZE_MB)
496
475
  })
497
476
  });
498
477
  if (!(await hasSingleKeyColumn(file))) {
@@ -501,10 +480,10 @@ const useUpload = () => {
501
480
  description: intl.formatMessage(messages$4.csvFormatErrorDescription)
502
481
  });
503
482
  }
504
- if (rowCount > maxItemCount) errors.push({
483
+ if (rowCount > IMPORT_MAX_ITEM_COUNT) errors.push({
505
484
  title: intl.formatMessage(messages$4.rowLimitExceededTitle),
506
485
  description: intl.formatMessage(messages$4.rowLimitExceededDescription, {
507
- rowLimit: intl.formatNumber(maxItemCount)
486
+ rowLimit: intl.formatNumber(IMPORT_MAX_ITEM_COUNT)
508
487
  })
509
488
  });
510
489
  if (errors.length > 0) {
@@ -851,6 +830,13 @@ var messages$3 = defineMessages({
851
830
  }
852
831
  });
853
832
 
833
+ const DOCUMENTATION_LINKS = {
834
+ product: 'https://docs.commercetools.com/merchant-center/product-list#bulk-delete-via-csv-import'
835
+ };
836
+ const TEMPLATE_DOWNLOAD_LINKS = {
837
+ product: 'https://docs.commercetools.com/merchant-center/downloads/product_delete_import_template.csv'
838
+ };
839
+
854
840
  function resourceTypeToMessage(resourceType) {
855
841
  const resourceTypeMap = {
856
842
  category: sharedMessages.category,
@@ -908,11 +894,8 @@ const Instructions = () => {
908
894
  const intl = useIntl();
909
895
  const _useDeleteResourcesCo = useDeleteResourcesContext(),
910
896
  resourceType = _useDeleteResourcesCo.resourceType;
911
- const isFileImportJobFlowEnabled = useFeatureToggle(FILE_IMPORT_JOB_FLOW);
912
897
  const documentTemplateLink = TEMPLATE_DOWNLOAD_LINKS[resourceType];
913
898
  const documentationLink = DOCUMENTATION_LINKS[resourceType];
914
- const maxFileSizeMB = isFileImportJobFlowEnabled ? IMPORT_MAX_FILE_SIZE_MB : IMPORT_LEGACY_MAX_FILE_SIZE_MB;
915
- const maxItemCount = isFileImportJobFlowEnabled ? IMPORT_MAX_ITEM_COUNT : IMPORT_LEGACY_MAX_ROW_COUNT;
916
899
  return jsxs(Spacings.Stack, {
917
900
  scale: "m",
918
901
  children: [jsxs(Text.Body, {
@@ -926,8 +909,8 @@ const Instructions = () => {
926
909
  }), jsx(Text.Body, {
927
910
  intlMessage: _objectSpread$5(_objectSpread$5({}, messages$3.fileUploadInstructionForMaxFileSize), {}, {
928
911
  values: {
929
- maxFileSize: intl.formatNumber(maxFileSizeMB),
930
- maxRowCount: intl.formatNumber(maxItemCount),
912
+ maxFileSize: intl.formatNumber(IMPORT_MAX_FILE_SIZE_MB),
913
+ maxRowCount: intl.formatNumber(IMPORT_MAX_ITEM_COUNT),
931
914
  csvTemplateLink: msg => jsx(Link, {
932
915
  tone: "secondary",
933
916
  isExternal: true,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@commercetools-frontend-extensions/delete-resources-modal",
3
3
  "description": "Shared import modal for deleting resources",
4
- "version": "1.7.5",
4
+ "version": "2.0.0",
5
5
  "license": "BSD-3-Clause",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -31,7 +31,7 @@
31
31
  "pluralize": "8.0.0",
32
32
  "prop-types": "15.8.1",
33
33
  "ramda": "^0.32.0",
34
- "@commercetools-frontend-extensions/operations": "3.6.2"
34
+ "@commercetools-frontend-extensions/operations": "4.0.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@commercetools-frontend/actions-global": "27.2.0",