@commercetools-frontend-extensions/unpublish-products-modal 1.2.9 → 1.3.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.
- package/dist/commercetools-frontend-extensions-unpublish-products-modal.cjs.dev.js +227 -100
- package/dist/commercetools-frontend-extensions-unpublish-products-modal.cjs.prod.js +225 -98
- package/dist/commercetools-frontend-extensions-unpublish-products-modal.esm.js +228 -101
- package/package.json +15 -15
|
@@ -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$
|
|
52
|
-
function _objectSpread$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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
|
|
418
|
-
|
|
484
|
+
const isFileImportJobFlowEnabled = applicationShell.useFeatureToggle(FILE_IMPORT_JOB_FLOW);
|
|
485
|
+
const _useFileUpload = operations.useFileUpload({
|
|
486
|
+
projectKey: projectKey,
|
|
487
|
+
useJobBasedFlow: isFileImportJobFlowEnabled
|
|
419
488
|
}),
|
|
420
|
-
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$
|
|
431
|
-
description: intl.formatMessage(messages$
|
|
496
|
+
title: intl.formatMessage(messages$4.dropAreaNotEnoughRowsTitle),
|
|
497
|
+
description: intl.formatMessage(messages$4.dropAreaNotEnoughRowsDescription)
|
|
432
498
|
});
|
|
433
|
-
if (file.size > operations.toBytes(
|
|
434
|
-
title: intl.formatMessage(messages$
|
|
435
|
-
description: intl.formatMessage(messages$
|
|
436
|
-
fileSizeLimit: intl.formatNumber(
|
|
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$
|
|
442
|
-
description: intl.formatMessage(messages$
|
|
507
|
+
title: intl.formatMessage(messages$4.csvFormatErrorTitle),
|
|
508
|
+
description: intl.formatMessage(messages$4.csvFormatErrorDescription)
|
|
443
509
|
});
|
|
444
510
|
}
|
|
445
|
-
if (rowCount >
|
|
446
|
-
title: intl.formatMessage(messages$
|
|
447
|
-
description: intl.formatMessage(messages$
|
|
448
|
-
rowLimit: intl.formatNumber(
|
|
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$
|
|
467
|
-
description: intl.formatMessage(messages$
|
|
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$
|
|
552
|
+
text: intl.formatMessage(messages$4.unexpectedError)
|
|
476
553
|
});
|
|
477
554
|
}
|
|
478
555
|
} else {
|
|
@@ -494,32 +571,54 @@ 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
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
actions.
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
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
|
+
actions.setCurrentStep('upload-preview');
|
|
609
|
+
},
|
|
610
|
+
onProgress: progress => {
|
|
611
|
+
actions.setProgress(progress);
|
|
612
|
+
},
|
|
613
|
+
onValidationProgress: job => {
|
|
614
|
+
const processed = job.summary?.total ?? 0;
|
|
615
|
+
actions.setValidationProgress({
|
|
616
|
+
processed,
|
|
617
|
+
isValidating: true
|
|
618
|
+
});
|
|
619
|
+
},
|
|
620
|
+
onError: handleUploadError
|
|
621
|
+
});
|
|
523
622
|
};
|
|
524
623
|
return {
|
|
525
624
|
handleUploadAndValidation
|
|
@@ -540,9 +639,9 @@ const FileDropArea = () => {
|
|
|
540
639
|
}, [actions]);
|
|
541
640
|
const handleDropRejected = React__default["default"].useCallback(errorType => {
|
|
542
641
|
const errorMessageMap = {
|
|
543
|
-
'too-many-files': messages$
|
|
544
|
-
'invalid-type': messages$
|
|
545
|
-
generic: messages$
|
|
642
|
+
'too-many-files': messages$5.tooManyFilesError,
|
|
643
|
+
'invalid-type': messages$5.fileFormatNotSupported,
|
|
644
|
+
generic: messages$5.genericError
|
|
546
645
|
};
|
|
547
646
|
showNotification({
|
|
548
647
|
kind: 'error',
|
|
@@ -566,10 +665,10 @@ const FileDropArea = () => {
|
|
|
566
665
|
isFileDropped: Boolean(state.droppedFile),
|
|
567
666
|
fileName: state.droppedFile?.name,
|
|
568
667
|
messages: {
|
|
569
|
-
dragAndDropCSV: intl.formatMessage(messages$
|
|
570
|
-
or: intl.formatMessage(messages$
|
|
571
|
-
browseButton: intl.formatMessage(messages$
|
|
572
|
-
chooseFile: intl.formatMessage(messages$
|
|
668
|
+
dragAndDropCSV: intl.formatMessage(messages$5.dragAndDropCSV),
|
|
669
|
+
or: intl.formatMessage(messages$5.or),
|
|
670
|
+
browseButton: intl.formatMessage(messages$5.browseButton),
|
|
671
|
+
chooseFile: intl.formatMessage(messages$5.chooseFile)
|
|
573
672
|
}
|
|
574
673
|
})
|
|
575
674
|
});
|
|
@@ -590,10 +689,15 @@ var sharedMessages = reactIntl.defineMessages({
|
|
|
590
689
|
id: 'UnpublishProductsModal.cancel',
|
|
591
690
|
description: 'The label for the cancel button',
|
|
592
691
|
defaultMessage: 'Cancel'
|
|
692
|
+
},
|
|
693
|
+
products: {
|
|
694
|
+
id: 'UnpublishProductsModal.products',
|
|
695
|
+
description: 'Products resource type label',
|
|
696
|
+
defaultMessage: 'Products'
|
|
593
697
|
}
|
|
594
698
|
});
|
|
595
699
|
|
|
596
|
-
var messages$
|
|
700
|
+
var messages$3 = reactIntl.defineMessages({
|
|
597
701
|
fileUploadInstructions: {
|
|
598
702
|
id: 'UnpublishProductsModal.fileUploadInstructions',
|
|
599
703
|
description: 'Instructions for uploading a CSV file with product keys to unpublish',
|
|
@@ -601,18 +705,18 @@ var messages$2 = reactIntl.defineMessages({
|
|
|
601
705
|
}
|
|
602
706
|
});
|
|
603
707
|
|
|
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
708
|
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
709
|
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
710
|
const Instructions = () => {
|
|
610
711
|
const intl = reactIntl.useIntl();
|
|
712
|
+
const isFileImportJobFlowEnabled = applicationShell.useFeatureToggle(FILE_IMPORT_JOB_FLOW);
|
|
713
|
+
const maxFileSizeMB = isFileImportJobFlowEnabled ? operations.IMPORT_MAX_FILE_SIZE_MB : operations.IMPORT_LEGACY_MAX_FILE_SIZE_MB;
|
|
714
|
+
const maxItemCount = isFileImportJobFlowEnabled ? operations.IMPORT_MAX_ITEM_COUNT : operations.IMPORT_LEGACY_MAX_ROW_COUNT;
|
|
611
715
|
return jsxRuntime.jsx(uiKit.Text.Body, {
|
|
612
|
-
intlMessage: _objectSpread$5(_objectSpread$5({}, messages$
|
|
716
|
+
intlMessage: _objectSpread$5(_objectSpread$5({}, messages$3.fileUploadInstructions), {}, {
|
|
613
717
|
values: {
|
|
614
|
-
maxFileSize: intl.formatNumber(
|
|
615
|
-
maxRowCount: intl.formatNumber(
|
|
718
|
+
maxFileSize: intl.formatNumber(maxFileSizeMB),
|
|
719
|
+
maxRowCount: intl.formatNumber(maxItemCount),
|
|
616
720
|
csvTemplateLink: msg => jsxRuntime.jsx(uiKit.Link, {
|
|
617
721
|
tone: "secondary",
|
|
618
722
|
isExternal: true,
|
|
@@ -641,7 +745,7 @@ const Upload = () => {
|
|
|
641
745
|
size: 16,
|
|
642
746
|
isOpen: true,
|
|
643
747
|
title: intl.formatMessage(sharedMessages.unpublishModalTitle),
|
|
644
|
-
labelPrimary: intl.formatMessage(messages$
|
|
748
|
+
labelPrimary: intl.formatMessage(messages$5.uploadAndPreview),
|
|
645
749
|
onPrimaryButtonClick: handleUploadAndValidation,
|
|
646
750
|
isPrimaryButtonDisabled: !Boolean(state.droppedFile),
|
|
647
751
|
onSecondaryButtonClick: () => onClose({
|
|
@@ -659,6 +763,13 @@ const Upload = () => {
|
|
|
659
763
|
});
|
|
660
764
|
};
|
|
661
765
|
|
|
766
|
+
var messages$2 = reactIntl.defineMessages({
|
|
767
|
+
validatingResources: {
|
|
768
|
+
id: 'UnpublishProductsModal.Uploading.validatingResources',
|
|
769
|
+
defaultMessage: 'Validating {processed} / {total} {resourceType}'
|
|
770
|
+
}
|
|
771
|
+
});
|
|
772
|
+
|
|
662
773
|
const Uploading = () => {
|
|
663
774
|
const intl = reactIntl.useIntl();
|
|
664
775
|
const _useUnpublishProducts = useUnpublishProductsContext(),
|
|
@@ -666,12 +777,19 @@ const Uploading = () => {
|
|
|
666
777
|
actions = _useUnpublishProducts.actions,
|
|
667
778
|
onClose = _useUnpublishProducts.onClose;
|
|
668
779
|
if (!state.droppedFile?.name) return null;
|
|
780
|
+
const showValidationProgress = state.isValidating && state.totalResourceCount && (state.validationProcessed ?? 0) > 0;
|
|
781
|
+
const statusMessage = showValidationProgress ? intl.formatMessage(messages$2.validatingResources, {
|
|
782
|
+
processed: intl.formatNumber(state.validationProcessed ?? 0),
|
|
783
|
+
total: intl.formatNumber(state.totalResourceCount ?? 0),
|
|
784
|
+
resourceType: intl.formatMessage(sharedMessages.products)
|
|
785
|
+
}) : undefined;
|
|
669
786
|
return jsxRuntime.jsx(operations.UploadingModal, {
|
|
670
787
|
isOpen: true,
|
|
671
788
|
title: intl.formatMessage(sharedMessages.unpublishModalTitle),
|
|
672
789
|
fileName: state.droppedFile.name,
|
|
673
790
|
fileSize: state.droppedFile.size,
|
|
674
791
|
progress: state.progress,
|
|
792
|
+
statusMessage: statusMessage,
|
|
675
793
|
cancelLabel: intl.formatMessage(sharedMessages.cancel),
|
|
676
794
|
onCancel: () => {
|
|
677
795
|
actions.setCurrentStep('upload');
|
|
@@ -764,7 +882,7 @@ const UploadErrorsModal = () => {
|
|
|
764
882
|
state = _useUnpublishProducts.state,
|
|
765
883
|
actions = _useUnpublishProducts.actions,
|
|
766
884
|
onClose = _useUnpublishProducts.onClose;
|
|
767
|
-
const errorsCount = state.fileUploadErrors
|
|
885
|
+
const errorsCount = state.fileUploadErrors?.length ?? 0;
|
|
768
886
|
return jsxRuntime.jsx(applicationComponents.InfoDialog, {
|
|
769
887
|
size: 16,
|
|
770
888
|
isOpen: true,
|
|
@@ -784,7 +902,7 @@ const UploadErrorsModal = () => {
|
|
|
784
902
|
})
|
|
785
903
|
})
|
|
786
904
|
}), jsxRuntime.jsx(UploadErrorTable, {
|
|
787
|
-
rows: operations.mapFileUploadErrorsToUploadFileErrorRows(state.fileUploadErrors)
|
|
905
|
+
rows: operations.mapFileUploadErrorsToUploadFileErrorRows(state.fileUploadErrors ?? [])
|
|
788
906
|
}), jsxRuntime.jsxs(uiKit.Spacings.Inline, {
|
|
789
907
|
scale: "m",
|
|
790
908
|
justifyContent: "flex-end",
|
|
@@ -929,11 +1047,20 @@ const UnpublishProductsConfirmationModal = () => {
|
|
|
929
1047
|
}, {
|
|
930
1048
|
dismissAfter: 5000
|
|
931
1049
|
});
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
1050
|
+
if (state.jobId) {
|
|
1051
|
+
await operations.processFileImportJob({
|
|
1052
|
+
projectKey,
|
|
1053
|
+
importContainerKey: state.containerKey,
|
|
1054
|
+
jobId: state.jobId,
|
|
1055
|
+
resourceType: 'product'
|
|
1056
|
+
});
|
|
1057
|
+
} else {
|
|
1058
|
+
await operations.processUploadedFile({
|
|
1059
|
+
projectKey,
|
|
1060
|
+
resourceType: 'product',
|
|
1061
|
+
importContainerKey: state.containerKey
|
|
1062
|
+
});
|
|
1063
|
+
}
|
|
937
1064
|
showNotification({
|
|
938
1065
|
kind: 'info',
|
|
939
1066
|
domain: constants.DOMAINS.SIDE,
|
|
@@ -964,7 +1091,7 @@ const UnpublishProductsConfirmationModal = () => {
|
|
|
964
1091
|
values: {
|
|
965
1092
|
projectName: projectName,
|
|
966
1093
|
// TODO: Replace with actual count
|
|
967
|
-
count: intl.formatNumber(state.uploadFileResponse?.rowsCount),
|
|
1094
|
+
count: intl.formatNumber(state.uploadFileResponse?.rowsCount ?? 0),
|
|
968
1095
|
b: getBold$1
|
|
969
1096
|
}
|
|
970
1097
|
})
|
|
@@ -1020,7 +1147,7 @@ function UploadPreviewModal() {
|
|
|
1020
1147
|
}), jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1021
1148
|
intlMessage: _objectSpread$1(_objectSpread$1({}, messages.productsToBeUnpublished), {}, {
|
|
1022
1149
|
values: {
|
|
1023
|
-
count: intl.formatNumber(state.uploadFileResponse?.rowsCount),
|
|
1150
|
+
count: intl.formatNumber(state.uploadFileResponse?.rowsCount ?? 0),
|
|
1024
1151
|
b: getBold
|
|
1025
1152
|
}
|
|
1026
1153
|
})
|