@commercetools-frontend-extensions/import-resources-modal 0.0.0-canary-20250930092515 → 0.0.0-canary-20251209161906

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