@commercetools-frontend-extensions/import-resources-modal 1.0.7 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/{active-drag-drop-area-427ef7c2.cjs.dev.js → active-drag-drop-area-8456b360.cjs.prod.js} +4 -5
- package/dist/{active-drag-drop-area-f930d60d.cjs.prod.js → active-drag-drop-area-a3479c4b.cjs.dev.js} +4 -5
- package/dist/{active-drag-drop-area-f7b6d1a7.esm.js → active-drag-drop-area-f5c4c801.esm.js} +4 -5
- package/dist/commercetools-frontend-extensions-import-resources-modal.cjs.dev.js +4 -5
- package/dist/commercetools-frontend-extensions-import-resources-modal.cjs.prod.js +4 -5
- package/dist/commercetools-frontend-extensions-import-resources-modal.esm.js +4 -5
- package/dist/declarations/src/@types/import-resources-modal-props.d.ts +1 -1
- package/dist/declarations/src/import-resources-modal.d.ts +1 -1
- package/dist/{enabled-drop-area-efc31de0.cjs.dev.js → enabled-drop-area-668a7291.cjs.prod.js} +4 -5
- package/dist/{enabled-drop-area-6b9b6762.cjs.prod.js → enabled-drop-area-83b1b98e.cjs.dev.js} +4 -5
- package/dist/{enabled-drop-area-20dad798.esm.js → enabled-drop-area-cc25daca.esm.js} +4 -5
- package/dist/{file-dropped-area-dfd7b665.cjs.dev.js → file-dropped-area-5320497d.cjs.prod.js} +4 -6
- package/dist/{file-dropped-area-89f07d26.esm.js → file-dropped-area-b714e041.esm.js} +4 -6
- package/dist/{file-dropped-area-98af1296.cjs.prod.js → file-dropped-area-fcc62264.cjs.dev.js} +4 -6
- package/dist/{index-c4f11e0f.esm.js → index-339a08f1.esm.js} +279 -192
- package/dist/{index-c1ea2041.cjs.dev.js → index-5b2739bc.cjs.dev.js} +280 -194
- package/dist/{index-28eb8566.cjs.prod.js → index-7498d508.cjs.prod.js} +280 -194
- package/package.json +1 -1
|
@@ -9,14 +9,13 @@ var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-
|
|
|
9
9
|
var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
|
|
10
10
|
var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
|
|
11
11
|
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
12
|
+
var _everyInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/every');
|
|
12
13
|
var reactIntl = require('react-intl');
|
|
13
14
|
var applicationShellConnectors = require('@commercetools-frontend/application-shell-connectors');
|
|
14
15
|
var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
15
16
|
var React = require('react');
|
|
16
17
|
var sdk = require('@commercetools-frontend/sdk');
|
|
17
18
|
var constants = require('@commercetools-frontend/constants');
|
|
18
|
-
var _everyInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/every');
|
|
19
|
-
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
20
19
|
var pluralize = require('pluralize');
|
|
21
20
|
var _Promise = require('@babel/runtime-corejs3/core-js-stable/promise');
|
|
22
21
|
var _Array$isArray = require('@babel/runtime-corejs3/core-js-stable/array/is-array');
|
|
@@ -27,7 +26,6 @@ var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/i
|
|
|
27
26
|
var Papa = require('papaparse');
|
|
28
27
|
var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
|
|
29
28
|
var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
|
|
30
|
-
var _someInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/some');
|
|
31
29
|
require('@babel/runtime-corejs3/core-js-stable/instance/starts-with');
|
|
32
30
|
require('querystring');
|
|
33
31
|
require('ramda');
|
|
@@ -35,15 +33,16 @@ var applicationShell = require('@commercetools-frontend/application-shell');
|
|
|
35
33
|
var _Reflect$construct = require('@babel/runtime-corejs3/core-js-stable/reflect/construct');
|
|
36
34
|
var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
|
|
37
35
|
var _classCallCheck = require('@babel/runtime-corejs3/helpers/classCallCheck');
|
|
38
|
-
var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
|
|
39
36
|
var _possibleConstructorReturn = require('@babel/runtime-corejs3/helpers/possibleConstructorReturn');
|
|
40
37
|
var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
|
|
38
|
+
var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
|
|
41
39
|
var _wrapNativeSuper = require('@babel/runtime-corejs3/helpers/wrapNativeSuper');
|
|
42
40
|
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
43
41
|
var applicationComponents = require('@commercetools-frontend/application-components');
|
|
44
42
|
var uiKit = require('@commercetools-frontend/ui-kit');
|
|
45
43
|
var actionsGlobal = require('@commercetools-frontend/actions-global');
|
|
46
44
|
var sentry = require('@commercetools-frontend/sentry');
|
|
45
|
+
var _someInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/some');
|
|
47
46
|
var reactDropzone = require('react-dropzone');
|
|
48
47
|
var _styled = require('@emotion/styled/base');
|
|
49
48
|
var react = require('@emotion/react');
|
|
@@ -61,9 +60,8 @@ var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachIns
|
|
|
61
60
|
var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
|
|
62
61
|
var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
|
|
63
62
|
var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
|
|
64
|
-
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
65
63
|
var _everyInstanceProperty__default = /*#__PURE__*/_interopDefault(_everyInstanceProperty);
|
|
66
|
-
var
|
|
64
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
67
65
|
var _Promise__default = /*#__PURE__*/_interopDefault(_Promise);
|
|
68
66
|
var _Array$isArray__default = /*#__PURE__*/_interopDefault(_Array$isArray);
|
|
69
67
|
var _flatMapInstanceProperty__default = /*#__PURE__*/_interopDefault(_flatMapInstanceProperty);
|
|
@@ -73,8 +71,8 @@ var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesI
|
|
|
73
71
|
var Papa__default = /*#__PURE__*/_interopDefault(Papa);
|
|
74
72
|
var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInstanceProperty);
|
|
75
73
|
var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
|
|
76
|
-
var _someInstanceProperty__default = /*#__PURE__*/_interopDefault(_someInstanceProperty);
|
|
77
74
|
var _Reflect$construct__default = /*#__PURE__*/_interopDefault(_Reflect$construct);
|
|
75
|
+
var _someInstanceProperty__default = /*#__PURE__*/_interopDefault(_someInstanceProperty);
|
|
78
76
|
var _styled__default = /*#__PURE__*/_interopDefault(_styled);
|
|
79
77
|
var _sliceInstanceProperty__default = /*#__PURE__*/_interopDefault(_sliceInstanceProperty);
|
|
80
78
|
var DataTable__default = /*#__PURE__*/_interopDefault(DataTable);
|
|
@@ -89,7 +87,7 @@ function isResourceType(maybeResourceType) {
|
|
|
89
87
|
}
|
|
90
88
|
function assertResourceType(maybeResourceType) {
|
|
91
89
|
if (isResourceType(maybeResourceType)) return;
|
|
92
|
-
throw new Error(
|
|
90
|
+
throw new Error(`Invalid value: ${maybeResourceType}`);
|
|
93
91
|
}
|
|
94
92
|
function isError(maybeError) {
|
|
95
93
|
if (maybeError instanceof Error) return true;
|
|
@@ -104,7 +102,6 @@ function hasRequiredFields(maybeValidObject, requiredFields) {
|
|
|
104
102
|
return typeof maybeValidObject === 'object' && maybeValidObject !== null && _everyInstanceProperty__default["default"](requiredFields).call(requiredFields, property => hasOwnProperty(maybeValidObject, property));
|
|
105
103
|
}
|
|
106
104
|
|
|
107
|
-
var _context;
|
|
108
105
|
const DEFAULT_DELIMITER = ',';
|
|
109
106
|
const INITIAL_COLUMN_DISPLAY_COUNT = 8;
|
|
110
107
|
const IMPORT_TAG_KEYS = {
|
|
@@ -113,7 +110,7 @@ const IMPORT_TAG_KEYS = {
|
|
|
113
110
|
const IMPORT_TAG_VALUES = {
|
|
114
111
|
fileUpload: 'file-upload'
|
|
115
112
|
};
|
|
116
|
-
const TAG_KEY_SOURCE_FILE_UPLOAD =
|
|
113
|
+
const TAG_KEY_SOURCE_FILE_UPLOAD = `${IMPORT_TAG_KEYS.source}:${IMPORT_TAG_VALUES.fileUpload}`;
|
|
117
114
|
|
|
118
115
|
const FILE_SIZE_LIMITS_MB = {
|
|
119
116
|
category: 10,
|
|
@@ -121,13 +118,13 @@ const FILE_SIZE_LIMITS_MB = {
|
|
|
121
118
|
product: 35
|
|
122
119
|
};
|
|
123
120
|
const ROW_LIMITS = {
|
|
124
|
-
category:
|
|
125
|
-
inventory:
|
|
126
|
-
product:
|
|
121
|
+
category: 5_000,
|
|
122
|
+
inventory: 4_000,
|
|
123
|
+
product: 70_000
|
|
127
124
|
};
|
|
128
125
|
const RESOURCE_TYPE_TEMPLATE_DOWNLOAD_LINKS = {
|
|
129
126
|
category: 'https://docs.commercetools.com/merchant-center/downloads/category_import_template.csv',
|
|
130
|
-
product: 'https://docs.commercetools.com/merchant-center/import-data#
|
|
127
|
+
product: 'https://docs.commercetools.com/merchant-center/import-data#download-a-csv-template',
|
|
131
128
|
inventory: 'https://docs.commercetools.com/merchant-center/downloads/inventory_entry_import_template.csv'
|
|
132
129
|
};
|
|
133
130
|
const RESOURCE_TYPE_DOCUMENTATION_LINKS = {
|
|
@@ -251,76 +248,67 @@ const encodeFileNameWithTimestampToContainerKey = fileName => {
|
|
|
251
248
|
};
|
|
252
249
|
|
|
253
250
|
function getCreateImportContainerURL(projectKey) {
|
|
254
|
-
return
|
|
251
|
+
return `/${projectKey}/import-containers`;
|
|
255
252
|
}
|
|
256
253
|
function getDeleteImportContainerURL(projectKey, containerKey) {
|
|
257
|
-
|
|
258
|
-
return _concatInstanceProperty__default["default"](_context6 = "/".concat(projectKey, "/import-containers/")).call(_context6, containerKey);
|
|
254
|
+
return `/${projectKey}/import-containers/${containerKey}`;
|
|
259
255
|
}
|
|
260
256
|
function getFileUploadURL(projectKey, resourceType, containerKey) {
|
|
261
|
-
|
|
262
|
-
return _concatInstanceProperty__default["default"](_context8 = _concatInstanceProperty__default["default"](_context9 = "/".concat(projectKey, "/")).call(_context9, pluralize.plural(resourceType), "/import-containers/")).call(_context8, containerKey, "/file-upload");
|
|
257
|
+
return `/${projectKey}/${pluralize.plural(resourceType)}/import-containers/${containerKey}/file-upload`;
|
|
263
258
|
}
|
|
264
259
|
function getProccessFileURL(projectKey, resourceType, containerKey) {
|
|
265
|
-
|
|
266
|
-
return _concatInstanceProperty__default["default"](_context10 = _concatInstanceProperty__default["default"](_context11 = "/".concat(projectKey, "/")).call(_context11, pluralize.plural(resourceType), "/import-containers/")).call(_context10, containerKey, "/process-file");
|
|
260
|
+
return `/${projectKey}/${pluralize.plural(resourceType)}/import-containers/${containerKey}/process-file`;
|
|
267
261
|
}
|
|
268
262
|
|
|
269
|
-
function
|
|
263
|
+
function _callSuper$3(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct$3() ? _Reflect$construct__default["default"](o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
270
264
|
function _isNativeReflectConstruct$3() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$3 = function () { return !!t; })(); }
|
|
271
265
|
let UnexpectedResourceTypeError = /*#__PURE__*/function (_Error) {
|
|
272
|
-
_inherits(UnexpectedResourceTypeError, _Error);
|
|
273
|
-
var _super = _createSuper$3(UnexpectedResourceTypeError);
|
|
274
266
|
function UnexpectedResourceTypeError(resourceType) {
|
|
275
267
|
var _this;
|
|
276
268
|
_classCallCheck(this, UnexpectedResourceTypeError);
|
|
277
|
-
_this =
|
|
269
|
+
_this = _callSuper$3(this, UnexpectedResourceTypeError, [`Unexpected resource type "${resourceType}"`]);
|
|
278
270
|
_this.name = 'UnexpectedResourceTypeError';
|
|
279
271
|
return _this;
|
|
280
272
|
}
|
|
273
|
+
_inherits(UnexpectedResourceTypeError, _Error);
|
|
281
274
|
return _createClass(UnexpectedResourceTypeError);
|
|
282
275
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
283
276
|
|
|
284
|
-
function
|
|
277
|
+
function _callSuper$2(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct$2() ? _Reflect$construct__default["default"](o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
285
278
|
function _isNativeReflectConstruct$2() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$2 = function () { return !!t; })(); }
|
|
286
279
|
let MissingImportResourceProviderError = /*#__PURE__*/function (_Error) {
|
|
287
|
-
_inherits(MissingImportResourceProviderError, _Error);
|
|
288
|
-
var _super = _createSuper$2(MissingImportResourceProviderError);
|
|
289
280
|
function MissingImportResourceProviderError() {
|
|
290
281
|
var _this;
|
|
291
282
|
_classCallCheck(this, MissingImportResourceProviderError);
|
|
292
|
-
_this =
|
|
283
|
+
_this = _callSuper$2(this, MissingImportResourceProviderError, ['useImportResourcesContext must be used within ImportResourcesProvider']);
|
|
293
284
|
_this.name = 'MissingImportResourceProviderError';
|
|
294
285
|
return _this;
|
|
295
286
|
}
|
|
287
|
+
_inherits(MissingImportResourceProviderError, _Error);
|
|
296
288
|
return _createClass(MissingImportResourceProviderError);
|
|
297
289
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
298
290
|
|
|
299
|
-
function
|
|
291
|
+
function _callSuper$1(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct$1() ? _Reflect$construct__default["default"](o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
300
292
|
function _isNativeReflectConstruct$1() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$1 = function () { return !!t; })(); }
|
|
301
293
|
let UnexpectedColumnError = /*#__PURE__*/function (_Error) {
|
|
302
|
-
_inherits(UnexpectedColumnError, _Error);
|
|
303
|
-
var _super = _createSuper$1(UnexpectedColumnError);
|
|
304
294
|
function UnexpectedColumnError(columnName) {
|
|
305
295
|
var _this;
|
|
306
296
|
_classCallCheck(this, UnexpectedColumnError);
|
|
307
|
-
_this =
|
|
297
|
+
_this = _callSuper$1(this, UnexpectedColumnError, [`Unexpected column "${columnName}"`]);
|
|
308
298
|
_this.name = 'UnexpectedColumnError';
|
|
309
299
|
return _this;
|
|
310
300
|
}
|
|
301
|
+
_inherits(UnexpectedColumnError, _Error);
|
|
311
302
|
return _createClass(UnexpectedColumnError);
|
|
312
303
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
313
304
|
|
|
314
|
-
function
|
|
305
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? _Reflect$construct__default["default"](o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
315
306
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); }
|
|
316
307
|
let HttpError = /*#__PURE__*/function (_Error) {
|
|
317
|
-
_inherits(HttpError, _Error);
|
|
318
|
-
var _super = _createSuper(HttpError);
|
|
319
308
|
function HttpError(statusCode, statusText, errorData) {
|
|
320
|
-
var _context;
|
|
321
309
|
var _this;
|
|
322
310
|
_classCallCheck(this, HttpError);
|
|
323
|
-
_this =
|
|
311
|
+
_this = _callSuper(this, HttpError, [`HTTP Error! Status code: ${statusCode}, message: "${statusText ? statusText : ''}"`]);
|
|
324
312
|
_this.statusCode = void 0;
|
|
325
313
|
_this.errorData = void 0;
|
|
326
314
|
_this.name = 'HttpError';
|
|
@@ -328,14 +316,14 @@ let HttpError = /*#__PURE__*/function (_Error) {
|
|
|
328
316
|
_this.errorData = errorData;
|
|
329
317
|
return _this;
|
|
330
318
|
}
|
|
319
|
+
_inherits(HttpError, _Error);
|
|
331
320
|
return _createClass(HttpError);
|
|
332
321
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
333
322
|
|
|
334
323
|
function ownKeys$e(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
335
|
-
function _objectSpread$e(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
324
|
+
function _objectSpread$e(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context2 = ownKeys$e(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context3 = ownKeys$e(Object(t))).call(_context3, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
336
325
|
const addProxyPrefixToUrl = (uri, proxy) => {
|
|
337
|
-
|
|
338
|
-
return proxy ? _concatInstanceProperty__default["default"](_context = "/proxy/".concat(proxy)).call(_context, uri) : uri;
|
|
326
|
+
return proxy ? `/proxy/${proxy}${uri}` : uri;
|
|
339
327
|
};
|
|
340
328
|
const fetchUsingXhr = _ref2 => {
|
|
341
329
|
let url = _ref2.url,
|
|
@@ -347,15 +335,15 @@ const fetchUsingXhr = _ref2 => {
|
|
|
347
335
|
const options = applicationShell.createHttpClientOptions({
|
|
348
336
|
headers: _objectSpread$e({
|
|
349
337
|
'Content-Type': 'application/json'
|
|
350
|
-
}, config
|
|
338
|
+
}, config?.headers)
|
|
351
339
|
});
|
|
352
340
|
const xhr = new XMLHttpRequest();
|
|
353
|
-
xhr.open(config
|
|
341
|
+
xhr.open(config?.method, applicationShell.buildApiUrl(addProxyPrefixToUrl(url, config?.proxy)), true);
|
|
354
342
|
// Include cookies in the request
|
|
355
343
|
xhr.withCredentials = true;
|
|
356
344
|
if (options.headers) {
|
|
357
|
-
var
|
|
358
|
-
_forEachInstanceProperty__default["default"](
|
|
345
|
+
var _context;
|
|
346
|
+
_forEachInstanceProperty__default["default"](_context = _Object$keys__default["default"](options.headers)).call(_context, key => {
|
|
359
347
|
xhr.setRequestHeader(key, options.headers[key]);
|
|
360
348
|
});
|
|
361
349
|
}
|
|
@@ -524,7 +512,7 @@ function reducer(state, action) {
|
|
|
524
512
|
throw new Error(getUnknownActionError(action));
|
|
525
513
|
}
|
|
526
514
|
function getUnknownActionError(actionType) {
|
|
527
|
-
return
|
|
515
|
+
return `Unkown type: ${actionType}`;
|
|
528
516
|
}
|
|
529
517
|
const initialState = {
|
|
530
518
|
currentStep: 1,
|
|
@@ -541,16 +529,13 @@ function ownKeys$b(e, r) { var t = _Object$keys__default["default"](e); if (_Obj
|
|
|
541
529
|
function _objectSpread$b(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$b(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$b(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
542
530
|
const ImportResourcesContext = /*#__PURE__*/React__default["default"].createContext();
|
|
543
531
|
const ImportResourcesProvider = props => {
|
|
544
|
-
const _useApplicationContex = applicationShellConnectors.useApplicationContext(context => {
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
projectKey: (_context$project = context.project) === null || _context$project === void 0 ? void 0 : _context$project.key
|
|
548
|
-
};
|
|
549
|
-
}),
|
|
532
|
+
const _useApplicationContex = applicationShellConnectors.useApplicationContext(context => ({
|
|
533
|
+
projectKey: context.project?.key
|
|
534
|
+
})),
|
|
550
535
|
projectKey = _useApplicationContex.projectKey;
|
|
551
536
|
const asyncDispatch = sdk.useAsyncDispatch();
|
|
552
537
|
const _React$useReducer = React__default["default"].useReducer(reducer, _objectSpread$b(_objectSpread$b({}, initialState), {}, {
|
|
553
|
-
resourceType: props.
|
|
538
|
+
resourceType: props.resourceTypes[0]
|
|
554
539
|
})),
|
|
555
540
|
_React$useReducer2 = _slicedToArray(_React$useReducer, 2),
|
|
556
541
|
state = _React$useReducer2[0],
|
|
@@ -559,13 +544,13 @@ const ImportResourcesProvider = props => {
|
|
|
559
544
|
type: 'setCurrentStep',
|
|
560
545
|
currentStep
|
|
561
546
|
});
|
|
562
|
-
const setUploadFileResponse =
|
|
547
|
+
const setUploadFileResponse = uploadFileResponse => dispatch({
|
|
563
548
|
type: 'setUploadFileResponse',
|
|
564
|
-
uploadFileResponse:
|
|
549
|
+
uploadFileResponse: uploadFileResponse
|
|
565
550
|
});
|
|
566
|
-
const setResourceType =
|
|
551
|
+
const setResourceType = resourceType => dispatch({
|
|
567
552
|
type: 'setResourceType',
|
|
568
|
-
resourceType:
|
|
553
|
+
resourceType: resourceType
|
|
569
554
|
});
|
|
570
555
|
const setContainerKey = containerKey => dispatch({
|
|
571
556
|
type: 'setContainerKey',
|
|
@@ -577,17 +562,17 @@ const ImportResourcesProvider = props => {
|
|
|
577
562
|
const uploadNewFile = () => dispatch({
|
|
578
563
|
type: 'uploadNewFile'
|
|
579
564
|
});
|
|
580
|
-
const setDroppedFile =
|
|
565
|
+
const setDroppedFile = droppedFile => dispatch({
|
|
581
566
|
type: 'setDroppedFile',
|
|
582
|
-
droppedFile:
|
|
567
|
+
droppedFile: droppedFile
|
|
583
568
|
});
|
|
584
|
-
const setAbortController =
|
|
569
|
+
const setAbortController = abortController => dispatch({
|
|
585
570
|
type: 'setAbortController',
|
|
586
|
-
abortController:
|
|
571
|
+
abortController: abortController
|
|
587
572
|
});
|
|
588
|
-
const setFileUploadClientSideErrors =
|
|
573
|
+
const setFileUploadClientSideErrors = fileUploadClientSideErrors => dispatch({
|
|
589
574
|
type: 'setFileUploadClientSideErrors',
|
|
590
|
-
fileUploadClientSideErrors:
|
|
575
|
+
fileUploadClientSideErrors: fileUploadClientSideErrors
|
|
591
576
|
});
|
|
592
577
|
const setProgress = progress => dispatch({
|
|
593
578
|
type: 'setProgress',
|
|
@@ -607,6 +592,7 @@ const ImportResourcesProvider = props => {
|
|
|
607
592
|
return jsxRuntime.jsx(ImportResourcesContext.Provider, {
|
|
608
593
|
value: {
|
|
609
594
|
state,
|
|
595
|
+
resourceTypes: props.resourceTypes,
|
|
610
596
|
onClose: handleClose,
|
|
611
597
|
onStartImportSuccess: handleStartImportSuccess,
|
|
612
598
|
actions: {
|
|
@@ -634,7 +620,7 @@ function useImportResourcesContext() {
|
|
|
634
620
|
return context;
|
|
635
621
|
}
|
|
636
622
|
|
|
637
|
-
var messages$
|
|
623
|
+
var messages$5 = reactIntl.defineMessages({
|
|
638
624
|
fileSizeExceededTitle: {
|
|
639
625
|
id: 'ImportResourcesModal.sizeExceededTitle',
|
|
640
626
|
defaultMessage: 'File size exceeded'
|
|
@@ -676,15 +662,17 @@ var messages$3 = reactIntl.defineMessages({
|
|
|
676
662
|
id: 'ImportResourcesModal.unexpectedError',
|
|
677
663
|
description: 'Generic notification message when file upload fails',
|
|
678
664
|
defaultMessage: 'An unexpected error occurred during the file upload. Please try again, or contact support if this error occurs again.'
|
|
665
|
+
},
|
|
666
|
+
missingKeyError: {
|
|
667
|
+
id: 'ImportResourcesModal.missingKeyError',
|
|
668
|
+
description: 'Error message displayed when the uploaded file is missing the key field',
|
|
669
|
+
defaultMessage: "The 'key' field is missing or incomplete in some rows. Please ensure every row has a 'key' value."
|
|
679
670
|
}
|
|
680
671
|
});
|
|
681
672
|
|
|
682
673
|
const useUpload = () => {
|
|
683
674
|
const intl = reactIntl.useIntl();
|
|
684
|
-
const projectKey = applicationShellConnectors.useApplicationContext(context =>
|
|
685
|
-
var _context$project;
|
|
686
|
-
return (_context$project = context.project) === null || _context$project === void 0 ? void 0 : _context$project.key;
|
|
687
|
-
});
|
|
675
|
+
const projectKey = applicationShellConnectors.useApplicationContext(context => context.project?.key);
|
|
688
676
|
const _useImportResourcesCo = useImportResourcesContext(),
|
|
689
677
|
state = _useImportResourcesCo.state,
|
|
690
678
|
actions = _useImportResourcesCo.actions;
|
|
@@ -699,25 +687,25 @@ const useUpload = () => {
|
|
|
699
687
|
const errors = [];
|
|
700
688
|
const delimiterCheck = await checkDelimiter(file);
|
|
701
689
|
if (!delimiterCheck.isValid) errors.push({
|
|
702
|
-
title: intl.formatMessage(messages$
|
|
703
|
-
description: intl.formatMessage(messages$
|
|
690
|
+
title: intl.formatMessage(messages$5.dropAreaWrongDelimiterTitle),
|
|
691
|
+
description: intl.formatMessage(messages$5.dropAreaWrongDelimiterDescription, {
|
|
704
692
|
delimiter: delimiterCheck.delimiter
|
|
705
693
|
})
|
|
706
694
|
});
|
|
707
695
|
const rowCount = await getRowCount(file);
|
|
708
696
|
if (rowCount < 1) errors.push({
|
|
709
|
-
title: intl.formatMessage(messages$
|
|
710
|
-
description: intl.formatMessage(messages$
|
|
697
|
+
title: intl.formatMessage(messages$5.dropAreaNotEnoughRowsTitle),
|
|
698
|
+
description: intl.formatMessage(messages$5.dropAreaNotEnoughRowsDescription)
|
|
711
699
|
});
|
|
712
700
|
if (state.resourceType && file.size > toBytes(FILE_SIZE_LIMITS_MB[state.resourceType])) errors.push({
|
|
713
|
-
title: intl.formatMessage(messages$
|
|
714
|
-
description: intl.formatMessage(messages$
|
|
701
|
+
title: intl.formatMessage(messages$5.fileSizeExceededTitle),
|
|
702
|
+
description: intl.formatMessage(messages$5.fileSizeExceededDescription, {
|
|
715
703
|
fileSizeLimit: intl.formatNumber(FILE_SIZE_LIMITS_MB[state.resourceType])
|
|
716
704
|
})
|
|
717
705
|
});
|
|
718
706
|
if (state.resourceType && rowCount > ROW_LIMITS[state.resourceType]) errors.push({
|
|
719
|
-
title: intl.formatMessage(messages$
|
|
720
|
-
description: intl.formatMessage(messages$
|
|
707
|
+
title: intl.formatMessage(messages$5.rowLimitExceededTitle),
|
|
708
|
+
description: intl.formatMessage(messages$5.rowLimitExceededDescription, {
|
|
721
709
|
rowLimit: intl.formatNumber(ROW_LIMITS[state.resourceType])
|
|
722
710
|
})
|
|
723
711
|
});
|
|
@@ -734,26 +722,24 @@ const useUpload = () => {
|
|
|
734
722
|
return;
|
|
735
723
|
}
|
|
736
724
|
if (error instanceof HttpError) {
|
|
737
|
-
|
|
738
|
-
if (((_error$errorData = error.errorData) === null || _error$errorData === void 0 ? void 0 : _error$errorData.code) === 'MISSING_KEY_ERROR') {
|
|
725
|
+
if (error.errorData?.code === 'MISSING_KEY_ERROR') {
|
|
739
726
|
actions.cancelImport();
|
|
740
727
|
showNotification({
|
|
741
728
|
kind: 'error',
|
|
742
729
|
domain: constants.DOMAINS.PAGE,
|
|
743
|
-
text:
|
|
730
|
+
text: intl.formatMessage(messages$5.unexpectedError)
|
|
744
731
|
});
|
|
745
|
-
} else if (
|
|
732
|
+
} else if (error.errorData?.invalid > 0) {
|
|
746
733
|
actions.setUploadFileResponse(error.errorData);
|
|
747
734
|
} else {
|
|
748
735
|
actions.cancelImport();
|
|
749
736
|
showNotification({
|
|
750
737
|
kind: 'error',
|
|
751
738
|
domain: constants.DOMAINS.PAGE,
|
|
752
|
-
text: intl.formatMessage(messages$
|
|
739
|
+
text: intl.formatMessage(messages$5.unexpectedError)
|
|
753
740
|
});
|
|
754
741
|
}
|
|
755
742
|
} else {
|
|
756
|
-
var _state$droppedFile;
|
|
757
743
|
actions.cancelImport();
|
|
758
744
|
showNotification({
|
|
759
745
|
kind: 'error',
|
|
@@ -766,7 +752,7 @@ const useUpload = () => {
|
|
|
766
752
|
projectKey,
|
|
767
753
|
containerKey: state.containerKey,
|
|
768
754
|
resourceType: state.resourceType,
|
|
769
|
-
fileSizeInBytes:
|
|
755
|
+
fileSizeInBytes: state.droppedFile?.size
|
|
770
756
|
}
|
|
771
757
|
});
|
|
772
758
|
}
|
|
@@ -813,7 +799,7 @@ const useUpload = () => {
|
|
|
813
799
|
};
|
|
814
800
|
};
|
|
815
801
|
|
|
816
|
-
function resourceTypeToDisplayName(_ref) {
|
|
802
|
+
function resourceTypeToDisplayName$1(_ref) {
|
|
817
803
|
let resourceType = _ref.resourceType,
|
|
818
804
|
_ref$isUpperCase = _ref.isUpperCase,
|
|
819
805
|
isUpperCase = _ref$isUpperCase === void 0 ? false : _ref$isUpperCase,
|
|
@@ -827,6 +813,9 @@ function resourceTypeToDisplayName(_ref) {
|
|
|
827
813
|
case 'product':
|
|
828
814
|
displayName = isPlural ? 'Products' : 'Product';
|
|
829
815
|
break;
|
|
816
|
+
case 'inventory':
|
|
817
|
+
displayName = isPlural ? 'Inventories' : 'Inventory';
|
|
818
|
+
break;
|
|
830
819
|
default:
|
|
831
820
|
throw new UnexpectedResourceTypeError(resourceType);
|
|
832
821
|
}
|
|
@@ -844,8 +833,12 @@ const getBorderColor = state => {
|
|
|
844
833
|
const getDashedBorder = function () {
|
|
845
834
|
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default';
|
|
846
835
|
const color = getBorderColor(state);
|
|
847
|
-
const svgContent =
|
|
848
|
-
|
|
836
|
+
const svgContent = `
|
|
837
|
+
<svg width="100%" height="100%" xmlns="http://www.w3.org/2000/svg">
|
|
838
|
+
<rect width="100%" height="100%" fill="none" stroke="${color}" stroke-width="2px" stroke-dasharray="6,6" stroke-dashoffset="0" stroke-linecap="square"/>
|
|
839
|
+
</svg>
|
|
840
|
+
`;
|
|
841
|
+
return `data:image/svg+xml,${encodeURIComponent(svgContent)}`;
|
|
849
842
|
};
|
|
850
843
|
const base = /*#__PURE__*/react.css("border-radius:", uiKit.customProperties.borderRadius6, ";min-height:136px;display:flex;justify-content:center;align-items:center;" + ("" ), "" );
|
|
851
844
|
const disabled = /*#__PURE__*/react.css("" , "" );
|
|
@@ -881,13 +874,13 @@ function getDefaultDropWrapperStyles(_dropAreaState) {
|
|
|
881
874
|
return /*#__PURE__*/react.css("" , "" );
|
|
882
875
|
}
|
|
883
876
|
|
|
884
|
-
var ActiveDragDropArea = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./active-drag-drop-area-
|
|
877
|
+
var ActiveDragDropArea = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./active-drag-drop-area-8456b360.cjs.prod.js' /* webpackChunkName: "active-drag-drop-area" */); }));
|
|
885
878
|
|
|
886
879
|
var DisabledDropArea = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./disabled-drop-area-99c1fa0b.cjs.prod.js' /* webpackChunkName: "disabled-drop-area" */); }));
|
|
887
880
|
|
|
888
|
-
var EnabledDropArea = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./enabled-drop-area-
|
|
881
|
+
var EnabledDropArea = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./enabled-drop-area-668a7291.cjs.prod.js' /* webpackChunkName: "enabled-drop-area" */); }));
|
|
889
882
|
|
|
890
|
-
var FileDropped = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./file-dropped-area-
|
|
883
|
+
var FileDropped = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./file-dropped-area-5320497d.cjs.prod.js' /* webpackChunkName: "filed-dropped-area" */); }));
|
|
891
884
|
|
|
892
885
|
function getDropArea(_ref) {
|
|
893
886
|
let dropAreaState = _ref.dropAreaState,
|
|
@@ -925,12 +918,7 @@ function getDropAreaState(flags) {
|
|
|
925
918
|
return 'ready-for-drop';
|
|
926
919
|
}
|
|
927
920
|
|
|
928
|
-
var messages$
|
|
929
|
-
modalDescription: {
|
|
930
|
-
id: 'ImportResourcesModal.modalDescription',
|
|
931
|
-
description: 'Label for the modal category description',
|
|
932
|
-
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>.'
|
|
933
|
-
},
|
|
921
|
+
var messages$4 = reactIntl.defineMessages({
|
|
934
922
|
dragAndDropCSV: {
|
|
935
923
|
id: 'ImportResourcesModal.dragAndDropCSV',
|
|
936
924
|
description: 'The message telling the user to drag and drop CSV file in the file drop area',
|
|
@@ -974,6 +962,16 @@ var messages$2 = reactIntl.defineMessages({
|
|
|
974
962
|
id: 'ImportResourcesModal.genericError',
|
|
975
963
|
description: 'Default error message for unexpected file upload issues (for unhandled cases)',
|
|
976
964
|
defaultMessage: 'Error occurred: Please try uploading the file again or contact our support team for assistance.'
|
|
965
|
+
},
|
|
966
|
+
dataType: {
|
|
967
|
+
id: 'ImportResourcesModal.dataType',
|
|
968
|
+
description: 'Label for the data type selection dropdown',
|
|
969
|
+
defaultMessage: 'Data type'
|
|
970
|
+
},
|
|
971
|
+
instructions: {
|
|
972
|
+
id: 'ImportResourcesModal.instructions',
|
|
973
|
+
description: 'Label for the instructions section',
|
|
974
|
+
defaultMessage: 'Instructions'
|
|
977
975
|
}
|
|
978
976
|
});
|
|
979
977
|
|
|
@@ -1008,7 +1006,7 @@ const FileDropArea = () => {
|
|
|
1008
1006
|
showNotification({
|
|
1009
1007
|
kind: 'error',
|
|
1010
1008
|
domain: constants.DOMAINS.PAGE,
|
|
1011
|
-
text: intl.formatMessage(messages$
|
|
1009
|
+
text: intl.formatMessage(messages$4.tooManyFilesError)
|
|
1012
1010
|
});
|
|
1013
1011
|
return;
|
|
1014
1012
|
}
|
|
@@ -1016,13 +1014,13 @@ const FileDropArea = () => {
|
|
|
1016
1014
|
showNotification({
|
|
1017
1015
|
kind: 'error',
|
|
1018
1016
|
domain: constants.DOMAINS.PAGE,
|
|
1019
|
-
text: intl.formatMessage(messages$
|
|
1017
|
+
text: intl.formatMessage(messages$4.fileFormatNotSupported)
|
|
1020
1018
|
});
|
|
1021
1019
|
} else {
|
|
1022
1020
|
showNotification({
|
|
1023
1021
|
kind: 'error',
|
|
1024
1022
|
domain: constants.DOMAINS.PAGE,
|
|
1025
|
-
text: intl.formatMessage(messages$
|
|
1023
|
+
text: intl.formatMessage(messages$4.genericError)
|
|
1026
1024
|
});
|
|
1027
1025
|
}
|
|
1028
1026
|
}
|
|
@@ -1075,21 +1073,19 @@ var sharedMessages = reactIntl.defineMessages({
|
|
|
1075
1073
|
}
|
|
1076
1074
|
});
|
|
1077
1075
|
|
|
1078
|
-
function ownKeys$9(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1079
|
-
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__default["default"](_context = ownKeys$9(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$9(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
1080
1076
|
const Upload = () => {
|
|
1081
1077
|
const _useImportResourcesCo = useImportResourcesContext(),
|
|
1082
1078
|
state = _useImportResourcesCo.state,
|
|
1083
|
-
onClose = _useImportResourcesCo.onClose
|
|
1079
|
+
onClose = _useImportResourcesCo.onClose,
|
|
1080
|
+
resourceTypes = _useImportResourcesCo.resourceTypes;
|
|
1084
1081
|
const intl = reactIntl.useIntl();
|
|
1085
|
-
const resourceTypePlural = resourceTypeToDisplayName({
|
|
1082
|
+
const resourceTypePlural = resourceTypeToDisplayName$1({
|
|
1086
1083
|
resourceType: state.resourceType,
|
|
1087
1084
|
isPlural: true
|
|
1088
1085
|
});
|
|
1089
1086
|
const _useUpload = useUpload(),
|
|
1090
1087
|
handleUploadAndValidation = _useUpload.handleUploadAndValidation;
|
|
1091
|
-
const
|
|
1092
|
-
const documentationLink = RESOURCE_TYPE_DOCUMENTATION_LINKS[state.resourceType];
|
|
1088
|
+
const isMultipleResourceTypes = resourceTypes.length > 1;
|
|
1093
1089
|
return jsxRuntime.jsx(applicationComponents.FormDialog, {
|
|
1094
1090
|
size: 16,
|
|
1095
1091
|
isOpen: true,
|
|
@@ -1107,31 +1103,30 @@ const Upload = () => {
|
|
|
1107
1103
|
}),
|
|
1108
1104
|
children: jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
1109
1105
|
scale: "l",
|
|
1110
|
-
children: [jsxRuntime.
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
}), jsxRuntime.jsx(FileDropArea, {})]
|
|
1106
|
+
children: [isMultipleResourceTypes ? jsxRuntime.jsxs(uiKit.Grid, {
|
|
1107
|
+
gridRowGap: uiKit.designTokens.spacingL,
|
|
1108
|
+
gridTemplateColumns: `calc(${uiKit.designTokens.constraint3} + ${uiKit.designTokens.spacingL}) auto`,
|
|
1109
|
+
children: [jsxRuntime.jsx(uiKit.Grid.Item, {
|
|
1110
|
+
children: jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1111
|
+
isBold: true,
|
|
1112
|
+
intlMessage: messages$4.dataType
|
|
1113
|
+
})
|
|
1114
|
+
}), jsxRuntime.jsx(uiKit.Grid.Item, {
|
|
1115
|
+
children: jsxRuntime.jsx(ResourceTypeSelection, {})
|
|
1116
|
+
}), jsxRuntime.jsx(uiKit.Grid.Item, {
|
|
1117
|
+
children: jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1118
|
+
isBold: true,
|
|
1119
|
+
intlMessage: messages$4.instructions
|
|
1120
|
+
})
|
|
1121
|
+
}), jsxRuntime.jsx(uiKit.Grid.Item, {
|
|
1122
|
+
children: jsxRuntime.jsx(Instructions, {})
|
|
1123
|
+
})]
|
|
1124
|
+
}) : jsxRuntime.jsx(Instructions, {}), jsxRuntime.jsx(FileDropArea, {})]
|
|
1130
1125
|
})
|
|
1131
1126
|
});
|
|
1132
1127
|
};
|
|
1133
1128
|
|
|
1134
|
-
var messages$
|
|
1129
|
+
var messages$3 = reactIntl.defineMessages({
|
|
1135
1130
|
startImportButton: {
|
|
1136
1131
|
id: 'ImportResourcesModal.startImportButton',
|
|
1137
1132
|
description: 'Label for the modal Start import button',
|
|
@@ -1209,8 +1204,8 @@ var messages$1 = reactIntl.defineMessages({
|
|
|
1209
1204
|
}
|
|
1210
1205
|
});
|
|
1211
1206
|
|
|
1212
|
-
function ownKeys$
|
|
1213
|
-
function _objectSpread$
|
|
1207
|
+
function ownKeys$9(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1208
|
+
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__default["default"](_context = ownKeys$9(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$9(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
1214
1209
|
const truncate = (isExpanded, columns, columnsCount) => {
|
|
1215
1210
|
return isExpanded ? columns.join(' | ') : _sliceInstanceProperty__default["default"](columns).call(columns, 0, columnsCount).join(' | ') + (columns.length > columnsCount ? '...' : '');
|
|
1216
1211
|
};
|
|
@@ -1236,7 +1231,7 @@ const ColumnList = props => {
|
|
|
1236
1231
|
e.preventDefault();
|
|
1237
1232
|
setIsExpanded(!isExpanded);
|
|
1238
1233
|
},
|
|
1239
|
-
children: isExpanded ? jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$
|
|
1234
|
+
children: isExpanded ? jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$9({}, messages$3.showLess)) : jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$9({}, messages$3.showMore))
|
|
1240
1235
|
})
|
|
1241
1236
|
})]
|
|
1242
1237
|
})
|
|
@@ -1244,8 +1239,8 @@ const ColumnList = props => {
|
|
|
1244
1239
|
});
|
|
1245
1240
|
};
|
|
1246
1241
|
|
|
1247
|
-
function ownKeys$
|
|
1248
|
-
function _objectSpread$
|
|
1242
|
+
function ownKeys$8(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1243
|
+
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__default["default"](_context = ownKeys$8(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$8(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
1249
1244
|
function UploadPreviewModal() {
|
|
1250
1245
|
const _useImportResourcesCo = useImportResourcesContext(),
|
|
1251
1246
|
state = _useImportResourcesCo.state;
|
|
@@ -1262,7 +1257,7 @@ function UploadPreviewModal() {
|
|
|
1262
1257
|
title: intl.formatMessage(sharedMessages.modalTitle, {
|
|
1263
1258
|
resourceType: state.resourceType
|
|
1264
1259
|
}),
|
|
1265
|
-
labelPrimary: intl.formatMessage(messages$
|
|
1260
|
+
labelPrimary: intl.formatMessage(messages$3.continue),
|
|
1266
1261
|
onSecondaryButtonClick: () => onClose({
|
|
1267
1262
|
shouldDeleteImportContainer: true
|
|
1268
1263
|
}),
|
|
@@ -1280,7 +1275,7 @@ function UploadPreviewModal() {
|
|
|
1280
1275
|
children: jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
1281
1276
|
scale: "m",
|
|
1282
1277
|
children: [jsxRuntime.jsx("div", {}), jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1283
|
-
intlMessage: messages$
|
|
1278
|
+
intlMessage: messages$3.previewOfYourImport
|
|
1284
1279
|
}), jsxRuntime.jsx(uiKit.Card, {
|
|
1285
1280
|
insetScale: "xl",
|
|
1286
1281
|
children: jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
@@ -1290,7 +1285,7 @@ function UploadPreviewModal() {
|
|
|
1290
1285
|
children: [jsxRuntime.jsx(uiKit.CheckBoldIcon, {
|
|
1291
1286
|
color: "success"
|
|
1292
1287
|
}), jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1293
|
-
intlMessage: _objectSpread$
|
|
1288
|
+
intlMessage: _objectSpread$8(_objectSpread$8({}, messages$3.rowsToBeImported), {}, {
|
|
1294
1289
|
values: {
|
|
1295
1290
|
rowCount: intl.formatNumber(state.uploadFileResponse.rowsCount),
|
|
1296
1291
|
b: getBold$3
|
|
@@ -1302,7 +1297,7 @@ function UploadPreviewModal() {
|
|
|
1302
1297
|
children: [jsxRuntime.jsx(uiKit.CheckBoldIcon, {
|
|
1303
1298
|
color: "success"
|
|
1304
1299
|
}), jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1305
|
-
intlMessage: _objectSpread$
|
|
1300
|
+
intlMessage: _objectSpread$8(_objectSpread$8({}, messages$3.columnsToBeImported), {}, {
|
|
1306
1301
|
values: {
|
|
1307
1302
|
columnCount: intl.formatNumber(validatedColumns.length),
|
|
1308
1303
|
b: getBold$3
|
|
@@ -1322,7 +1317,7 @@ function UploadPreviewModal() {
|
|
|
1322
1317
|
children: [jsxRuntime.jsx(uiKit.EyeCrossedIcon, {
|
|
1323
1318
|
color: "neutral60"
|
|
1324
1319
|
}), jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1325
|
-
intlMessage: _objectSpread$
|
|
1320
|
+
intlMessage: _objectSpread$8(_objectSpread$8({}, messages$3.columnsToBeIgnored), {}, {
|
|
1326
1321
|
values: {
|
|
1327
1322
|
columnCount: intl.formatNumber(ignoredColumns.length),
|
|
1328
1323
|
b: getBold$3
|
|
@@ -1348,33 +1343,29 @@ function getBold$3(msg) {
|
|
|
1348
1343
|
});
|
|
1349
1344
|
}
|
|
1350
1345
|
|
|
1351
|
-
function ownKeys$
|
|
1352
|
-
function _objectSpread$
|
|
1346
|
+
function ownKeys$7(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1347
|
+
function _objectSpread$7(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$7(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$7(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
1353
1348
|
const getNewLine = () => jsxRuntime.jsx("br", {});
|
|
1354
1349
|
const getImportLogsLink = (msg, projectKey) => jsxRuntime.jsx(uiKit.Link, {
|
|
1355
|
-
to:
|
|
1350
|
+
to: `/${projectKey}/operations/import/logs`,
|
|
1356
1351
|
children: msg
|
|
1357
1352
|
});
|
|
1358
1353
|
const ImportConfirmationModal = () => {
|
|
1359
|
-
var _state$uploadFileResp;
|
|
1360
1354
|
const intl = reactIntl.useIntl();
|
|
1361
1355
|
const _useImportResourcesCo = useImportResourcesContext(),
|
|
1362
1356
|
state = _useImportResourcesCo.state,
|
|
1363
1357
|
onStartImportSuccess = _useImportResourcesCo.onStartImportSuccess,
|
|
1364
1358
|
onClose = _useImportResourcesCo.onClose;
|
|
1365
|
-
const _useApplicationContex = applicationShellConnectors.useApplicationContext(context => {
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
projectName: (_context$project2 = context.project) === null || _context$project2 === void 0 ? void 0 : _context$project2.name
|
|
1370
|
-
};
|
|
1371
|
-
}),
|
|
1359
|
+
const _useApplicationContex = applicationShellConnectors.useApplicationContext(context => ({
|
|
1360
|
+
projectKey: context.project?.key,
|
|
1361
|
+
projectName: context.project?.name
|
|
1362
|
+
})),
|
|
1372
1363
|
projectKey = _useApplicationContex.projectKey,
|
|
1373
1364
|
projectName = _useApplicationContex.projectName;
|
|
1374
1365
|
const asyncDispatch = sdk.useAsyncDispatch();
|
|
1375
1366
|
const showNotification = actionsGlobal.useShowNotification();
|
|
1376
1367
|
const ImportRunningTextNotification = () => jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1377
|
-
intlMessage: _objectSpread$
|
|
1368
|
+
intlMessage: _objectSpread$7(_objectSpread$7({}, messages$3.uploadNotificationSuccessMessage), {}, {
|
|
1378
1369
|
values: {
|
|
1379
1370
|
newline: getNewLine,
|
|
1380
1371
|
logsLink: msg => getImportLogsLink(msg, projectKey),
|
|
@@ -1384,12 +1375,12 @@ const ImportConfirmationModal = () => {
|
|
|
1384
1375
|
});
|
|
1385
1376
|
return jsxRuntime.jsx(applicationComponents.ConfirmationDialog, {
|
|
1386
1377
|
title: intl.formatMessage(sharedMessages.modalTitle, {
|
|
1387
|
-
resourceType: resourceTypeToDisplayName({
|
|
1378
|
+
resourceType: resourceTypeToDisplayName$1({
|
|
1388
1379
|
resourceType: state.resourceType,
|
|
1389
1380
|
isPlural: true
|
|
1390
1381
|
})
|
|
1391
1382
|
}),
|
|
1392
|
-
labelPrimary: intl.formatMessage(messages$
|
|
1383
|
+
labelPrimary: intl.formatMessage(messages$3.startImportButton),
|
|
1393
1384
|
isOpen: true,
|
|
1394
1385
|
onClose: () => onClose({
|
|
1395
1386
|
shouldDeleteImportContainer: true
|
|
@@ -1405,8 +1396,7 @@ const ImportConfirmationModal = () => {
|
|
|
1405
1396
|
},
|
|
1406
1397
|
onConfirm: async () => {
|
|
1407
1398
|
try {
|
|
1408
|
-
|
|
1409
|
-
const canConfirm = projectKey && state.containerKey && ((_state$droppedFile = state.droppedFile) === null || _state$droppedFile === void 0 ? void 0 : _state$droppedFile.name) && state.resourceType;
|
|
1399
|
+
const canConfirm = projectKey && state.containerKey && state.droppedFile?.name && state.resourceType;
|
|
1410
1400
|
if (!canConfirm) return;
|
|
1411
1401
|
onClose();
|
|
1412
1402
|
await processUploadedFile({
|
|
@@ -1440,18 +1430,18 @@ const ImportConfirmationModal = () => {
|
|
|
1440
1430
|
scale: "xl",
|
|
1441
1431
|
children: [jsxRuntime.jsxs("div", {
|
|
1442
1432
|
children: [jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1443
|
-
intlMessage: _objectSpread$
|
|
1433
|
+
intlMessage: _objectSpread$7(_objectSpread$7({}, messages$3.confirmationBodyText), {}, {
|
|
1444
1434
|
values: {
|
|
1445
1435
|
projectName: projectName,
|
|
1446
|
-
count: intl.formatNumber(
|
|
1436
|
+
count: intl.formatNumber(state?.uploadFileResponse?.rowsCount || 0),
|
|
1447
1437
|
bold: getBold$2
|
|
1448
1438
|
}
|
|
1449
1439
|
})
|
|
1450
1440
|
}), jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1451
|
-
intlMessage: messages$
|
|
1441
|
+
intlMessage: messages$3.confirmationBodyNote
|
|
1452
1442
|
})]
|
|
1453
1443
|
}), jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1454
|
-
intlMessage: messages$
|
|
1444
|
+
intlMessage: messages$3.confirmationBodyQuestion
|
|
1455
1445
|
})]
|
|
1456
1446
|
})
|
|
1457
1447
|
});
|
|
@@ -1464,7 +1454,7 @@ function getBold$2(msg) {
|
|
|
1464
1454
|
});
|
|
1465
1455
|
}
|
|
1466
1456
|
|
|
1467
|
-
var messages = reactIntl.defineMessages({
|
|
1457
|
+
var messages$2 = reactIntl.defineMessages({
|
|
1468
1458
|
row: {
|
|
1469
1459
|
id: 'ImportResourcesModal.row',
|
|
1470
1460
|
description: 'In Upload file error modal - "Row" column',
|
|
@@ -1497,15 +1487,15 @@ var messages = reactIntl.defineMessages({
|
|
|
1497
1487
|
}
|
|
1498
1488
|
});
|
|
1499
1489
|
|
|
1500
|
-
function ownKeys$
|
|
1501
|
-
function _objectSpread$
|
|
1490
|
+
function ownKeys$6(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1491
|
+
function _objectSpread$6(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context2 = ownKeys$6(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context3 = ownKeys$6(Object(t))).call(_context3, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
1502
1492
|
const getColumns$1 = () => [{
|
|
1503
1493
|
key: 'errorType',
|
|
1504
|
-
label: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$
|
|
1494
|
+
label: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$6({}, messages$2.errorType)),
|
|
1505
1495
|
width: 'max-content'
|
|
1506
1496
|
}, {
|
|
1507
1497
|
key: 'details',
|
|
1508
|
-
label: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$
|
|
1498
|
+
label: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$6({}, messages$2.details))
|
|
1509
1499
|
}];
|
|
1510
1500
|
const UploadClientSideErrorTable = props => {
|
|
1511
1501
|
var _context;
|
|
@@ -1548,10 +1538,9 @@ function itemRenderer$1(item, column) {
|
|
|
1548
1538
|
}
|
|
1549
1539
|
}
|
|
1550
1540
|
|
|
1551
|
-
function ownKeys$
|
|
1552
|
-
function _objectSpread$
|
|
1541
|
+
function ownKeys$5(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1542
|
+
function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$5(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$5(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
1553
1543
|
const UploadClientSideErrorsModal = () => {
|
|
1554
|
-
var _state$droppedFile;
|
|
1555
1544
|
const intl = reactIntl.useIntl();
|
|
1556
1545
|
const _useImportResourcesCo = useImportResourcesContext(),
|
|
1557
1546
|
state = _useImportResourcesCo.state,
|
|
@@ -1562,7 +1551,7 @@ const UploadClientSideErrorsModal = () => {
|
|
|
1562
1551
|
size: 16,
|
|
1563
1552
|
isOpen: true,
|
|
1564
1553
|
title: intl.formatMessage(sharedMessages.modalTitle, {
|
|
1565
|
-
resourceType: resourceTypeToDisplayName({
|
|
1554
|
+
resourceType: resourceTypeToDisplayName$1({
|
|
1566
1555
|
resourceType: state.resourceType,
|
|
1567
1556
|
isPlural: true
|
|
1568
1557
|
})
|
|
@@ -1571,9 +1560,9 @@ const UploadClientSideErrorsModal = () => {
|
|
|
1571
1560
|
children: jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
1572
1561
|
scale: "l",
|
|
1573
1562
|
children: [jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1574
|
-
intlMessage: _objectSpread$
|
|
1563
|
+
intlMessage: _objectSpread$5(_objectSpread$5({}, messages$2.uploadingError), {}, {
|
|
1575
1564
|
values: {
|
|
1576
|
-
fileName:
|
|
1565
|
+
fileName: state.droppedFile?.name,
|
|
1577
1566
|
errorsCount: intl.formatNumber(errorsCount),
|
|
1578
1567
|
b: getBold$1
|
|
1579
1568
|
}
|
|
@@ -1588,7 +1577,7 @@ const UploadClientSideErrorsModal = () => {
|
|
|
1588
1577
|
onClick: () => onClose()
|
|
1589
1578
|
}), jsxRuntime.jsx(uiKit.PrimaryButton, {
|
|
1590
1579
|
iconLeft: jsxRuntime.jsx(uiKit.ImportIcon, {}),
|
|
1591
|
-
label: intl.formatMessage(messages.uploadNewFile),
|
|
1580
|
+
label: intl.formatMessage(messages$2.uploadNewFile),
|
|
1592
1581
|
onClick: () => actions.uploadNewFile()
|
|
1593
1582
|
})]
|
|
1594
1583
|
})]
|
|
@@ -1603,19 +1592,19 @@ function getBold$1(msg) {
|
|
|
1603
1592
|
});
|
|
1604
1593
|
}
|
|
1605
1594
|
|
|
1606
|
-
function ownKeys$
|
|
1607
|
-
function _objectSpread$
|
|
1595
|
+
function ownKeys$4(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1596
|
+
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__default["default"](_context2 = ownKeys$4(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context3 = ownKeys$4(Object(t))).call(_context3, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
1608
1597
|
const getColumns = () => [{
|
|
1609
1598
|
key: 'row',
|
|
1610
|
-
label: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$
|
|
1599
|
+
label: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$4({}, messages$2.row)),
|
|
1611
1600
|
width: 'max-content'
|
|
1612
1601
|
}, {
|
|
1613
1602
|
key: 'errorType',
|
|
1614
|
-
label: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$
|
|
1603
|
+
label: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$4({}, messages$2.errorType)),
|
|
1615
1604
|
width: 'max-content'
|
|
1616
1605
|
}, {
|
|
1617
1606
|
key: 'details',
|
|
1618
|
-
label: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$
|
|
1607
|
+
label: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$4({}, messages$2.details))
|
|
1619
1608
|
}];
|
|
1620
1609
|
const UploadServerSideErrorTable = props => {
|
|
1621
1610
|
var _context;
|
|
@@ -1666,22 +1655,21 @@ function itemRenderer(item, column) {
|
|
|
1666
1655
|
}
|
|
1667
1656
|
}
|
|
1668
1657
|
|
|
1669
|
-
function ownKeys$
|
|
1670
|
-
function _objectSpread$
|
|
1658
|
+
function ownKeys$3(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1659
|
+
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__default["default"](_context = ownKeys$3(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$3(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
1671
1660
|
const UploadServerSideErrorsModal = () => {
|
|
1672
|
-
var _state$uploadFileResp, _state$droppedFile, _state$uploadFileResp2;
|
|
1673
1661
|
const intl = reactIntl.useIntl();
|
|
1674
1662
|
const _useImportResourcesCo = useImportResourcesContext(),
|
|
1675
1663
|
state = _useImportResourcesCo.state,
|
|
1676
1664
|
actions = _useImportResourcesCo.actions,
|
|
1677
1665
|
onClose = _useImportResourcesCo.onClose;
|
|
1678
|
-
const errorsCount = getFileUploadErrorsCount(
|
|
1666
|
+
const errorsCount = getFileUploadErrorsCount(state.uploadFileResponse?.results);
|
|
1679
1667
|
const documentationLink = RESOURCE_TYPE_DOCUMENTATION_LINKS[state.resourceType];
|
|
1680
1668
|
return jsxRuntime.jsx(applicationComponents.InfoDialog, {
|
|
1681
1669
|
size: 16,
|
|
1682
1670
|
isOpen: true,
|
|
1683
1671
|
title: intl.formatMessage(sharedMessages.modalTitle, {
|
|
1684
|
-
resourceType: resourceTypeToDisplayName({
|
|
1672
|
+
resourceType: resourceTypeToDisplayName$1({
|
|
1685
1673
|
resourceType: state.resourceType,
|
|
1686
1674
|
isPlural: true
|
|
1687
1675
|
})
|
|
@@ -1692,15 +1680,15 @@ const UploadServerSideErrorsModal = () => {
|
|
|
1692
1680
|
children: [jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
1693
1681
|
scale: "xs",
|
|
1694
1682
|
children: [jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1695
|
-
intlMessage: _objectSpread$
|
|
1683
|
+
intlMessage: _objectSpread$3(_objectSpread$3({}, messages$2.uploadingError), {}, {
|
|
1696
1684
|
values: {
|
|
1697
|
-
fileName:
|
|
1685
|
+
fileName: state.droppedFile?.name,
|
|
1698
1686
|
errorsCount: intl.formatNumber(errorsCount),
|
|
1699
1687
|
b: getBold
|
|
1700
1688
|
}
|
|
1701
1689
|
})
|
|
1702
1690
|
}), jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1703
|
-
intlMessage: _objectSpread$
|
|
1691
|
+
intlMessage: _objectSpread$3(_objectSpread$3({}, messages$2.supportedValuesDocumentation), {}, {
|
|
1704
1692
|
values: {
|
|
1705
1693
|
documentationLink: msg => jsxRuntime.jsx(uiKit.Link, {
|
|
1706
1694
|
tone: "secondary",
|
|
@@ -1712,7 +1700,7 @@ const UploadServerSideErrorsModal = () => {
|
|
|
1712
1700
|
})
|
|
1713
1701
|
})]
|
|
1714
1702
|
}), jsxRuntime.jsx(UploadServerSideErrorTable, {
|
|
1715
|
-
rows: mapUploadFileErrorsResponseToUploadFileErrorRows(
|
|
1703
|
+
rows: mapUploadFileErrorsResponseToUploadFileErrorRows(state.uploadFileResponse?.results)
|
|
1716
1704
|
}), jsxRuntime.jsxs(uiKit.Spacings.Inline, {
|
|
1717
1705
|
scale: "m",
|
|
1718
1706
|
justifyContent: "flex-end",
|
|
@@ -1721,7 +1709,7 @@ const UploadServerSideErrorsModal = () => {
|
|
|
1721
1709
|
onClick: () => onClose()
|
|
1722
1710
|
}), jsxRuntime.jsx(uiKit.PrimaryButton, {
|
|
1723
1711
|
iconLeft: jsxRuntime.jsx(uiKit.ImportIcon, {}),
|
|
1724
|
-
label: intl.formatMessage(messages.uploadNewFile),
|
|
1712
|
+
label: intl.formatMessage(messages$2.uploadNewFile),
|
|
1725
1713
|
onClick: () => actions.uploadNewFile()
|
|
1726
1714
|
})]
|
|
1727
1715
|
})]
|
|
@@ -1737,18 +1725,17 @@ function getBold(msg) {
|
|
|
1737
1725
|
}
|
|
1738
1726
|
|
|
1739
1727
|
const UploadResult = () => {
|
|
1740
|
-
var _state$uploadFileResp;
|
|
1741
1728
|
const _useImportResourcesCo = useImportResourcesContext(),
|
|
1742
1729
|
state = _useImportResourcesCo.state;
|
|
1743
1730
|
if (state.fileUploadClientSideErrors.length > 0) return jsxRuntime.jsx(UploadClientSideErrorsModal, {});
|
|
1744
|
-
if (
|
|
1731
|
+
if (state.uploadFileResponse?.invalid > 0) return jsxRuntime.jsx(UploadServerSideErrorsModal, {});
|
|
1745
1732
|
return jsxRuntime.jsx(UploadPreviewModal, {});
|
|
1746
1733
|
};
|
|
1747
1734
|
|
|
1748
|
-
function ownKeys$
|
|
1749
|
-
function _objectSpread$
|
|
1735
|
+
function ownKeys$2(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1736
|
+
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__default["default"](_context = ownKeys$2(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$2(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
1750
1737
|
var FileIcon = function FileIcon(props) {
|
|
1751
|
-
return jsxRuntime.jsxs("svg", _objectSpread$
|
|
1738
|
+
return jsxRuntime.jsxs("svg", _objectSpread$2(_objectSpread$2({}, props), {}, {
|
|
1752
1739
|
children: [jsxRuntime.jsx("mask", {
|
|
1753
1740
|
id: "a",
|
|
1754
1741
|
style: {
|
|
@@ -1779,17 +1766,16 @@ FileIcon.defaultProps = {
|
|
|
1779
1766
|
xmlns: "http://www.w3.org/2000/svg"
|
|
1780
1767
|
};
|
|
1781
1768
|
const Uploading = () => {
|
|
1782
|
-
var _state$droppedFile;
|
|
1783
1769
|
const intl = reactIntl.useIntl();
|
|
1784
1770
|
const _useImportResourcesCo = useImportResourcesContext(),
|
|
1785
1771
|
state = _useImportResourcesCo.state,
|
|
1786
1772
|
actions = _useImportResourcesCo.actions,
|
|
1787
1773
|
onClose = _useImportResourcesCo.onClose;
|
|
1788
|
-
const resourceTypePlural = resourceTypeToDisplayName({
|
|
1774
|
+
const resourceTypePlural = resourceTypeToDisplayName$1({
|
|
1789
1775
|
resourceType: state.resourceType,
|
|
1790
1776
|
isPlural: true
|
|
1791
1777
|
});
|
|
1792
|
-
if (
|
|
1778
|
+
if (state.droppedFile?.name) return jsxRuntime.jsx(applicationComponents.InfoDialog, {
|
|
1793
1779
|
size: 16,
|
|
1794
1780
|
isOpen: true,
|
|
1795
1781
|
title: intl.formatMessage(sharedMessages.modalTitle, {
|
|
@@ -1849,6 +1835,97 @@ const CurrentStep = () => {
|
|
|
1849
1835
|
return steps[state.currentStep] || null;
|
|
1850
1836
|
};
|
|
1851
1837
|
|
|
1838
|
+
var messages$1 = reactIntl.defineMessages({
|
|
1839
|
+
products: {
|
|
1840
|
+
id: 'ImportResourcesModal.radio.products',
|
|
1841
|
+
description: 'Label for the products radio button',
|
|
1842
|
+
defaultMessage: 'Products (including variants, assets, prices and images)'
|
|
1843
|
+
},
|
|
1844
|
+
inventories: {
|
|
1845
|
+
id: 'ImportResourcesModal.radio.inventories',
|
|
1846
|
+
description: 'Label for the inventories radio button',
|
|
1847
|
+
defaultMessage: 'Inventories'
|
|
1848
|
+
},
|
|
1849
|
+
categories: {
|
|
1850
|
+
id: 'ImportResourcesModal.radio.categories',
|
|
1851
|
+
description: 'Label for the categories radio button',
|
|
1852
|
+
defaultMessage: 'Categories'
|
|
1853
|
+
}
|
|
1854
|
+
});
|
|
1855
|
+
|
|
1856
|
+
const resourceTypeToDisplayName = resourceType => {
|
|
1857
|
+
switch (resourceType) {
|
|
1858
|
+
case 'product':
|
|
1859
|
+
return messages$1.products;
|
|
1860
|
+
case 'inventory':
|
|
1861
|
+
return messages$1.inventories;
|
|
1862
|
+
case 'category':
|
|
1863
|
+
return messages$1.categories;
|
|
1864
|
+
default:
|
|
1865
|
+
throw new Error(`Unknown resource type: ${resourceType}`);
|
|
1866
|
+
}
|
|
1867
|
+
};
|
|
1868
|
+
const ResourceTypeSelection = () => {
|
|
1869
|
+
const _useImportResourcesCo = useImportResourcesContext(),
|
|
1870
|
+
state = _useImportResourcesCo.state,
|
|
1871
|
+
actions = _useImportResourcesCo.actions,
|
|
1872
|
+
resourceTypes = _useImportResourcesCo.resourceTypes;
|
|
1873
|
+
return jsxRuntime.jsx(uiKit.RadioInput.Group, {
|
|
1874
|
+
value: state.resourceType,
|
|
1875
|
+
onChange: e => {
|
|
1876
|
+
actions.setResourceType(e.target.value);
|
|
1877
|
+
},
|
|
1878
|
+
direction: "stack",
|
|
1879
|
+
directionProps: {
|
|
1880
|
+
scale: 's'
|
|
1881
|
+
},
|
|
1882
|
+
children: _mapInstanceProperty__default["default"](resourceTypes).call(resourceTypes, resourceType => jsxRuntime.jsx(uiKit.RadioInput.Option, {
|
|
1883
|
+
value: resourceType,
|
|
1884
|
+
children: jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1885
|
+
intlMessage: resourceTypeToDisplayName(resourceType)
|
|
1886
|
+
})
|
|
1887
|
+
}, resourceType))
|
|
1888
|
+
});
|
|
1889
|
+
};
|
|
1890
|
+
|
|
1891
|
+
var messages = reactIntl.defineMessages({
|
|
1892
|
+
fileUploadInstructions: {
|
|
1893
|
+
id: 'ImportResourcesModal.fileUploadInstructions',
|
|
1894
|
+
description: 'Label for the modal category description',
|
|
1895
|
+
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>.'
|
|
1896
|
+
}
|
|
1897
|
+
});
|
|
1898
|
+
|
|
1899
|
+
function ownKeys$1(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1900
|
+
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__default["default"](_context = ownKeys$1(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$1(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
1901
|
+
const Instructions = () => {
|
|
1902
|
+
const intl = reactIntl.useIntl();
|
|
1903
|
+
const _useImportResourcesCo = useImportResourcesContext(),
|
|
1904
|
+
state = _useImportResourcesCo.state;
|
|
1905
|
+
const templateLink = RESOURCE_TYPE_TEMPLATE_DOWNLOAD_LINKS[state.resourceType];
|
|
1906
|
+
const documentationLink = RESOURCE_TYPE_DOCUMENTATION_LINKS[state.resourceType];
|
|
1907
|
+
return jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1908
|
+
intlMessage: _objectSpread$1(_objectSpread$1({}, messages.fileUploadInstructions), {}, {
|
|
1909
|
+
values: {
|
|
1910
|
+
fileSize: intl.formatNumber(FILE_SIZE_LIMITS_MB[state.resourceType]),
|
|
1911
|
+
rowLimit: intl.formatNumber(ROW_LIMITS[state.resourceType]),
|
|
1912
|
+
csvTemplateLink: msg => jsxRuntime.jsx(uiKit.Link, {
|
|
1913
|
+
tone: "secondary",
|
|
1914
|
+
isExternal: true,
|
|
1915
|
+
to: templateLink,
|
|
1916
|
+
children: msg
|
|
1917
|
+
}),
|
|
1918
|
+
documentationLink: msg => jsxRuntime.jsx(uiKit.Link, {
|
|
1919
|
+
tone: "secondary",
|
|
1920
|
+
isExternal: true,
|
|
1921
|
+
to: documentationLink,
|
|
1922
|
+
children: msg
|
|
1923
|
+
})
|
|
1924
|
+
}
|
|
1925
|
+
})
|
|
1926
|
+
});
|
|
1927
|
+
};
|
|
1928
|
+
|
|
1852
1929
|
const getChunkImport = locale => {
|
|
1853
1930
|
const intlLocale = i18n.mapLocaleToIntlLocale(locale);
|
|
1854
1931
|
switch (intlLocale) {
|
|
@@ -1874,8 +1951,8 @@ const loadMessages = async locale => {
|
|
|
1874
1951
|
return i18n.parseChunkImport(chunkImport);
|
|
1875
1952
|
} catch (error) {
|
|
1876
1953
|
// eslint-disable-next-line no-console
|
|
1877
|
-
console.warn(
|
|
1878
|
-
sentry.reportErrorToSentry(new Error(
|
|
1954
|
+
console.warn(`Something went wrong while loading the import-resources-modal messages for ${locale}`, error);
|
|
1955
|
+
sentry.reportErrorToSentry(new Error(`Something went wrong while loading the import-resources-modal messages for ${locale}`), {
|
|
1879
1956
|
extra: error
|
|
1880
1957
|
});
|
|
1881
1958
|
return {};
|
|
@@ -1918,14 +1995,23 @@ const useAsyncIntlMessages = (locale, loader) => {
|
|
|
1918
1995
|
};
|
|
1919
1996
|
|
|
1920
1997
|
function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1921
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
1998
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(t))).call(_context3, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
1922
1999
|
const ImportResourcesModal = props => {
|
|
2000
|
+
var _context;
|
|
1923
2001
|
const _useApplicationContex = applicationShellConnectors.useApplicationContext(context => ({
|
|
1924
2002
|
locale: context.user && context.user.locale
|
|
1925
2003
|
})),
|
|
1926
2004
|
locale = _useApplicationContex.locale;
|
|
1927
2005
|
const messages = useAsyncIntlMessages(locale, loadMessages);
|
|
1928
2006
|
if (!props.isOpen || messages.isLoading) return null;
|
|
2007
|
+
if (!props.resourceTypes?.length) {
|
|
2008
|
+
console.error('No resource types provided for import resources modal');
|
|
2009
|
+
return null;
|
|
2010
|
+
}
|
|
2011
|
+
if (!_everyInstanceProperty__default["default"](_context = props.resourceTypes).call(_context, isResourceType)) {
|
|
2012
|
+
console.error('Invalid resource types provided for import resources modal');
|
|
2013
|
+
return null;
|
|
2014
|
+
}
|
|
1929
2015
|
return jsxRuntime.jsx(reactIntl.IntlProvider, {
|
|
1930
2016
|
locale: locale,
|
|
1931
2017
|
messages: messages.messages,
|
|
@@ -1939,5 +2025,5 @@ ImportResourcesModal.displayName = 'ImportResourcesModal';
|
|
|
1939
2025
|
exports.EnabledDropArea = EnabledDropArea;
|
|
1940
2026
|
exports.FileDropped = FileDropped;
|
|
1941
2027
|
exports.ImportResourcesModal = ImportResourcesModal;
|
|
1942
|
-
exports.messages = messages$
|
|
2028
|
+
exports.messages = messages$4;
|
|
1943
2029
|
exports.useImportResourcesContext = useImportResourcesContext;
|