@commercetools-frontend-extensions/unpublish-products-modal 1.2.9 → 1.4.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,6 +29,7 @@ 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');
32
33
  var sentry = require('@commercetools-frontend/sentry');
33
34
  var _sliceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/slice');
34
35
  require('@emotion/react');
@@ -48,55 +49,79 @@ var React__default = /*#__PURE__*/_interopDefault(React);
48
49
  var _Reflect$construct__default = /*#__PURE__*/_interopDefault(_Reflect$construct);
49
50
  var _sliceInstanceProperty__default = /*#__PURE__*/_interopDefault(_sliceInstanceProperty);
50
51
 
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; }
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; }
53
54
  function reducer(state, action) {
54
- if (action.type === 'setCurrentStep') return _objectSpread$6(_objectSpread$6({}, state), {}, {
55
+ if (action.type === 'setCurrentStep') return _objectSpread$7(_objectSpread$7({}, state), {}, {
55
56
  currentStep: action.currentStep,
56
57
  progress: 0
57
58
  });
58
- if (action.type === 'setContainerKey') return _objectSpread$6(_objectSpread$6({}, state), {}, {
59
+ if (action.type === 'setContainerKey') return _objectSpread$7(_objectSpread$7({}, state), {}, {
59
60
  containerKey: action.containerKey
60
61
  });
61
- if (action.type === 'cancelImport') return _objectSpread$6(_objectSpread$6({}, state), {}, {
62
+ if (action.type === 'cancelImport') return _objectSpread$7(_objectSpread$7({}, state), {}, {
62
63
  currentStep: 'upload',
63
64
  containerKey: undefined,
64
65
  droppedFile: undefined,
65
66
  dropAreaState: 'ready-for-drop',
66
- progress: 0
67
+ progress: 0,
68
+ jobId: undefined,
69
+ totalResourceCount: undefined,
70
+ validationProcessed: undefined,
71
+ isValidating: false
67
72
  });
68
- if (action.type === 'uploadNewFile') return _objectSpread$6(_objectSpread$6({}, state), {}, {
73
+ if (action.type === 'uploadNewFile') return _objectSpread$7(_objectSpread$7({}, state), {}, {
69
74
  currentStep: 'upload',
70
75
  containerKey: undefined,
71
76
  droppedFile: undefined,
72
77
  dropAreaState: 'ready-for-drop',
73
- progress: 0
78
+ progress: 0,
79
+ jobId: undefined,
80
+ totalResourceCount: undefined,
81
+ validationProcessed: undefined,
82
+ isValidating: false
74
83
  });
75
84
  if (action.type === 'setDroppedFile') {
76
- return _objectSpread$6(_objectSpread$6({}, state), {}, {
85
+ return _objectSpread$7(_objectSpread$7({}, state), {}, {
77
86
  droppedFile: action.droppedFile
78
87
  });
79
88
  }
80
89
  if (action.type === 'setAbortController') {
81
- return _objectSpread$6(_objectSpread$6({}, state), {}, {
90
+ return _objectSpread$7(_objectSpread$7({}, state), {}, {
82
91
  abortController: action.abortController
83
92
  });
84
93
  }
85
94
  if (action.type === 'setProgress') {
86
- return _objectSpread$6(_objectSpread$6({}, state), {}, {
95
+ return _objectSpread$7(_objectSpread$7({}, state), {}, {
87
96
  progress: action.progress
88
97
  });
89
98
  }
90
99
  if (action.type === 'setUploadFileResponse') {
91
- return _objectSpread$6(_objectSpread$6({}, state), {}, {
100
+ return _objectSpread$7(_objectSpread$7({}, state), {}, {
92
101
  uploadFileResponse: action.uploadFileResponse
93
102
  });
94
103
  }
95
104
  if (action.type === 'setFileUploadErrors') {
96
- return _objectSpread$6(_objectSpread$6({}, state), {}, {
105
+ return _objectSpread$7(_objectSpread$7({}, state), {}, {
97
106
  fileUploadErrors: action.fileUploadErrors
98
107
  });
99
108
  }
109
+ if (action.type === 'setJobId') {
110
+ return _objectSpread$7(_objectSpread$7({}, state), {}, {
111
+ jobId: action.jobId
112
+ });
113
+ }
114
+ if (action.type === 'setTotalResourceCount') {
115
+ return _objectSpread$7(_objectSpread$7({}, state), {}, {
116
+ totalResourceCount: action.totalResourceCount
117
+ });
118
+ }
119
+ if (action.type === 'setValidationProgress') {
120
+ return _objectSpread$7(_objectSpread$7({}, state), {}, {
121
+ validationProcessed: action.processed,
122
+ isValidating: action.isValidating
123
+ });
124
+ }
100
125
  throw new Error(getUnknownActionError(action));
101
126
  }
102
127
  function getUnknownActionError(actionType) {
@@ -138,6 +163,15 @@ const initialActions = {
138
163
  },
139
164
  setProgress(_progress) {
140
165
  /**/
166
+ },
167
+ setJobId(_jobId) {
168
+ /**/
169
+ },
170
+ setTotalResourceCount(_totalResourceCount) {
171
+ /**/
172
+ },
173
+ setValidationProgress(_params) {
174
+ /**/
141
175
  }
142
176
  };
143
177
 
@@ -193,6 +227,37 @@ const UnpublishProductsProvider = props => {
193
227
  uploadFileResponse
194
228
  });
195
229
  };
230
+ const setJobId = jobId => dispatch({
231
+ type: 'setJobId',
232
+ jobId
233
+ });
234
+ const setTotalResourceCount = totalResourceCount => dispatch({
235
+ type: 'setTotalResourceCount',
236
+ totalResourceCount
237
+ });
238
+ const setValidationProgress = _ref => {
239
+ let processed = _ref.processed,
240
+ isValidating = _ref.isValidating;
241
+ return dispatch({
242
+ type: 'setValidationProgress',
243
+ processed,
244
+ isValidating
245
+ });
246
+ };
247
+ const actions = {
248
+ setCurrentStep,
249
+ cancelImport,
250
+ uploadNewFile,
251
+ setDroppedFile,
252
+ setUploadFileResponse,
253
+ setFileUploadErrors,
254
+ setContainerKey,
255
+ setAbortController,
256
+ setProgress,
257
+ setJobId,
258
+ setTotalResourceCount,
259
+ setValidationProgress
260
+ };
196
261
  const handleClose = function () {
197
262
  let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
198
263
  if (state.abortController) state.abortController.abort();
@@ -207,17 +272,7 @@ const UnpublishProductsProvider = props => {
207
272
  value: {
208
273
  state,
209
274
  onClose: handleClose,
210
- actions: {
211
- setCurrentStep,
212
- cancelImport,
213
- uploadNewFile,
214
- setDroppedFile,
215
- setUploadFileResponse,
216
- setFileUploadErrors,
217
- setContainerKey,
218
- setAbortController,
219
- setProgress
220
- }
275
+ actions
221
276
  },
222
277
  children: props.children
223
278
  });
@@ -269,7 +324,7 @@ function getDropAreaState(flags) {
269
324
  return 'ready-for-drop';
270
325
  }
271
326
 
272
- var messages$4 = reactIntl.defineMessages({
327
+ var messages$5 = reactIntl.defineMessages({
273
328
  dragAndDropCSV: {
274
329
  id: 'UnpublishProductsModal.dragAndDropCSV',
275
330
  description: 'The message telling the user to drag and drop CSV file in the file drop area',
@@ -348,7 +403,7 @@ const useUnpublishProductsContext = () => {
348
403
  return context;
349
404
  };
350
405
 
351
- var messages$3 = reactIntl.defineMessages({
406
+ var messages$4 = reactIntl.defineMessages({
352
407
  fileSizeExceededTitle: {
353
408
  id: 'UnpublishProductsModal.sizeExceededTitle',
354
409
  defaultMessage: 'File size exceeded'
@@ -404,6 +459,18 @@ var messages$3 = reactIntl.defineMessages({
404
459
  }
405
460
  });
406
461
 
462
+ 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; }
463
+ 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; }
464
+ const FILE_IMPORT_JOB_FLOW = 'fileImportJobFlow';
465
+ const DEFAULT_SHORT_LIVED_FLAGS = {
466
+ [FILE_IMPORT_JOB_FLOW]: false
467
+ };
468
+ const DEFAULT_LONG_LIVED_FLAGS = {};
469
+ _objectSpread$6(_objectSpread$6({}, DEFAULT_SHORT_LIVED_FLAGS), DEFAULT_LONG_LIVED_FLAGS);
470
+
471
+ const DOCUMENTATION_LINK = 'https://docs.commercetools.com/merchant-center/product-list#bulk-unpublish-via-csv-import';
472
+ const TEMPLATE_DOWNLOAD_LINK = 'https://docs.commercetools.com/merchant-center/downloads/product_unpublish_import_template.csv';
473
+
407
474
  const useUpload = () => {
408
475
  const intl = reactIntl.useIntl();
409
476
  const _useApplicationContex = applicationShellConnectors.useApplicationContext(context => ({
@@ -414,38 +481,37 @@ const useUpload = () => {
414
481
  state = _useUnpublishProducts.state,
415
482
  actions = _useUnpublishProducts.actions;
416
483
  const showNotification = actionsGlobal.useShowNotification();
417
- const _useImportContainerUp = operations.useImportContainerUpload({
418
- projectKey: projectKey
484
+ const isFileImportJobFlowEnabled = applicationShell.useFeatureToggle(FILE_IMPORT_JOB_FLOW);
485
+ const _useFileUpload = operations.useFileUpload({
486
+ projectKey: projectKey,
487
+ useJobBasedFlow: isFileImportJobFlowEnabled
419
488
  }),
420
- upload = _useImportContainerUp.upload;
421
- React__default["default"].useEffect(() => {
422
- return () => {
423
- if (state.abortController) state.abortController.abort();
424
- };
425
- }, [state.abortController]);
489
+ upload = _useFileUpload.upload;
426
490
  const isFileValid = async file => {
427
491
  const errors = [];
492
+ const maxFileSizeMB = isFileImportJobFlowEnabled ? operations.IMPORT_MAX_FILE_SIZE_MB : operations.IMPORT_LEGACY_MAX_FILE_SIZE_MB;
493
+ const maxItemCount = isFileImportJobFlowEnabled ? operations.IMPORT_MAX_ITEM_COUNT : operations.IMPORT_LEGACY_MAX_ROW_COUNT;
428
494
  const rowCount = await operations.getRowCount(file);
429
495
  if (rowCount < 1) errors.push({
430
- title: intl.formatMessage(messages$3.dropAreaNotEnoughRowsTitle),
431
- description: intl.formatMessage(messages$3.dropAreaNotEnoughRowsDescription)
496
+ title: intl.formatMessage(messages$4.dropAreaNotEnoughRowsTitle),
497
+ description: intl.formatMessage(messages$4.dropAreaNotEnoughRowsDescription)
432
498
  });
433
- if (file.size > operations.toBytes(operations.MAX_FILE_SIZE_MB)) errors.push({
434
- title: intl.formatMessage(messages$3.fileSizeExceededTitle),
435
- description: intl.formatMessage(messages$3.fileSizeExceededDescription, {
436
- fileSizeLimit: intl.formatNumber(operations.MAX_FILE_SIZE_MB)
499
+ if (file.size > operations.toBytes(maxFileSizeMB)) errors.push({
500
+ title: intl.formatMessage(messages$4.fileSizeExceededTitle),
501
+ description: intl.formatMessage(messages$4.fileSizeExceededDescription, {
502
+ fileSizeLimit: intl.formatNumber(maxFileSizeMB)
437
503
  })
438
504
  });
439
505
  if (!(await operations.hasSingleKeyColumn(file))) {
440
506
  errors.push({
441
- title: intl.formatMessage(messages$3.csvFormatErrorTitle),
442
- description: intl.formatMessage(messages$3.csvFormatErrorDescription)
507
+ title: intl.formatMessage(messages$4.csvFormatErrorTitle),
508
+ description: intl.formatMessage(messages$4.csvFormatErrorDescription)
443
509
  });
444
510
  }
445
- if (rowCount > operations.MAX_ROW_COUNT) errors.push({
446
- title: intl.formatMessage(messages$3.rowLimitExceededTitle),
447
- description: intl.formatMessage(messages$3.rowLimitExceededDescription, {
448
- rowLimit: intl.formatNumber(operations.MAX_ROW_COUNT)
511
+ if (rowCount > maxItemCount) errors.push({
512
+ title: intl.formatMessage(messages$4.rowLimitExceededTitle),
513
+ description: intl.formatMessage(messages$4.rowLimitExceededDescription, {
514
+ rowLimit: intl.formatNumber(maxItemCount)
449
515
  })
450
516
  });
451
517
  if (errors.length > 0) {
@@ -453,6 +519,10 @@ const useUpload = () => {
453
519
  actions.setCurrentStep('upload-error');
454
520
  return false;
455
521
  }
522
+ if (isFileImportJobFlowEnabled) {
523
+ const resourceCount = await operations.countUniqueResourcesInCsv(file);
524
+ actions.setTotalResourceCount(resourceCount);
525
+ }
456
526
  return true;
457
527
  };
458
528
  const handleUploadError = error => {
@@ -461,18 +531,25 @@ const useUpload = () => {
461
531
  return;
462
532
  }
463
533
  if (error instanceof operations.HttpError) {
534
+ actions.setValidationProgress({
535
+ processed: 0,
536
+ isValidating: false
537
+ });
464
538
  if (error.errorData?.code === 'MISSING_KEY_ERROR') {
465
539
  actions.setFileUploadErrors([{
466
- title: intl.formatMessage(messages$3.missingRequiredField),
467
- description: intl.formatMessage(messages$3.missingKeyError)
540
+ title: intl.formatMessage(messages$4.missingRequiredField),
541
+ description: intl.formatMessage(messages$4.missingKeyError)
468
542
  }]);
469
543
  actions.setCurrentStep('upload-error');
544
+ } else if (error.errorData?.invalid > 0) {
545
+ actions.setUploadFileResponse(error.errorData);
546
+ actions.setCurrentStep('upload-error');
470
547
  } else {
471
548
  actions.cancelImport();
472
549
  showNotification({
473
550
  kind: 'error',
474
551
  domain: constants.DOMAINS.PAGE,
475
- text: intl.formatMessage(messages$3.unexpectedError)
552
+ text: intl.formatMessage(messages$4.unexpectedError)
476
553
  });
477
554
  }
478
555
  } else {
@@ -494,32 +571,58 @@ const useUpload = () => {
494
571
  if (!state.droppedFile) return;
495
572
  const canUpload = await isFileValid(state.droppedFile);
496
573
  if (!canUpload) return;
574
+ const abortController = new AbortController();
575
+ actions.setAbortController(abortController);
497
576
  actions.setCurrentStep('uploading');
498
- try {
499
- const xhr = await upload({
500
- file: state.droppedFile,
501
- resourceType: 'product',
502
- settings: {
503
- resourceType: 'product-draft',
504
- format: 'CSV',
505
- options: {
506
- unpublishAllChanges: true
507
- }
508
- },
509
- onSuccess: (fileUploadResponse, containerKey) => {
510
- actions.setContainerKey(containerKey);
511
- actions.setUploadFileResponse(fileUploadResponse);
577
+ await upload({
578
+ file: state.droppedFile,
579
+ resourceType: 'product',
580
+ settings: {
581
+ format: 'CSV',
582
+ options: {
583
+ unpublishAllChanges: true
584
+ }
585
+ },
586
+ abortSignal: abortController.signal,
587
+ onSuccess: result => {
588
+ actions.setValidationProgress({
589
+ processed: 0,
590
+ isValidating: false
591
+ });
592
+ actions.setContainerKey(result.containerKey);
593
+ if (result.jobId) {
594
+ actions.setJobId(result.jobId);
595
+ }
596
+ const fileUploadResponse = {
597
+ results: result.summary.results,
598
+ invalid: result.summary.invalid,
599
+ valid: result.summary.valid,
600
+ fileName: state.droppedFile?.name || '',
601
+ itemsCount: result.summary.total,
602
+ rowsCount: result.summary.total,
603
+ columnsCount: result.summary.fieldsCount,
604
+ fields: result.summary.fields,
605
+ ignoredFields: result.summary.ignoredFields
606
+ };
607
+ actions.setUploadFileResponse(fileUploadResponse);
608
+ if (result.summary.invalid > 0) {
609
+ actions.setCurrentStep('upload-error');
610
+ } else {
512
611
  actions.setCurrentStep('upload-preview');
513
- },
514
- onProgress: progress => {
515
- actions.setProgress(progress);
516
- },
517
- onError: handleUploadError
518
- });
519
- actions.setAbortController(xhr);
520
- } catch (error) {
521
- handleUploadError(error);
522
- }
612
+ }
613
+ },
614
+ onProgress: progress => {
615
+ actions.setProgress(progress);
616
+ },
617
+ onValidationProgress: job => {
618
+ const processed = job.summary?.total ?? 0;
619
+ actions.setValidationProgress({
620
+ processed,
621
+ isValidating: true
622
+ });
623
+ },
624
+ onError: handleUploadError
625
+ });
523
626
  };
524
627
  return {
525
628
  handleUploadAndValidation
@@ -540,9 +643,9 @@ const FileDropArea = () => {
540
643
  }, [actions]);
541
644
  const handleDropRejected = React__default["default"].useCallback(errorType => {
542
645
  const errorMessageMap = {
543
- 'too-many-files': messages$4.tooManyFilesError,
544
- 'invalid-type': messages$4.fileFormatNotSupported,
545
- generic: messages$4.genericError
646
+ 'too-many-files': messages$5.tooManyFilesError,
647
+ 'invalid-type': messages$5.fileFormatNotSupported,
648
+ generic: messages$5.genericError
546
649
  };
547
650
  showNotification({
548
651
  kind: 'error',
@@ -566,10 +669,10 @@ const FileDropArea = () => {
566
669
  isFileDropped: Boolean(state.droppedFile),
567
670
  fileName: state.droppedFile?.name,
568
671
  messages: {
569
- dragAndDropCSV: intl.formatMessage(messages$4.dragAndDropCSV),
570
- or: intl.formatMessage(messages$4.or),
571
- browseButton: intl.formatMessage(messages$4.browseButton),
572
- chooseFile: intl.formatMessage(messages$4.chooseFile)
672
+ dragAndDropCSV: intl.formatMessage(messages$5.dragAndDropCSV),
673
+ or: intl.formatMessage(messages$5.or),
674
+ browseButton: intl.formatMessage(messages$5.browseButton),
675
+ chooseFile: intl.formatMessage(messages$5.chooseFile)
573
676
  }
574
677
  })
575
678
  });
@@ -590,10 +693,15 @@ var sharedMessages = reactIntl.defineMessages({
590
693
  id: 'UnpublishProductsModal.cancel',
591
694
  description: 'The label for the cancel button',
592
695
  defaultMessage: 'Cancel'
696
+ },
697
+ products: {
698
+ id: 'UnpublishProductsModal.products',
699
+ description: 'Products resource type label',
700
+ defaultMessage: 'Products'
593
701
  }
594
702
  });
595
703
 
596
- var messages$2 = reactIntl.defineMessages({
704
+ var messages$3 = reactIntl.defineMessages({
597
705
  fileUploadInstructions: {
598
706
  id: 'UnpublishProductsModal.fileUploadInstructions',
599
707
  description: 'Instructions for uploading a CSV file with product keys to unpublish',
@@ -601,18 +709,18 @@ var messages$2 = reactIntl.defineMessages({
601
709
  }
602
710
  });
603
711
 
604
- const DOCUMENTATION_LINK = 'https://docs.commercetools.com/merchant-center/product-list#bulk-unpublish-via-csv-import';
605
- const TEMPLATE_DOWNLOAD_LINK = 'https://docs.commercetools.com/merchant-center/downloads/product_unpublish_import_template.csv';
606
-
607
712
  function ownKeys$5(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; }
608
713
  function _objectSpread$5(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$5(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$5(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
609
714
  const Instructions = () => {
610
715
  const intl = reactIntl.useIntl();
716
+ const isFileImportJobFlowEnabled = applicationShell.useFeatureToggle(FILE_IMPORT_JOB_FLOW);
717
+ const maxFileSizeMB = isFileImportJobFlowEnabled ? operations.IMPORT_MAX_FILE_SIZE_MB : operations.IMPORT_LEGACY_MAX_FILE_SIZE_MB;
718
+ const maxItemCount = isFileImportJobFlowEnabled ? operations.IMPORT_MAX_ITEM_COUNT : operations.IMPORT_LEGACY_MAX_ROW_COUNT;
611
719
  return jsxRuntime.jsx(uiKit.Text.Body, {
612
- intlMessage: _objectSpread$5(_objectSpread$5({}, messages$2.fileUploadInstructions), {}, {
720
+ intlMessage: _objectSpread$5(_objectSpread$5({}, messages$3.fileUploadInstructions), {}, {
613
721
  values: {
614
- maxFileSize: intl.formatNumber(operations.MAX_FILE_SIZE_MB),
615
- maxRowCount: intl.formatNumber(operations.MAX_ROW_COUNT),
722
+ maxFileSize: intl.formatNumber(maxFileSizeMB),
723
+ maxRowCount: intl.formatNumber(maxItemCount),
616
724
  csvTemplateLink: msg => jsxRuntime.jsx(uiKit.Link, {
617
725
  tone: "secondary",
618
726
  isExternal: true,
@@ -641,7 +749,7 @@ const Upload = () => {
641
749
  size: 16,
642
750
  isOpen: true,
643
751
  title: intl.formatMessage(sharedMessages.unpublishModalTitle),
644
- labelPrimary: intl.formatMessage(messages$4.uploadAndPreview),
752
+ labelPrimary: intl.formatMessage(messages$5.uploadAndPreview),
645
753
  onPrimaryButtonClick: handleUploadAndValidation,
646
754
  isPrimaryButtonDisabled: !Boolean(state.droppedFile),
647
755
  onSecondaryButtonClick: () => onClose({
@@ -659,6 +767,13 @@ const Upload = () => {
659
767
  });
660
768
  };
661
769
 
770
+ var messages$2 = reactIntl.defineMessages({
771
+ validatingResources: {
772
+ id: 'UnpublishProductsModal.Uploading.validatingResources',
773
+ defaultMessage: 'Validating {processed} / {total} {resourceType}'
774
+ }
775
+ });
776
+
662
777
  const Uploading = () => {
663
778
  const intl = reactIntl.useIntl();
664
779
  const _useUnpublishProducts = useUnpublishProductsContext(),
@@ -666,12 +781,19 @@ const Uploading = () => {
666
781
  actions = _useUnpublishProducts.actions,
667
782
  onClose = _useUnpublishProducts.onClose;
668
783
  if (!state.droppedFile?.name) return null;
784
+ const showValidationProgress = state.isValidating && state.totalResourceCount && (state.validationProcessed ?? 0) > 0;
785
+ const statusMessage = showValidationProgress ? intl.formatMessage(messages$2.validatingResources, {
786
+ processed: intl.formatNumber(state.validationProcessed ?? 0),
787
+ total: intl.formatNumber(state.totalResourceCount ?? 0),
788
+ resourceType: intl.formatMessage(sharedMessages.products)
789
+ }) : undefined;
669
790
  return jsxRuntime.jsx(operations.UploadingModal, {
670
791
  isOpen: true,
671
792
  title: intl.formatMessage(sharedMessages.unpublishModalTitle),
672
793
  fileName: state.droppedFile.name,
673
794
  fileSize: state.droppedFile.size,
674
795
  progress: state.progress,
796
+ statusMessage: statusMessage,
675
797
  cancelLabel: intl.formatMessage(sharedMessages.cancel),
676
798
  onCancel: () => {
677
799
  actions.setCurrentStep('upload');
@@ -764,7 +886,7 @@ const UploadErrorsModal = () => {
764
886
  state = _useUnpublishProducts.state,
765
887
  actions = _useUnpublishProducts.actions,
766
888
  onClose = _useUnpublishProducts.onClose;
767
- const errorsCount = state.fileUploadErrors.length;
889
+ const errorsCount = state.fileUploadErrors?.length ?? 0;
768
890
  return jsxRuntime.jsx(applicationComponents.InfoDialog, {
769
891
  size: 16,
770
892
  isOpen: true,
@@ -784,7 +906,7 @@ const UploadErrorsModal = () => {
784
906
  })
785
907
  })
786
908
  }), jsxRuntime.jsx(UploadErrorTable, {
787
- rows: operations.mapFileUploadErrorsToUploadFileErrorRows(state.fileUploadErrors)
909
+ rows: operations.mapFileUploadErrorsToUploadFileErrorRows(state.fileUploadErrors ?? [])
788
910
  }), jsxRuntime.jsxs(uiKit.Spacings.Inline, {
789
911
  scale: "m",
790
912
  justifyContent: "flex-end",
@@ -929,11 +1051,20 @@ const UnpublishProductsConfirmationModal = () => {
929
1051
  }, {
930
1052
  dismissAfter: 5000
931
1053
  });
932
- await operations.processUploadedFile({
933
- projectKey,
934
- resourceType: 'product',
935
- importContainerKey: state.containerKey
936
- });
1054
+ if (state.jobId) {
1055
+ await operations.processFileImportJob({
1056
+ projectKey,
1057
+ importContainerKey: state.containerKey,
1058
+ jobId: state.jobId,
1059
+ resourceType: 'product'
1060
+ });
1061
+ } else {
1062
+ await operations.processUploadedFile({
1063
+ projectKey,
1064
+ resourceType: 'product',
1065
+ importContainerKey: state.containerKey
1066
+ });
1067
+ }
937
1068
  showNotification({
938
1069
  kind: 'info',
939
1070
  domain: constants.DOMAINS.SIDE,
@@ -964,7 +1095,7 @@ const UnpublishProductsConfirmationModal = () => {
964
1095
  values: {
965
1096
  projectName: projectName,
966
1097
  // TODO: Replace with actual count
967
- count: intl.formatNumber(state.uploadFileResponse?.rowsCount),
1098
+ count: intl.formatNumber(state.uploadFileResponse?.rowsCount ?? 0),
968
1099
  b: getBold$1
969
1100
  }
970
1101
  })
@@ -1020,7 +1151,7 @@ function UploadPreviewModal() {
1020
1151
  }), jsxRuntime.jsx(uiKit.Text.Body, {
1021
1152
  intlMessage: _objectSpread$1(_objectSpread$1({}, messages.productsToBeUnpublished), {}, {
1022
1153
  values: {
1023
- count: intl.formatNumber(state.uploadFileResponse?.rowsCount),
1154
+ count: intl.formatNumber(state.uploadFileResponse?.rowsCount ?? 0),
1024
1155
  b: getBold
1025
1156
  }
1026
1157
  })