@commercetools-frontend-extensions/import-resources-modal 1.11.2 → 1.11.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/dist/commercetools-frontend-extensions-import-resources-modal.cjs.dev.js +2086 -53
  2. package/dist/commercetools-frontend-extensions-import-resources-modal.cjs.prod.js +2062 -53
  3. package/dist/commercetools-frontend-extensions-import-resources-modal.esm.js +2071 -51
  4. package/dist/declarations/src/@types/index.d.ts +0 -6
  5. package/package.json +2 -2
  6. package/dist/active-drag-drop-area-3ad5dd22.esm.js +0 -60
  7. package/dist/active-drag-drop-area-94cea372.cjs.prod.js +0 -62
  8. package/dist/active-drag-drop-area-edf9d7a9.cjs.dev.js +0 -62
  9. package/dist/declarations/src/@types/api.d.ts +0 -13
  10. package/dist/declarations/src/@types/file-upload.d.ts +0 -60
  11. package/dist/declarations/src/@types/import-container.d.ts +0 -36
  12. package/dist/declarations/src/@types/import-states.d.ts +0 -9
  13. package/dist/declarations/src/@types/import-summary.d.ts +0 -12
  14. package/dist/declarations/src/@types/shared.d.ts +0 -7
  15. package/dist/disabled-drop-area-6af7f861.cjs.dev.js +0 -105
  16. package/dist/disabled-drop-area-d068b119.esm.js +0 -92
  17. package/dist/disabled-drop-area-d8a66b62.cjs.prod.js +0 -105
  18. package/dist/enabled-drop-area-819e5dd2.cjs.dev.js +0 -79
  19. package/dist/enabled-drop-area-b6fe0252.cjs.prod.js +0 -79
  20. package/dist/enabled-drop-area-d5d394ff.esm.js +0 -77
  21. package/dist/file-dropped-area-0e55c4a0.cjs.prod.js +0 -82
  22. package/dist/file-dropped-area-b64c266f.esm.js +0 -80
  23. package/dist/file-dropped-area-d4d52da4.cjs.dev.js +0 -82
  24. package/dist/index-c0e77d3f.cjs.dev.js +0 -2733
  25. package/dist/index-f14adfdc.esm.js +0 -2699
  26. package/dist/index-f96fadf7.cjs.prod.js +0 -2701
@@ -1,52 +1,2072 @@
1
- export { I as default, b as useImportPermission } from './index-f14adfdc.esm.js';
2
- import 'react';
3
- import '@babel/runtime-corejs3/core-js-stable/object/keys';
4
- import '@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols';
5
- import '@babel/runtime-corejs3/core-js-stable/instance/filter';
6
- import '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor';
7
- import '@babel/runtime-corejs3/core-js-stable/instance/for-each';
8
- import '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors';
9
- import '@babel/runtime-corejs3/core-js-stable/object/define-properties';
10
- import '@babel/runtime-corejs3/core-js-stable/object/define-property';
11
- import '@babel/runtime-corejs3/helpers/defineProperty';
12
- import '@babel/runtime-corejs3/helpers/slicedToArray';
13
- import '@commercetools-frontend/application-shell-connectors';
14
- import '@commercetools-frontend/sdk';
15
- import '@commercetools-frontend/constants';
16
- import '@commercetools-frontend/application-shell';
17
- import '@babel/runtime-corejs3/core-js-stable/reflect/construct';
18
- import '@babel/runtime-corejs3/helpers/createClass';
19
- import '@babel/runtime-corejs3/helpers/classCallCheck';
20
- import '@babel/runtime-corejs3/helpers/possibleConstructorReturn';
21
- import '@babel/runtime-corejs3/helpers/getPrototypeOf';
22
- import '@babel/runtime-corejs3/helpers/inherits';
23
- import '@babel/runtime-corejs3/helpers/wrapNativeSuper';
24
- import 'pluralize';
25
- import '@babel/runtime-corejs3/core-js-stable/array/is-array';
26
- import '@babel/runtime-corejs3/core-js-stable/instance/reduce';
27
- import '@babel/runtime-corejs3/core-js-stable/instance/map';
28
- import '@babel/runtime-corejs3/core-js-stable/instance/slice';
29
- import '@babel/runtime-corejs3/core-js-stable/json/stringify';
30
- import '@babel/runtime-corejs3/core-js-stable/instance/some';
31
- import '@babel/runtime-corejs3/core-js-stable/instance/bind';
32
- import '@babel/runtime-corejs3/core-js-stable/instance/starts-with';
33
- import '@babel/runtime-corejs3/core-js-stable/url-search-params';
34
- import '@babel/runtime-corejs3/core-js-stable/object/entries';
35
- import '@babel/runtime-corejs3/core-js-stable/instance/every';
36
- import '@emotion/react/jsx-runtime';
37
- import 'react-intl';
38
- import '@commercetools-frontend/application-components';
39
- import '@commercetools-frontend/fullstory';
40
- import '@commercetools-frontend/ui-kit';
41
- import 'react-dropzone';
42
- import '@commercetools-frontend/actions-global';
43
- import '@commercetools-frontend/permissions';
44
- import '@commercetools-frontend/sentry';
45
- import '@babel/runtime-corejs3/core-js-stable/promise';
46
- import '@babel/runtime-corejs3/core-js-stable/instance/includes';
47
- import '@babel/runtime-corejs3/core-js-stable/instance/flat-map';
48
- import '@babel/runtime-corejs3/core-js-stable/instance/find';
49
- import 'papaparse';
50
- import '@emotion/styled/base';
1
+ import _Object$keys from '@babel/runtime-corejs3/core-js-stable/object/keys';
2
+ import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols';
3
+ import _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/filter';
4
+ import _Object$getOwnPropertyDescriptor from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor';
5
+ import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/for-each';
6
+ import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors';
7
+ import _Object$defineProperties from '@babel/runtime-corejs3/core-js-stable/object/define-properties';
8
+ import _Object$defineProperty from '@babel/runtime-corejs3/core-js-stable/object/define-property';
9
+ import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
10
+ import _everyInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/every';
11
+ import { defineMessages, useIntl, FormattedMessage, IntlProvider } from 'react-intl';
12
+ import { useApplicationContext } from '@commercetools-frontend/application-shell-connectors';
13
+ import { deleteImportContainer, FileDroppedArea, DisabledDropArea, EnabledDropArea, ActiveDragDropArea, COLUMN_DELIMITERS, useImportContainerUpload, validateDelimiter, getRowCount, toBytes, MAX_FILE_SIZE_MB, MAX_ROW_COUNT, isAbortError, HttpError, formatKeys, isError, assertResourceType, FileDropArea as FileDropArea$1, InfoBox, CT_API_DOCS_URL, UploadSeparator, UploadSettings, UnexpectedColumnError, mapFileUploadErrorsToUploadFileErrorRows, extractErrorDescriptionFromValidationMessage, formatErrorCode, getFileUploadErrorsCount, RESOURCE_TYPE_DOCUMENTATION_LINKS, mapUploadFileErrorsResponseToUploadFileErrorRows, getValidatedColumns, processUploadedFile, UploadingModal, RESOURCE_TYPE_TEMPLATE_DOWNLOAD_LINKS, isResourceType } from '@commercetools-frontend-extensions/operations';
14
+ import _slicedToArray from '@babel/runtime-corejs3/helpers/esm/slicedToArray';
15
+ import React, { useContext, useMemo, useState, useEffect } from 'react';
16
+ import { jsx, jsxs, Fragment } from '@emotion/react/jsx-runtime';
17
+ import { FormDialog, InfoDialog, PageContentNarrow, ConfirmationDialog } from '@commercetools-frontend/application-components';
18
+ import { Masking } from '@commercetools-frontend/fullstory';
19
+ import { useIsAuthorized } from '@commercetools-frontend/permissions';
20
+ import { Spacings, Grid, designTokens, Text, Link, usePaginationState, DataTable, PageNavigator, Stamp, SecondaryButton, PrimaryButton, ImportIcon, TagList, Card, CheckBoldIcon, EyeCrossedIcon, RadioInput } from '@commercetools-frontend/ui-kit';
21
+ import { useShowNotification } from '@commercetools-frontend/actions-global';
22
+ import { DOMAINS } from '@commercetools-frontend/constants';
23
+ import _Reflect$construct from '@babel/runtime-corejs3/core-js-stable/reflect/construct';
24
+ import _createClass from '@babel/runtime-corejs3/helpers/esm/createClass';
25
+ import _classCallCheck from '@babel/runtime-corejs3/helpers/esm/classCallCheck';
26
+ import _possibleConstructorReturn from '@babel/runtime-corejs3/helpers/esm/possibleConstructorReturn';
27
+ import _getPrototypeOf from '@babel/runtime-corejs3/helpers/esm/getPrototypeOf';
28
+ import _inherits from '@babel/runtime-corejs3/helpers/esm/inherits';
29
+ import _wrapNativeSuper from '@babel/runtime-corejs3/helpers/esm/wrapNativeSuper';
30
+ import { reportErrorToSentry } from '@commercetools-frontend/sentry';
31
+ import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/map';
32
+ import _sliceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/slice';
33
+ import _styled from '@emotion/styled/base';
51
34
  import '@emotion/react';
52
- import '@commercetools-frontend/i18n';
35
+ import { parseChunkImport, mapLocaleToIntlLocale } from '@commercetools-frontend/i18n';
36
+
37
+ let CurrentStep$1 = /*#__PURE__*/function (CurrentStep) {
38
+ CurrentStep["Upload"] = "upload";
39
+ CurrentStep["Uploading"] = "uploading";
40
+ CurrentStep["UploadResult"] = "upload-result";
41
+ CurrentStep["ImportConfirmationModal"] = "import-confirmation-modal";
42
+ return CurrentStep;
43
+ }({});
44
+
45
+ function ownKeys$c(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; }
46
+ function _objectSpread$c(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys$c(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys$c(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
47
+
48
+ // TODO: make this resource type specific
49
+
50
+ function reducer(state, action) {
51
+ if (action.type === 'setCurrentStep') return _objectSpread$c(_objectSpread$c({}, state), {}, {
52
+ currentStep: action.currentStep,
53
+ progress: 0
54
+ });
55
+ if (action.type === 'setUploadFileResponse') return _objectSpread$c(_objectSpread$c({}, state), {}, {
56
+ uploadFileResponse: action.uploadFileResponse
57
+ });
58
+ if (action.type === 'setResourceType') return _objectSpread$c(_objectSpread$c({}, state), {}, {
59
+ resourceType: action.resourceType
60
+ });
61
+ if (action.type === 'setContainerKey') return _objectSpread$c(_objectSpread$c({}, state), {}, {
62
+ containerKey: action.containerKey
63
+ });
64
+ if (action.type === 'cancelImport') return _objectSpread$c(_objectSpread$c({}, state), {}, {
65
+ currentStep: CurrentStep$1.Upload,
66
+ containerKey: undefined,
67
+ fileUploadErrors: [],
68
+ uploadFileResponse: undefined,
69
+ droppedFile: undefined,
70
+ dropAreaState: 'disabled',
71
+ progress: 0
72
+ });
73
+ if (action.type === 'uploadNewFile') return _objectSpread$c(_objectSpread$c({}, state), {}, {
74
+ currentStep: CurrentStep$1.Upload,
75
+ containerKey: undefined,
76
+ fileUploadErrors: [],
77
+ uploadFileResponse: undefined,
78
+ droppedFile: undefined,
79
+ dropAreaState: 'ready-for-drop',
80
+ progress: 0
81
+ });
82
+ if (action.type === 'setDroppedFile') {
83
+ return _objectSpread$c(_objectSpread$c({}, state), {}, {
84
+ droppedFile: action.droppedFile
85
+ });
86
+ }
87
+ if (action.type === 'setFileUploadErrors') {
88
+ return _objectSpread$c(_objectSpread$c({}, state), {}, {
89
+ fileUploadErrors: action.fileUploadErrors
90
+ });
91
+ }
92
+ if (action.type === 'setAbortController') {
93
+ return _objectSpread$c(_objectSpread$c({}, state), {}, {
94
+ abortController: action.abortController
95
+ });
96
+ }
97
+ if (action.type === 'setProgress') {
98
+ return _objectSpread$c(_objectSpread$c({}, state), {}, {
99
+ progress: action.progress
100
+ });
101
+ }
102
+ if (action.type === 'setUploadSettings') {
103
+ return _objectSpread$c(_objectSpread$c({}, state), {}, {
104
+ settings: _objectSpread$c(_objectSpread$c({}, state.settings), action.settings)
105
+ });
106
+ }
107
+ throw new Error(getUnknownActionError(action));
108
+ }
109
+ function getUnknownActionError(actionType) {
110
+ return `Unkown type: ${actionType}`;
111
+ }
112
+ const initialState = {
113
+ currentStep: CurrentStep$1.Upload,
114
+ abortController: new AbortController(),
115
+ dropAreaState: 'disabled',
116
+ uploadFileResponse: undefined,
117
+ fileUploadErrors: [],
118
+ resourceType: 'category',
119
+ containerKey: undefined,
120
+ progress: 0,
121
+ settings: {
122
+ decimalSeparator: '.'
123
+ }
124
+ };
125
+
126
+ function ownKeys$b(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; }
127
+ function _objectSpread$b(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys$b(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys$b(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
128
+ const ImportResourcesContext = /*#__PURE__*/React.createContext();
129
+ const ImportResourcesProvider = props => {
130
+ const _useApplicationContex = useApplicationContext(context => ({
131
+ projectKey: context.project?.key
132
+ })),
133
+ projectKey = _useApplicationContex.projectKey;
134
+ const _React$useReducer = React.useReducer(reducer, _objectSpread$b(_objectSpread$b({}, initialState), {}, {
135
+ resourceType: props.resourceTypes[0]
136
+ })),
137
+ _React$useReducer2 = _slicedToArray(_React$useReducer, 2),
138
+ state = _React$useReducer2[0],
139
+ dispatch = _React$useReducer2[1];
140
+ const setCurrentStep = currentStep => dispatch({
141
+ type: 'setCurrentStep',
142
+ currentStep
143
+ });
144
+ const setUploadFileResponse = uploadFileResponse => dispatch({
145
+ type: 'setUploadFileResponse',
146
+ uploadFileResponse: uploadFileResponse
147
+ });
148
+ const setResourceType = resourceType => dispatch({
149
+ type: 'setResourceType',
150
+ resourceType: resourceType
151
+ });
152
+ const setContainerKey = containerKey => dispatch({
153
+ type: 'setContainerKey',
154
+ containerKey
155
+ });
156
+ const cancelImport = () => dispatch({
157
+ type: 'cancelImport'
158
+ });
159
+ const uploadNewFile = () => dispatch({
160
+ type: 'uploadNewFile'
161
+ });
162
+ const setDroppedFile = droppedFile => dispatch({
163
+ type: 'setDroppedFile',
164
+ droppedFile: droppedFile
165
+ });
166
+ const setAbortController = abortController => dispatch({
167
+ type: 'setAbortController',
168
+ abortController: abortController
169
+ });
170
+ const setFileUploadErrors = fileUploadErrors => dispatch({
171
+ type: 'setFileUploadErrors',
172
+ fileUploadErrors: fileUploadErrors
173
+ });
174
+ const setProgress = progress => dispatch({
175
+ type: 'setProgress',
176
+ progress
177
+ });
178
+ const setUploadSettings = nextSettings => {
179
+ dispatch({
180
+ type: 'setUploadSettings',
181
+ settings: nextSettings
182
+ });
183
+ };
184
+ const handleClose = function () {
185
+ let _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
186
+ shouldDeleteImportContainer = _ref.shouldDeleteImportContainer;
187
+ if (state.abortController) state.abortController.abort();
188
+ if (typeof props.onClose === 'function') props.onClose();
189
+ // Removes the associated import container when the import is closed
190
+ if (shouldDeleteImportContainer && projectKey && state.containerKey) deleteImportContainer({
191
+ projectKey,
192
+ importContainerKey: state.containerKey
193
+ });
194
+ };
195
+ const handleStartImportSuccess = () => {
196
+ if (typeof props.onStartImportSuccess === 'function') props.onStartImportSuccess();
197
+ };
198
+ return jsx(ImportResourcesContext.Provider, {
199
+ value: {
200
+ state,
201
+ resourceTypes: props.resourceTypes,
202
+ onClose: handleClose,
203
+ onStartImportSuccess: handleStartImportSuccess,
204
+ actions: {
205
+ setCurrentStep,
206
+ cancelImport,
207
+ uploadNewFile,
208
+ setUploadFileResponse,
209
+ setResourceType,
210
+ setDroppedFile,
211
+ setContainerKey,
212
+ setAbortController,
213
+ setFileUploadErrors,
214
+ setProgress,
215
+ setUploadSettings
216
+ }
217
+ },
218
+ children: props.children
219
+ });
220
+ };
221
+
222
+ function getDropArea(_ref) {
223
+ let dropAreaState = _ref.dropAreaState,
224
+ resourceType = _ref.resourceType,
225
+ isFileDropped = _ref.isFileDropped,
226
+ fileName = _ref.fileName,
227
+ messages = _ref.messages;
228
+ if (dropAreaState === 'file-dropped') {
229
+ return jsx(FileDroppedArea, {
230
+ fileName: fileName,
231
+ chooseFileLabel: messages.chooseFile
232
+ });
233
+ }
234
+ if (dropAreaState === 'disabled' || !resourceType) {
235
+ return jsx(DisabledDropArea, {});
236
+ }
237
+ if (dropAreaState === 'ready-for-drop') {
238
+ return jsx(EnabledDropArea, {
239
+ dragAndDropText: messages.dragAndDropCSV,
240
+ orText: messages.or,
241
+ browseFileText: messages.browseButton
242
+ });
243
+ }
244
+ if (dropAreaState === 'active-drag') {
245
+ return jsx(ActiveDragDropArea, {
246
+ isFileDropped: isFileDropped,
247
+ fileName: fileName,
248
+ chooseFileLabel: messages.chooseFile,
249
+ dragAndDropText: messages.dragAndDropCSV,
250
+ orText: messages.or,
251
+ browseFileText: messages.browseButton
252
+ });
253
+ }
254
+ return fallbackDropArea();
255
+ }
256
+ function fallbackDropArea(_dropAreaState) {
257
+ return jsx(DisabledDropArea, {});
258
+ }
259
+ function getDropAreaState(flags) {
260
+ if (flags.isDragActive) {
261
+ return 'active-drag';
262
+ }
263
+ if (flags.hasResourceType) {
264
+ return 'disabled';
265
+ }
266
+ if (flags.isReady) {
267
+ return 'file-dropped';
268
+ }
269
+ return 'ready-for-drop';
270
+ }
271
+
272
+ var messages$5 = defineMessages({
273
+ dragAndDropCSV: {
274
+ id: 'ImportResourcesModal.dragAndDropCSV',
275
+ description: 'The message telling the user to drag and drop CSV file in the file drop area',
276
+ defaultMessage: 'Drag and drop CSV'
277
+ },
278
+ or: {
279
+ id: 'ImportResourcesModal.or',
280
+ description: 'The word "or" in the drag and drop message',
281
+ defaultMessage: 'or'
282
+ },
283
+ browseButton: {
284
+ id: 'ImportResourcesModal.browseFile',
285
+ defaultMessage: 'Browse file'
286
+ },
287
+ uploadFile: {
288
+ id: 'ImportResourcesModal.uploadFile',
289
+ description: 'Label for a button on the file upload page, shown on active drop area state',
290
+ defaultMessage: 'Upload file'
291
+ },
292
+ chooseFile: {
293
+ id: 'ImportResourcesModal.chooseFile',
294
+ description: 'Label for a button on the file upload page, shown on ready to upload state',
295
+ defaultMessage: 'Choose file'
296
+ },
297
+ fileUploadFailed: {
298
+ id: 'ImportResourcesModal.fileUploadFailed',
299
+ description: 'A title on the file upload page, shown on file upload error state',
300
+ defaultMessage: 'File upload failed'
301
+ },
302
+ fileFormatNotSupported: {
303
+ id: 'ImportResourcesModal.fileFormatNotSupported',
304
+ description: 'Error message displayed when a user drags and drops a non-CSV file',
305
+ defaultMessage: 'Invalid file format: The file is not in CSV format and cannot be processed.'
306
+ },
307
+ tooManyFilesError: {
308
+ id: 'ImportResourcesModal.tooManyFilesError',
309
+ description: 'Error message displayed when a user drags and drops multiple files at once',
310
+ defaultMessage: 'Multiple files detected: You can only drag and drop one file at a time.'
311
+ },
312
+ genericError: {
313
+ id: 'ImportResourcesModal.genericError',
314
+ description: 'Default error message for unexpected file upload issues (for unhandled cases)',
315
+ defaultMessage: 'Error occurred: Please try uploading the file again or contact our support team for assistance.'
316
+ },
317
+ dataType: {
318
+ id: 'ImportResourcesModal.dataType',
319
+ description: 'Label for the data type selection dropdown',
320
+ defaultMessage: 'Data type'
321
+ },
322
+ instructions: {
323
+ id: 'ImportResourcesModal.instructions',
324
+ description: 'Label for the instructions section',
325
+ defaultMessage: 'Instructions'
326
+ },
327
+ prerequisitesOfImportingData: {
328
+ id: 'ImportResourcesModal.infoBox.prerequisitesOfImportingData',
329
+ description: 'A message to guide users to check the prerequisites of importing data',
330
+ defaultMessage: 'Prerequisites of importing data'
331
+ },
332
+ keysForEveryResource: {
333
+ id: 'ImportResourcesModal.infoBox.keysForEveryResource',
334
+ description: 'A message to guide users to provide keys for every resource they import',
335
+ defaultMessage: 'You must provide keys for every resource you import, including embedded resources such as Prices and Assets. Please consult with your admins to assign keys through <link>the HTTP API</link>.'
336
+ },
337
+ publishProducts: {
338
+ id: 'ImportResourcesModal.settings.publishProducts',
339
+ description: 'Label for the publish products checkbox',
340
+ defaultMessage: 'Publish all products in the file'
341
+ },
342
+ separatorTitle: {
343
+ id: 'ImportResourcesModal.uploadSeparator.separatorTitle',
344
+ description: 'Title for the separator selection',
345
+ defaultMessage: 'Separator'
346
+ },
347
+ decimalsSeparatorDescription: {
348
+ id: 'ImportResourcesModal.uploadSeparator.decimalsSeparatorDescription',
349
+ description: 'Description for the decimals separator selection',
350
+ defaultMessage: 'Select the decimals separator that match your CSV file. The column separator is automatically detected.'
351
+ },
352
+ decimalSeparatorPoint: {
353
+ id: 'ImportResourcesModal.uploadSeparator.decimalSeparatorPoint',
354
+ description: 'Label for point decimal separator option',
355
+ defaultMessage: 'point (.)'
356
+ },
357
+ decimalSeparatorComma: {
358
+ id: 'ImportResourcesModal.uploadSeparator.decimalSeparatorComma',
359
+ description: 'Label for comma decimal separator option',
360
+ defaultMessage: 'comma (,)'
361
+ },
362
+ decimals: {
363
+ id: 'ImportResourcesModal.uploadSeparator.decimals',
364
+ description: 'Label for decimal separator select',
365
+ defaultMessage: 'Decimals'
366
+ }
367
+ });
368
+
369
+ function _callSuper$1(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct$1() ? _Reflect$construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
370
+ function _isNativeReflectConstruct$1() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$1 = function () { return !!t; })(); }
371
+ let UnexpectedResourceTypeError = /*#__PURE__*/function (_Error) {
372
+ function UnexpectedResourceTypeError(resourceType) {
373
+ var _this;
374
+ _classCallCheck(this, UnexpectedResourceTypeError);
375
+ _this = _callSuper$1(this, UnexpectedResourceTypeError, [`Unexpected resource type "${resourceType}"`]);
376
+ _this.name = 'UnexpectedResourceTypeError';
377
+ return _this;
378
+ }
379
+ _inherits(UnexpectedResourceTypeError, _Error);
380
+ return _createClass(UnexpectedResourceTypeError);
381
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
382
+
383
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? _Reflect$construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
384
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); }
385
+ let MissingImportResourceProviderError = /*#__PURE__*/function (_Error) {
386
+ function MissingImportResourceProviderError() {
387
+ var _this;
388
+ _classCallCheck(this, MissingImportResourceProviderError);
389
+ _this = _callSuper(this, MissingImportResourceProviderError, ['useImportResourcesContext must be used within ImportResourcesProvider']);
390
+ _this.name = 'MissingImportResourceProviderError';
391
+ return _this;
392
+ }
393
+ _inherits(MissingImportResourceProviderError, _Error);
394
+ return _createClass(MissingImportResourceProviderError);
395
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
396
+
397
+ function useImportResourcesContext() {
398
+ const context = useContext(ImportResourcesContext);
399
+ if (!context) {
400
+ throw new MissingImportResourceProviderError();
401
+ }
402
+ return context;
403
+ }
404
+
405
+ var messages$4 = defineMessages({
406
+ fileSizeExceededTitle: {
407
+ id: 'ImportResourcesModal.sizeExceededTitle',
408
+ defaultMessage: 'File size exceeded'
409
+ },
410
+ fileSizeExceededDescription: {
411
+ id: 'ImportResourcesModal.sizeExceededDescription',
412
+ description: 'Error description when the file size exceeds the allowable limit',
413
+ defaultMessage: 'The file exceeds the maximum allowed size of {fileSizeLimit} MB'
414
+ },
415
+ rowLimitExceededTitle: {
416
+ id: 'ImportResourcesModal.rowLimitExceededTitle',
417
+ defaultMessage: 'Row limit exceeded'
418
+ },
419
+ rowLimitExceededDescription: {
420
+ id: 'ImportResourcesModal.rowLimitExceededDescription',
421
+ description: 'Error description when the file contains more rows than the allowable maximum',
422
+ defaultMessage: 'The file contains more than the allowable maximum of {rowLimit} rows'
423
+ },
424
+ wrongSeparatorTitle: {
425
+ id: 'ImportResourcesModal.wrongSeparatorTitle',
426
+ defaultMessage: 'Wrong separator'
427
+ },
428
+ wrongSeparatorDescription: {
429
+ id: 'ImportResourcesModal.wrongSeparatorDescription',
430
+ description: 'Message within the drop area when a CSV file uses an unexpected separator',
431
+ defaultMessage: 'The file is using an unsupported separator. Please use one of the allowed separators: {delimiterList}.'
432
+ },
433
+ dropAreaNotEnoughRowsTitle: {
434
+ id: 'ImportResourcesModal.dropAreaNotEnoughRowsTitle',
435
+ description: 'Error title shown when the uploaded CSV file does not contain a header and at least one row of data',
436
+ defaultMessage: 'Invalid CSV file'
437
+ },
438
+ dropAreaNotEnoughRowsDescription: {
439
+ id: 'ImportResourcesModal.dropAreaNotEnoughRowsDescription',
440
+ description: 'Error description shown when the uploaded CSV file does not contain a header and at least one row of data',
441
+ defaultMessage: 'Make sure the file contains a header and at least one row of data'
442
+ },
443
+ unexpectedError: {
444
+ id: 'ImportResourcesModal.unexpectedError',
445
+ description: 'Generic notification message when file upload fails',
446
+ defaultMessage: 'An unexpected error occurred during the file upload. Please try again, or contact support if this error occurs again.'
447
+ },
448
+ missingRequiredField: {
449
+ id: 'ImportResourcesModal.missingRequiredField',
450
+ description: 'Error message displayed when a required field is missing',
451
+ defaultMessage: 'Missing required field'
452
+ },
453
+ missingKeyError: {
454
+ id: 'ImportResourcesModal.missingKeyError',
455
+ description: 'Error message displayed when the uploaded file is missing the key field',
456
+ defaultMessage: "The 'key' field is missing or incomplete in some rows. Please ensure every row has a 'key' value."
457
+ },
458
+ missingRequiredKeys: {
459
+ id: 'ImportResourcesModal.missingRequiredKeys',
460
+ description: 'Error message displayed when the uploaded file is missing required keys',
461
+ defaultMessage: 'Make sure the file contains required keys for the elements including {fieldNames}'
462
+ }
463
+ });
464
+
465
+ const IMPORTABLE_RESOURCES = {
466
+ CATEGORY: 'category',
467
+ PRODUCT: 'product',
468
+ INVENTORY: 'inventory',
469
+ DISCOUNT_CODE: 'discount-code',
470
+ CUSTOMER: 'customer',
471
+ ORDER: 'order',
472
+ PRODUCT_TYPE: 'product-type',
473
+ BUSINESS_UNIT: 'business-unit'
474
+ };
475
+
476
+ var sharedMessages = defineMessages({
477
+ [`modalTitle.${IMPORTABLE_RESOURCES.CATEGORY}`]: {
478
+ id: 'ImportResourcesModal.modalTitle.category',
479
+ description: 'Label for the categories modal title',
480
+ defaultMessage: 'Import categories by CSV'
481
+ },
482
+ [`modalTitle.${IMPORTABLE_RESOURCES.PRODUCT}`]: {
483
+ id: 'ImportResourcesModal.modalTitle.product',
484
+ description: 'Label for the products modal title',
485
+ defaultMessage: 'Import products by CSV'
486
+ },
487
+ [`modalTitle.${IMPORTABLE_RESOURCES.INVENTORY}`]: {
488
+ id: 'ImportResourcesModal.modalTitle.inventoryEntry',
489
+ description: 'Label for the inventories modal title',
490
+ defaultMessage: 'Import inventories by CSV'
491
+ },
492
+ [`modalTitle.${IMPORTABLE_RESOURCES.DISCOUNT_CODE}`]: {
493
+ id: 'ImportResourcesModal.modalTitle.discountCode',
494
+ description: 'Label for the inventories modal title',
495
+ defaultMessage: 'Import discount codes by CSV'
496
+ },
497
+ [`modalTitle.${IMPORTABLE_RESOURCES.BUSINESS_UNIT}`]: {
498
+ id: 'ImportResourcesModal.modalTitle.businessUnit',
499
+ description: 'Label for the business units modal title',
500
+ defaultMessage: 'Import business units by CSV'
501
+ },
502
+ [`modalTitle.${IMPORTABLE_RESOURCES.CUSTOMER}`]: {
503
+ id: 'ImportResourcesModal.modalTitle.customer',
504
+ description: 'Label for the customers modal title',
505
+ defaultMessage: 'Import customers by CSV'
506
+ },
507
+ [`modalTitle.${IMPORTABLE_RESOURCES.ORDER}`]: {
508
+ id: 'ImportResourcesModal.modalTitle.order',
509
+ description: 'Label for the order modal title',
510
+ defaultMessage: 'Import orders by CSV'
511
+ },
512
+ [`modalTitle.${IMPORTABLE_RESOURCES.PRODUCT_TYPE}`]: {
513
+ id: 'ImportResourcesModal.modalTitle.productType',
514
+ description: 'Label for the product type modal title',
515
+ defaultMessage: 'Import product types by CSV'
516
+ },
517
+ uploadButton: {
518
+ id: 'ImportResourcesModal.uploadButton',
519
+ description: 'Label for the upload button',
520
+ defaultMessage: 'Upload and preview'
521
+ },
522
+ cancel: {
523
+ id: 'ImportResourcesModal.cancel',
524
+ description: 'Label for the cancel button',
525
+ defaultMessage: 'Cancel'
526
+ },
527
+ close: {
528
+ id: 'ImportResourcesModal.close',
529
+ description: 'Label for the close button',
530
+ defaultMessage: 'Close'
531
+ },
532
+ listConjunctionOr: {
533
+ id: 'ImportResourcesModal.listConjunctionOr',
534
+ description: 'Label for the list conjunction or',
535
+ defaultMessage: 'or'
536
+ },
537
+ delimiterComma: {
538
+ id: 'ImportResourcesModal.delimiterComma',
539
+ description: 'Label for the delimiter name comma',
540
+ defaultMessage: 'comma'
541
+ },
542
+ delimiterSemicolon: {
543
+ id: 'ImportResourcesModal.delimiterSemicolon',
544
+ description: 'Label for the delimiter name semicolon',
545
+ defaultMessage: 'semicolon'
546
+ },
547
+ delimiterPipe: {
548
+ id: 'ImportResourcesModal.delimiterPipe',
549
+ description: 'Label for the delimiter name pipe',
550
+ defaultMessage: 'pipe'
551
+ },
552
+ delimiterTab: {
553
+ id: 'ImportResourcesModal.delimiterTab',
554
+ description: 'Label for the delimiter name tab',
555
+ defaultMessage: 'tab'
556
+ },
557
+ // Resource types
558
+ product: {
559
+ id: 'ImportResourcesModal.product',
560
+ description: 'Label for the product resource type',
561
+ defaultMessage: 'Product'
562
+ },
563
+ products: {
564
+ id: 'ImportResourcesModal.products',
565
+ description: 'Label for the products resource type',
566
+ defaultMessage: 'Products'
567
+ },
568
+ inventory: {
569
+ id: 'ImportResourcesModal.inventory',
570
+ description: 'Label for the inventory entry resource type',
571
+ defaultMessage: 'Inventory'
572
+ },
573
+ inventories: {
574
+ id: 'ImportResourcesModal.inventories',
575
+ description: 'Label for the inventories entry resource type',
576
+ defaultMessage: 'Inventories'
577
+ },
578
+ category: {
579
+ id: 'ImportResourcesModal.category',
580
+ description: 'Label for the category resource type',
581
+ defaultMessage: 'Category'
582
+ },
583
+ categories: {
584
+ id: 'ImportResourcesModal.categories',
585
+ description: 'Label for the categories resource type',
586
+ defaultMessage: 'Categories'
587
+ },
588
+ 'custom-object': {
589
+ id: 'ImportResourcesModal.custom-object',
590
+ description: 'Label for the custom-object resource type',
591
+ defaultMessage: 'Custom object'
592
+ },
593
+ 'custom-objects': {
594
+ id: 'ImportResourcesModal.custom-objects',
595
+ description: 'Label for the custom-objects resource type',
596
+ defaultMessage: 'Custom objects'
597
+ },
598
+ customer: {
599
+ id: 'ImportResourcesModal.customer',
600
+ description: 'Label for the customer resource type',
601
+ defaultMessage: 'Customer'
602
+ },
603
+ customers: {
604
+ id: 'ImportResourcesModal.customers',
605
+ description: 'Label for the customers resource type',
606
+ defaultMessage: 'Customers'
607
+ },
608
+ order: {
609
+ id: 'ImportResourcesModal.order',
610
+ description: 'Label for the order resource type',
611
+ defaultMessage: 'Order'
612
+ },
613
+ orders: {
614
+ id: 'ImportResourcesModal.orders',
615
+ description: 'Label for the orders resource type',
616
+ defaultMessage: 'Orders'
617
+ },
618
+ 'order-patch': {
619
+ id: 'ImportResourcesModal.order-patch',
620
+ description: 'Label for the order-patch resource type',
621
+ defaultMessage: 'Order patch'
622
+ },
623
+ 'order-patches': {
624
+ id: 'ImportResourcesModal.order-patches',
625
+ description: 'Label for the order-patches resource type',
626
+ defaultMessage: 'Order patches'
627
+ },
628
+ price: {
629
+ id: 'ImportResourcesModal.price',
630
+ description: 'Label for the price resource type',
631
+ defaultMessage: 'Price'
632
+ },
633
+ prices: {
634
+ id: 'ImportResourcesModal.prices',
635
+ description: 'Label for the prices resource type',
636
+ defaultMessage: 'Prices'
637
+ },
638
+ 'product-draft': {
639
+ id: 'ImportResourcesModal.product-draft',
640
+ description: 'Label for the product-draft resource type',
641
+ defaultMessage: 'Product draft'
642
+ },
643
+ 'product-drafts': {
644
+ id: 'ImportResourcesModal.product-drafts',
645
+ description: 'Label for the product-drafts resource type',
646
+ defaultMessage: 'Product drafts'
647
+ },
648
+ 'product-type': {
649
+ id: 'ImportResourcesModal.product-type',
650
+ description: 'Label for the product-type resource type',
651
+ defaultMessage: 'Product type'
652
+ },
653
+ 'product-types': {
654
+ id: 'ImportResourcesModal.product-types',
655
+ description: 'Label for the product-types resource type',
656
+ defaultMessage: 'Product types'
657
+ },
658
+ 'product-variant': {
659
+ id: 'ImportResourcesModal.product-variant',
660
+ description: 'Label for the product-variant resource type',
661
+ defaultMessage: 'Product variant'
662
+ },
663
+ 'product-variants': {
664
+ id: 'ImportResourcesModal.product-variants',
665
+ description: 'Label for the product-variants resource type',
666
+ defaultMessage: 'Product variants'
667
+ },
668
+ 'product-variant-patch': {
669
+ id: 'ImportResourcesModal.product-variant-patch',
670
+ description: 'Label for the product-variant-patch resource type',
671
+ defaultMessage: 'Product variant patch'
672
+ },
673
+ 'product-variant-patches': {
674
+ id: 'ImportResourcesModal.product-variant-patches',
675
+ description: 'Label for the product-variant-patches resource type',
676
+ defaultMessage: 'Product variant patches'
677
+ },
678
+ 'standalone-price': {
679
+ id: 'ImportResourcesModal.standalone-price',
680
+ description: 'Label for the standalone-price resource type',
681
+ defaultMessage: 'Standalone price'
682
+ },
683
+ 'standalone-prices': {
684
+ id: 'ImportResourcesModal.standalone-prices',
685
+ description: 'Label for the standalone-prices resource type',
686
+ defaultMessage: 'Standalone prices'
687
+ },
688
+ type: {
689
+ id: 'ImportResourcesModal.type',
690
+ description: 'Label for the type resource type',
691
+ defaultMessage: 'Type'
692
+ },
693
+ types: {
694
+ id: 'ImportResourcesModal.types',
695
+ description: 'Label for the types resource type',
696
+ defaultMessage: 'Types'
697
+ },
698
+ 'discount-code': {
699
+ id: 'ImportResourcesModal.discount-code',
700
+ description: 'Label for the discount-code resource type',
701
+ defaultMessage: 'Discount code'
702
+ },
703
+ 'discount-codes': {
704
+ id: 'ImportResourcesModal.discount-codes',
705
+ description: 'Label for the discount-codes resource type',
706
+ defaultMessage: 'Discount codes'
707
+ },
708
+ 'business-unit': {
709
+ id: 'ImportResourcesModal.business-unit',
710
+ description: 'Label for the business-unit resource type',
711
+ defaultMessage: 'Business unit'
712
+ },
713
+ 'business-units': {
714
+ id: 'ImportResourcesModal.business-units',
715
+ description: 'Label for the business-units resource type',
716
+ defaultMessage: 'Business units'
717
+ },
718
+ unknownResourceType: {
719
+ id: 'ImportResourcesModal.unknown-resource-type',
720
+ description: 'Label for the unknown resource type',
721
+ defaultMessage: 'Unknown resource type'
722
+ }
723
+ //
724
+ });
725
+
726
+ const formatAllowedDelimitersForMessageDisplay = intl => {
727
+ const localizedOr = intl.formatMessage(sharedMessages.listConjunctionOr);
728
+ const descriptions = _mapInstanceProperty(COLUMN_DELIMITERS).call(COLUMN_DELIMITERS, delimiter => {
729
+ let nameDescriptor;
730
+ switch (delimiter) {
731
+ case ',':
732
+ nameDescriptor = sharedMessages.delimiterComma;
733
+ break;
734
+ case ';':
735
+ nameDescriptor = sharedMessages.delimiterSemicolon;
736
+ break;
737
+ case '|':
738
+ nameDescriptor = sharedMessages.delimiterPipe;
739
+ break;
740
+ case '\t':
741
+ nameDescriptor = sharedMessages.delimiterTab;
742
+ break;
743
+ default:
744
+ nameDescriptor = undefined;
745
+ }
746
+ const name = nameDescriptor ? intl.formatMessage(nameDescriptor) : delimiter;
747
+ return delimiter === '\t' ? name : `${name} (${delimiter})`;
748
+ });
749
+ if (descriptions.length === 1) {
750
+ return descriptions[0];
751
+ }
752
+ const lastDescription = descriptions.pop();
753
+ return `${descriptions.join(', ')} ${localizedOr} ${lastDescription}`;
754
+ };
755
+
756
+ function resourceTypeToMessage(resourceType) {
757
+ const resourceTypeMap = {
758
+ category: sharedMessages.category,
759
+ product: sharedMessages.product,
760
+ 'product-type': sharedMessages['product-type'],
761
+ order: sharedMessages.order,
762
+ customer: sharedMessages.customer,
763
+ 'discount-code': sharedMessages['discount-code'],
764
+ inventory: sharedMessages.inventory,
765
+ 'inventory-entry': sharedMessages.inventory,
766
+ 'order-patch': sharedMessages['order-patch'],
767
+ price: sharedMessages.price,
768
+ 'product-draft': sharedMessages['product-draft'],
769
+ 'product-variant': sharedMessages['product-variant'],
770
+ 'product-variant-patch': sharedMessages['product-variant-patch'],
771
+ 'standalone-price': sharedMessages['standalone-price'],
772
+ 'custom-object': sharedMessages['custom-object'],
773
+ 'business-unit': sharedMessages['business-unit'],
774
+ type: sharedMessages.type
775
+ };
776
+ const message = resourceTypeMap[resourceType];
777
+ if (!message) {
778
+ console.warn(new UnexpectedResourceTypeError(resourceType));
779
+ return sharedMessages.unknownResourceType;
780
+ }
781
+ return message;
782
+ }
783
+ function resourceTypeToPluralMessage(resourceType) {
784
+ const resourceTypePluralMap = {
785
+ category: sharedMessages.categories,
786
+ 'custom-object': sharedMessages['custom-objects'],
787
+ product: sharedMessages.products,
788
+ 'product-type': sharedMessages['product-types'],
789
+ order: sharedMessages.orders,
790
+ customer: sharedMessages.customers,
791
+ 'discount-code': sharedMessages['discount-codes'],
792
+ inventory: sharedMessages.inventories,
793
+ 'inventory-entry': sharedMessages.inventories,
794
+ 'order-patch': sharedMessages['order-patches'],
795
+ price: sharedMessages.prices,
796
+ 'product-draft': sharedMessages['product-drafts'],
797
+ 'product-variant': sharedMessages['product-variants'],
798
+ 'product-variant-patch': sharedMessages['product-variant-patches'],
799
+ 'standalone-price': sharedMessages['standalone-prices'],
800
+ 'business-unit': sharedMessages['business-units']
801
+ };
802
+ const message = resourceTypePluralMap[resourceType];
803
+ if (!message) {
804
+ console.warn(new UnexpectedResourceTypeError(resourceType));
805
+ return sharedMessages.unknownResourceType;
806
+ }
807
+ return message;
808
+ }
809
+
810
+ function ownKeys$a(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; }
811
+ function _objectSpread$a(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys$a(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys$a(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
812
+ const useUpload = () => {
813
+ const intl = useIntl();
814
+ const _useApplicationContex = useApplicationContext(context => ({
815
+ projectKey: context.project?.key
816
+ })),
817
+ projectKey = _useApplicationContex.projectKey;
818
+ const _useImportResourcesCo = useImportResourcesContext(),
819
+ state = _useImportResourcesCo.state,
820
+ actions = _useImportResourcesCo.actions;
821
+ const showNotification = useShowNotification();
822
+ const _useImportContainerUp = useImportContainerUpload({
823
+ projectKey: projectKey
824
+ }),
825
+ upload = _useImportContainerUp.upload;
826
+ React.useEffect(() => {
827
+ return () => {
828
+ if (state.abortController) state.abortController.abort();
829
+ };
830
+ }, [state.abortController]);
831
+ const isFileValid = async file => {
832
+ const errors = [];
833
+ const isDelimiterValid = await validateDelimiter(file, COLUMN_DELIMITERS);
834
+ if (!isDelimiterValid) errors.push({
835
+ title: intl.formatMessage(messages$4.wrongSeparatorTitle),
836
+ description: intl.formatMessage(messages$4.wrongSeparatorDescription, {
837
+ delimiterList: formatAllowedDelimitersForMessageDisplay(intl)
838
+ })
839
+ });
840
+ const rowCount = await getRowCount(file);
841
+ if (rowCount < 1) errors.push({
842
+ title: intl.formatMessage(messages$4.dropAreaNotEnoughRowsTitle),
843
+ description: intl.formatMessage(messages$4.dropAreaNotEnoughRowsDescription)
844
+ });
845
+ if (state.resourceType && file.size > toBytes(MAX_FILE_SIZE_MB)) errors.push({
846
+ title: intl.formatMessage(messages$4.fileSizeExceededTitle),
847
+ description: intl.formatMessage(messages$4.fileSizeExceededDescription, {
848
+ fileSizeLimit: intl.formatNumber(MAX_FILE_SIZE_MB)
849
+ })
850
+ });
851
+ if (state.resourceType && rowCount > MAX_ROW_COUNT) errors.push({
852
+ title: intl.formatMessage(messages$4.rowLimitExceededTitle),
853
+ description: intl.formatMessage(messages$4.rowLimitExceededDescription, {
854
+ rowLimit: intl.formatNumber(MAX_ROW_COUNT)
855
+ })
856
+ });
857
+ if (errors.length > 0) {
858
+ actions.setFileUploadErrors(errors);
859
+ actions.setCurrentStep(CurrentStep$1.UploadResult);
860
+ return false;
861
+ }
862
+ return true;
863
+ };
864
+ const handleUploadError = error => {
865
+ if (isAbortError(error)) {
866
+ actions.cancelImport();
867
+ return;
868
+ }
869
+ if (error instanceof HttpError) {
870
+ if (error.errorData?.code === 'MISSING_KEY_ERROR') {
871
+ actions.setFileUploadErrors([{
872
+ title: intl.formatMessage(messages$4.missingRequiredField),
873
+ description: intl.formatMessage(messages$4.missingKeyError)
874
+ }]);
875
+ actions.setCurrentStep(CurrentStep$1.UploadResult);
876
+ } else if (error.errorData?.code === 'MissingCsvFieldIdentifier') {
877
+ const MissingCsvFieldIdentifierError = error.errorData;
878
+ const fieldNames = formatKeys(MissingCsvFieldIdentifierError.rowValue);
879
+ actions.setFileUploadErrors([{
880
+ title: intl.formatMessage(messages$4.missingRequiredField),
881
+ description: intl.formatMessage(messages$4.missingRequiredKeys, {
882
+ fieldNames
883
+ })
884
+ }]);
885
+ actions.setCurrentStep(CurrentStep$1.UploadResult);
886
+ } else if (error.errorData?.invalid > 0) {
887
+ actions.setUploadFileResponse(error.errorData);
888
+ actions.setCurrentStep(CurrentStep$1.UploadResult);
889
+ } else {
890
+ actions.cancelImport();
891
+ showNotification({
892
+ kind: 'error',
893
+ domain: DOMAINS.PAGE,
894
+ text: intl.formatMessage(messages$4.unexpectedError)
895
+ });
896
+ }
897
+ } else {
898
+ actions.cancelImport();
899
+ showNotification({
900
+ kind: 'error',
901
+ domain: DOMAINS.PAGE,
902
+ text: isError(error) ? error.toString() : String(error)
903
+ });
904
+ reportErrorToSentry(new Error('Upload File Error: An unexpected issue occurred while uploading the file'), {
905
+ extra: {
906
+ error,
907
+ resourceType: state.resourceType,
908
+ fileSizeInBytes: state.droppedFile?.size
909
+ }
910
+ });
911
+ }
912
+ };
913
+ const handleUploadAndValidation = async () => {
914
+ if (!state.droppedFile || !state.resourceType) return;
915
+ const canUpload = await isFileValid(state.droppedFile);
916
+ if (!canUpload) return;
917
+ actions.setCurrentStep(CurrentStep$1.Uploading);
918
+ try {
919
+ const shouldApplyPublishSettings = state.resourceType === 'product';
920
+ const xhr = await upload({
921
+ file: state.droppedFile,
922
+ resourceType: state.resourceType,
923
+ settings: _objectSpread$a({
924
+ format: 'CSV',
925
+ decimalSeparator: state.settings?.decimalSeparator
926
+ }, shouldApplyPublishSettings ? {
927
+ resourceType: state.resourceType === 'product' ? 'product-draft' : state.resourceType,
928
+ options: {
929
+ publishAllChanges: state.settings?.publish ?? false
930
+ }
931
+ } : {}),
932
+ onSuccess: (fileUploadResponse, containerKey) => {
933
+ actions.setContainerKey(containerKey);
934
+ actions.setUploadFileResponse(fileUploadResponse);
935
+ actions.setCurrentStep(CurrentStep$1.UploadResult);
936
+ },
937
+ onProgress: progress => {
938
+ actions.setProgress(progress);
939
+ },
940
+ onError: handleUploadError
941
+ });
942
+ actions.setAbortController(xhr);
943
+ } catch (error) {
944
+ handleUploadError(error);
945
+ actions.setCurrentStep(CurrentStep$1.UploadResult);
946
+ }
947
+ };
948
+ return {
949
+ handleUploadAndValidation
950
+ };
951
+ };
952
+
953
+ const INITIAL_COLUMN_DISPLAY_COUNT = 8;
954
+
955
+ const PERMISSIONS = {
956
+ // Categories
957
+ ManageCategories: 'ManageCategories',
958
+ ViewCategories: 'ViewCategories',
959
+ // Products
960
+ ManageProducts: 'ManageProducts',
961
+ ViewProducts: 'ViewProducts',
962
+ // ProductTypes
963
+ ManageProductTypes: 'ManageProductTypes',
964
+ ViewProductTypes: 'ViewProductTypes',
965
+ // DiscountCodes
966
+ ManageDiscountCodes: 'ManageDiscountCodes',
967
+ ViewDiscountCodes: 'ViewDiscountCodes',
968
+ // Customers
969
+ ManageCustomers: 'ManageCustomers',
970
+ ViewCustomers: 'ViewCustomers',
971
+ // Orders
972
+ ManageOrders: 'ManageOrders',
973
+ ViewOrders: 'ViewOrders',
974
+ // KeyValueDocuments
975
+ ManageKeyValueDocuments: 'ManageKeyValueDocuments',
976
+ ViewKeyValueDocuments: 'ViewKeyValueDocuments',
977
+ // BusinessUnits
978
+ ManageBusinessUnits: 'ManageBusinessUnits',
979
+ ViewBusinessUnits: 'ViewBusinessUnits'
980
+ };
981
+
982
+ function ownKeys$9(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; }
983
+ function _objectSpread$9(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys$9(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys$9(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
984
+ const DEFAULT_SHORT_LIVED_FLAGS = {};
985
+ const DEFAULT_LONG_LIVED_FLAGS = {};
986
+ _objectSpread$9(_objectSpread$9({}, DEFAULT_SHORT_LIVED_FLAGS), DEFAULT_LONG_LIVED_FLAGS);
987
+
988
+ const useImportPermission = () => {
989
+ const _useApplicationContex = useApplicationContext(applicationContext => ({
990
+ actionRights: applicationContext.actionRights?.products
991
+ })),
992
+ actionRights = _useApplicationContex.actionRights;
993
+ const canManageProducts = useIsAuthorized({
994
+ demandedPermissions: [PERMISSIONS.ManageProducts]
995
+ });
996
+ const canManageCustomers = useIsAuthorized({
997
+ demandedPermissions: [PERMISSIONS.ManageCustomers]
998
+ });
999
+ const canManageOrders = useIsAuthorized({
1000
+ demandedPermissions: [PERMISSIONS.ManageOrders]
1001
+ });
1002
+ const canManageKeyValueDocuments = useIsAuthorized({
1003
+ demandedPermissions: [PERMISSIONS.ManageKeyValueDocuments]
1004
+ });
1005
+ const canMAnageCategories = useIsAuthorized({
1006
+ demandedPermissions: [PERMISSIONS.ManageCategories]
1007
+ });
1008
+ const canManageDiscountCodes = useIsAuthorized({
1009
+ demandedPermissions: [PERMISSIONS.ManageDiscountCodes]
1010
+ });
1011
+ const canManageBusinessUnits = useIsAuthorized({
1012
+ demandedPermissions: [PERMISSIONS.ManageBusinessUnits]
1013
+ });
1014
+ const canImportProducts = useMemo(() => {
1015
+ if (!actionRights) return false;
1016
+ const canAddPrices = actionRights.canAddPrices,
1017
+ canAddProducts = actionRights.canAddProducts,
1018
+ canEditAttributesAll = actionRights['canEditAttributes:all'],
1019
+ canEditPrices = actionRights.canEditPrices;
1020
+ return canManageProducts && canAddPrices && canAddProducts && canEditAttributesAll && canEditPrices;
1021
+ }, [canManageProducts, actionRights]);
1022
+ const canManageCustomObjects = useMemo(() => {
1023
+ return canManageProducts || canManageCustomers || canManageOrders || canManageKeyValueDocuments;
1024
+ }, [canManageCustomers, canManageOrders, canManageProducts, canManageKeyValueDocuments]);
1025
+ return {
1026
+ canImportProducts,
1027
+ canImportCategories: canMAnageCategories,
1028
+ canImportDiscountCodes: canManageDiscountCodes,
1029
+ canImportBusinessUnits: canManageBusinessUnits,
1030
+ canImportInventories: canManageProducts,
1031
+ canImportProductTypes: canManageProducts,
1032
+ canImportCustomObjects: canManageCustomObjects
1033
+ };
1034
+ };
1035
+
1036
+ const FileDropArea = () => {
1037
+ const intl = useIntl();
1038
+ const _useImportResourcesCo = useImportResourcesContext(),
1039
+ state = _useImportResourcesCo.state,
1040
+ actions = _useImportResourcesCo.actions;
1041
+ const isResourceTypeSelected = Boolean(state.resourceType);
1042
+ const showNotification = useShowNotification();
1043
+ const onDrop = React.useCallback(_ref => {
1044
+ let _ref2 = _slicedToArray(_ref, 1),
1045
+ file = _ref2[0];
1046
+ if (!file) return;
1047
+ assertResourceType(state.resourceType);
1048
+ actions.setDroppedFile(file);
1049
+ }, [state.resourceType, actions]);
1050
+ const handleDropRejected = React.useCallback(errorType => {
1051
+ const errorMessageMap = {
1052
+ 'too-many-files': messages$5.tooManyFilesError,
1053
+ 'invalid-type': messages$5.fileFormatNotSupported,
1054
+ generic: messages$5.genericError
1055
+ };
1056
+ showNotification({
1057
+ kind: 'error',
1058
+ domain: DOMAINS.PAGE,
1059
+ text: intl.formatMessage(errorMessageMap[errorType])
1060
+ });
1061
+ }, [intl, showNotification]);
1062
+ const getState = React.useCallback(isDragActive => getDropAreaState({
1063
+ isReady: Boolean(state.droppedFile),
1064
+ hasResourceType: !state.resourceType,
1065
+ isDragActive
1066
+ }), [state.resourceType, state.droppedFile]);
1067
+ return jsx(FileDropArea$1, {
1068
+ onDrop: onDrop,
1069
+ onDropRejected: handleDropRejected,
1070
+ disabled: !isResourceTypeSelected,
1071
+ accept: {
1072
+ 'text/csv': ['.csv']
1073
+ },
1074
+ getDropAreaState: getState,
1075
+ children: dropAreaState => getDropArea({
1076
+ dropAreaState,
1077
+ resourceType: 'category',
1078
+ isFileDropped: Boolean(state.droppedFile),
1079
+ fileName: state.droppedFile?.name,
1080
+ messages: {
1081
+ chooseFile: intl.formatMessage(messages$5.chooseFile),
1082
+ dragAndDropCSV: intl.formatMessage(messages$5.dragAndDropCSV),
1083
+ or: intl.formatMessage(messages$5.or),
1084
+ browseButton: intl.formatMessage(messages$5.browseButton)
1085
+ }
1086
+ })
1087
+ });
1088
+ };
1089
+
1090
+ const Upload = () => {
1091
+ const _useImportResourcesCo = useImportResourcesContext(),
1092
+ state = _useImportResourcesCo.state,
1093
+ onClose = _useImportResourcesCo.onClose,
1094
+ resourceTypes = _useImportResourcesCo.resourceTypes,
1095
+ actions = _useImportResourcesCo.actions;
1096
+ const intl = useIntl();
1097
+ const _useUpload = useUpload(),
1098
+ handleUploadAndValidation = _useUpload.handleUploadAndValidation;
1099
+ const isMultipleResourceTypes = resourceTypes.length > 1;
1100
+ const canPublishProducts = useIsAuthorized({
1101
+ demandedPermissions: ['ManageProducts'],
1102
+ demandedActionRights: [{
1103
+ group: 'products',
1104
+ name: 'PublishProducts'
1105
+ }]
1106
+ });
1107
+ return jsx(FormDialog, {
1108
+ size: 16,
1109
+ isOpen: true,
1110
+ title: intl.formatMessage(sharedMessages[`modalTitle.${state.resourceType}`]),
1111
+ labelPrimary: intl.formatMessage(sharedMessages.uploadButton),
1112
+ onPrimaryButtonClick: handleUploadAndValidation,
1113
+ isPrimaryButtonDisabled: !Boolean(state.droppedFile),
1114
+ onSecondaryButtonClick: () => onClose({
1115
+ shouldDeleteImportContainer: true
1116
+ }),
1117
+ onClose: () => onClose({
1118
+ shouldDeleteImportContainer: true
1119
+ }),
1120
+ dataAttributesPrimaryButton: {
1121
+ 'data-tracking-target': `${state.resourceType}_import-upload_and_preview_button`
1122
+ },
1123
+ children: jsx(Masking.Unmask, {
1124
+ children: jsxs(Spacings.Stack, {
1125
+ scale: "l",
1126
+ children: [isMultipleResourceTypes ? jsxs(Grid, {
1127
+ gridRowGap: designTokens.spacingL,
1128
+ gridTemplateColumns: `calc(${designTokens.constraint3} + ${designTokens.spacingL}) auto`,
1129
+ children: [jsx(Grid.Item, {
1130
+ children: jsx(Text.Body, {
1131
+ isBold: true,
1132
+ intlMessage: messages$5.dataType
1133
+ })
1134
+ }), jsx(Grid.Item, {
1135
+ children: jsx(ResourceTypeSelection, {})
1136
+ }), jsx(Grid.Item, {
1137
+ children: jsx(Text.Body, {
1138
+ isBold: true,
1139
+ intlMessage: messages$5.instructions
1140
+ })
1141
+ }), jsx(Grid.Item, {
1142
+ children: jsx(Instructions, {})
1143
+ })]
1144
+ }) : jsx(Fragment, {
1145
+ children: jsx(Instructions, {})
1146
+ }), jsx(InfoBox, {
1147
+ title: intl.formatMessage(messages$5.prerequisitesOfImportingData),
1148
+ description: intl.formatMessage(messages$5.keysForEveryResource, {
1149
+ link: msg => jsx(Link, {
1150
+ tone: "secondary",
1151
+ isExternal: true,
1152
+ to: CT_API_DOCS_URL,
1153
+ children: msg
1154
+ }, "link")
1155
+ })
1156
+ }), jsx(UploadSeparator, {
1157
+ value: state.settings?.decimalSeparator,
1158
+ onChange: decimalSeparator => {
1159
+ actions.setUploadSettings({
1160
+ decimalSeparator
1161
+ });
1162
+ },
1163
+ separatorTitle: intl.formatMessage(messages$5.separatorTitle),
1164
+ decimalsSeparatorDescription: intl.formatMessage(messages$5.decimalsSeparatorDescription),
1165
+ decimalSeparatorPointLabel: intl.formatMessage(messages$5.decimalSeparatorPoint),
1166
+ decimalSeparatorCommaLabel: intl.formatMessage(messages$5.decimalSeparatorComma),
1167
+ decimalsLabel: intl.formatMessage(messages$5.decimals)
1168
+ }), jsx(Masking.Mask, {
1169
+ children: jsx(FileDropArea, {})
1170
+ }), jsx(UploadSettings, {
1171
+ resourceType: state.resourceType,
1172
+ isPublishChecked: state.settings?.publish,
1173
+ onPublishChange: checked => {
1174
+ actions.setUploadSettings({
1175
+ publish: checked
1176
+ });
1177
+ },
1178
+ publishProductsLabel: intl.formatMessage(messages$5.publishProducts),
1179
+ dataTrackingTarget: "product_import-publish_checkbox",
1180
+ canPublishProducts: canPublishProducts
1181
+ })]
1182
+ })
1183
+ })
1184
+ });
1185
+ };
1186
+
1187
+ var messages$3 = defineMessages({
1188
+ row: {
1189
+ id: 'ImportResourcesModal.row',
1190
+ description: 'In Upload file error modal - "Row" column',
1191
+ defaultMessage: 'Row'
1192
+ },
1193
+ errorType: {
1194
+ id: 'ImportResourcesModal.errorType',
1195
+ description: 'In Upload file error modal - "Error type" column',
1196
+ defaultMessage: 'Error type'
1197
+ },
1198
+ details: {
1199
+ id: 'ImportResourcesModal.details',
1200
+ description: 'In Upload file error modal - "Details" column',
1201
+ defaultMessage: 'Details'
1202
+ },
1203
+ uploadErrorDescription: {
1204
+ id: 'ImportResourcesModal.uploadErrorDescription',
1205
+ description: 'Title when errors detected while uploading file',
1206
+ defaultMessage: 'There {errorsCount, plural, one {is <b>{errorsCount}</b> error} other {are <b>{errorsCount}</b> errors}} detected while uploading the file <b>{fileName}</b>.'
1207
+ },
1208
+ supportedValuesDocumentation: {
1209
+ id: 'ImportResourcesModal.supportedValuesDocumentation',
1210
+ description: 'Link to the documentation for supported values',
1211
+ defaultMessage: '<documentationLink>View the documentation</documentationLink> for supported values.'
1212
+ },
1213
+ uploadNewFile: {
1214
+ id: 'ImportResourcesModal.uploadNewFile',
1215
+ description: 'Upload new file button',
1216
+ defaultMessage: 'Upload new file'
1217
+ }
1218
+ });
1219
+
1220
+ function ownKeys$8(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; }
1221
+ function _objectSpread$8(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context2 = ownKeys$8(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context3 = ownKeys$8(Object(t))).call(_context3, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
1222
+ const getColumns$1 = () => [{
1223
+ key: 'errorType',
1224
+ label: jsx(FormattedMessage, _objectSpread$8({}, messages$3.errorType)),
1225
+ width: 'max-content'
1226
+ }, {
1227
+ key: 'details',
1228
+ label: jsx(FormattedMessage, _objectSpread$8({}, messages$3.details))
1229
+ }];
1230
+ const UploadErrorTable = props => {
1231
+ var _context;
1232
+ const pagination = usePaginationState({
1233
+ perPage: 10
1234
+ });
1235
+ const startIndex = (pagination.page.value - 1) * pagination.perPage.value;
1236
+ const endIndex = startIndex + pagination.perPage.value;
1237
+ const currentPageRows = _sliceInstanceProperty(_context = props.rows).call(_context, startIndex, endIndex);
1238
+ const shouldShowPagination = props.rows.length > pagination.perPage.value;
1239
+ return jsxs(Spacings.Stack, {
1240
+ scale: "l",
1241
+ children: [jsx(DataTable, {
1242
+ verticalCellAlignment: "center",
1243
+ isCondensed: true,
1244
+ rows: currentPageRows,
1245
+ columns: getColumns$1(),
1246
+ itemRenderer: itemRenderer$1
1247
+ }), shouldShowPagination && jsx(PageNavigator, {
1248
+ onPageChange: pagination.page.onChange,
1249
+ page: pagination.page.value,
1250
+ totalPages: Math.ceil(props.rows.length / pagination.perPage.value)
1251
+ })]
1252
+ });
1253
+ };
1254
+ function itemRenderer$1(item, column) {
1255
+ switch (column.key) {
1256
+ case 'errorType':
1257
+ return jsx(Stamp, {
1258
+ isCondensed: true,
1259
+ label: item.title,
1260
+ tone: "critical"
1261
+ });
1262
+ case 'details':
1263
+ return jsx(Text.Body, {
1264
+ children: item.description
1265
+ });
1266
+ default:
1267
+ throw new UnexpectedColumnError(column.key);
1268
+ }
1269
+ }
1270
+
1271
+ 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; }
1272
+ 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; }
1273
+ const UploadErrorsModal = () => {
1274
+ const intl = useIntl();
1275
+ const _useImportResourcesCo = useImportResourcesContext(),
1276
+ state = _useImportResourcesCo.state,
1277
+ actions = _useImportResourcesCo.actions,
1278
+ onClose = _useImportResourcesCo.onClose;
1279
+ const errorsCount = state.fileUploadErrors.length;
1280
+ return jsx(InfoDialog, {
1281
+ size: 16,
1282
+ isOpen: true,
1283
+ title: intl.formatMessage(sharedMessages[`modalTitle.${state.resourceType}`]),
1284
+ onClose: () => onClose(),
1285
+ children: jsx(Masking.Unmask, {
1286
+ children: jsxs(Spacings.Stack, {
1287
+ scale: "l",
1288
+ children: [jsx(Masking.Mask, {
1289
+ children: jsx(Text.Body, {
1290
+ intlMessage: _objectSpread$7(_objectSpread$7({}, messages$3.uploadErrorDescription), {}, {
1291
+ values: {
1292
+ fileName: state.droppedFile?.name,
1293
+ errorsCount: intl.formatNumber(errorsCount),
1294
+ b: getBold$3
1295
+ }
1296
+ })
1297
+ })
1298
+ }), jsx(UploadErrorTable, {
1299
+ rows: mapFileUploadErrorsToUploadFileErrorRows(state.fileUploadErrors)
1300
+ }), jsxs(Spacings.Inline, {
1301
+ scale: "m",
1302
+ justifyContent: "flex-end",
1303
+ children: [jsx(SecondaryButton, {
1304
+ label: intl.formatMessage(sharedMessages.close),
1305
+ onClick: () => onClose()
1306
+ }), jsx(PrimaryButton, {
1307
+ iconLeft: jsx(ImportIcon, {}),
1308
+ label: intl.formatMessage(messages$3.uploadNewFile),
1309
+ onClick: () => actions.uploadNewFile()
1310
+ })]
1311
+ })]
1312
+ })
1313
+ })
1314
+ });
1315
+ };
1316
+ function getBold$3(msg) {
1317
+ return jsx(Text.Body, {
1318
+ as: "span",
1319
+ isBold: true,
1320
+ children: msg
1321
+ }, crypto.randomUUID());
1322
+ }
1323
+
1324
+ 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; }
1325
+ function _objectSpread$6(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context2 = ownKeys$6(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context3 = ownKeys$6(Object(t))).call(_context3, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
1326
+ const getColumns = () => [{
1327
+ key: 'row',
1328
+ label: jsx(FormattedMessage, _objectSpread$6({}, messages$3.row)),
1329
+ width: 'max-content'
1330
+ }, {
1331
+ key: 'errorType',
1332
+ label: jsx(FormattedMessage, _objectSpread$6({}, messages$3.errorType)),
1333
+ width: 'max-content'
1334
+ }, {
1335
+ key: 'details',
1336
+ label: jsx(FormattedMessage, _objectSpread$6({}, messages$3.details))
1337
+ }];
1338
+ const UploadRowErrorTable = props => {
1339
+ var _context;
1340
+ const pagination = usePaginationState({
1341
+ perPage: 10
1342
+ });
1343
+ const startIndex = (pagination.page.value - 1) * pagination.perPage.value;
1344
+ const endIndex = startIndex + pagination.perPage.value;
1345
+ const currentPageRows = _sliceInstanceProperty(_context = props.rows).call(_context, startIndex, endIndex);
1346
+ const shouldShowPagination = props.rows.length > pagination.perPage.value;
1347
+ return jsxs(Spacings.Stack, {
1348
+ scale: "l",
1349
+ children: [jsx(DataTable, {
1350
+ verticalCellAlignment: "center",
1351
+ isCondensed: true,
1352
+ rows: currentPageRows,
1353
+ columns: getColumns(),
1354
+ itemRenderer: itemRenderer
1355
+ }), shouldShowPagination && jsx(PageNavigator, {
1356
+ onPageChange: pagination.page.onChange,
1357
+ page: pagination.page.value,
1358
+ totalPages: Math.ceil(props.rows.length / pagination.perPage.value)
1359
+ })]
1360
+ });
1361
+ };
1362
+ function itemRenderer(item, column) {
1363
+ switch (column.key) {
1364
+ case 'row':
1365
+ return item.row;
1366
+ case 'errorType':
1367
+ return jsx(Stamp, {
1368
+ isCondensed: true,
1369
+ label: formatErrorCode(item.code),
1370
+ tone: "critical"
1371
+ });
1372
+ case 'details':
1373
+ return jsxs(Spacings.Inline, {
1374
+ scale: "xs",
1375
+ children: [jsx(Text.Body, {
1376
+ tone: "information",
1377
+ children: item.field
1378
+ }), jsx(Text.Body, {
1379
+ children: extractErrorDescriptionFromValidationMessage(item.validationMessage)
1380
+ })]
1381
+ });
1382
+ default:
1383
+ throw new UnexpectedColumnError(column.key);
1384
+ }
1385
+ }
1386
+
1387
+ function ownKeys$5(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; }
1388
+ 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(_context = ownKeys$5(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys$5(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
1389
+ const UploadRowErrorsModal = () => {
1390
+ const intl = useIntl();
1391
+ const _useImportResourcesCo = useImportResourcesContext(),
1392
+ state = _useImportResourcesCo.state,
1393
+ actions = _useImportResourcesCo.actions,
1394
+ onClose = _useImportResourcesCo.onClose;
1395
+ const errorsCount = getFileUploadErrorsCount(state.uploadFileResponse?.results);
1396
+ const documentationLink = RESOURCE_TYPE_DOCUMENTATION_LINKS[state.resourceType];
1397
+ return jsx(InfoDialog, {
1398
+ size: 16,
1399
+ isOpen: true,
1400
+ title: intl.formatMessage(sharedMessages[`modalTitle.${state.resourceType}`]),
1401
+ onClose: onClose,
1402
+ children: jsx(Masking.Unmask, {
1403
+ children: jsxs(Spacings.Stack, {
1404
+ scale: "l",
1405
+ children: [jsxs(Spacings.Stack, {
1406
+ scale: "xs",
1407
+ children: [jsx(Masking.Mask, {
1408
+ children: jsx(Text.Body, {
1409
+ intlMessage: _objectSpread$5(_objectSpread$5({}, messages$3.uploadErrorDescription), {}, {
1410
+ values: {
1411
+ fileName: state.droppedFile?.name,
1412
+ errorsCount: intl.formatNumber(errorsCount),
1413
+ b: getBold$2
1414
+ }
1415
+ })
1416
+ })
1417
+ }), jsx(Text.Body, {
1418
+ intlMessage: _objectSpread$5(_objectSpread$5({}, messages$3.supportedValuesDocumentation), {}, {
1419
+ values: {
1420
+ documentationLink: msg => jsx(Link, {
1421
+ tone: "secondary",
1422
+ isExternal: true,
1423
+ to: documentationLink,
1424
+ children: msg
1425
+ }, "documentationLink")
1426
+ }
1427
+ })
1428
+ })]
1429
+ }), jsx(UploadRowErrorTable, {
1430
+ rows: mapUploadFileErrorsResponseToUploadFileErrorRows(state.uploadFileResponse?.results)
1431
+ }), jsxs(Spacings.Inline, {
1432
+ scale: "m",
1433
+ justifyContent: "flex-end",
1434
+ children: [jsx(SecondaryButton, {
1435
+ label: intl.formatMessage(sharedMessages.close),
1436
+ onClick: () => onClose()
1437
+ }), jsx(PrimaryButton, {
1438
+ iconLeft: jsx(ImportIcon, {}),
1439
+ label: intl.formatMessage(messages$3.uploadNewFile),
1440
+ onClick: () => actions.uploadNewFile()
1441
+ })]
1442
+ })]
1443
+ })
1444
+ })
1445
+ });
1446
+ };
1447
+ function getBold$2(msg) {
1448
+ return jsx(Text.Body, {
1449
+ as: "span",
1450
+ isBold: true,
1451
+ children: msg
1452
+ }, crypto.randomUUID());
1453
+ }
1454
+
1455
+ var messages$2 = defineMessages({
1456
+ startImportButton: {
1457
+ id: 'ImportResourcesModal.startImportButton',
1458
+ description: 'Label for the modal Start import button',
1459
+ defaultMessage: 'Start import'
1460
+ },
1461
+ importNotificationSuccessMessage: {
1462
+ id: 'ImportResourcesModal.successMessage',
1463
+ description: 'Notification success message',
1464
+ defaultMessage: '<b>Your import has started.</b><newline></newline> <logsLink>Go to Import logs</logsLink> to view the progress.'
1465
+ },
1466
+ importNotificationPrepareMessage: {
1467
+ id: 'ImportResourcesModal.prepareMessage',
1468
+ description: 'Notification for preparing import',
1469
+ defaultMessage: '<b>Prepare import</b><newline></newline>Once preparation is complete, you can track the import progress <logsLink>in the Import logs</logsLink>.'
1470
+ },
1471
+ previewOfYourImport: {
1472
+ id: 'ImportResourcesModal.previewOfYourImport',
1473
+ description: 'Label for modal path',
1474
+ defaultMessage: "Here's a preview of your import"
1475
+ },
1476
+ itemsToBeImported: {
1477
+ id: 'ImportResourcesModal.itemsToBeImported',
1478
+ description: 'This message indicates the number of items that are ready to be imported into the project.',
1479
+ defaultMessage: '{itemCount, plural, one {<b>1</b> {resourceType} to be imported{publish, select, true { and published} other {}}} other {<b>{itemCount}</b> {resourceTypePlural} to be imported{publish, select, true { and published} other {}}}}'
1480
+ },
1481
+ columnsToBeImported: {
1482
+ id: 'ImportResourcesModal.columnsToBeImported',
1483
+ description: 'This message indicates the number of columns that are ready to be imported into the system.',
1484
+ defaultMessage: '<b>{columnCount}</b> columns to be imported'
1485
+ },
1486
+ columnsToBeIgnored: {
1487
+ id: 'ImportResourcesModal.columnsToBeIgnored',
1488
+ description: "This message indicates the number of columns that will be deliberately skipped during the import because they can't be imported",
1489
+ defaultMessage: "We will intentionally ignore <b>{columnCount}</b> columns as they can't be imported"
1490
+ },
1491
+ showMore: {
1492
+ id: 'ImportResourcesModal.showMore',
1493
+ description: 'A button label for expanding the import preview to show more details.',
1494
+ defaultMessage: 'Show more'
1495
+ },
1496
+ showLess: {
1497
+ id: 'ImportResourcesModal.showLess',
1498
+ description: 'A button label for collapsing the import preview to show fewer details.',
1499
+ defaultMessage: 'Show less'
1500
+ },
1501
+ continue: {
1502
+ id: 'ImportResourcesModal.continue',
1503
+ description: 'Confirmation dialog continue button',
1504
+ defaultMessage: 'Continue'
1505
+ },
1506
+ confirmationBodyText: {
1507
+ id: 'ImportResourcesModal.confirmationBodyText',
1508
+ description: 'Confirmation dialog text',
1509
+ defaultMessage: 'You are about to import {count, plural, one {<bold>1</bold> row} other {<bold>{count}</bold> rows}} in the project: <bold>{projectName}</bold>.'
1510
+ },
1511
+ confirmationBodyNote: {
1512
+ id: 'ImportResourcesModal.confirmationBodyNote',
1513
+ description: 'Confirmation dialog text',
1514
+ defaultMessage: 'Please be aware that existing values with the same keys will be overwritten by the data included in the CSV.'
1515
+ },
1516
+ confirmationBodyQuestion: {
1517
+ id: 'ImportResourcesModal.confirmationBodyQuestion',
1518
+ description: 'Confirmation question',
1519
+ defaultMessage: 'Proceed with the import?'
1520
+ }
1521
+ });
1522
+
1523
+ function ownKeys$4(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; }
1524
+ function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context2 = ownKeys$4(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context3 = ownKeys$4(Object(t))).call(_context3, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
1525
+ function _EMOTION_STRINGIFIED_CSS_ERROR__$1() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
1526
+ const AlignedContainer = /*#__PURE__*/_styled("div", process.env.NODE_ENV === "production" ? {
1527
+ target: "e1amawj91"
1528
+ } : {
1529
+ target: "e1amawj91",
1530
+ label: "AlignedContainer"
1531
+ })(process.env.NODE_ENV === "production" ? {
1532
+ name: "1x0d6yz",
1533
+ styles: "padding-top:5px"
1534
+ } : {
1535
+ name: "1x0d6yz",
1536
+ styles: "padding-top:5px/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImNvbHVtbi1saXN0LnRzeCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFXMEMiLCJmaWxlIjoiY29sdW1uLWxpc3QudHN4Iiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFJlYWN0IGZyb20gJ3JlYWN0J1xuaW1wb3J0IHsgRm9ybWF0dGVkTWVzc2FnZSB9IGZyb20gJ3JlYWN0LWludGwnXG5pbXBvcnQgeyBMaW5rLCBTdGFtcCwgVGFnTGlzdCB9IGZyb20gJ0Bjb21tZXJjZXRvb2xzLWZyb250ZW5kL3VpLWtpdCdcbmltcG9ydCBzdHlsZWQgZnJvbSAnQGVtb3Rpb24vc3R5bGVkJ1xuaW1wb3J0IG1lc3NhZ2VzIGZyb20gJy4vbWVzc2FnZXMnXG5pbXBvcnQgeyBJTklUSUFMX0NPTFVNTl9ESVNQTEFZX0NPVU5UIH0gZnJvbSAnLi4vLi4vQGNvbnN0YW50cydcblxuaW50ZXJmYWNlIFByb3BzIHtcbiAgY29sdW1uczogQXJyYXk8c3RyaW5nPlxufVxuXG5leHBvcnQgY29uc3QgQWxpZ25lZENvbnRhaW5lciA9IHN0eWxlZC5kaXZgXG4gIHBhZGRpbmctdG9wOiA1cHg7XG5gXG5cbmV4cG9ydCBjb25zdCBNb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mRlZClcbiAgICAgICAgICAgIH19XG4gICAgICAgICAgPlxuICAgICAgICAgICAge2lzRXhwYW5kZWQgPyAoXG4gICAgICAgICAgICAgIDxGb3JtYXR0ZWRNZXNzYWdlIHsuLi5tZXNzYWdlcy5zaG93TGVzc30gLz5cbiAgICAgICAgICAgICkgOiAoXG4gICAgICAgICAgICAgIDxGb3JtYXR0ZWRNZXNzYWdlIHsuLi5tZXNzYWdlcy5zaG93TW9yZX0gLz5cbiAgICAgICAgICAgICl9XG4gICAgICAgICAgPC9MaW5rPlxuICAgICAgICA8L0FsaWduZWRDb250YWluZXI+XG4gICAgICApfVxuICAgIDwvTW9kaWZpZWRUYWdMaXN0PlxuICApXG59XG4iXX0= */",
1537
+ toString: _EMOTION_STRINGIFIED_CSS_ERROR__$1
1538
+ });
1539
+ const ModifiedTagList = /*#__PURE__*/_styled(TagList, process.env.NODE_ENV === "production" ? {
1540
+ target: "e1amawj90"
1541
+ } : {
1542
+ target: "e1amawj90",
1543
+ label: "ModifiedTagList"
1544
+ })(process.env.NODE_ENV === "production" ? {
1545
+ name: "u9abxe",
1546
+ styles: ">div{margin:8px 8px 0 0;}"
1547
+ } : {
1548
+ name: "u9abxe",
1549
+ styles: ">div{margin:8px 8px 0 0;}/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImNvbHVtbi1saXN0LnRzeCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFlOEMiLCJmaWxlIjoiY29sdW1uLWxpc3QudHN4Iiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFJlYWN0IGZyb20gJ3JlYWN0J1xuaW1wb3J0IHsgRm9ybWF0dGVkTWVzc2FnZSB9IGZyb20gJ3JlYWN0LWludGwnXG5pbXBvcnQgeyBMaW5rLCBTdGFtcCwgVGFnTGlzdCB9IGZyb20gJ0Bjb21tZXJjZXRvb2xzLWZyb250ZW5kL3VpLWtpdCdcbmltcG9ydCBzd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2luZGV4fSBsYWJlbD17Y29sdW1ufSB0b25lPVwic2Vjb25kYXJ5XCIgLz5cbiAgICAgICkpfVxuICAgICAge3Nob3VsZFNob3dFeHBhbmRCdXR0b24gJiYgKFxuICAgICAgICA8QWxpZ25lZENvbnRhaW5lcj5cbiAgICAgICAgICA8TGlua1xuICAgICAgICAgICAgdG89XCJcIlxuICAgICAgICAgICAgdG9uZT1cInNlY29uZGFyeVwiXG4gICAgICAgICAgICBvbkNsaWNrPXsoZSkgPT4ge1xuICAgICAgICAgICAgICBlLnByZXZlbnREZWZhdWx0KClcbiAgICAgICAgICAgICAgc2V0SXNFeHBhbmRlZCghaXNFeHBhbmRlZClcbiAgICAgICAgICAgIH19XG4gICAgICAgICAgPlxuICAgICAgICAgICAge2lzRXhwYW5kZWQgPyAoXG4gICAgICAgICAgICAgIDxGb3JtYXR0ZWRNZXNzYWdlIHsuLi5tZXNzYWdlcy5zaG93TGVzc30gLz5cbiAgICAgICAgICAgICkgOiAoXG4gICAgICAgICAgICAgIDxGb3JtYXR0ZWRNZXNzYWdlIHsuLi5tZXNzYWdlcy5zaG93TW9yZX0gLz5cbiAgICAgICAgICAgICl9XG4gICAgICAgICAgPC9MaW5rPlxuICAgICAgICA8L0FsaWduZWRDb250YWluZXI+XG4gICAgICApfVxuICAgIDwvTW9kaWZpZWRUYWdMaXN0PlxuICApXG59XG4iXX0= */",
1550
+ toString: _EMOTION_STRINGIFIED_CSS_ERROR__$1
1551
+ });
1552
+ const ColumnList = props => {
1553
+ var _context;
1554
+ const _React$useState = React.useState(false),
1555
+ _React$useState2 = _slicedToArray(_React$useState, 2),
1556
+ isExpanded = _React$useState2[0],
1557
+ setIsExpanded = _React$useState2[1];
1558
+ const shouldShowExpandButton = props.columns.length > INITIAL_COLUMN_DISPLAY_COUNT;
1559
+ const finalColumns = isExpanded ? props.columns : _sliceInstanceProperty(_context = props.columns).call(_context, 0, INITIAL_COLUMN_DISPLAY_COUNT);
1560
+ return jsxs(ModifiedTagList, {
1561
+ children: [_mapInstanceProperty(finalColumns).call(finalColumns, (column, index) => jsx(Stamp, {
1562
+ label: column,
1563
+ tone: "secondary"
1564
+ }, index)), shouldShowExpandButton && jsx(AlignedContainer, {
1565
+ children: jsx(Link, {
1566
+ to: "",
1567
+ tone: "secondary",
1568
+ onClick: e => {
1569
+ e.preventDefault();
1570
+ setIsExpanded(!isExpanded);
1571
+ },
1572
+ children: isExpanded ? jsx(FormattedMessage, _objectSpread$4({}, messages$2.showLess)) : jsx(FormattedMessage, _objectSpread$4({}, messages$2.showMore))
1573
+ })
1574
+ })]
1575
+ });
1576
+ };
1577
+
1578
+ function ownKeys$3(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; }
1579
+ function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys$3(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys$3(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
1580
+ function UploadPreviewModal() {
1581
+ const _useImportResourcesCo = useImportResourcesContext(),
1582
+ state = _useImportResourcesCo.state;
1583
+ const intl = useIntl();
1584
+ const _useImportResourcesCo2 = useImportResourcesContext(),
1585
+ actions = _useImportResourcesCo2.actions,
1586
+ onClose = _useImportResourcesCo2.onClose;
1587
+ if (!state.resourceType || !state.uploadFileResponse) return null;
1588
+ const resourceTypeMessage = resourceTypeToMessage(state.resourceType);
1589
+ const resourceType = intl.formatMessage(resourceTypeMessage).toLowerCase();
1590
+ const resourceTypePluralMessage = resourceTypeToPluralMessage(state.resourceType);
1591
+ const resourceTypePlural = intl.formatMessage(resourceTypePluralMessage).toLowerCase();
1592
+ const ignoredColumns = state.uploadFileResponse.ignoredColumns;
1593
+ const validatedColumns = getValidatedColumns(state.uploadFileResponse.columns, ignoredColumns);
1594
+ return jsx(FormDialog, {
1595
+ size: 16,
1596
+ isOpen: true,
1597
+ title: intl.formatMessage(sharedMessages[`modalTitle.${state.resourceType}`]),
1598
+ labelPrimary: intl.formatMessage(messages$2.continue),
1599
+ onSecondaryButtonClick: () => onClose({
1600
+ shouldDeleteImportContainer: true
1601
+ }),
1602
+ onPrimaryButtonClick: () => {
1603
+ actions.setCurrentStep(CurrentStep$1.ImportConfirmationModal);
1604
+ },
1605
+ onClose: () => onClose({
1606
+ shouldDeleteImportContainer: true
1607
+ }),
1608
+ children: jsx(Masking.Unmask, {
1609
+ children: jsx(PageContentNarrow, {
1610
+ children: jsx(Spacings.Stack, {
1611
+ scale: "xxxl",
1612
+ children: jsx(Spacings.Stack, {
1613
+ scale: "xl",
1614
+ children: jsxs(Spacings.Stack, {
1615
+ scale: "m",
1616
+ children: [jsx("div", {}), jsx(Text.Body, {
1617
+ intlMessage: messages$2.previewOfYourImport
1618
+ }), jsx(Card, {
1619
+ insetScale: "xl",
1620
+ children: jsxs(Spacings.Stack, {
1621
+ scale: "s",
1622
+ children: [jsxs(Spacings.Stack, {
1623
+ scale: "xs",
1624
+ children: [jsxs(Spacings.Inline, {
1625
+ alignItems: "center",
1626
+ children: [jsx(CheckBoldIcon, {
1627
+ color: "success"
1628
+ }), jsx(Text.Body, {
1629
+ intlMessage: _objectSpread$3(_objectSpread$3({}, messages$2.itemsToBeImported), {}, {
1630
+ values: {
1631
+ resourceType,
1632
+ resourceTypePlural,
1633
+ itemCount: intl.formatNumber(state.uploadFileResponse.itemsCount),
1634
+ publish: state.resourceType === 'product' && state.settings?.publish,
1635
+ b: getBold$1
1636
+ }
1637
+ })
1638
+ })]
1639
+ }), jsxs(Spacings.Inline, {
1640
+ alignItems: "center",
1641
+ children: [jsx(CheckBoldIcon, {
1642
+ color: "success"
1643
+ }), jsx(Text.Body, {
1644
+ intlMessage: _objectSpread$3(_objectSpread$3({}, messages$2.columnsToBeImported), {}, {
1645
+ values: {
1646
+ columnCount: intl.formatNumber(validatedColumns.length),
1647
+ b: getBold$1
1648
+ }
1649
+ })
1650
+ })]
1651
+ })]
1652
+ }), jsx(ColumnList, {
1653
+ columns: validatedColumns
1654
+ })]
1655
+ })
1656
+ }), ignoredColumns.length > 0 && jsx(Card, {
1657
+ insetScale: "xl",
1658
+ children: jsxs(Spacings.Stack, {
1659
+ scale: "s",
1660
+ children: [jsxs(Spacings.Inline, {
1661
+ alignItems: "center",
1662
+ children: [jsx(EyeCrossedIcon, {
1663
+ color: "neutral60"
1664
+ }), jsx(Text.Body, {
1665
+ intlMessage: _objectSpread$3(_objectSpread$3({}, messages$2.columnsToBeIgnored), {}, {
1666
+ values: {
1667
+ columnCount: intl.formatNumber(ignoredColumns.length),
1668
+ b: getBold$1
1669
+ }
1670
+ })
1671
+ })]
1672
+ }), jsx(ColumnList, {
1673
+ columns: ignoredColumns
1674
+ })]
1675
+ })
1676
+ })]
1677
+ })
1678
+ })
1679
+ })
1680
+ })
1681
+ })
1682
+ });
1683
+ }
1684
+ function getBold$1(msg) {
1685
+ return jsx(Text.Body, {
1686
+ as: "span",
1687
+ isBold: true,
1688
+ children: msg
1689
+ }, crypto.randomUUID());
1690
+ }
1691
+
1692
+ function ownKeys$2(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; }
1693
+ function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys$2(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys$2(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
1694
+ function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
1695
+ const getNewLine = () => jsx("br", {}, "break");
1696
+ const getImportLogsLink = (msg, projectKey) => jsx(Link, {
1697
+ to: `/${projectKey}/operations/import/logs`,
1698
+ children: msg
1699
+ }, "link");
1700
+ var _ref2 = process.env.NODE_ENV === "production" ? {
1701
+ name: "1vs9i7r",
1702
+ styles: "width:360px"
1703
+ } : {
1704
+ name: "g36yzl-ImportRunningTextNotification",
1705
+ styles: "width:360px;label:ImportRunningTextNotification;/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImltcG9ydC1jb25maXJtYXRpb24tbW9kYWwudHN4Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQXlCWSIsImZpbGUiOiJpbXBvcnQtY29uZmlybWF0aW9uLW1vZGFsLnRzeCIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IHVzZUludGwgfSBmcm9tICdyZWFjdC1pbnRsJ1xuaW1wb3J0IHsgdXNlU2hvd05vdGlmaWNhdGlvbiB9IGZyb20gJ0Bjb21tZXJjZXRvb2xzLWZyb250ZW5kL2FjdGlvbnMtZ2xvYmFsJ1xuaW1wb3J0IHsgQ29uZmlybWF0aW9uRGlhbG9nIH0gZnJvbSAnQGNvbW1lcmNldG9vbHMtZnJvbnRlbmQvYXBwbGljYXRpb24tY29tcG9uZW50cydcbmltcG9ydCB7IHVzZUFwcGxpY2F0aW9uQ29udGV4dCB9IGZyb20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taWQnOiAnY29uZmlybWF0aW9uLWRpYWxvZy1jYW5jZWwnLFxuICAgICAgICAnZGF0YS10cmFja2luZy10YXJnZXQnOiBgJHtzdGF0ZS5yZXNvdXJjZVR5cGV9X2ltcG9ydC1zdGFydF9pbXBvcnRfYnV0dG9uYCxcbiAgICAgIH19XG4gICAgICBvbkNvbmZpcm09e2FzeW5jICgpID0+IHtcbiAgICAgICAgdHJ5IHtcbiAgICAgICAgICBjb25zdCBjYW5Db25maXJtID1cbiAgICAgICAgICAgIHByb2plY3RLZXkgJiZcbiAgICAgICAgICAgIHN0YXRlLmNvbnRhaW5lcktleSAmJlxuICAgICAgICAgICAgc3RhdGUuZHJvcHBlZEZpbGU/Lm5hbWUgJiZcbiAgICAgICAgICAgIHN0YXRlLnJlc291cmNlVHlwZVxuICAgICAgICAgIGlmICghY2FuQ29uZmlybSkgcmV0dXJuXG4gICAgICAgICAgb25DbG9zZSgpXG4gICAgICAgICAgc2hvd05vdGlmaWNhdGlvbihcbiAgICAgICAgICAgIHtcbiAgICAgICAgICAgICAga2luZDogJ2luZm8nLFxuICAgICAgICAgICAgICBkb21haW46IERPTUFJTlMuU0lERSxcbiAgICAgICAgICAgICAgLy8gQHRzLWlnbm9yZVxuICAgICAgICAgICAgICB0ZXh0OiA8SW1wb3J0UHJlcGFyaW5nVGV4dE5vdGlmaWNhdGlvbiBwcm9qZWN0S2V5PXtwcm9qZWN0S2V5fSAvPixcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICB7XG4gICAgICAgICAgICAgIGRpc21pc3NBZnRlcjogNTAwMCxcbiAgICAgICAgICAgIH1cbiAgICAgICAgICApXG4gICAgICAgICAgYXdhaXQgcHJvY2Vzc1VwbG9hZGVkRmlsZSh7XG4gICAgICAgICAgICBwcm9qZWN0S2V5LFxuICAgICAgICAgICAgaW1wb3J0Q29udGFpbmVyS2V5OiBzdGF0ZS5jb250YWluZXJLZXkhLFxuICAgICAgICAgICAgcmVzb3VyY2VUeXBlOiBzdGF0ZS5yZXNvdXJjZVR5cGUhLFxuICAgICAgICAgIH0pXG4gICAgICAgICAgb25TdGFydEltcG9ydFN1Y2Nlc3MoKVxuICAgICAgICAgIHNob3dOb3RpZmljYXRpb24oXG4gICAgICAgICAgICB7XG4gICAgICAgICAgICAgIGtpbmQ6ICdpbmZvJyxcbiAgICAgICAgICAgICAgZG9tYWluOiBET01BSU5TLlNJREUsXG4gICAgICAgICAgICAgIC8vIEB0cy1pZ25vcmVcbiAgICAgICAgICAgICAgdGV4dDogPEltcG9ydFJ1bm5pbmdUZXh0Tm90aWZpY2F0aW9uIHByb2plY3RLZXk9e3Byb2plY3RLZXl9IC8+LFxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIHtcbiAgICAgICAgICAgICAgZGlzbWlzc0FmdGVyOiA1MDAwLFxuICAgICAgICAgICAgfVxuICAgICAgICAgIClcbiAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHtcbiAgICAgICAgICBvbkNsb3NlKHsgc2hvdWxkRGVsZXRlSW1wb3J0Q29udGFpbmVyOiB0cnVlIH0pXG4gICAgICAgICAgc2hvd05vdGlmaWNhdGlvbih7XG4gICAgICAgICAgICBraW5kOiAnZXJyb3InLFxuICAgICAgICAgICAgZG9tYWluOiBET01BSU5TLlBBR0UsXG4gICAgICAgICAgICB0ZXh0OiBpc0Vycm9yKGVycm9yKSA/IGVycm9yLnRvU3RyaW5nKCkgOiBTdHJpbmcoZXJyb3IpLFxuICAgICAgICAgIH0pXG4gICAgICAgIH1cbiAgICAgIH19XG4gICAgICBzaXplPXsxNn1cbiAgICA+XG4gICAgICA8RnVsbFN0b3J5TWFza2luZy5Vbm1hc2s+XG4gICAgICAgIDxTcGFjaW5ncy5TdGFjayBzY2FsZT1cInhsXCI+XG4gICAgICAgICAgPGRpdj5cbiAgICAgICAgICAgIDxUZXh0LkJvZHlcbiAgICAgICAgICAgICAgaW50bE1lc3NhZ2U9e3tcbiAgICAgICAgICAgICAgICAuLi5tZXNzYWdlcy5jb25maXJtYXRpb25Cb2R5VGV4dCxcbiAgICAgICAgICAgICAgICB2YWx1ZXM6IHtcbiAgICAgICAgICAgICAgICAgIHByb2plY3ROYW1lOiBwcm9qZWN0TmFtZSxcbiAgICAgICAgICAgICAgICAgIGNvdW50OiBpbnRsLmZvcm1hdE51bWJlcihcbiAgICAgICAgICAgICAgICAgICAgc3RhdGU/LnVwbG9hZEZpbGVSZXNwb25zZT8ucm93c0NvdW50IHx8IDBcbiAgICAgICAgICAgICAgICAgICksXG4gICAgICAgICAgICAgICAgICBib2xkOiBnZXRCb2xkLFxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgIH19XG4gICAgICAgICAgICAvPlxuICAgICAgICAgICAgPFRleHQuQm9keSBpbnRsTWVzc2FnZT17bWVzc2FnZXMuY29uZmlybWF0aW9uQm9keU5vdGV9IC8+XG4gICAgICAgICAgPC9kaXY+XG4gICAgICAgICAgPFRleHQuQm9keSBpbnRsTWVzc2FnZT17bWVzc2FnZXMuY29uZmlybWF0aW9uQm9keVF1ZXN0aW9ufSAvPlxuICAgICAgICA8L1NwYWNpbmdzLlN0YWNrPlxuICAgICAgPC9GdWxsU3RvcnlNYXNraW5nLlVubWFzaz5cbiAgICA8L0NvbmZpcm1hdGlvbkRpYWxvZz5cbiAgKVxufVxuXG5mdW5jdGlvbiBnZXRCb2xkKG1zZykge1xuICByZXR1cm4gKFxuICAgIDxUZXh0LkJvZHkgYXM9XCJzcGFuXCIgaXNCb2xkIGtleT17Y3J5cHRvLnJhbmRvbVVVSUQoKX0+XG4gICAgICB7bXNnfVxuICAgIDwvVGV4dC5Cb2R5PlxuICApXG59XG4iXX0= */",
1706
+ toString: _EMOTION_STRINGIFIED_CSS_ERROR__
1707
+ };
1708
+ const ImportRunningTextNotification = props => jsx("div", {
1709
+ css: _ref2,
1710
+ children: jsx(Text.Body, {
1711
+ intlMessage: _objectSpread$2(_objectSpread$2({}, messages$2.importNotificationSuccessMessage), {}, {
1712
+ values: {
1713
+ newline: getNewLine,
1714
+ logsLink: msg => getImportLogsLink(msg, props.projectKey),
1715
+ b: getBold
1716
+ }
1717
+ })
1718
+ })
1719
+ });
1720
+ var _ref = process.env.NODE_ENV === "production" ? {
1721
+ name: "1vs9i7r",
1722
+ styles: "width:360px"
1723
+ } : {
1724
+ name: "mjwslu-ImportPreparingTextNotification",
1725
+ styles: "width:360px;label:ImportPreparingTextNotification;/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImltcG9ydC1jb25maXJtYXRpb24tbW9kYWwudHN4Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQTRDWSIsImZpbGUiOiJpbXBvcnQtY29uZmlybWF0aW9uLW1vZGFsLnRzeCIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IHVzZUludGwgfSBmcm9tICdyZWFjdC1pbnRsJ1xuaW1wb3J0IHsgdXNlU2hvd05vdGlmaWNhdGlvbiB9IGZyb20gJ0Bjb21tZXJjZXRvb2xzLWZyb250ZW5kL2FjdGlvbnMtZ2xvYmFsJ1xuaW1wb3J0IHsgQ29uZmlybWF0aW9uRGlhbG9nIH0gZnJvbSAnQGNvbW1lcmNldG9vbHMtZnJvbnRlbmQvYXBwbGljYXRpb24tY29tcG9uZW50cydcbmltcG9ydCB7IHVzZUFwcGxpY2F0aW9uQ29udGV4dCB9IGZyb20gJ0Bjb21tZXJjZXRvb2xzLWZyb250ZW5kL2FwcGxpY2F0aW9uLXNoZWxsLWNvbm5lY3RvcnMnXG5pbXBvcnQgeyBET01BSU5TIH0gZnJvbSAnQGNvbW1lcmNldG9vbHMtZnJvbnRlbmQvY29uc3RhbnRzJ1xuaW1wb3J0IHsgTWFza2luZyBhcyBGdWxsU3RvcnlNYXNraW5nIH0gZnJvbSAnQGNvbW1lcmNldG9vbHMtZnJvbnRlbmQvZnVsbHN0b3J5J1xuaW1wb3J0IHsgTGluaywgU3BhY2luZ3MsIFRleHQgfSB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HN0YXRlLmNvbnRhaW5lcktleSAmJlxuICAgICAgICAgICAgc3RhdGUuZHJvcHBlZEZpbGU/Lm5hbWUgJiZcbiAgICAgICAgICAgIHN0YXRlLnJlc291cmNlVHlwZVxuICAgICAgICAgIGlmICghY2FuQ29uZmlybSkgcmV0dXJuXG4gICAgICAgICAgb25DbG9zZSgpXG4gICAgICAgICAgc2hvd05vdGlmaWNhdGlvbihcbiAgICAgICAgICAgIHtcbiAgICAgICAgICAgICAga2luZDogJ2luZm8nLFxuICAgICAgICAgICAgICBkb21haW46IERPTUFJTlMuU0lERSxcbiAgICAgICAgICAgICAgLy8gQHRzLWlnbm9yZVxuICAgICAgICAgICAgICB0ZXh0OiA8SW1wb3J0UHJlcGFyaW5nVGV4dE5vdGlmaWNhdGlvbiBwcm9qZWN0S2V5PXtwcm9qZWN0S2V5fSAvPixcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICB7XG4gICAgICAgICAgICAgIGRpc21pc3NBZnRlcjogNTAwMCxcbiAgICAgICAgICAgIH1cbiAgICAgICAgICApXG4gICAgICAgICAgYXdhaXQgcHJvY2Vzc1VwbG9hZGVkRmlsZSh7XG4gICAgICAgICAgICBwcm9qZWN0S2V5LFxuICAgICAgICAgICAgaW1wb3J0Q29udGFpbmVyS2V5OiBzdGF0ZS5jb250YWluZXJLZXkhLFxuICAgICAgICAgICAgcmVzb3VyY2VUeXBlOiBzdGF0ZS5yZXNvdXJjZVR5cGUhLFxuICAgICAgICAgIH0pXG4gICAgICAgICAgb25TdGFydEltcG9ydFN1Y2Nlc3MoKVxuICAgICAgICAgIHNob3dOb3RpZmljYXRpb24oXG4gICAgICAgICAgICB7XG4gICAgICAgICAgICAgIGtpbmQ6ICdpbmZvJyxcbiAgICAgICAgICAgICAgZG9tYWluOiBET01BSU5TLlNJREUsXG4gICAgICAgICAgICAgIC8vIEB0cy1pZ25vcmVcbiAgICAgICAgICAgICAgdGV4dDogPEltcG9ydFJ1bm5pbmdUZXh0Tm90aWZpY2F0aW9uIHByb2plY3RLZXk9e3Byb2plY3RLZXl9IC8+LFxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIHtcbiAgICAgICAgICAgICAgZGlzbWlzc0FmdGVyOiA1MDAwLFxuICAgICAgICAgICAgfVxuICAgICAgICAgIClcbiAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHtcbiAgICAgICAgICBvbkNsb3NlKHsgc2hvdWxkRGVsZXRlSW1wb3J0Q29udGFpbmVyOiB0cnVlIH0pXG4gICAgICAgICAgc2hvd05vdGlmaWNhdGlvbih7XG4gICAgICAgICAgICBraW5kOiAnZXJyb3InLFxuICAgICAgICAgICAgZG9tYWluOiBET01BSU5TLlBBR0UsXG4gICAgICAgICAgICB0ZXh0OiBpc0Vycm9yKGVycm9yKSA/IGVycm9yLnRvU3RyaW5nKCkgOiBTdHJpbmcoZXJyb3IpLFxuICAgICAgICAgIH0pXG4gICAgICAgIH1cbiAgICAgIH19XG4gICAgICBzaXplPXsxNn1cbiAgICA+XG4gICAgICA8RnVsbFN0b3J5TWFza2luZy5Vbm1hc2s+XG4gICAgICAgIDxTcGFjaW5ncy5TdGFjayBzY2FsZT1cInhsXCI+XG4gICAgICAgICAgPGRpdj5cbiAgICAgICAgICAgIDxUZXh0LkJvZHlcbiAgICAgICAgICAgICAgaW50bE1lc3NhZ2U9e3tcbiAgICAgICAgICAgICAgICAuLi5tZXNzYWdlcy5jb25maXJtYXRpb25Cb2R5VGV4dCxcbiAgICAgICAgICAgICAgICB2YWx1ZXM6IHtcbiAgICAgICAgICAgICAgICAgIHByb2plY3ROYW1lOiBwcm9qZWN0TmFtZSxcbiAgICAgICAgICAgICAgICAgIGNvdW50OiBpbnRsLmZvcm1hdE51bWJlcihcbiAgICAgICAgICAgICAgICAgICAgc3RhdGU/LnVwbG9hZEZpbGVSZXNwb25zZT8ucm93c0NvdW50IHx8IDBcbiAgICAgICAgICAgICAgICAgICksXG4gICAgICAgICAgICAgICAgICBib2xkOiBnZXRCb2xkLFxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgIH19XG4gICAgICAgICAgICAvPlxuICAgICAgICAgICAgPFRleHQuQm9keSBpbnRsTWVzc2FnZT17bWVzc2FnZXMuY29uZmlybWF0aW9uQm9keU5vdGV9IC8+XG4gICAgICAgICAgPC9kaXY+XG4gICAgICAgICAgPFRleHQuQm9keSBpbnRsTWVzc2FnZT17bWVzc2FnZXMuY29uZmlybWF0aW9uQm9keVF1ZXN0aW9ufSAvPlxuICAgICAgICA8L1NwYWNpbmdzLlN0YWNrPlxuICAgICAgPC9GdWxsU3RvcnlNYXNraW5nLlVubWFzaz5cbiAgICA8L0NvbmZpcm1hdGlvbkRpYWxvZz5cbiAgKVxufVxuXG5mdW5jdGlvbiBnZXRCb2xkKG1zZykge1xuICByZXR1cm4gKFxuICAgIDxUZXh0LkJvZHkgYXM9XCJzcGFuXCIgaXNCb2xkIGtleT17Y3J5cHRvLnJhbmRvbVVVSUQoKX0+XG4gICAgICB7bXNnfVxuICAgIDwvVGV4dC5Cb2R5PlxuICApXG59XG4iXX0= */",
1726
+ toString: _EMOTION_STRINGIFIED_CSS_ERROR__
1727
+ };
1728
+ const ImportPreparingTextNotification = props => jsx("div", {
1729
+ css: _ref,
1730
+ children: jsx(Text.Body, {
1731
+ intlMessage: _objectSpread$2(_objectSpread$2({}, messages$2.importNotificationPrepareMessage), {}, {
1732
+ values: {
1733
+ newline: getNewLine,
1734
+ logsLink: msg => getImportLogsLink(msg, props.projectKey),
1735
+ b: getBold
1736
+ }
1737
+ })
1738
+ })
1739
+ });
1740
+ const ImportConfirmationModal = () => {
1741
+ const intl = useIntl();
1742
+ const _useImportResourcesCo = useImportResourcesContext(),
1743
+ state = _useImportResourcesCo.state,
1744
+ onStartImportSuccess = _useImportResourcesCo.onStartImportSuccess,
1745
+ onClose = _useImportResourcesCo.onClose;
1746
+ const _useApplicationContex = useApplicationContext(context => ({
1747
+ projectKey: context.project?.key,
1748
+ projectName: context.project?.name
1749
+ })),
1750
+ projectKey = _useApplicationContex.projectKey,
1751
+ projectName = _useApplicationContex.projectName;
1752
+ const showNotification = useShowNotification();
1753
+ return jsx(ConfirmationDialog, {
1754
+ title: intl.formatMessage(sharedMessages[`modalTitle.${state.resourceType}`]),
1755
+ labelPrimary: intl.formatMessage(messages$2.startImportButton),
1756
+ isOpen: true,
1757
+ onClose: () => onClose({
1758
+ shouldDeleteImportContainer: true
1759
+ }),
1760
+ onCancel: () => onClose({
1761
+ shouldDeleteImportContainer: true
1762
+ }),
1763
+ dataAttributesPrimaryButton: {
1764
+ 'data-test-id': 'confirmation-dialog-confirm'
1765
+ },
1766
+ dataAttributesSecondaryButton: {
1767
+ 'data-test-id': 'confirmation-dialog-cancel',
1768
+ 'data-tracking-target': `${state.resourceType}_import-start_import_button`
1769
+ },
1770
+ onConfirm: async () => {
1771
+ try {
1772
+ const canConfirm = projectKey && state.containerKey && state.droppedFile?.name && state.resourceType;
1773
+ if (!canConfirm) return;
1774
+ onClose();
1775
+ showNotification({
1776
+ kind: 'info',
1777
+ domain: DOMAINS.SIDE,
1778
+ // @ts-ignore
1779
+ text: jsx(ImportPreparingTextNotification, {
1780
+ projectKey: projectKey
1781
+ })
1782
+ }, {
1783
+ dismissAfter: 5000
1784
+ });
1785
+ await processUploadedFile({
1786
+ projectKey,
1787
+ importContainerKey: state.containerKey,
1788
+ resourceType: state.resourceType
1789
+ });
1790
+ onStartImportSuccess();
1791
+ showNotification({
1792
+ kind: 'info',
1793
+ domain: DOMAINS.SIDE,
1794
+ // @ts-ignore
1795
+ text: jsx(ImportRunningTextNotification, {
1796
+ projectKey: projectKey
1797
+ })
1798
+ }, {
1799
+ dismissAfter: 5000
1800
+ });
1801
+ } catch (error) {
1802
+ onClose({
1803
+ shouldDeleteImportContainer: true
1804
+ });
1805
+ showNotification({
1806
+ kind: 'error',
1807
+ domain: DOMAINS.PAGE,
1808
+ text: isError(error) ? error.toString() : String(error)
1809
+ });
1810
+ }
1811
+ },
1812
+ size: 16,
1813
+ children: jsx(Masking.Unmask, {
1814
+ children: jsxs(Spacings.Stack, {
1815
+ scale: "xl",
1816
+ children: [jsxs("div", {
1817
+ children: [jsx(Text.Body, {
1818
+ intlMessage: _objectSpread$2(_objectSpread$2({}, messages$2.confirmationBodyText), {}, {
1819
+ values: {
1820
+ projectName: projectName,
1821
+ count: intl.formatNumber(state?.uploadFileResponse?.rowsCount || 0),
1822
+ bold: getBold
1823
+ }
1824
+ })
1825
+ }), jsx(Text.Body, {
1826
+ intlMessage: messages$2.confirmationBodyNote
1827
+ })]
1828
+ }), jsx(Text.Body, {
1829
+ intlMessage: messages$2.confirmationBodyQuestion
1830
+ })]
1831
+ })
1832
+ })
1833
+ });
1834
+ };
1835
+ function getBold(msg) {
1836
+ return jsx(Text.Body, {
1837
+ as: "span",
1838
+ isBold: true,
1839
+ children: msg
1840
+ }, crypto.randomUUID());
1841
+ }
1842
+
1843
+ const UploadResult = () => {
1844
+ const _useImportResourcesCo = useImportResourcesContext(),
1845
+ state = _useImportResourcesCo.state;
1846
+ if (state.fileUploadErrors.length > 0) return jsx(UploadErrorsModal, {});
1847
+ if (state.uploadFileResponse?.invalid > 0) return jsx(UploadRowErrorsModal, {});
1848
+ return jsx(UploadPreviewModal, {});
1849
+ };
1850
+
1851
+ const Uploading = () => {
1852
+ const intl = useIntl();
1853
+ const _useImportResourcesCo = useImportResourcesContext(),
1854
+ state = _useImportResourcesCo.state,
1855
+ actions = _useImportResourcesCo.actions,
1856
+ onClose = _useImportResourcesCo.onClose;
1857
+ if (!state.droppedFile?.name) return null;
1858
+ return jsx(UploadingModal, {
1859
+ isOpen: true,
1860
+ title: intl.formatMessage(sharedMessages[`modalTitle.${state.resourceType}`]),
1861
+ fileName: state.droppedFile.name,
1862
+ fileSize: state.droppedFile.size,
1863
+ progress: state.progress,
1864
+ cancelLabel: intl.formatMessage(sharedMessages.cancel),
1865
+ onCancel: () => {
1866
+ actions.setCurrentStep(CurrentStep$1.Upload);
1867
+ state.abortController.abort();
1868
+ },
1869
+ onClose: () => onClose({
1870
+ shouldDeleteImportContainer: true
1871
+ })
1872
+ });
1873
+ };
1874
+
1875
+ const CurrentStep = () => {
1876
+ const _useImportResourcesCo = useImportResourcesContext(),
1877
+ state = _useImportResourcesCo.state;
1878
+ const steps = {
1879
+ upload: jsx(Upload, {}),
1880
+ uploading: jsx(Uploading, {}),
1881
+ 'upload-result': jsx(UploadResult, {}),
1882
+ 'import-confirmation-modal': jsx(ImportConfirmationModal, {})
1883
+ };
1884
+ return steps[state.currentStep] || null;
1885
+ };
1886
+
1887
+ var messages$1 = defineMessages({
1888
+ products: {
1889
+ id: 'ImportResourcesModal.radio.products',
1890
+ description: 'Label for the products radio button',
1891
+ defaultMessage: 'Products (including variants, assets, prices and images)'
1892
+ },
1893
+ inventories: {
1894
+ id: 'ImportResourcesModal.radio.inventories',
1895
+ description: 'Label for the inventories radio button',
1896
+ defaultMessage: 'Inventories'
1897
+ },
1898
+ categories: {
1899
+ id: 'ImportResourcesModal.radio.categories',
1900
+ description: 'Label for the categories radio button',
1901
+ defaultMessage: 'Categories'
1902
+ }
1903
+ });
1904
+
1905
+ const resourceTypeToDisplayName = resourceType => {
1906
+ switch (resourceType) {
1907
+ case IMPORTABLE_RESOURCES.PRODUCT:
1908
+ return messages$1.products;
1909
+ case IMPORTABLE_RESOURCES.INVENTORY:
1910
+ return messages$1.inventories;
1911
+ case IMPORTABLE_RESOURCES.CATEGORY:
1912
+ return messages$1.categories;
1913
+ default:
1914
+ throw new Error(`Unknown resource type: ${resourceType}`);
1915
+ }
1916
+ };
1917
+ const ResourceTypeSelection = () => {
1918
+ const _useImportResourcesCo = useImportResourcesContext(),
1919
+ state = _useImportResourcesCo.state,
1920
+ actions = _useImportResourcesCo.actions,
1921
+ resourceTypes = _useImportResourcesCo.resourceTypes;
1922
+ return jsx(RadioInput.Group, {
1923
+ value: state.resourceType,
1924
+ onChange: e => {
1925
+ actions.setResourceType(e.target.value);
1926
+ },
1927
+ direction: "stack",
1928
+ directionProps: {
1929
+ scale: 's'
1930
+ },
1931
+ children: _mapInstanceProperty(resourceTypes).call(resourceTypes, resourceType => jsx(RadioInput.Option, {
1932
+ value: resourceType,
1933
+ children: jsx(Text.Body, {
1934
+ intlMessage: resourceTypeToDisplayName(resourceType)
1935
+ })
1936
+ }, resourceType))
1937
+ });
1938
+ };
1939
+
1940
+ var messages = defineMessages({
1941
+ fileUploadInstructions: {
1942
+ id: 'ImportResourcesModal.fileUploadInstructions',
1943
+ description: 'Label for the modal category description',
1944
+ defaultMessage: 'Maximum file size is {fileSize} MB with a limit of {rowLimit} rows. Download <csvTemplateLink>the CSV template</csvTemplateLink> or refer to <documentationLink>the documentation</documentationLink>.'
1945
+ }
1946
+ });
1947
+
1948
+ function ownKeys$1(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; }
1949
+ function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys$1(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys$1(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
1950
+ const Instructions = () => {
1951
+ const intl = useIntl();
1952
+ const _useImportResourcesCo = useImportResourcesContext(),
1953
+ state = _useImportResourcesCo.state;
1954
+ const templateLink = RESOURCE_TYPE_TEMPLATE_DOWNLOAD_LINKS[state.resourceType];
1955
+ const documentationLink = RESOURCE_TYPE_DOCUMENTATION_LINKS[state.resourceType];
1956
+ return jsx(Text.Body, {
1957
+ intlMessage: _objectSpread$1(_objectSpread$1({}, messages.fileUploadInstructions), {}, {
1958
+ values: {
1959
+ fileSize: intl.formatNumber(MAX_FILE_SIZE_MB),
1960
+ rowLimit: intl.formatNumber(MAX_ROW_COUNT),
1961
+ csvTemplateLink: msg => jsx(Link, {
1962
+ tone: "secondary",
1963
+ isExternal: true,
1964
+ to: templateLink,
1965
+ children: msg
1966
+ }, "csvTemplateLink"),
1967
+ documentationLink: msg => jsx(Link, {
1968
+ tone: "secondary",
1969
+ isExternal: true,
1970
+ to: documentationLink,
1971
+ children: msg
1972
+ }, "documentationLink")
1973
+ }
1974
+ })
1975
+ });
1976
+ };
1977
+
1978
+ const getChunkImport = locale => {
1979
+ const intlLocale = mapLocaleToIntlLocale(locale);
1980
+ switch (intlLocale) {
1981
+ case 'de':
1982
+ return import('./de-ba5c0732.esm.js');
1983
+ case 'es':
1984
+ return import('./es-44c7763d.esm.js');
1985
+ case 'fr-FR':
1986
+ return import('./fr-FR-58d893b4.esm.js');
1987
+ case 'ja':
1988
+ return import('./ja-73c088a7.esm.js');
1989
+ case 'pt-BR':
1990
+ return import('./pt-BR-365e883e.esm.js');
1991
+ default:
1992
+ return import('./en-30a40b0e.esm.js');
1993
+ }
1994
+ };
1995
+ const loadMessages = async locale => {
1996
+ try {
1997
+ const chunkImport = await getChunkImport(locale);
1998
+ return parseChunkImport(chunkImport);
1999
+ } catch (error) {
2000
+ // eslint-disable-next-line no-console
2001
+ console.warn(`Something went wrong while loading the import-resources-modal messages for ${locale}`, error);
2002
+ reportErrorToSentry(new Error(`Something went wrong while loading the import-resources-modal messages for ${locale}`), {
2003
+ extra: error
2004
+ });
2005
+ return {};
2006
+ }
2007
+ };
2008
+
2009
+ const useAsyncIntlMessages = (locale, loader) => {
2010
+ const _useState = useState({
2011
+ isLoading: true,
2012
+ messages: undefined,
2013
+ error: undefined
2014
+ }),
2015
+ _useState2 = _slicedToArray(_useState, 2),
2016
+ state = _useState2[0],
2017
+ setState = _useState2[1];
2018
+ useEffect(() => {
2019
+ let _isUnmounting = false;
2020
+ async function load() {
2021
+ try {
2022
+ if (!_isUnmounting) {
2023
+ const messages = await loader(locale);
2024
+ setState({
2025
+ isLoading: false,
2026
+ messages
2027
+ });
2028
+ }
2029
+ } catch (error) {
2030
+ setState({
2031
+ isLoading: false,
2032
+ error
2033
+ });
2034
+ }
2035
+ }
2036
+ if (locale) load();
2037
+ return () => {
2038
+ _isUnmounting = true;
2039
+ };
2040
+ }, [locale, loader]);
2041
+ return state;
2042
+ };
2043
+
2044
+ function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2045
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context3 = ownKeys(Object(t))).call(_context3, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
2046
+ const ImportResourcesModal = props => {
2047
+ var _context;
2048
+ const _useApplicationContex = useApplicationContext(context => ({
2049
+ locale: context.user && context.user.locale
2050
+ })),
2051
+ locale = _useApplicationContex.locale;
2052
+ const messages = useAsyncIntlMessages(locale, loadMessages);
2053
+ if (!props.isOpen || messages.isLoading) return null;
2054
+ if (!props.resourceTypes?.length) {
2055
+ console.error('No resource types provided for import resources modal');
2056
+ return null;
2057
+ }
2058
+ if (!_everyInstanceProperty(_context = props.resourceTypes).call(_context, isResourceType)) {
2059
+ console.error('Invalid resource types provided for import resources modal');
2060
+ return null;
2061
+ }
2062
+ return jsx(IntlProvider, {
2063
+ locale: locale,
2064
+ messages: messages.messages,
2065
+ children: jsx(ImportResourcesProvider, _objectSpread(_objectSpread({}, props), {}, {
2066
+ children: jsx(CurrentStep, {})
2067
+ }))
2068
+ });
2069
+ };
2070
+ ImportResourcesModal.displayName = 'ImportResourcesModal';
2071
+
2072
+ export { ImportResourcesModal as default, useImportPermission };