@commercetools-frontend-extensions/import-resources-modal 1.2.4 → 1.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{active-drag-drop-area-52119833.cjs.dev.js → active-drag-drop-area-1e3ee12d.cjs.prod.js} +12 -13
- package/dist/{active-drag-drop-area-89f8264c.cjs.prod.js → active-drag-drop-area-bd312745.cjs.dev.js} +12 -13
- package/dist/{active-drag-drop-area-0096403f.esm.js → active-drag-drop-area-d640b658.esm.js} +12 -13
- package/dist/commercetools-frontend-extensions-import-resources-modal.cjs.dev.js +12 -13
- package/dist/commercetools-frontend-extensions-import-resources-modal.cjs.prod.js +12 -13
- package/dist/commercetools-frontend-extensions-import-resources-modal.esm.js +12 -13
- package/dist/{enabled-drop-area-cd1ff191.cjs.dev.js → enabled-drop-area-14e5f889.cjs.dev.js} +12 -13
- package/dist/{enabled-drop-area-8a60a954.esm.js → enabled-drop-area-de4a5ab0.esm.js} +12 -13
- package/dist/{enabled-drop-area-77836aae.cjs.prod.js → enabled-drop-area-fbf01f88.cjs.prod.js} +12 -13
- package/dist/{file-dropped-area-29daabcd.esm.js → file-dropped-area-8d434988.esm.js} +17 -19
- package/dist/{file-dropped-area-922d238a.cjs.dev.js → file-dropped-area-90b9f712.cjs.prod.js} +17 -19
- package/dist/{file-dropped-area-47e83d97.cjs.prod.js → file-dropped-area-f0a939ac.cjs.dev.js} +17 -19
- package/dist/{index-4a4bda05.cjs.prod.js → index-23bf2043.cjs.prod.js} +712 -738
- package/dist/{index-0756fe60.cjs.dev.js → index-828897b3.cjs.dev.js} +716 -742
- package/dist/{index-8ce079d8.esm.js → index-c3c6d321.esm.js} +718 -743
- package/package.json +23 -23
|
@@ -16,7 +16,14 @@ var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
|
16
16
|
var React = require('react');
|
|
17
17
|
var sdk = require('@commercetools-frontend/sdk');
|
|
18
18
|
var constants = require('@commercetools-frontend/constants');
|
|
19
|
-
var
|
|
19
|
+
var applicationShell = require('@commercetools-frontend/application-shell');
|
|
20
|
+
var _Reflect$construct = require('@babel/runtime-corejs3/core-js-stable/reflect/construct');
|
|
21
|
+
var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
|
|
22
|
+
var _classCallCheck = require('@babel/runtime-corejs3/helpers/classCallCheck');
|
|
23
|
+
var _possibleConstructorReturn = require('@babel/runtime-corejs3/helpers/possibleConstructorReturn');
|
|
24
|
+
var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
|
|
25
|
+
var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
|
|
26
|
+
var _wrapNativeSuper = require('@babel/runtime-corejs3/helpers/wrapNativeSuper');
|
|
20
27
|
var pluralize = require('pluralize');
|
|
21
28
|
var _Promise = require('@babel/runtime-corejs3/core-js-stable/promise');
|
|
22
29
|
var _Array$isArray = require('@babel/runtime-corejs3/core-js-stable/array/is-array');
|
|
@@ -27,27 +34,19 @@ var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/i
|
|
|
27
34
|
var Papa = require('papaparse');
|
|
28
35
|
var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
|
|
29
36
|
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
37
|
require('@babel/runtime-corejs3/core-js-stable/instance/starts-with');
|
|
32
38
|
require('querystring');
|
|
33
39
|
require('ramda');
|
|
34
|
-
var applicationShell = require('@commercetools-frontend/application-shell');
|
|
35
|
-
var _Reflect$construct = require('@babel/runtime-corejs3/core-js-stable/reflect/construct');
|
|
36
|
-
var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
|
|
37
|
-
var _classCallCheck = require('@babel/runtime-corejs3/helpers/classCallCheck');
|
|
38
|
-
var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
|
|
39
|
-
var _possibleConstructorReturn = require('@babel/runtime-corejs3/helpers/possibleConstructorReturn');
|
|
40
|
-
var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
|
|
41
|
-
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 fullstory = require('@commercetools-frontend/fullstory');
|
|
45
43
|
var uiKit = require('@commercetools-frontend/ui-kit');
|
|
46
|
-
var
|
|
47
|
-
var sentry = require('@commercetools-frontend/sentry');
|
|
44
|
+
var _someInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/some');
|
|
48
45
|
var reactDropzone = require('react-dropzone');
|
|
46
|
+
var actionsGlobal = require('@commercetools-frontend/actions-global');
|
|
49
47
|
var _styled = require('@emotion/styled/base');
|
|
50
48
|
var react = require('@emotion/react');
|
|
49
|
+
var sentry = require('@commercetools-frontend/sentry');
|
|
51
50
|
var _sliceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/slice');
|
|
52
51
|
var DataTable = require('@commercetools-uikit/data-table');
|
|
53
52
|
var i18n = require('@commercetools-frontend/i18n');
|
|
@@ -64,7 +63,7 @@ var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$def
|
|
|
64
63
|
var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
|
|
65
64
|
var _everyInstanceProperty__default = /*#__PURE__*/_interopDefault(_everyInstanceProperty);
|
|
66
65
|
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
67
|
-
var
|
|
66
|
+
var _Reflect$construct__default = /*#__PURE__*/_interopDefault(_Reflect$construct);
|
|
68
67
|
var _Promise__default = /*#__PURE__*/_interopDefault(_Promise);
|
|
69
68
|
var _Array$isArray__default = /*#__PURE__*/_interopDefault(_Array$isArray);
|
|
70
69
|
var _flatMapInstanceProperty__default = /*#__PURE__*/_interopDefault(_flatMapInstanceProperty);
|
|
@@ -75,38 +74,183 @@ var Papa__default = /*#__PURE__*/_interopDefault(Papa);
|
|
|
75
74
|
var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInstanceProperty);
|
|
76
75
|
var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
|
|
77
76
|
var _someInstanceProperty__default = /*#__PURE__*/_interopDefault(_someInstanceProperty);
|
|
78
|
-
var _Reflect$construct__default = /*#__PURE__*/_interopDefault(_Reflect$construct);
|
|
79
77
|
var _styled__default = /*#__PURE__*/_interopDefault(_styled);
|
|
80
78
|
var _sliceInstanceProperty__default = /*#__PURE__*/_interopDefault(_sliceInstanceProperty);
|
|
81
79
|
var DataTable__default = /*#__PURE__*/_interopDefault(DataTable);
|
|
82
80
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
if (
|
|
94
|
-
|
|
81
|
+
function ownKeys$f(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; }
|
|
82
|
+
function _objectSpread$f(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$f(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$f(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
83
|
+
function reducer(state, action) {
|
|
84
|
+
if (action.type === 'setCurrentStep') return _objectSpread$f(_objectSpread$f({}, state), {}, {
|
|
85
|
+
currentStep: action.currentStep,
|
|
86
|
+
progress: 0
|
|
87
|
+
});
|
|
88
|
+
if (action.type === 'setUploadFileResponse') return _objectSpread$f(_objectSpread$f({}, state), {}, {
|
|
89
|
+
uploadFileResponse: action.uploadFileResponse
|
|
90
|
+
});
|
|
91
|
+
if (action.type === 'setResourceType') return _objectSpread$f(_objectSpread$f({}, state), {}, {
|
|
92
|
+
resourceType: action.resourceType
|
|
93
|
+
});
|
|
94
|
+
if (action.type === 'setContainerKey') return _objectSpread$f(_objectSpread$f({}, state), {}, {
|
|
95
|
+
containerKey: action.containerKey
|
|
96
|
+
});
|
|
97
|
+
if (action.type === 'cancelImport') return _objectSpread$f(_objectSpread$f({}, state), {}, {
|
|
98
|
+
currentStep: 1,
|
|
99
|
+
containerKey: undefined,
|
|
100
|
+
fileUploadClientSideErrors: [],
|
|
101
|
+
uploadFileResponse: undefined,
|
|
102
|
+
droppedFile: undefined,
|
|
103
|
+
dropAreaState: 'disabled',
|
|
104
|
+
progress: 0
|
|
105
|
+
});
|
|
106
|
+
if (action.type === 'uploadNewFile') return _objectSpread$f(_objectSpread$f({}, state), {}, {
|
|
107
|
+
currentStep: 1,
|
|
108
|
+
containerKey: undefined,
|
|
109
|
+
fileUploadClientSideErrors: [],
|
|
110
|
+
uploadFileResponse: undefined,
|
|
111
|
+
droppedFile: undefined,
|
|
112
|
+
dropAreaState: 'ready-for-drop',
|
|
113
|
+
progress: 0
|
|
114
|
+
});
|
|
115
|
+
if (action.type === 'setDroppedFile') {
|
|
116
|
+
return _objectSpread$f(_objectSpread$f({}, state), {}, {
|
|
117
|
+
droppedFile: action.droppedFile
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
if (action.type === 'setFileUploadClientSideErrors') {
|
|
121
|
+
return _objectSpread$f(_objectSpread$f({}, state), {}, {
|
|
122
|
+
fileUploadClientSideErrors: action.fileUploadClientSideErrors
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
if (action.type === 'setAbortController') {
|
|
126
|
+
return _objectSpread$f(_objectSpread$f({}, state), {}, {
|
|
127
|
+
abortController: action.abortController
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
if (action.type === 'setProgress') {
|
|
131
|
+
return _objectSpread$f(_objectSpread$f({}, state), {}, {
|
|
132
|
+
progress: action.progress
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
throw new Error(getUnknownActionError(action));
|
|
95
136
|
}
|
|
96
|
-
function
|
|
97
|
-
|
|
98
|
-
return false;
|
|
137
|
+
function getUnknownActionError(actionType) {
|
|
138
|
+
return `Unkown type: ${actionType}`;
|
|
99
139
|
}
|
|
140
|
+
const initialState = {
|
|
141
|
+
currentStep: 1,
|
|
142
|
+
abortController: new AbortController(),
|
|
143
|
+
dropAreaState: 'disabled',
|
|
144
|
+
uploadFileResponse: undefined,
|
|
145
|
+
fileUploadClientSideErrors: [],
|
|
146
|
+
resourceType: 'category',
|
|
147
|
+
containerKey: undefined,
|
|
148
|
+
progress: 0
|
|
149
|
+
};
|
|
100
150
|
|
|
101
|
-
|
|
102
|
-
function
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
151
|
+
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)); }
|
|
152
|
+
function _isNativeReflectConstruct$2() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$2 = function () { return !!t; })(); }
|
|
153
|
+
let MissingImportResourceProviderError = /*#__PURE__*/function (_Error) {
|
|
154
|
+
function MissingImportResourceProviderError() {
|
|
155
|
+
var _this;
|
|
156
|
+
_classCallCheck(this, MissingImportResourceProviderError);
|
|
157
|
+
_this = _callSuper$2(this, MissingImportResourceProviderError, ['useImportResourcesContext must be used within ImportResourcesProvider']);
|
|
158
|
+
_this.name = 'MissingImportResourceProviderError';
|
|
159
|
+
return _this;
|
|
160
|
+
}
|
|
161
|
+
_inherits(MissingImportResourceProviderError, _Error);
|
|
162
|
+
return _createClass(MissingImportResourceProviderError);
|
|
163
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
164
|
+
|
|
165
|
+
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)); }
|
|
166
|
+
function _isNativeReflectConstruct$1() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$1 = function () { return !!t; })(); }
|
|
167
|
+
let UnexpectedColumnError = /*#__PURE__*/function (_Error) {
|
|
168
|
+
function UnexpectedColumnError(columnName) {
|
|
169
|
+
var _this;
|
|
170
|
+
_classCallCheck(this, UnexpectedColumnError);
|
|
171
|
+
_this = _callSuper$1(this, UnexpectedColumnError, [`Unexpected column "${columnName}"`]);
|
|
172
|
+
_this.name = 'UnexpectedColumnError';
|
|
173
|
+
return _this;
|
|
174
|
+
}
|
|
175
|
+
_inherits(UnexpectedColumnError, _Error);
|
|
176
|
+
return _createClass(UnexpectedColumnError);
|
|
177
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
178
|
+
|
|
179
|
+
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)); }
|
|
180
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); }
|
|
181
|
+
let HttpError = /*#__PURE__*/function (_Error) {
|
|
182
|
+
function HttpError(statusCode, statusText, errorData) {
|
|
183
|
+
var _this;
|
|
184
|
+
_classCallCheck(this, HttpError);
|
|
185
|
+
_this = _callSuper(this, HttpError, [`HTTP Error! Status code: ${statusCode}, message: "${statusText ? statusText : ''}"`]);
|
|
186
|
+
_this.statusCode = void 0;
|
|
187
|
+
_this.errorData = void 0;
|
|
188
|
+
_this.name = 'HttpError';
|
|
189
|
+
_this.statusCode = statusCode;
|
|
190
|
+
_this.errorData = errorData;
|
|
191
|
+
return _this;
|
|
192
|
+
}
|
|
193
|
+
_inherits(HttpError, _Error);
|
|
194
|
+
return _createClass(HttpError);
|
|
195
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
196
|
+
|
|
197
|
+
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; }
|
|
198
|
+
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; }
|
|
199
|
+
const addProxyPrefixToUrl = (uri, proxy) => {
|
|
200
|
+
return proxy ? `/proxy/${proxy}${uri}` : uri;
|
|
201
|
+
};
|
|
202
|
+
const fetchUsingXhr = _ref2 => {
|
|
203
|
+
let url = _ref2.url,
|
|
204
|
+
payload = _ref2.payload,
|
|
205
|
+
config = _ref2.config,
|
|
206
|
+
onProgress = _ref2.onProgress,
|
|
207
|
+
onSuccess = _ref2.onSuccess,
|
|
208
|
+
onError = _ref2.onError;
|
|
209
|
+
const options = applicationShell.createHttpClientOptions({
|
|
210
|
+
headers: _objectSpread$e({
|
|
211
|
+
'Content-Type': 'application/json'
|
|
212
|
+
}, config?.headers)
|
|
213
|
+
});
|
|
214
|
+
const xhr = new XMLHttpRequest();
|
|
215
|
+
xhr.open(config?.method, applicationShell.buildApiUrl(addProxyPrefixToUrl(url, config?.proxy)), true);
|
|
216
|
+
// Include cookies in the request
|
|
217
|
+
xhr.withCredentials = true;
|
|
218
|
+
if (options.headers) {
|
|
219
|
+
var _context;
|
|
220
|
+
_forEachInstanceProperty__default["default"](_context = _Object$keys__default["default"](options.headers)).call(_context, key => {
|
|
221
|
+
xhr.setRequestHeader(key, options.headers[key]);
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
xhr.upload.onprogress = function (event) {
|
|
225
|
+
if (event.lengthComputable) {
|
|
226
|
+
const percentComplete = event.loaded / event.total * 100;
|
|
227
|
+
onProgress(percentComplete);
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
xhr.onload = function () {
|
|
231
|
+
const data = JSON.parse(xhr.responseText);
|
|
232
|
+
// Code copied from `executeHttpClientRequest` to replicate the same behavior
|
|
233
|
+
const refreshedSessionToken = xhr.getResponseHeader('x-refreshed-session-token');
|
|
234
|
+
if (refreshedSessionToken) {
|
|
235
|
+
applicationShellConnectors.oidcStorage.setActiveSession(refreshedSessionToken);
|
|
236
|
+
}
|
|
237
|
+
if (xhr.status >= 200 && xhr.status < 300) {
|
|
238
|
+
onSuccess(data);
|
|
239
|
+
} else {
|
|
240
|
+
onError(new HttpError(xhr.status, xhr.statusText, data));
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
xhr.onerror = function () {
|
|
244
|
+
const errorData = JSON.parse(xhr.responseText);
|
|
245
|
+
onError(new HttpError(xhr.status, xhr.statusText, errorData));
|
|
246
|
+
};
|
|
247
|
+
xhr.onabort = function () {
|
|
248
|
+
onError(new DOMException('Aborted', 'AbortError'));
|
|
249
|
+
};
|
|
250
|
+
xhr.send(payload);
|
|
251
|
+
return xhr;
|
|
252
|
+
};
|
|
108
253
|
|
|
109
|
-
var _context;
|
|
110
254
|
const DEFAULT_DELIMITER = ',';
|
|
111
255
|
const INITIAL_COLUMN_DISPLAY_COUNT = 8;
|
|
112
256
|
const IMPORT_TAG_KEYS = {
|
|
@@ -115,7 +259,7 @@ const IMPORT_TAG_KEYS = {
|
|
|
115
259
|
const IMPORT_TAG_VALUES = {
|
|
116
260
|
fileUpload: 'file-upload'
|
|
117
261
|
};
|
|
118
|
-
const TAG_KEY_SOURCE_FILE_UPLOAD =
|
|
262
|
+
const TAG_KEY_SOURCE_FILE_UPLOAD = `${IMPORT_TAG_KEYS.source}:${IMPORT_TAG_VALUES.fileUpload}`;
|
|
119
263
|
|
|
120
264
|
const IMPORTABLE_RESOURCES = {
|
|
121
265
|
CATEGORY: 'category',
|
|
@@ -131,10 +275,10 @@ const FILE_SIZE_LIMITS_MB = {
|
|
|
131
275
|
[IMPORTABLE_RESOURCES.DISCOUNT_CODE]: 10
|
|
132
276
|
};
|
|
133
277
|
const ROW_LIMITS = {
|
|
134
|
-
[IMPORTABLE_RESOURCES.CATEGORY]:
|
|
135
|
-
[IMPORTABLE_RESOURCES.INVENTORY]:
|
|
136
|
-
[IMPORTABLE_RESOURCES.PRODUCT]:
|
|
137
|
-
[IMPORTABLE_RESOURCES.DISCOUNT_CODE]:
|
|
278
|
+
[IMPORTABLE_RESOURCES.CATEGORY]: 5_000,
|
|
279
|
+
[IMPORTABLE_RESOURCES.INVENTORY]: 4_000,
|
|
280
|
+
[IMPORTABLE_RESOURCES.PRODUCT]: 70_000,
|
|
281
|
+
[IMPORTABLE_RESOURCES.DISCOUNT_CODE]: 4_000
|
|
138
282
|
};
|
|
139
283
|
const RESOURCE_TYPE_TEMPLATE_DOWNLOAD_LINKS = {
|
|
140
284
|
[IMPORTABLE_RESOURCES.CATEGORY]: 'https://docs.commercetools.com/merchant-center/downloads/category_import_template.csv',
|
|
@@ -149,9 +293,8 @@ const RESOURCE_TYPE_DOCUMENTATION_LINKS = {
|
|
|
149
293
|
[IMPORTABLE_RESOURCES.DISCOUNT_CODE]: 'https://docs.commercetools.com/merchant-center/import-discount-codes#supported-headers-and-values'
|
|
150
294
|
};
|
|
151
295
|
|
|
152
|
-
function ownKeys$
|
|
153
|
-
function _objectSpread$
|
|
154
|
-
|
|
296
|
+
function ownKeys$d(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; }
|
|
297
|
+
function _objectSpread$d(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$d(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$d(Object(t))).call(_context3, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
155
298
|
/**
|
|
156
299
|
* This function checks if the provided `expectedDelimiter` is used consistently in the first 10 lines of a CSV file.
|
|
157
300
|
* Returns a Promise that resolves to an object containing a boolean `isValid` property and the detected delimiter `delimiter`.
|
|
@@ -206,7 +349,7 @@ const mapUploadFileErrorsResponseToUploadFileErrorRows = uploadFileErrorsRespons
|
|
|
206
349
|
};
|
|
207
350
|
const mapUploadFileClientSideErrorsToUploadFileErrorRows = uploadFileClientSideErrors => {
|
|
208
351
|
let idCounter = 1;
|
|
209
|
-
return _mapInstanceProperty__default["default"](uploadFileClientSideErrors).call(uploadFileClientSideErrors, uploadFileClientSideError => _objectSpread$
|
|
352
|
+
return _mapInstanceProperty__default["default"](uploadFileClientSideErrors).call(uploadFileClientSideErrors, uploadFileClientSideError => _objectSpread$d(_objectSpread$d({}, uploadFileClientSideError), {}, {
|
|
210
353
|
id: String(idCounter++)
|
|
211
354
|
}));
|
|
212
355
|
};
|
|
@@ -264,128 +407,43 @@ const encodeFileNameWithTimestampToContainerKey = fileName => {
|
|
|
264
407
|
};
|
|
265
408
|
|
|
266
409
|
function getCreateImportContainerURL(projectKey) {
|
|
267
|
-
return
|
|
410
|
+
return `/${projectKey}/import-containers`;
|
|
268
411
|
}
|
|
269
412
|
function getDeleteImportContainerURL(projectKey, containerKey) {
|
|
270
|
-
|
|
271
|
-
return _concatInstanceProperty__default["default"](_context6 = "/".concat(projectKey, "/import-containers/")).call(_context6, containerKey);
|
|
413
|
+
return `/${projectKey}/import-containers/${containerKey}`;
|
|
272
414
|
}
|
|
273
415
|
function getFileUploadURL(projectKey, resourceType, containerKey) {
|
|
274
|
-
|
|
275
|
-
return _concatInstanceProperty__default["default"](_context8 = _concatInstanceProperty__default["default"](_context9 = "/".concat(projectKey, "/")).call(_context9, pluralize.plural(resourceType), "/import-containers/")).call(_context8, containerKey, "/file-upload");
|
|
416
|
+
return `/${projectKey}/${pluralize.plural(resourceType)}/import-containers/${containerKey}/file-upload`;
|
|
276
417
|
}
|
|
277
418
|
function getProccessFileURL(projectKey, resourceType, containerKey) {
|
|
278
|
-
|
|
279
|
-
return _concatInstanceProperty__default["default"](_context10 = _concatInstanceProperty__default["default"](_context11 = "/".concat(projectKey, "/")).call(_context11, pluralize.plural(resourceType), "/import-containers/")).call(_context10, containerKey, "/process-file");
|
|
419
|
+
return `/${projectKey}/${pluralize.plural(resourceType)}/import-containers/${containerKey}/process-file`;
|
|
280
420
|
}
|
|
281
421
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
|
|
422
|
+
const EnabledResourceType = {
|
|
423
|
+
category: true,
|
|
424
|
+
product: true,
|
|
425
|
+
inventory: true,
|
|
426
|
+
'discount-code': true
|
|
427
|
+
};
|
|
428
|
+
function isResourceType(maybeResourceType) {
|
|
429
|
+
return typeof maybeResourceType === 'string' && maybeResourceType in EnabledResourceType;
|
|
430
|
+
}
|
|
431
|
+
function assertResourceType(maybeResourceType) {
|
|
432
|
+
if (isResourceType(maybeResourceType)) return;
|
|
433
|
+
throw new Error(`Invalid value: ${maybeResourceType}`);
|
|
434
|
+
}
|
|
435
|
+
function isError(maybeError) {
|
|
436
|
+
if (maybeError instanceof Error) return true;
|
|
437
|
+
return false;
|
|
438
|
+
}
|
|
296
439
|
|
|
297
|
-
|
|
298
|
-
function
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
_classCallCheck(this, UnexpectedColumnError);
|
|
305
|
-
_this = _super.call(this, "Unexpected column \"".concat(columnName, "\""));
|
|
306
|
-
_this.name = 'UnexpectedColumnError';
|
|
307
|
-
return _this;
|
|
308
|
-
}
|
|
309
|
-
return _createClass(UnexpectedColumnError);
|
|
310
|
-
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
311
|
-
|
|
312
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct__default["default"](Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
313
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); }
|
|
314
|
-
let HttpError = /*#__PURE__*/function (_Error) {
|
|
315
|
-
_inherits(HttpError, _Error);
|
|
316
|
-
var _super = _createSuper(HttpError);
|
|
317
|
-
function HttpError(statusCode, statusText, errorData) {
|
|
318
|
-
var _context;
|
|
319
|
-
var _this;
|
|
320
|
-
_classCallCheck(this, HttpError);
|
|
321
|
-
_this = _super.call(this, _concatInstanceProperty__default["default"](_context = "HTTP Error! Status code: ".concat(statusCode, ", message: \"")).call(_context, statusText ? statusText : '', "\""));
|
|
322
|
-
_this.statusCode = void 0;
|
|
323
|
-
_this.errorData = void 0;
|
|
324
|
-
_this.name = 'HttpError';
|
|
325
|
-
_this.statusCode = statusCode;
|
|
326
|
-
_this.errorData = errorData;
|
|
327
|
-
return _this;
|
|
328
|
-
}
|
|
329
|
-
return _createClass(HttpError);
|
|
330
|
-
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
331
|
-
|
|
332
|
-
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; }
|
|
333
|
-
function _objectSpread$e(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys$e(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys$e(Object(t))).call(_context4, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
334
|
-
const addProxyPrefixToUrl = (uri, proxy) => {
|
|
335
|
-
var _context;
|
|
336
|
-
return proxy ? _concatInstanceProperty__default["default"](_context = "/proxy/".concat(proxy)).call(_context, uri) : uri;
|
|
337
|
-
};
|
|
338
|
-
const fetchUsingXhr = _ref2 => {
|
|
339
|
-
let url = _ref2.url,
|
|
340
|
-
payload = _ref2.payload,
|
|
341
|
-
config = _ref2.config,
|
|
342
|
-
onProgress = _ref2.onProgress,
|
|
343
|
-
onSuccess = _ref2.onSuccess,
|
|
344
|
-
onError = _ref2.onError;
|
|
345
|
-
const options = applicationShell.createHttpClientOptions({
|
|
346
|
-
headers: _objectSpread$e({
|
|
347
|
-
'Content-Type': 'application/json'
|
|
348
|
-
}, config === null || config === void 0 ? void 0 : config.headers)
|
|
349
|
-
});
|
|
350
|
-
const xhr = new XMLHttpRequest();
|
|
351
|
-
xhr.open(config === null || config === void 0 ? void 0 : config.method, applicationShell.buildApiUrl(addProxyPrefixToUrl(url, config === null || config === void 0 ? void 0 : config.proxy)), true);
|
|
352
|
-
// Include cookies in the request
|
|
353
|
-
xhr.withCredentials = true;
|
|
354
|
-
if (options.headers) {
|
|
355
|
-
var _context2;
|
|
356
|
-
_forEachInstanceProperty__default["default"](_context2 = _Object$keys__default["default"](options.headers)).call(_context2, key => {
|
|
357
|
-
xhr.setRequestHeader(key, options.headers[key]);
|
|
358
|
-
});
|
|
359
|
-
}
|
|
360
|
-
xhr.upload.onprogress = function (event) {
|
|
361
|
-
if (event.lengthComputable) {
|
|
362
|
-
const percentComplete = event.loaded / event.total * 100;
|
|
363
|
-
onProgress(percentComplete);
|
|
364
|
-
}
|
|
365
|
-
};
|
|
366
|
-
xhr.onload = function () {
|
|
367
|
-
const data = JSON.parse(xhr.responseText);
|
|
368
|
-
// Code copied from `executeHttpClientRequest` to replicate the same behavior
|
|
369
|
-
const refreshedSessionToken = xhr.getResponseHeader('x-refreshed-session-token');
|
|
370
|
-
if (refreshedSessionToken) {
|
|
371
|
-
applicationShellConnectors.oidcStorage.setActiveSession(refreshedSessionToken);
|
|
372
|
-
}
|
|
373
|
-
if (xhr.status >= 200 && xhr.status < 300) {
|
|
374
|
-
onSuccess(data);
|
|
375
|
-
} else {
|
|
376
|
-
onError(new HttpError(xhr.status, xhr.statusText, data));
|
|
377
|
-
}
|
|
378
|
-
};
|
|
379
|
-
xhr.onerror = function () {
|
|
380
|
-
const errorData = JSON.parse(xhr.responseText);
|
|
381
|
-
onError(new HttpError(xhr.status, xhr.statusText, errorData));
|
|
382
|
-
};
|
|
383
|
-
xhr.onabort = function () {
|
|
384
|
-
onError(new DOMException('Aborted', 'AbortError'));
|
|
385
|
-
};
|
|
386
|
-
xhr.send(payload);
|
|
387
|
-
return xhr;
|
|
388
|
-
};
|
|
440
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
441
|
+
function hasOwnProperty(obj, prop) {
|
|
442
|
+
return typeof obj === 'object' && obj !== null && obj.hasOwnProperty(prop);
|
|
443
|
+
}
|
|
444
|
+
function hasRequiredFields(maybeValidObject, requiredFields) {
|
|
445
|
+
return typeof maybeValidObject === 'object' && maybeValidObject !== null && _everyInstanceProperty__default["default"](requiredFields).call(requiredFields, property => hasOwnProperty(maybeValidObject, property));
|
|
446
|
+
}
|
|
389
447
|
|
|
390
448
|
function uploadFileForImport(_ref) {
|
|
391
449
|
let projectKey = _ref.projectKey,
|
|
@@ -416,8 +474,8 @@ function uploadFileForImport(_ref) {
|
|
|
416
474
|
});
|
|
417
475
|
}
|
|
418
476
|
|
|
419
|
-
function ownKeys$
|
|
420
|
-
function _objectSpread$
|
|
477
|
+
function ownKeys$c(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; }
|
|
478
|
+
function _objectSpread$c(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$c(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$c(Object(t))).call(_context3, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
421
479
|
function createImportContainerForFileUpload(importContainerDraft, projectKey, asyncDispatch) {
|
|
422
480
|
return asyncDispatch(sdk.actions.post({
|
|
423
481
|
mcApiProxyTarget: constants.MC_API_PROXY_TARGETS.IMPORT,
|
|
@@ -426,7 +484,7 @@ function createImportContainerForFileUpload(importContainerDraft, projectKey, as
|
|
|
426
484
|
accept: 'application/json',
|
|
427
485
|
'Content-Type': 'application/json'
|
|
428
486
|
},
|
|
429
|
-
payload: _JSON$stringify__default["default"](_objectSpread$
|
|
487
|
+
payload: _JSON$stringify__default["default"](_objectSpread$c(_objectSpread$c({}, importContainerDraft), {}, {
|
|
430
488
|
tags: [TAG_KEY_SOURCE_FILE_UPLOAD]
|
|
431
489
|
}))
|
|
432
490
|
}));
|
|
@@ -465,86 +523,13 @@ function assertProcessFileResponse(maybeProcessFileResponse) {
|
|
|
465
523
|
throw new Error('Invalid response');
|
|
466
524
|
}
|
|
467
525
|
|
|
468
|
-
function ownKeys$c(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; }
|
|
469
|
-
function _objectSpread$c(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$c(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$c(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
470
|
-
function reducer(state, action) {
|
|
471
|
-
if (action.type === 'setCurrentStep') return _objectSpread$c(_objectSpread$c({}, state), {}, {
|
|
472
|
-
currentStep: action.currentStep,
|
|
473
|
-
progress: 0
|
|
474
|
-
});
|
|
475
|
-
if (action.type === 'setUploadFileResponse') return _objectSpread$c(_objectSpread$c({}, state), {}, {
|
|
476
|
-
uploadFileResponse: action.uploadFileResponse
|
|
477
|
-
});
|
|
478
|
-
if (action.type === 'setResourceType') return _objectSpread$c(_objectSpread$c({}, state), {}, {
|
|
479
|
-
resourceType: action.resourceType
|
|
480
|
-
});
|
|
481
|
-
if (action.type === 'setContainerKey') return _objectSpread$c(_objectSpread$c({}, state), {}, {
|
|
482
|
-
containerKey: action.containerKey
|
|
483
|
-
});
|
|
484
|
-
if (action.type === 'cancelImport') return _objectSpread$c(_objectSpread$c({}, state), {}, {
|
|
485
|
-
currentStep: 1,
|
|
486
|
-
containerKey: undefined,
|
|
487
|
-
fileUploadClientSideErrors: [],
|
|
488
|
-
uploadFileResponse: undefined,
|
|
489
|
-
droppedFile: undefined,
|
|
490
|
-
dropAreaState: 'disabled',
|
|
491
|
-
progress: 0
|
|
492
|
-
});
|
|
493
|
-
if (action.type === 'uploadNewFile') return _objectSpread$c(_objectSpread$c({}, state), {}, {
|
|
494
|
-
currentStep: 1,
|
|
495
|
-
containerKey: undefined,
|
|
496
|
-
fileUploadClientSideErrors: [],
|
|
497
|
-
uploadFileResponse: undefined,
|
|
498
|
-
droppedFile: undefined,
|
|
499
|
-
dropAreaState: 'ready-for-drop',
|
|
500
|
-
progress: 0
|
|
501
|
-
});
|
|
502
|
-
if (action.type === 'setDroppedFile') {
|
|
503
|
-
return _objectSpread$c(_objectSpread$c({}, state), {}, {
|
|
504
|
-
droppedFile: action.droppedFile
|
|
505
|
-
});
|
|
506
|
-
}
|
|
507
|
-
if (action.type === 'setFileUploadClientSideErrors') {
|
|
508
|
-
return _objectSpread$c(_objectSpread$c({}, state), {}, {
|
|
509
|
-
fileUploadClientSideErrors: action.fileUploadClientSideErrors
|
|
510
|
-
});
|
|
511
|
-
}
|
|
512
|
-
if (action.type === 'setAbortController') {
|
|
513
|
-
return _objectSpread$c(_objectSpread$c({}, state), {}, {
|
|
514
|
-
abortController: action.abortController
|
|
515
|
-
});
|
|
516
|
-
}
|
|
517
|
-
if (action.type === 'setProgress') {
|
|
518
|
-
return _objectSpread$c(_objectSpread$c({}, state), {}, {
|
|
519
|
-
progress: action.progress
|
|
520
|
-
});
|
|
521
|
-
}
|
|
522
|
-
throw new Error(getUnknownActionError(action));
|
|
523
|
-
}
|
|
524
|
-
function getUnknownActionError(actionType) {
|
|
525
|
-
return "Unkown type: ".concat(actionType);
|
|
526
|
-
}
|
|
527
|
-
const initialState = {
|
|
528
|
-
currentStep: 1,
|
|
529
|
-
abortController: new AbortController(),
|
|
530
|
-
dropAreaState: 'disabled',
|
|
531
|
-
uploadFileResponse: undefined,
|
|
532
|
-
fileUploadClientSideErrors: [],
|
|
533
|
-
resourceType: 'category',
|
|
534
|
-
containerKey: undefined,
|
|
535
|
-
progress: 0
|
|
536
|
-
};
|
|
537
|
-
|
|
538
526
|
function ownKeys$b(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; }
|
|
539
527
|
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; }
|
|
540
528
|
const ImportResourcesContext = /*#__PURE__*/React__default["default"].createContext();
|
|
541
529
|
const ImportResourcesProvider = props => {
|
|
542
|
-
const _useApplicationContex = applicationShellConnectors.useApplicationContext(context => {
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
projectKey: (_context$project = context.project) === null || _context$project === void 0 ? void 0 : _context$project.key
|
|
546
|
-
};
|
|
547
|
-
}),
|
|
530
|
+
const _useApplicationContex = applicationShellConnectors.useApplicationContext(context => ({
|
|
531
|
+
projectKey: context.project?.key
|
|
532
|
+
})),
|
|
548
533
|
projectKey = _useApplicationContex.projectKey;
|
|
549
534
|
const asyncDispatch = sdk.useAsyncDispatch();
|
|
550
535
|
const _React$useReducer = React__default["default"].useReducer(reducer, _objectSpread$b(_objectSpread$b({}, initialState), {}, {
|
|
@@ -625,6 +610,159 @@ const ImportResourcesProvider = props => {
|
|
|
625
610
|
});
|
|
626
611
|
};
|
|
627
612
|
|
|
613
|
+
const getBorderColor = state => {
|
|
614
|
+
const borderColors = {
|
|
615
|
+
default: '#909dbc',
|
|
616
|
+
error: '#e60050',
|
|
617
|
+
active: uiKit.customProperties.colorPrimary
|
|
618
|
+
};
|
|
619
|
+
return borderColors[state] || borderColors.default;
|
|
620
|
+
};
|
|
621
|
+
const getDashedBorder = function () {
|
|
622
|
+
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default';
|
|
623
|
+
const color = getBorderColor(state);
|
|
624
|
+
const svgContent = `
|
|
625
|
+
<svg width="100%" height="100%" xmlns="http://www.w3.org/2000/svg">
|
|
626
|
+
<rect width="100%" height="100%" fill="none" stroke="${color}" stroke-width="2px" stroke-dasharray="6,6" stroke-dashoffset="0" stroke-linecap="square"/>
|
|
627
|
+
</svg>
|
|
628
|
+
`;
|
|
629
|
+
return `data:image/svg+xml,${encodeURIComponent(svgContent)}`;
|
|
630
|
+
};
|
|
631
|
+
const base = /*#__PURE__*/react.css("border-radius:", uiKit.customProperties.borderRadius6, ";min-height:136px;display:flex;justify-content:center;align-items:center;" + ("" ), "" );
|
|
632
|
+
const disabled = /*#__PURE__*/react.css("" , "" );
|
|
633
|
+
const readyForDrop = /*#__PURE__*/react.css("background-image:url(\"", getDashedBorder(), "\");background-color:", uiKit.customProperties.colorSurface, ";" + ("" ), "" );
|
|
634
|
+
const activeDrag = /*#__PURE__*/react.css("background-image:url(\"", getDashedBorder('active'), "\");background-color:", uiKit.customProperties.colorPrimary95, ";padding:", uiKit.customProperties.spacing50, " 100px;" + ("" ), "" );
|
|
635
|
+
const fileDropped = /*#__PURE__*/react.css("background-image:url(\"", getDashedBorder(), "\");background-color:", uiKit.customProperties.colorSurface, ";padding:", uiKit.customProperties.spacing50, " 100px;" + ("" ), "" );
|
|
636
|
+
const styles = {
|
|
637
|
+
base,
|
|
638
|
+
readyForDrop,
|
|
639
|
+
fileDropped,
|
|
640
|
+
disabled,
|
|
641
|
+
activeDrag
|
|
642
|
+
};
|
|
643
|
+
|
|
644
|
+
const DropWrapper = /*#__PURE__*/_styled__default["default"]("div", {
|
|
645
|
+
target: "ef0z5en0"
|
|
646
|
+
} )(styles.base, " ", props => {
|
|
647
|
+
if (props.dropAreaState === 'disabled') {
|
|
648
|
+
return styles.disabled;
|
|
649
|
+
}
|
|
650
|
+
if (props.dropAreaState === 'ready-for-drop') {
|
|
651
|
+
return styles.readyForDrop;
|
|
652
|
+
}
|
|
653
|
+
if (props.dropAreaState === 'active-drag') {
|
|
654
|
+
return styles.activeDrag;
|
|
655
|
+
}
|
|
656
|
+
if (props.dropAreaState === 'file-dropped') {
|
|
657
|
+
return styles.fileDropped;
|
|
658
|
+
}
|
|
659
|
+
return getDefaultDropWrapperStyles(props.dropAreaState);
|
|
660
|
+
}, ";" + ("" ));
|
|
661
|
+
function getDefaultDropWrapperStyles(_dropAreaState) {
|
|
662
|
+
return /*#__PURE__*/react.css("" , "" );
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
var ActiveDragDropArea = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./active-drag-drop-area-1e3ee12d.cjs.prod.js' /* webpackChunkName: "active-drag-drop-area" */); }));
|
|
666
|
+
|
|
667
|
+
var DisabledDropArea = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./disabled-drop-area-99c1fa0b.cjs.prod.js' /* webpackChunkName: "disabled-drop-area" */); }));
|
|
668
|
+
|
|
669
|
+
var EnabledDropArea = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./enabled-drop-area-fbf01f88.cjs.prod.js' /* webpackChunkName: "enabled-drop-area" */); }));
|
|
670
|
+
|
|
671
|
+
var FileDropped = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./file-dropped-area-90b9f712.cjs.prod.js' /* webpackChunkName: "filed-dropped-area" */); }));
|
|
672
|
+
|
|
673
|
+
function getDropArea(_ref) {
|
|
674
|
+
let dropAreaState = _ref.dropAreaState,
|
|
675
|
+
resourceType = _ref.resourceType,
|
|
676
|
+
isFileDropped = _ref.isFileDropped;
|
|
677
|
+
if (dropAreaState === 'file-dropped') {
|
|
678
|
+
return jsxRuntime.jsx(FileDropped, {});
|
|
679
|
+
}
|
|
680
|
+
if (dropAreaState === 'disabled' || !resourceType) {
|
|
681
|
+
return jsxRuntime.jsx(DisabledDropArea, {});
|
|
682
|
+
}
|
|
683
|
+
if (dropAreaState === 'ready-for-drop') {
|
|
684
|
+
return jsxRuntime.jsx(EnabledDropArea, {});
|
|
685
|
+
}
|
|
686
|
+
if (dropAreaState === 'active-drag') {
|
|
687
|
+
return jsxRuntime.jsx(ActiveDragDropArea, {
|
|
688
|
+
isFileDropped: isFileDropped
|
|
689
|
+
});
|
|
690
|
+
}
|
|
691
|
+
return fallbackDropArea();
|
|
692
|
+
}
|
|
693
|
+
function fallbackDropArea(_invalidDropAreaState) {
|
|
694
|
+
return jsxRuntime.jsx(DisabledDropArea, {});
|
|
695
|
+
}
|
|
696
|
+
function getDropAreaState(flags) {
|
|
697
|
+
if (flags.isDragActive) {
|
|
698
|
+
return 'active-drag';
|
|
699
|
+
}
|
|
700
|
+
if (flags.hasResourceType) {
|
|
701
|
+
return 'disabled';
|
|
702
|
+
}
|
|
703
|
+
if (flags.isReady) {
|
|
704
|
+
return 'file-dropped';
|
|
705
|
+
}
|
|
706
|
+
return 'ready-for-drop';
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
var messages$5 = reactIntl.defineMessages({
|
|
710
|
+
dragAndDropCSV: {
|
|
711
|
+
id: 'ImportResourcesModal.dragAndDropCSV',
|
|
712
|
+
description: 'The message telling the user to drag and drop CSV file in the file drop area',
|
|
713
|
+
defaultMessage: 'Drag and drop CSV'
|
|
714
|
+
},
|
|
715
|
+
or: {
|
|
716
|
+
id: 'ImportResourcesModal.or',
|
|
717
|
+
description: 'The word "or" in the drag and drop message',
|
|
718
|
+
defaultMessage: 'or'
|
|
719
|
+
},
|
|
720
|
+
browseButton: {
|
|
721
|
+
id: 'ImportResourcesModal.browseFile',
|
|
722
|
+
defaultMessage: 'Browse file'
|
|
723
|
+
},
|
|
724
|
+
uploadFile: {
|
|
725
|
+
id: 'ImportResourcesModal.uploadFile',
|
|
726
|
+
description: 'Label for a button on the file upload page, shown on active drop area state',
|
|
727
|
+
defaultMessage: 'Upload file'
|
|
728
|
+
},
|
|
729
|
+
chooseFile: {
|
|
730
|
+
id: 'ImportResourcesModal.chooseFile',
|
|
731
|
+
description: 'Label for a button on the file upload page, shown on ready to upload state',
|
|
732
|
+
defaultMessage: 'Choose file'
|
|
733
|
+
},
|
|
734
|
+
fileUploadFailed: {
|
|
735
|
+
id: 'ImportResourcesModal.fileUploadFailed',
|
|
736
|
+
description: 'A title on the file upload page, shown on file upload error state',
|
|
737
|
+
defaultMessage: 'File upload failed'
|
|
738
|
+
},
|
|
739
|
+
fileFormatNotSupported: {
|
|
740
|
+
id: 'ImportResourcesModal.fileFormatNotSupported',
|
|
741
|
+
description: 'Error message displayed when a user drags and drops a non-CSV file',
|
|
742
|
+
defaultMessage: 'Invalid file format: The file is not in CSV format and cannot be processed.'
|
|
743
|
+
},
|
|
744
|
+
tooManyFilesError: {
|
|
745
|
+
id: 'ImportResourcesModal.tooManyFilesError',
|
|
746
|
+
description: 'Error message displayed when a user drags and drops multiple files at once',
|
|
747
|
+
defaultMessage: 'Multiple files detected: You can only drag and drop one file at a time.'
|
|
748
|
+
},
|
|
749
|
+
genericError: {
|
|
750
|
+
id: 'ImportResourcesModal.genericError',
|
|
751
|
+
description: 'Default error message for unexpected file upload issues (for unhandled cases)',
|
|
752
|
+
defaultMessage: 'Error occurred: Please try uploading the file again or contact our support team for assistance.'
|
|
753
|
+
},
|
|
754
|
+
dataType: {
|
|
755
|
+
id: 'ImportResourcesModal.dataType',
|
|
756
|
+
description: 'Label for the data type selection dropdown',
|
|
757
|
+
defaultMessage: 'Data type'
|
|
758
|
+
},
|
|
759
|
+
instructions: {
|
|
760
|
+
id: 'ImportResourcesModal.instructions',
|
|
761
|
+
description: 'Label for the instructions section',
|
|
762
|
+
defaultMessage: 'Instructions'
|
|
763
|
+
}
|
|
764
|
+
});
|
|
765
|
+
|
|
628
766
|
function useImportResourcesContext() {
|
|
629
767
|
const context = React.useContext(ImportResourcesContext);
|
|
630
768
|
if (!context) {
|
|
@@ -633,7 +771,7 @@ function useImportResourcesContext() {
|
|
|
633
771
|
return context;
|
|
634
772
|
}
|
|
635
773
|
|
|
636
|
-
var messages$
|
|
774
|
+
var messages$4 = reactIntl.defineMessages({
|
|
637
775
|
fileSizeExceededTitle: {
|
|
638
776
|
id: 'ImportResourcesModal.sizeExceededTitle',
|
|
639
777
|
defaultMessage: 'File size exceeded'
|
|
@@ -685,10 +823,7 @@ var messages$5 = reactIntl.defineMessages({
|
|
|
685
823
|
|
|
686
824
|
const useUpload = () => {
|
|
687
825
|
const intl = reactIntl.useIntl();
|
|
688
|
-
const projectKey = applicationShellConnectors.useApplicationContext(context =>
|
|
689
|
-
var _context$project;
|
|
690
|
-
return (_context$project = context.project) === null || _context$project === void 0 ? void 0 : _context$project.key;
|
|
691
|
-
});
|
|
826
|
+
const projectKey = applicationShellConnectors.useApplicationContext(context => context.project?.key);
|
|
692
827
|
const _useImportResourcesCo = useImportResourcesContext(),
|
|
693
828
|
state = _useImportResourcesCo.state,
|
|
694
829
|
actions = _useImportResourcesCo.actions;
|
|
@@ -703,25 +838,25 @@ const useUpload = () => {
|
|
|
703
838
|
const errors = [];
|
|
704
839
|
const delimiterCheck = await checkDelimiter(file);
|
|
705
840
|
if (!delimiterCheck.isValid) errors.push({
|
|
706
|
-
title: intl.formatMessage(messages$
|
|
707
|
-
description: intl.formatMessage(messages$
|
|
841
|
+
title: intl.formatMessage(messages$4.dropAreaWrongDelimiterTitle),
|
|
842
|
+
description: intl.formatMessage(messages$4.dropAreaWrongDelimiterDescription, {
|
|
708
843
|
delimiter: delimiterCheck.delimiter
|
|
709
844
|
})
|
|
710
845
|
});
|
|
711
846
|
const rowCount = await getRowCount(file);
|
|
712
847
|
if (rowCount < 1) errors.push({
|
|
713
|
-
title: intl.formatMessage(messages$
|
|
714
|
-
description: intl.formatMessage(messages$
|
|
848
|
+
title: intl.formatMessage(messages$4.dropAreaNotEnoughRowsTitle),
|
|
849
|
+
description: intl.formatMessage(messages$4.dropAreaNotEnoughRowsDescription)
|
|
715
850
|
});
|
|
716
851
|
if (state.resourceType && file.size > toBytes(FILE_SIZE_LIMITS_MB[state.resourceType])) errors.push({
|
|
717
|
-
title: intl.formatMessage(messages$
|
|
718
|
-
description: intl.formatMessage(messages$
|
|
852
|
+
title: intl.formatMessage(messages$4.fileSizeExceededTitle),
|
|
853
|
+
description: intl.formatMessage(messages$4.fileSizeExceededDescription, {
|
|
719
854
|
fileSizeLimit: intl.formatNumber(FILE_SIZE_LIMITS_MB[state.resourceType])
|
|
720
855
|
})
|
|
721
856
|
});
|
|
722
857
|
if (state.resourceType && rowCount > ROW_LIMITS[state.resourceType]) errors.push({
|
|
723
|
-
title: intl.formatMessage(messages$
|
|
724
|
-
description: intl.formatMessage(messages$
|
|
858
|
+
title: intl.formatMessage(messages$4.rowLimitExceededTitle),
|
|
859
|
+
description: intl.formatMessage(messages$4.rowLimitExceededDescription, {
|
|
725
860
|
rowLimit: intl.formatNumber(ROW_LIMITS[state.resourceType])
|
|
726
861
|
})
|
|
727
862
|
});
|
|
@@ -738,26 +873,24 @@ const useUpload = () => {
|
|
|
738
873
|
return;
|
|
739
874
|
}
|
|
740
875
|
if (error instanceof HttpError) {
|
|
741
|
-
|
|
742
|
-
if (((_error$errorData = error.errorData) === null || _error$errorData === void 0 ? void 0 : _error$errorData.code) === 'MISSING_KEY_ERROR') {
|
|
876
|
+
if (error.errorData?.code === 'MISSING_KEY_ERROR') {
|
|
743
877
|
actions.cancelImport();
|
|
744
878
|
showNotification({
|
|
745
879
|
kind: 'error',
|
|
746
880
|
domain: constants.DOMAINS.PAGE,
|
|
747
|
-
text: intl.formatMessage(messages$
|
|
881
|
+
text: intl.formatMessage(messages$4.unexpectedError)
|
|
748
882
|
});
|
|
749
|
-
} else if (
|
|
883
|
+
} else if (error.errorData?.invalid > 0) {
|
|
750
884
|
actions.setUploadFileResponse(error.errorData);
|
|
751
885
|
} else {
|
|
752
886
|
actions.cancelImport();
|
|
753
887
|
showNotification({
|
|
754
888
|
kind: 'error',
|
|
755
889
|
domain: constants.DOMAINS.PAGE,
|
|
756
|
-
text: intl.formatMessage(messages$
|
|
890
|
+
text: intl.formatMessage(messages$4.unexpectedError)
|
|
757
891
|
});
|
|
758
892
|
}
|
|
759
893
|
} else {
|
|
760
|
-
var _state$droppedFile;
|
|
761
894
|
actions.cancelImport();
|
|
762
895
|
showNotification({
|
|
763
896
|
kind: 'error',
|
|
@@ -770,7 +903,7 @@ const useUpload = () => {
|
|
|
770
903
|
projectKey,
|
|
771
904
|
containerKey: state.containerKey,
|
|
772
905
|
resourceType: state.resourceType,
|
|
773
|
-
fileSizeInBytes:
|
|
906
|
+
fileSizeInBytes: state.droppedFile?.size
|
|
774
907
|
}
|
|
775
908
|
});
|
|
776
909
|
}
|
|
@@ -815,156 +948,7 @@ const useUpload = () => {
|
|
|
815
948
|
return {
|
|
816
949
|
handleUploadAndValidation
|
|
817
950
|
};
|
|
818
|
-
};
|
|
819
|
-
|
|
820
|
-
const getBorderColor = state => {
|
|
821
|
-
const borderColors = {
|
|
822
|
-
default: '#909dbc',
|
|
823
|
-
error: '#e60050',
|
|
824
|
-
active: uiKit.customProperties.colorPrimary
|
|
825
|
-
};
|
|
826
|
-
return borderColors[state] || borderColors.default;
|
|
827
|
-
};
|
|
828
|
-
const getDashedBorder = function () {
|
|
829
|
-
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default';
|
|
830
|
-
const color = getBorderColor(state);
|
|
831
|
-
const svgContent = "\n <svg width=\"100%\" height=\"100%\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect width=\"100%\" height=\"100%\" fill=\"none\" stroke=\"".concat(color, "\" stroke-width=\"2px\" stroke-dasharray=\"6,6\" stroke-dashoffset=\"0\" stroke-linecap=\"square\"/>\n </svg>\n ");
|
|
832
|
-
return "data:image/svg+xml,".concat(encodeURIComponent(svgContent));
|
|
833
|
-
};
|
|
834
|
-
const base = /*#__PURE__*/react.css("border-radius:", uiKit.customProperties.borderRadius6, ";min-height:136px;display:flex;justify-content:center;align-items:center;" + ("" ), "" );
|
|
835
|
-
const disabled = /*#__PURE__*/react.css("" , "" );
|
|
836
|
-
const readyForDrop = /*#__PURE__*/react.css("background-image:url(\"", getDashedBorder(), "\");background-color:", uiKit.customProperties.colorSurface, ";" + ("" ), "" );
|
|
837
|
-
const activeDrag = /*#__PURE__*/react.css("background-image:url(\"", getDashedBorder('active'), "\");background-color:", uiKit.customProperties.colorPrimary95, ";padding:", uiKit.customProperties.spacing50, " 100px;" + ("" ), "" );
|
|
838
|
-
const fileDropped = /*#__PURE__*/react.css("background-image:url(\"", getDashedBorder(), "\");background-color:", uiKit.customProperties.colorSurface, ";padding:", uiKit.customProperties.spacing50, " 100px;" + ("" ), "" );
|
|
839
|
-
const styles = {
|
|
840
|
-
base,
|
|
841
|
-
readyForDrop,
|
|
842
|
-
fileDropped,
|
|
843
|
-
disabled,
|
|
844
|
-
activeDrag
|
|
845
|
-
};
|
|
846
|
-
|
|
847
|
-
const DropWrapper = /*#__PURE__*/_styled__default["default"]("div", {
|
|
848
|
-
target: "ef0z5en0"
|
|
849
|
-
} )(styles.base, " ", props => {
|
|
850
|
-
if (props.dropAreaState === 'disabled') {
|
|
851
|
-
return styles.disabled;
|
|
852
|
-
}
|
|
853
|
-
if (props.dropAreaState === 'ready-for-drop') {
|
|
854
|
-
return styles.readyForDrop;
|
|
855
|
-
}
|
|
856
|
-
if (props.dropAreaState === 'active-drag') {
|
|
857
|
-
return styles.activeDrag;
|
|
858
|
-
}
|
|
859
|
-
if (props.dropAreaState === 'file-dropped') {
|
|
860
|
-
return styles.fileDropped;
|
|
861
|
-
}
|
|
862
|
-
return getDefaultDropWrapperStyles(props.dropAreaState);
|
|
863
|
-
}, ";" + ("" ));
|
|
864
|
-
function getDefaultDropWrapperStyles(_dropAreaState) {
|
|
865
|
-
return /*#__PURE__*/react.css("" , "" );
|
|
866
|
-
}
|
|
867
|
-
|
|
868
|
-
var ActiveDragDropArea = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./active-drag-drop-area-89f8264c.cjs.prod.js' /* webpackChunkName: "active-drag-drop-area" */); }));
|
|
869
|
-
|
|
870
|
-
var DisabledDropArea = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./disabled-drop-area-99c1fa0b.cjs.prod.js' /* webpackChunkName: "disabled-drop-area" */); }));
|
|
871
|
-
|
|
872
|
-
var EnabledDropArea = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./enabled-drop-area-77836aae.cjs.prod.js' /* webpackChunkName: "enabled-drop-area" */); }));
|
|
873
|
-
|
|
874
|
-
var FileDropped = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./file-dropped-area-47e83d97.cjs.prod.js' /* webpackChunkName: "filed-dropped-area" */); }));
|
|
875
|
-
|
|
876
|
-
function getDropArea(_ref) {
|
|
877
|
-
let dropAreaState = _ref.dropAreaState,
|
|
878
|
-
resourceType = _ref.resourceType,
|
|
879
|
-
isFileDropped = _ref.isFileDropped;
|
|
880
|
-
if (dropAreaState === 'file-dropped') {
|
|
881
|
-
return jsxRuntime.jsx(FileDropped, {});
|
|
882
|
-
}
|
|
883
|
-
if (dropAreaState === 'disabled' || !resourceType) {
|
|
884
|
-
return jsxRuntime.jsx(DisabledDropArea, {});
|
|
885
|
-
}
|
|
886
|
-
if (dropAreaState === 'ready-for-drop') {
|
|
887
|
-
return jsxRuntime.jsx(EnabledDropArea, {});
|
|
888
|
-
}
|
|
889
|
-
if (dropAreaState === 'active-drag') {
|
|
890
|
-
return jsxRuntime.jsx(ActiveDragDropArea, {
|
|
891
|
-
isFileDropped: isFileDropped
|
|
892
|
-
});
|
|
893
|
-
}
|
|
894
|
-
return fallbackDropArea();
|
|
895
|
-
}
|
|
896
|
-
function fallbackDropArea(_invalidDropAreaState) {
|
|
897
|
-
return jsxRuntime.jsx(DisabledDropArea, {});
|
|
898
|
-
}
|
|
899
|
-
function getDropAreaState(flags) {
|
|
900
|
-
if (flags.isDragActive) {
|
|
901
|
-
return 'active-drag';
|
|
902
|
-
}
|
|
903
|
-
if (flags.hasResourceType) {
|
|
904
|
-
return 'disabled';
|
|
905
|
-
}
|
|
906
|
-
if (flags.isReady) {
|
|
907
|
-
return 'file-dropped';
|
|
908
|
-
}
|
|
909
|
-
return 'ready-for-drop';
|
|
910
|
-
}
|
|
911
|
-
|
|
912
|
-
var messages$4 = reactIntl.defineMessages({
|
|
913
|
-
dragAndDropCSV: {
|
|
914
|
-
id: 'ImportResourcesModal.dragAndDropCSV',
|
|
915
|
-
description: 'The message telling the user to drag and drop CSV file in the file drop area',
|
|
916
|
-
defaultMessage: 'Drag and drop CSV'
|
|
917
|
-
},
|
|
918
|
-
or: {
|
|
919
|
-
id: 'ImportResourcesModal.or',
|
|
920
|
-
description: 'The word "or" in the drag and drop message',
|
|
921
|
-
defaultMessage: 'or'
|
|
922
|
-
},
|
|
923
|
-
browseButton: {
|
|
924
|
-
id: 'ImportResourcesModal.browseFile',
|
|
925
|
-
defaultMessage: 'Browse file'
|
|
926
|
-
},
|
|
927
|
-
uploadFile: {
|
|
928
|
-
id: 'ImportResourcesModal.uploadFile',
|
|
929
|
-
description: 'Label for a button on the file upload page, shown on active drop area state',
|
|
930
|
-
defaultMessage: 'Upload file'
|
|
931
|
-
},
|
|
932
|
-
chooseFile: {
|
|
933
|
-
id: 'ImportResourcesModal.chooseFile',
|
|
934
|
-
description: 'Label for a button on the file upload page, shown on ready to upload state',
|
|
935
|
-
defaultMessage: 'Choose file'
|
|
936
|
-
},
|
|
937
|
-
fileUploadFailed: {
|
|
938
|
-
id: 'ImportResourcesModal.fileUploadFailed',
|
|
939
|
-
description: 'A title on the file upload page, shown on file upload error state',
|
|
940
|
-
defaultMessage: 'File upload failed'
|
|
941
|
-
},
|
|
942
|
-
fileFormatNotSupported: {
|
|
943
|
-
id: 'ImportResourcesModal.fileFormatNotSupported',
|
|
944
|
-
description: 'Error message displayed when a user drags and drops a non-CSV file',
|
|
945
|
-
defaultMessage: 'Invalid file format: The file is not in CSV format and cannot be processed.'
|
|
946
|
-
},
|
|
947
|
-
tooManyFilesError: {
|
|
948
|
-
id: 'ImportResourcesModal.tooManyFilesError',
|
|
949
|
-
description: 'Error message displayed when a user drags and drops multiple files at once',
|
|
950
|
-
defaultMessage: 'Multiple files detected: You can only drag and drop one file at a time.'
|
|
951
|
-
},
|
|
952
|
-
genericError: {
|
|
953
|
-
id: 'ImportResourcesModal.genericError',
|
|
954
|
-
description: 'Default error message for unexpected file upload issues (for unhandled cases)',
|
|
955
|
-
defaultMessage: 'Error occurred: Please try uploading the file again or contact our support team for assistance.'
|
|
956
|
-
},
|
|
957
|
-
dataType: {
|
|
958
|
-
id: 'ImportResourcesModal.dataType',
|
|
959
|
-
description: 'Label for the data type selection dropdown',
|
|
960
|
-
defaultMessage: 'Data type'
|
|
961
|
-
},
|
|
962
|
-
instructions: {
|
|
963
|
-
id: 'ImportResourcesModal.instructions',
|
|
964
|
-
description: 'Label for the instructions section',
|
|
965
|
-
defaultMessage: 'Instructions'
|
|
966
|
-
}
|
|
967
|
-
});
|
|
951
|
+
};
|
|
968
952
|
|
|
969
953
|
function ownKeys$a(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; }
|
|
970
954
|
function _objectSpread$a(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys$a(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys$a(Object(t))).call(_context4, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
@@ -997,7 +981,7 @@ const FileDropArea = () => {
|
|
|
997
981
|
showNotification({
|
|
998
982
|
kind: 'error',
|
|
999
983
|
domain: constants.DOMAINS.PAGE,
|
|
1000
|
-
text: intl.formatMessage(messages$
|
|
984
|
+
text: intl.formatMessage(messages$5.tooManyFilesError)
|
|
1001
985
|
});
|
|
1002
986
|
return;
|
|
1003
987
|
}
|
|
@@ -1005,13 +989,13 @@ const FileDropArea = () => {
|
|
|
1005
989
|
showNotification({
|
|
1006
990
|
kind: 'error',
|
|
1007
991
|
domain: constants.DOMAINS.PAGE,
|
|
1008
|
-
text: intl.formatMessage(messages$
|
|
992
|
+
text: intl.formatMessage(messages$5.fileFormatNotSupported)
|
|
1009
993
|
});
|
|
1010
994
|
} else {
|
|
1011
995
|
showNotification({
|
|
1012
996
|
kind: 'error',
|
|
1013
997
|
domain: constants.DOMAINS.PAGE,
|
|
1014
|
-
text: intl.formatMessage(messages$
|
|
998
|
+
text: intl.formatMessage(messages$5.genericError)
|
|
1015
999
|
});
|
|
1016
1000
|
}
|
|
1017
1001
|
}
|
|
@@ -1042,22 +1026,22 @@ const FileDropArea = () => {
|
|
|
1042
1026
|
};
|
|
1043
1027
|
|
|
1044
1028
|
var sharedMessages = reactIntl.defineMessages({
|
|
1045
|
-
[
|
|
1029
|
+
[`modalTitle.${IMPORTABLE_RESOURCES.CATEGORY}`]: {
|
|
1046
1030
|
id: 'ImportResourcesModal.modalTitle.category',
|
|
1047
1031
|
description: 'Label for the categories modal title',
|
|
1048
1032
|
defaultMessage: 'Import categories by CSV'
|
|
1049
1033
|
},
|
|
1050
|
-
[
|
|
1034
|
+
[`modalTitle.${IMPORTABLE_RESOURCES.PRODUCT}`]: {
|
|
1051
1035
|
id: 'ImportResourcesModal.modalTitle.product',
|
|
1052
1036
|
description: 'Label for the products modal title',
|
|
1053
1037
|
defaultMessage: 'Import products by CSV'
|
|
1054
1038
|
},
|
|
1055
|
-
[
|
|
1039
|
+
[`modalTitle.${IMPORTABLE_RESOURCES.INVENTORY}`]: {
|
|
1056
1040
|
id: 'ImportResourcesModal.modalTitle.inventoryEntry',
|
|
1057
1041
|
description: 'Label for the inventories modal title',
|
|
1058
1042
|
defaultMessage: 'Import inventories by CSV'
|
|
1059
1043
|
},
|
|
1060
|
-
[
|
|
1044
|
+
[`modalTitle.${IMPORTABLE_RESOURCES.DISCOUNT_CODE}`]: {
|
|
1061
1045
|
id: 'ImportResourcesModal.modalTitle.discountCode',
|
|
1062
1046
|
description: 'Label for the inventories modal title',
|
|
1063
1047
|
defaultMessage: 'Import discount codes by CSV'
|
|
@@ -1080,7 +1064,6 @@ var sharedMessages = reactIntl.defineMessages({
|
|
|
1080
1064
|
});
|
|
1081
1065
|
|
|
1082
1066
|
const Upload = () => {
|
|
1083
|
-
var _context;
|
|
1084
1067
|
const _useImportResourcesCo = useImportResourcesContext(),
|
|
1085
1068
|
state = _useImportResourcesCo.state,
|
|
1086
1069
|
onClose = _useImportResourcesCo.onClose,
|
|
@@ -1092,7 +1075,7 @@ const Upload = () => {
|
|
|
1092
1075
|
return jsxRuntime.jsx(applicationComponents.FormDialog, {
|
|
1093
1076
|
size: 16,
|
|
1094
1077
|
isOpen: true,
|
|
1095
|
-
title: intl.formatMessage(sharedMessages[
|
|
1078
|
+
title: intl.formatMessage(sharedMessages[`modalTitle.${state.resourceType}`]),
|
|
1096
1079
|
labelPrimary: intl.formatMessage(sharedMessages.uploadButton),
|
|
1097
1080
|
onPrimaryButtonClick: handleUploadAndValidation,
|
|
1098
1081
|
isPrimaryButtonDisabled: !Boolean(state.droppedFile),
|
|
@@ -1107,18 +1090,18 @@ const Upload = () => {
|
|
|
1107
1090
|
scale: "l",
|
|
1108
1091
|
children: [isMultipleResourceTypes ? jsxRuntime.jsxs(uiKit.Grid, {
|
|
1109
1092
|
gridRowGap: uiKit.designTokens.spacingL,
|
|
1110
|
-
gridTemplateColumns:
|
|
1093
|
+
gridTemplateColumns: `calc(${uiKit.designTokens.constraint3} + ${uiKit.designTokens.spacingL}) auto`,
|
|
1111
1094
|
children: [jsxRuntime.jsx(uiKit.Grid.Item, {
|
|
1112
1095
|
children: jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1113
1096
|
isBold: true,
|
|
1114
|
-
intlMessage: messages$
|
|
1097
|
+
intlMessage: messages$5.dataType
|
|
1115
1098
|
})
|
|
1116
1099
|
}), jsxRuntime.jsx(uiKit.Grid.Item, {
|
|
1117
1100
|
children: jsxRuntime.jsx(ResourceTypeSelection, {})
|
|
1118
1101
|
}), jsxRuntime.jsx(uiKit.Grid.Item, {
|
|
1119
1102
|
children: jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1120
1103
|
isBold: true,
|
|
1121
|
-
intlMessage: messages$
|
|
1104
|
+
intlMessage: messages$5.instructions
|
|
1122
1105
|
})
|
|
1123
1106
|
}), jsxRuntime.jsx(uiKit.Grid.Item, {
|
|
1124
1107
|
children: jsxRuntime.jsx(Instructions, {})
|
|
@@ -1132,6 +1115,274 @@ const Upload = () => {
|
|
|
1132
1115
|
};
|
|
1133
1116
|
|
|
1134
1117
|
var messages$3 = reactIntl.defineMessages({
|
|
1118
|
+
row: {
|
|
1119
|
+
id: 'ImportResourcesModal.row',
|
|
1120
|
+
description: 'In Upload file error modal - "Row" column',
|
|
1121
|
+
defaultMessage: 'Row'
|
|
1122
|
+
},
|
|
1123
|
+
errorType: {
|
|
1124
|
+
id: 'ImportResourcesModal.errorType',
|
|
1125
|
+
description: 'In Upload file error modal - "Error type" column',
|
|
1126
|
+
defaultMessage: 'Error type'
|
|
1127
|
+
},
|
|
1128
|
+
details: {
|
|
1129
|
+
id: 'ImportResourcesModal.details',
|
|
1130
|
+
description: 'In Upload file error modal - "Details" column',
|
|
1131
|
+
defaultMessage: 'Details'
|
|
1132
|
+
},
|
|
1133
|
+
uploadingError: {
|
|
1134
|
+
id: 'ImportResourcesModal.uploadingError',
|
|
1135
|
+
description: 'Title when errors detected while uploading file',
|
|
1136
|
+
defaultMessage: 'There are <b>{errorsCount}</b> errors detected while uploading the file <b>{fileName}</b>.'
|
|
1137
|
+
},
|
|
1138
|
+
supportedValuesDocumentation: {
|
|
1139
|
+
id: 'ImportResourcesModal.supportedValuesDocumentation',
|
|
1140
|
+
description: 'Link to the documentation for supported values',
|
|
1141
|
+
defaultMessage: '<documentationLink>View the documentation</documentationLink> for supported values.'
|
|
1142
|
+
},
|
|
1143
|
+
uploadNewFile: {
|
|
1144
|
+
id: 'ImportResourcesModal.uploadNewFile',
|
|
1145
|
+
description: 'Upload new file button',
|
|
1146
|
+
defaultMessage: 'Upload new file'
|
|
1147
|
+
}
|
|
1148
|
+
});
|
|
1149
|
+
|
|
1150
|
+
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; }
|
|
1151
|
+
function _objectSpread$9(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$9(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$9(Object(t))).call(_context3, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
1152
|
+
const getColumns$1 = () => [{
|
|
1153
|
+
key: 'errorType',
|
|
1154
|
+
label: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$9({}, messages$3.errorType)),
|
|
1155
|
+
width: 'max-content'
|
|
1156
|
+
}, {
|
|
1157
|
+
key: 'details',
|
|
1158
|
+
label: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$9({}, messages$3.details))
|
|
1159
|
+
}];
|
|
1160
|
+
const UploadClientSideErrorTable = props => {
|
|
1161
|
+
var _context;
|
|
1162
|
+
const pagination = uiKit.usePaginationState({
|
|
1163
|
+
perPage: 10
|
|
1164
|
+
});
|
|
1165
|
+
const startIndex = (pagination.page.value - 1) * pagination.perPage.value;
|
|
1166
|
+
const endIndex = startIndex + pagination.perPage.value;
|
|
1167
|
+
const currentPageRows = _sliceInstanceProperty__default["default"](_context = props.rows).call(_context, startIndex, endIndex);
|
|
1168
|
+
const shouldShowPagination = props.rows.length > pagination.perPage.value;
|
|
1169
|
+
return jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
1170
|
+
scale: "l",
|
|
1171
|
+
children: [jsxRuntime.jsx(DataTable__default["default"], {
|
|
1172
|
+
verticalCellAlignment: "center",
|
|
1173
|
+
isCondensed: true,
|
|
1174
|
+
rows: currentPageRows,
|
|
1175
|
+
columns: getColumns$1(),
|
|
1176
|
+
itemRenderer: itemRenderer$1
|
|
1177
|
+
}), shouldShowPagination && jsxRuntime.jsx(uiKit.PageNavigator, {
|
|
1178
|
+
onPageChange: pagination.page.onChange,
|
|
1179
|
+
page: pagination.page.value,
|
|
1180
|
+
totalPages: Math.ceil(props.rows.length / pagination.perPage.value)
|
|
1181
|
+
})]
|
|
1182
|
+
});
|
|
1183
|
+
};
|
|
1184
|
+
function itemRenderer$1(item, column) {
|
|
1185
|
+
switch (column.key) {
|
|
1186
|
+
case 'errorType':
|
|
1187
|
+
return jsxRuntime.jsx(uiKit.Stamp, {
|
|
1188
|
+
isCondensed: true,
|
|
1189
|
+
label: item.title,
|
|
1190
|
+
tone: "critical"
|
|
1191
|
+
});
|
|
1192
|
+
case 'details':
|
|
1193
|
+
return jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1194
|
+
children: item.description
|
|
1195
|
+
});
|
|
1196
|
+
default:
|
|
1197
|
+
throw new UnexpectedColumnError(column.key);
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
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; }
|
|
1202
|
+
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; }
|
|
1203
|
+
const UploadClientSideErrorsModal = () => {
|
|
1204
|
+
const intl = reactIntl.useIntl();
|
|
1205
|
+
const _useImportResourcesCo = useImportResourcesContext(),
|
|
1206
|
+
state = _useImportResourcesCo.state,
|
|
1207
|
+
actions = _useImportResourcesCo.actions,
|
|
1208
|
+
onClose = _useImportResourcesCo.onClose;
|
|
1209
|
+
const errorsCount = state.fileUploadClientSideErrors.length;
|
|
1210
|
+
return jsxRuntime.jsx(applicationComponents.InfoDialog, {
|
|
1211
|
+
size: 16,
|
|
1212
|
+
isOpen: true,
|
|
1213
|
+
title: intl.formatMessage(sharedMessages[`modalTitle.${state.resourceType}`]),
|
|
1214
|
+
onClose: () => onClose(),
|
|
1215
|
+
children: jsxRuntime.jsx(fullstory.Masking.Unmask, {
|
|
1216
|
+
children: jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
1217
|
+
scale: "l",
|
|
1218
|
+
children: [jsxRuntime.jsx(fullstory.Masking.Mask, {
|
|
1219
|
+
children: jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1220
|
+
intlMessage: _objectSpread$8(_objectSpread$8({}, messages$3.uploadingError), {}, {
|
|
1221
|
+
values: {
|
|
1222
|
+
fileName: state.droppedFile?.name,
|
|
1223
|
+
errorsCount: intl.formatNumber(errorsCount),
|
|
1224
|
+
b: getBold$3
|
|
1225
|
+
}
|
|
1226
|
+
})
|
|
1227
|
+
})
|
|
1228
|
+
}), jsxRuntime.jsx(UploadClientSideErrorTable, {
|
|
1229
|
+
rows: mapUploadFileClientSideErrorsToUploadFileErrorRows(state.fileUploadClientSideErrors)
|
|
1230
|
+
}), jsxRuntime.jsxs(uiKit.Spacings.Inline, {
|
|
1231
|
+
scale: "m",
|
|
1232
|
+
justifyContent: "flex-end",
|
|
1233
|
+
children: [jsxRuntime.jsx(uiKit.SecondaryButton, {
|
|
1234
|
+
label: intl.formatMessage(sharedMessages.close),
|
|
1235
|
+
onClick: () => onClose()
|
|
1236
|
+
}), jsxRuntime.jsx(uiKit.PrimaryButton, {
|
|
1237
|
+
iconLeft: jsxRuntime.jsx(uiKit.ImportIcon, {}),
|
|
1238
|
+
label: intl.formatMessage(messages$3.uploadNewFile),
|
|
1239
|
+
onClick: () => actions.uploadNewFile()
|
|
1240
|
+
})]
|
|
1241
|
+
})]
|
|
1242
|
+
})
|
|
1243
|
+
})
|
|
1244
|
+
});
|
|
1245
|
+
};
|
|
1246
|
+
function getBold$3(msg) {
|
|
1247
|
+
return jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1248
|
+
as: "span",
|
|
1249
|
+
isBold: true,
|
|
1250
|
+
children: msg
|
|
1251
|
+
});
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1254
|
+
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; }
|
|
1255
|
+
function _objectSpread$7(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$7(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$7(Object(t))).call(_context3, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
1256
|
+
const getColumns = () => [{
|
|
1257
|
+
key: 'row',
|
|
1258
|
+
label: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$7({}, messages$3.row)),
|
|
1259
|
+
width: 'max-content'
|
|
1260
|
+
}, {
|
|
1261
|
+
key: 'errorType',
|
|
1262
|
+
label: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$7({}, messages$3.errorType)),
|
|
1263
|
+
width: 'max-content'
|
|
1264
|
+
}, {
|
|
1265
|
+
key: 'details',
|
|
1266
|
+
label: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$7({}, messages$3.details))
|
|
1267
|
+
}];
|
|
1268
|
+
const UploadServerSideErrorTable = props => {
|
|
1269
|
+
var _context;
|
|
1270
|
+
const pagination = uiKit.usePaginationState({
|
|
1271
|
+
perPage: 10
|
|
1272
|
+
});
|
|
1273
|
+
const startIndex = (pagination.page.value - 1) * pagination.perPage.value;
|
|
1274
|
+
const endIndex = startIndex + pagination.perPage.value;
|
|
1275
|
+
const currentPageRows = _sliceInstanceProperty__default["default"](_context = props.rows).call(_context, startIndex, endIndex);
|
|
1276
|
+
const shouldShowPagination = props.rows.length > pagination.perPage.value;
|
|
1277
|
+
return jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
1278
|
+
scale: "l",
|
|
1279
|
+
children: [jsxRuntime.jsx(DataTable__default["default"], {
|
|
1280
|
+
verticalCellAlignment: "center",
|
|
1281
|
+
isCondensed: true,
|
|
1282
|
+
rows: currentPageRows,
|
|
1283
|
+
columns: getColumns(),
|
|
1284
|
+
itemRenderer: itemRenderer
|
|
1285
|
+
}), shouldShowPagination && jsxRuntime.jsx(uiKit.PageNavigator, {
|
|
1286
|
+
onPageChange: pagination.page.onChange,
|
|
1287
|
+
page: pagination.page.value,
|
|
1288
|
+
totalPages: Math.ceil(props.rows.length / pagination.perPage.value)
|
|
1289
|
+
})]
|
|
1290
|
+
});
|
|
1291
|
+
};
|
|
1292
|
+
function itemRenderer(item, column) {
|
|
1293
|
+
switch (column.key) {
|
|
1294
|
+
case 'row':
|
|
1295
|
+
return item.row;
|
|
1296
|
+
case 'errorType':
|
|
1297
|
+
return jsxRuntime.jsx(uiKit.Stamp, {
|
|
1298
|
+
isCondensed: true,
|
|
1299
|
+
label: item.code,
|
|
1300
|
+
tone: "critical"
|
|
1301
|
+
});
|
|
1302
|
+
case 'details':
|
|
1303
|
+
return jsxRuntime.jsxs(uiKit.Spacings.Inline, {
|
|
1304
|
+
scale: "xs",
|
|
1305
|
+
children: [jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1306
|
+
tone: "information",
|
|
1307
|
+
children: item.field
|
|
1308
|
+
}), jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1309
|
+
children: extractErrorDescriptionFromValidationMessage(item.validationMessage)
|
|
1310
|
+
})]
|
|
1311
|
+
});
|
|
1312
|
+
default:
|
|
1313
|
+
throw new UnexpectedColumnError(column.key);
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
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; }
|
|
1318
|
+
function _objectSpread$6(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$6(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$6(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
1319
|
+
const UploadServerSideErrorsModal = () => {
|
|
1320
|
+
const intl = reactIntl.useIntl();
|
|
1321
|
+
const _useImportResourcesCo = useImportResourcesContext(),
|
|
1322
|
+
state = _useImportResourcesCo.state,
|
|
1323
|
+
actions = _useImportResourcesCo.actions,
|
|
1324
|
+
onClose = _useImportResourcesCo.onClose;
|
|
1325
|
+
const errorsCount = getFileUploadErrorsCount(state.uploadFileResponse?.results);
|
|
1326
|
+
const documentationLink = RESOURCE_TYPE_DOCUMENTATION_LINKS[state.resourceType];
|
|
1327
|
+
return jsxRuntime.jsx(applicationComponents.InfoDialog, {
|
|
1328
|
+
size: 16,
|
|
1329
|
+
isOpen: true,
|
|
1330
|
+
title: intl.formatMessage(sharedMessages[`modalTitle.${state.resourceType}`]),
|
|
1331
|
+
onClose: onClose,
|
|
1332
|
+
children: jsxRuntime.jsx(fullstory.Masking.Unmask, {
|
|
1333
|
+
children: jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
1334
|
+
scale: "l",
|
|
1335
|
+
children: [jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
1336
|
+
scale: "xs",
|
|
1337
|
+
children: [jsxRuntime.jsx(fullstory.Masking.Mask, {
|
|
1338
|
+
children: jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1339
|
+
intlMessage: _objectSpread$6(_objectSpread$6({}, messages$3.uploadingError), {}, {
|
|
1340
|
+
values: {
|
|
1341
|
+
fileName: state.droppedFile?.name,
|
|
1342
|
+
errorsCount: intl.formatNumber(errorsCount),
|
|
1343
|
+
b: getBold$2
|
|
1344
|
+
}
|
|
1345
|
+
})
|
|
1346
|
+
})
|
|
1347
|
+
}), jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1348
|
+
intlMessage: _objectSpread$6(_objectSpread$6({}, messages$3.supportedValuesDocumentation), {}, {
|
|
1349
|
+
values: {
|
|
1350
|
+
documentationLink: msg => jsxRuntime.jsx(uiKit.Link, {
|
|
1351
|
+
tone: "secondary",
|
|
1352
|
+
isExternal: true,
|
|
1353
|
+
to: documentationLink,
|
|
1354
|
+
children: msg
|
|
1355
|
+
})
|
|
1356
|
+
}
|
|
1357
|
+
})
|
|
1358
|
+
})]
|
|
1359
|
+
}), jsxRuntime.jsx(UploadServerSideErrorTable, {
|
|
1360
|
+
rows: mapUploadFileErrorsResponseToUploadFileErrorRows(state.uploadFileResponse?.results)
|
|
1361
|
+
}), jsxRuntime.jsxs(uiKit.Spacings.Inline, {
|
|
1362
|
+
scale: "m",
|
|
1363
|
+
justifyContent: "flex-end",
|
|
1364
|
+
children: [jsxRuntime.jsx(uiKit.SecondaryButton, {
|
|
1365
|
+
label: intl.formatMessage(sharedMessages.close),
|
|
1366
|
+
onClick: () => onClose()
|
|
1367
|
+
}), jsxRuntime.jsx(uiKit.PrimaryButton, {
|
|
1368
|
+
iconLeft: jsxRuntime.jsx(uiKit.ImportIcon, {}),
|
|
1369
|
+
label: intl.formatMessage(messages$3.uploadNewFile),
|
|
1370
|
+
onClick: () => actions.uploadNewFile()
|
|
1371
|
+
})]
|
|
1372
|
+
})]
|
|
1373
|
+
})
|
|
1374
|
+
})
|
|
1375
|
+
});
|
|
1376
|
+
};
|
|
1377
|
+
function getBold$2(msg) {
|
|
1378
|
+
return jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1379
|
+
as: "span",
|
|
1380
|
+
isBold: true,
|
|
1381
|
+
children: msg
|
|
1382
|
+
});
|
|
1383
|
+
}
|
|
1384
|
+
|
|
1385
|
+
var messages$2 = reactIntl.defineMessages({
|
|
1135
1386
|
startImportButton: {
|
|
1136
1387
|
id: 'ImportResourcesModal.startImportButton',
|
|
1137
1388
|
description: 'Label for the modal Start import button',
|
|
@@ -1209,8 +1460,8 @@ var messages$3 = reactIntl.defineMessages({
|
|
|
1209
1460
|
}
|
|
1210
1461
|
});
|
|
1211
1462
|
|
|
1212
|
-
function ownKeys$
|
|
1213
|
-
function _objectSpread$
|
|
1463
|
+
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; }
|
|
1464
|
+
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; }
|
|
1214
1465
|
const truncate = (isExpanded, columns, columnsCount) => {
|
|
1215
1466
|
return isExpanded ? columns.join(' | ') : _sliceInstanceProperty__default["default"](columns).call(columns, 0, columnsCount).join(' | ') + (columns.length > columnsCount ? '...' : '');
|
|
1216
1467
|
};
|
|
@@ -1236,7 +1487,7 @@ const ColumnList = props => {
|
|
|
1236
1487
|
e.preventDefault();
|
|
1237
1488
|
setIsExpanded(!isExpanded);
|
|
1238
1489
|
},
|
|
1239
|
-
children: isExpanded ? jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$
|
|
1490
|
+
children: isExpanded ? jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$5({}, messages$2.showLess)) : jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$5({}, messages$2.showMore))
|
|
1240
1491
|
})
|
|
1241
1492
|
})]
|
|
1242
1493
|
})
|
|
@@ -1244,8 +1495,8 @@ const ColumnList = props => {
|
|
|
1244
1495
|
});
|
|
1245
1496
|
};
|
|
1246
1497
|
|
|
1247
|
-
function ownKeys$
|
|
1248
|
-
function _objectSpread$
|
|
1498
|
+
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; }
|
|
1499
|
+
function _objectSpread$4(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$4(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$4(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
1249
1500
|
function UploadPreviewModal() {
|
|
1250
1501
|
const _useImportResourcesCo = useImportResourcesContext(),
|
|
1251
1502
|
state = _useImportResourcesCo.state;
|
|
@@ -1259,8 +1510,8 @@ function UploadPreviewModal() {
|
|
|
1259
1510
|
return jsxRuntime.jsx(applicationComponents.FormDialog, {
|
|
1260
1511
|
size: 16,
|
|
1261
1512
|
isOpen: true,
|
|
1262
|
-
title: intl.formatMessage(sharedMessages[
|
|
1263
|
-
labelPrimary: intl.formatMessage(messages$
|
|
1513
|
+
title: intl.formatMessage(sharedMessages[`modalTitle.${state.resourceType}`]),
|
|
1514
|
+
labelPrimary: intl.formatMessage(messages$2.continue),
|
|
1264
1515
|
onSecondaryButtonClick: () => onClose({
|
|
1265
1516
|
shouldDeleteImportContainer: true
|
|
1266
1517
|
}),
|
|
@@ -1279,7 +1530,7 @@ function UploadPreviewModal() {
|
|
|
1279
1530
|
children: jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
1280
1531
|
scale: "m",
|
|
1281
1532
|
children: [jsxRuntime.jsx("div", {}), jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1282
|
-
intlMessage: messages$
|
|
1533
|
+
intlMessage: messages$2.previewOfYourImport
|
|
1283
1534
|
}), jsxRuntime.jsx(uiKit.Card, {
|
|
1284
1535
|
insetScale: "xl",
|
|
1285
1536
|
children: jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
@@ -1289,10 +1540,10 @@ function UploadPreviewModal() {
|
|
|
1289
1540
|
children: [jsxRuntime.jsx(uiKit.CheckBoldIcon, {
|
|
1290
1541
|
color: "success"
|
|
1291
1542
|
}), jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1292
|
-
intlMessage: _objectSpread$
|
|
1543
|
+
intlMessage: _objectSpread$4(_objectSpread$4({}, messages$2.rowsToBeImported), {}, {
|
|
1293
1544
|
values: {
|
|
1294
1545
|
rowCount: intl.formatNumber(state.uploadFileResponse.rowsCount),
|
|
1295
|
-
b: getBold$
|
|
1546
|
+
b: getBold$1
|
|
1296
1547
|
}
|
|
1297
1548
|
})
|
|
1298
1549
|
})]
|
|
@@ -1301,10 +1552,10 @@ function UploadPreviewModal() {
|
|
|
1301
1552
|
children: [jsxRuntime.jsx(uiKit.CheckBoldIcon, {
|
|
1302
1553
|
color: "success"
|
|
1303
1554
|
}), jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1304
|
-
intlMessage: _objectSpread$
|
|
1555
|
+
intlMessage: _objectSpread$4(_objectSpread$4({}, messages$2.columnsToBeImported), {}, {
|
|
1305
1556
|
values: {
|
|
1306
1557
|
columnCount: intl.formatNumber(validatedColumns.length),
|
|
1307
|
-
b: getBold$
|
|
1558
|
+
b: getBold$1
|
|
1308
1559
|
}
|
|
1309
1560
|
})
|
|
1310
1561
|
})]
|
|
@@ -1321,10 +1572,10 @@ function UploadPreviewModal() {
|
|
|
1321
1572
|
children: [jsxRuntime.jsx(uiKit.EyeCrossedIcon, {
|
|
1322
1573
|
color: "neutral60"
|
|
1323
1574
|
}), jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1324
|
-
intlMessage: _objectSpread$
|
|
1575
|
+
intlMessage: _objectSpread$4(_objectSpread$4({}, messages$2.columnsToBeIgnored), {}, {
|
|
1325
1576
|
values: {
|
|
1326
1577
|
columnCount: intl.formatNumber(ignoredColumns.length),
|
|
1327
|
-
b: getBold$
|
|
1578
|
+
b: getBold$1
|
|
1328
1579
|
}
|
|
1329
1580
|
})
|
|
1330
1581
|
})]
|
|
@@ -1340,7 +1591,7 @@ function UploadPreviewModal() {
|
|
|
1340
1591
|
})
|
|
1341
1592
|
});
|
|
1342
1593
|
}
|
|
1343
|
-
function getBold$
|
|
1594
|
+
function getBold$1(msg) {
|
|
1344
1595
|
return jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1345
1596
|
as: "span",
|
|
1346
1597
|
isBold: true,
|
|
@@ -1348,43 +1599,39 @@ function getBold$3(msg) {
|
|
|
1348
1599
|
});
|
|
1349
1600
|
}
|
|
1350
1601
|
|
|
1351
|
-
function ownKeys$
|
|
1352
|
-
function _objectSpread$
|
|
1602
|
+
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; }
|
|
1603
|
+
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; }
|
|
1353
1604
|
const getNewLine = () => jsxRuntime.jsx("br", {});
|
|
1354
1605
|
const getImportLogsLink = (msg, projectKey) => jsxRuntime.jsx(uiKit.Link, {
|
|
1355
|
-
to:
|
|
1606
|
+
to: `/${projectKey}/operations/import/logs`,
|
|
1356
1607
|
children: msg
|
|
1357
1608
|
});
|
|
1358
1609
|
const ImportConfirmationModal = () => {
|
|
1359
|
-
var _state$uploadFileResp;
|
|
1360
1610
|
const intl = reactIntl.useIntl();
|
|
1361
1611
|
const _useImportResourcesCo = useImportResourcesContext(),
|
|
1362
1612
|
state = _useImportResourcesCo.state,
|
|
1363
1613
|
onStartImportSuccess = _useImportResourcesCo.onStartImportSuccess,
|
|
1364
1614
|
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
|
-
}),
|
|
1615
|
+
const _useApplicationContex = applicationShellConnectors.useApplicationContext(context => ({
|
|
1616
|
+
projectKey: context.project?.key,
|
|
1617
|
+
projectName: context.project?.name
|
|
1618
|
+
})),
|
|
1372
1619
|
projectKey = _useApplicationContex.projectKey,
|
|
1373
1620
|
projectName = _useApplicationContex.projectName;
|
|
1374
1621
|
const asyncDispatch = sdk.useAsyncDispatch();
|
|
1375
1622
|
const showNotification = actionsGlobal.useShowNotification();
|
|
1376
1623
|
const ImportRunningTextNotification = () => jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1377
|
-
intlMessage: _objectSpread$
|
|
1624
|
+
intlMessage: _objectSpread$3(_objectSpread$3({}, messages$2.uploadNotificationSuccessMessage), {}, {
|
|
1378
1625
|
values: {
|
|
1379
1626
|
newline: getNewLine,
|
|
1380
1627
|
logsLink: msg => getImportLogsLink(msg, projectKey),
|
|
1381
|
-
b: getBold
|
|
1628
|
+
b: getBold
|
|
1382
1629
|
}
|
|
1383
1630
|
})
|
|
1384
1631
|
});
|
|
1385
1632
|
return jsxRuntime.jsx(applicationComponents.ConfirmationDialog, {
|
|
1386
|
-
title: intl.formatMessage(sharedMessages[
|
|
1387
|
-
labelPrimary: intl.formatMessage(messages$
|
|
1633
|
+
title: intl.formatMessage(sharedMessages[`modalTitle.${state.resourceType}`]),
|
|
1634
|
+
labelPrimary: intl.formatMessage(messages$2.startImportButton),
|
|
1388
1635
|
isOpen: true,
|
|
1389
1636
|
onClose: () => onClose({
|
|
1390
1637
|
shouldDeleteImportContainer: true
|
|
@@ -1400,8 +1647,7 @@ const ImportConfirmationModal = () => {
|
|
|
1400
1647
|
},
|
|
1401
1648
|
onConfirm: async () => {
|
|
1402
1649
|
try {
|
|
1403
|
-
|
|
1404
|
-
const canConfirm = projectKey && state.containerKey && ((_state$droppedFile = state.droppedFile) === null || _state$droppedFile === void 0 ? void 0 : _state$droppedFile.name) && state.resourceType;
|
|
1650
|
+
const canConfirm = projectKey && state.containerKey && state.droppedFile?.name && state.resourceType;
|
|
1405
1651
|
if (!canConfirm) return;
|
|
1406
1652
|
onClose();
|
|
1407
1653
|
await processUploadedFile({
|
|
@@ -1436,288 +1682,18 @@ const ImportConfirmationModal = () => {
|
|
|
1436
1682
|
scale: "xl",
|
|
1437
1683
|
children: [jsxRuntime.jsxs("div", {
|
|
1438
1684
|
children: [jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1439
|
-
intlMessage: _objectSpread$
|
|
1685
|
+
intlMessage: _objectSpread$3(_objectSpread$3({}, messages$2.confirmationBodyText), {}, {
|
|
1440
1686
|
values: {
|
|
1441
1687
|
projectName: projectName,
|
|
1442
|
-
count: intl.formatNumber(
|
|
1443
|
-
bold: getBold
|
|
1688
|
+
count: intl.formatNumber(state?.uploadFileResponse?.rowsCount || 0),
|
|
1689
|
+
bold: getBold
|
|
1444
1690
|
}
|
|
1445
1691
|
})
|
|
1446
1692
|
}), jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1447
|
-
intlMessage: messages$
|
|
1448
|
-
})]
|
|
1449
|
-
}), jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1450
|
-
intlMessage: messages$3.confirmationBodyQuestion
|
|
1451
|
-
})]
|
|
1452
|
-
})
|
|
1453
|
-
})
|
|
1454
|
-
});
|
|
1455
|
-
};
|
|
1456
|
-
function getBold$2(msg) {
|
|
1457
|
-
return jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1458
|
-
as: "span",
|
|
1459
|
-
isBold: true,
|
|
1460
|
-
children: msg
|
|
1461
|
-
});
|
|
1462
|
-
}
|
|
1463
|
-
|
|
1464
|
-
var messages$2 = reactIntl.defineMessages({
|
|
1465
|
-
row: {
|
|
1466
|
-
id: 'ImportResourcesModal.row',
|
|
1467
|
-
description: 'In Upload file error modal - "Row" column',
|
|
1468
|
-
defaultMessage: 'Row'
|
|
1469
|
-
},
|
|
1470
|
-
errorType: {
|
|
1471
|
-
id: 'ImportResourcesModal.errorType',
|
|
1472
|
-
description: 'In Upload file error modal - "Error type" column',
|
|
1473
|
-
defaultMessage: 'Error type'
|
|
1474
|
-
},
|
|
1475
|
-
details: {
|
|
1476
|
-
id: 'ImportResourcesModal.details',
|
|
1477
|
-
description: 'In Upload file error modal - "Details" column',
|
|
1478
|
-
defaultMessage: 'Details'
|
|
1479
|
-
},
|
|
1480
|
-
uploadingError: {
|
|
1481
|
-
id: 'ImportResourcesModal.uploadingError',
|
|
1482
|
-
description: 'Title when errors detected while uploading file',
|
|
1483
|
-
defaultMessage: 'There are <b>{errorsCount}</b> errors detected while uploading the file <b>{fileName}</b>.'
|
|
1484
|
-
},
|
|
1485
|
-
supportedValuesDocumentation: {
|
|
1486
|
-
id: 'ImportResourcesModal.supportedValuesDocumentation',
|
|
1487
|
-
description: 'Link to the documentation for supported values',
|
|
1488
|
-
defaultMessage: '<documentationLink>View the documentation</documentationLink> for supported values.'
|
|
1489
|
-
},
|
|
1490
|
-
uploadNewFile: {
|
|
1491
|
-
id: 'ImportResourcesModal.uploadNewFile',
|
|
1492
|
-
description: 'Upload new file button',
|
|
1493
|
-
defaultMessage: 'Upload new file'
|
|
1494
|
-
}
|
|
1495
|
-
});
|
|
1496
|
-
|
|
1497
|
-
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; }
|
|
1498
|
-
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; }
|
|
1499
|
-
const getColumns$1 = () => [{
|
|
1500
|
-
key: 'errorType',
|
|
1501
|
-
label: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$6({}, messages$2.errorType)),
|
|
1502
|
-
width: 'max-content'
|
|
1503
|
-
}, {
|
|
1504
|
-
key: 'details',
|
|
1505
|
-
label: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$6({}, messages$2.details))
|
|
1506
|
-
}];
|
|
1507
|
-
const UploadClientSideErrorTable = props => {
|
|
1508
|
-
var _context;
|
|
1509
|
-
const pagination = uiKit.usePaginationState({
|
|
1510
|
-
perPage: 10
|
|
1511
|
-
});
|
|
1512
|
-
const startIndex = (pagination.page.value - 1) * pagination.perPage.value;
|
|
1513
|
-
const endIndex = startIndex + pagination.perPage.value;
|
|
1514
|
-
const currentPageRows = _sliceInstanceProperty__default["default"](_context = props.rows).call(_context, startIndex, endIndex);
|
|
1515
|
-
const shouldShowPagination = props.rows.length > pagination.perPage.value;
|
|
1516
|
-
return jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
1517
|
-
scale: "l",
|
|
1518
|
-
children: [jsxRuntime.jsx(DataTable__default["default"], {
|
|
1519
|
-
verticalCellAlignment: "center",
|
|
1520
|
-
isCondensed: true,
|
|
1521
|
-
rows: currentPageRows,
|
|
1522
|
-
columns: getColumns$1(),
|
|
1523
|
-
itemRenderer: itemRenderer$1
|
|
1524
|
-
}), shouldShowPagination && jsxRuntime.jsx(uiKit.PageNavigator, {
|
|
1525
|
-
onPageChange: pagination.page.onChange,
|
|
1526
|
-
page: pagination.page.value,
|
|
1527
|
-
totalPages: Math.ceil(props.rows.length / pagination.perPage.value)
|
|
1528
|
-
})]
|
|
1529
|
-
});
|
|
1530
|
-
};
|
|
1531
|
-
function itemRenderer$1(item, column) {
|
|
1532
|
-
switch (column.key) {
|
|
1533
|
-
case 'errorType':
|
|
1534
|
-
return jsxRuntime.jsx(uiKit.Stamp, {
|
|
1535
|
-
isCondensed: true,
|
|
1536
|
-
label: item.title,
|
|
1537
|
-
tone: "critical"
|
|
1538
|
-
});
|
|
1539
|
-
case 'details':
|
|
1540
|
-
return jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1541
|
-
children: item.description
|
|
1542
|
-
});
|
|
1543
|
-
default:
|
|
1544
|
-
throw new UnexpectedColumnError(column.key);
|
|
1545
|
-
}
|
|
1546
|
-
}
|
|
1547
|
-
|
|
1548
|
-
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; }
|
|
1549
|
-
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; }
|
|
1550
|
-
const UploadClientSideErrorsModal = () => {
|
|
1551
|
-
var _state$droppedFile;
|
|
1552
|
-
const intl = reactIntl.useIntl();
|
|
1553
|
-
const _useImportResourcesCo = useImportResourcesContext(),
|
|
1554
|
-
state = _useImportResourcesCo.state,
|
|
1555
|
-
actions = _useImportResourcesCo.actions,
|
|
1556
|
-
onClose = _useImportResourcesCo.onClose;
|
|
1557
|
-
const errorsCount = state.fileUploadClientSideErrors.length;
|
|
1558
|
-
return jsxRuntime.jsx(applicationComponents.InfoDialog, {
|
|
1559
|
-
size: 16,
|
|
1560
|
-
isOpen: true,
|
|
1561
|
-
title: intl.formatMessage(sharedMessages["modalTitle.".concat(state.resourceType)]),
|
|
1562
|
-
onClose: () => onClose(),
|
|
1563
|
-
children: jsxRuntime.jsx(fullstory.Masking.Unmask, {
|
|
1564
|
-
children: jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
1565
|
-
scale: "l",
|
|
1566
|
-
children: [jsxRuntime.jsx(fullstory.Masking.Mask, {
|
|
1567
|
-
children: jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1568
|
-
intlMessage: _objectSpread$5(_objectSpread$5({}, messages$2.uploadingError), {}, {
|
|
1569
|
-
values: {
|
|
1570
|
-
fileName: (_state$droppedFile = state.droppedFile) === null || _state$droppedFile === void 0 ? void 0 : _state$droppedFile.name,
|
|
1571
|
-
errorsCount: intl.formatNumber(errorsCount),
|
|
1572
|
-
b: getBold$1
|
|
1573
|
-
}
|
|
1574
|
-
})
|
|
1575
|
-
})
|
|
1576
|
-
}), jsxRuntime.jsx(UploadClientSideErrorTable, {
|
|
1577
|
-
rows: mapUploadFileClientSideErrorsToUploadFileErrorRows(state.fileUploadClientSideErrors)
|
|
1578
|
-
}), jsxRuntime.jsxs(uiKit.Spacings.Inline, {
|
|
1579
|
-
scale: "m",
|
|
1580
|
-
justifyContent: "flex-end",
|
|
1581
|
-
children: [jsxRuntime.jsx(uiKit.SecondaryButton, {
|
|
1582
|
-
label: intl.formatMessage(sharedMessages.close),
|
|
1583
|
-
onClick: () => onClose()
|
|
1584
|
-
}), jsxRuntime.jsx(uiKit.PrimaryButton, {
|
|
1585
|
-
iconLeft: jsxRuntime.jsx(uiKit.ImportIcon, {}),
|
|
1586
|
-
label: intl.formatMessage(messages$2.uploadNewFile),
|
|
1587
|
-
onClick: () => actions.uploadNewFile()
|
|
1693
|
+
intlMessage: messages$2.confirmationBodyNote
|
|
1588
1694
|
})]
|
|
1589
|
-
})]
|
|
1590
|
-
})
|
|
1591
|
-
})
|
|
1592
|
-
});
|
|
1593
|
-
};
|
|
1594
|
-
function getBold$1(msg) {
|
|
1595
|
-
return jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1596
|
-
as: "span",
|
|
1597
|
-
isBold: true,
|
|
1598
|
-
children: msg
|
|
1599
|
-
});
|
|
1600
|
-
}
|
|
1601
|
-
|
|
1602
|
-
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; }
|
|
1603
|
-
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; }
|
|
1604
|
-
const getColumns = () => [{
|
|
1605
|
-
key: 'row',
|
|
1606
|
-
label: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$4({}, messages$2.row)),
|
|
1607
|
-
width: 'max-content'
|
|
1608
|
-
}, {
|
|
1609
|
-
key: 'errorType',
|
|
1610
|
-
label: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$4({}, messages$2.errorType)),
|
|
1611
|
-
width: 'max-content'
|
|
1612
|
-
}, {
|
|
1613
|
-
key: 'details',
|
|
1614
|
-
label: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$4({}, messages$2.details))
|
|
1615
|
-
}];
|
|
1616
|
-
const UploadServerSideErrorTable = props => {
|
|
1617
|
-
var _context;
|
|
1618
|
-
const pagination = uiKit.usePaginationState({
|
|
1619
|
-
perPage: 10
|
|
1620
|
-
});
|
|
1621
|
-
const startIndex = (pagination.page.value - 1) * pagination.perPage.value;
|
|
1622
|
-
const endIndex = startIndex + pagination.perPage.value;
|
|
1623
|
-
const currentPageRows = _sliceInstanceProperty__default["default"](_context = props.rows).call(_context, startIndex, endIndex);
|
|
1624
|
-
const shouldShowPagination = props.rows.length > pagination.perPage.value;
|
|
1625
|
-
return jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
1626
|
-
scale: "l",
|
|
1627
|
-
children: [jsxRuntime.jsx(DataTable__default["default"], {
|
|
1628
|
-
verticalCellAlignment: "center",
|
|
1629
|
-
isCondensed: true,
|
|
1630
|
-
rows: currentPageRows,
|
|
1631
|
-
columns: getColumns(),
|
|
1632
|
-
itemRenderer: itemRenderer
|
|
1633
|
-
}), shouldShowPagination && jsxRuntime.jsx(uiKit.PageNavigator, {
|
|
1634
|
-
onPageChange: pagination.page.onChange,
|
|
1635
|
-
page: pagination.page.value,
|
|
1636
|
-
totalPages: Math.ceil(props.rows.length / pagination.perPage.value)
|
|
1637
|
-
})]
|
|
1638
|
-
});
|
|
1639
|
-
};
|
|
1640
|
-
function itemRenderer(item, column) {
|
|
1641
|
-
switch (column.key) {
|
|
1642
|
-
case 'row':
|
|
1643
|
-
return item.row;
|
|
1644
|
-
case 'errorType':
|
|
1645
|
-
return jsxRuntime.jsx(uiKit.Stamp, {
|
|
1646
|
-
isCondensed: true,
|
|
1647
|
-
label: item.code,
|
|
1648
|
-
tone: "critical"
|
|
1649
|
-
});
|
|
1650
|
-
case 'details':
|
|
1651
|
-
return jsxRuntime.jsxs(uiKit.Spacings.Inline, {
|
|
1652
|
-
scale: "xs",
|
|
1653
|
-
children: [jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1654
|
-
tone: "information",
|
|
1655
|
-
children: item.field
|
|
1656
1695
|
}), jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1657
|
-
|
|
1658
|
-
})]
|
|
1659
|
-
});
|
|
1660
|
-
default:
|
|
1661
|
-
throw new UnexpectedColumnError(column.key);
|
|
1662
|
-
}
|
|
1663
|
-
}
|
|
1664
|
-
|
|
1665
|
-
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; }
|
|
1666
|
-
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; }
|
|
1667
|
-
const UploadServerSideErrorsModal = () => {
|
|
1668
|
-
var _state$uploadFileResp, _state$droppedFile, _state$uploadFileResp2;
|
|
1669
|
-
const intl = reactIntl.useIntl();
|
|
1670
|
-
const _useImportResourcesCo = useImportResourcesContext(),
|
|
1671
|
-
state = _useImportResourcesCo.state,
|
|
1672
|
-
actions = _useImportResourcesCo.actions,
|
|
1673
|
-
onClose = _useImportResourcesCo.onClose;
|
|
1674
|
-
const errorsCount = getFileUploadErrorsCount((_state$uploadFileResp = state.uploadFileResponse) === null || _state$uploadFileResp === void 0 ? void 0 : _state$uploadFileResp.results);
|
|
1675
|
-
const documentationLink = RESOURCE_TYPE_DOCUMENTATION_LINKS[state.resourceType];
|
|
1676
|
-
return jsxRuntime.jsx(applicationComponents.InfoDialog, {
|
|
1677
|
-
size: 16,
|
|
1678
|
-
isOpen: true,
|
|
1679
|
-
title: intl.formatMessage(sharedMessages["modalTitle.".concat(state.resourceType)]),
|
|
1680
|
-
onClose: onClose,
|
|
1681
|
-
children: jsxRuntime.jsx(fullstory.Masking.Unmask, {
|
|
1682
|
-
children: jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
1683
|
-
scale: "l",
|
|
1684
|
-
children: [jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
1685
|
-
scale: "xs",
|
|
1686
|
-
children: [jsxRuntime.jsx(fullstory.Masking.Mask, {
|
|
1687
|
-
children: jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1688
|
-
intlMessage: _objectSpread$3(_objectSpread$3({}, messages$2.uploadingError), {}, {
|
|
1689
|
-
values: {
|
|
1690
|
-
fileName: (_state$droppedFile = state.droppedFile) === null || _state$droppedFile === void 0 ? void 0 : _state$droppedFile.name,
|
|
1691
|
-
errorsCount: intl.formatNumber(errorsCount),
|
|
1692
|
-
b: getBold
|
|
1693
|
-
}
|
|
1694
|
-
})
|
|
1695
|
-
})
|
|
1696
|
-
}), jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1697
|
-
intlMessage: _objectSpread$3(_objectSpread$3({}, messages$2.supportedValuesDocumentation), {}, {
|
|
1698
|
-
values: {
|
|
1699
|
-
documentationLink: msg => jsxRuntime.jsx(uiKit.Link, {
|
|
1700
|
-
tone: "secondary",
|
|
1701
|
-
isExternal: true,
|
|
1702
|
-
to: documentationLink,
|
|
1703
|
-
children: msg
|
|
1704
|
-
})
|
|
1705
|
-
}
|
|
1706
|
-
})
|
|
1707
|
-
})]
|
|
1708
|
-
}), jsxRuntime.jsx(UploadServerSideErrorTable, {
|
|
1709
|
-
rows: mapUploadFileErrorsResponseToUploadFileErrorRows((_state$uploadFileResp2 = state.uploadFileResponse) === null || _state$uploadFileResp2 === void 0 ? void 0 : _state$uploadFileResp2.results)
|
|
1710
|
-
}), jsxRuntime.jsxs(uiKit.Spacings.Inline, {
|
|
1711
|
-
scale: "m",
|
|
1712
|
-
justifyContent: "flex-end",
|
|
1713
|
-
children: [jsxRuntime.jsx(uiKit.SecondaryButton, {
|
|
1714
|
-
label: intl.formatMessage(sharedMessages.close),
|
|
1715
|
-
onClick: () => onClose()
|
|
1716
|
-
}), jsxRuntime.jsx(uiKit.PrimaryButton, {
|
|
1717
|
-
iconLeft: jsxRuntime.jsx(uiKit.ImportIcon, {}),
|
|
1718
|
-
label: intl.formatMessage(messages$2.uploadNewFile),
|
|
1719
|
-
onClick: () => actions.uploadNewFile()
|
|
1720
|
-
})]
|
|
1696
|
+
intlMessage: messages$2.confirmationBodyQuestion
|
|
1721
1697
|
})]
|
|
1722
1698
|
})
|
|
1723
1699
|
})
|
|
@@ -1732,11 +1708,10 @@ function getBold(msg) {
|
|
|
1732
1708
|
}
|
|
1733
1709
|
|
|
1734
1710
|
const UploadResult = () => {
|
|
1735
|
-
var _state$uploadFileResp;
|
|
1736
1711
|
const _useImportResourcesCo = useImportResourcesContext(),
|
|
1737
1712
|
state = _useImportResourcesCo.state;
|
|
1738
1713
|
if (state.fileUploadClientSideErrors.length > 0) return jsxRuntime.jsx(UploadClientSideErrorsModal, {});
|
|
1739
|
-
if (
|
|
1714
|
+
if (state.uploadFileResponse?.invalid > 0) return jsxRuntime.jsx(UploadServerSideErrorsModal, {});
|
|
1740
1715
|
return jsxRuntime.jsx(UploadPreviewModal, {});
|
|
1741
1716
|
};
|
|
1742
1717
|
|
|
@@ -1774,16 +1749,15 @@ FileIcon.defaultProps = {
|
|
|
1774
1749
|
xmlns: "http://www.w3.org/2000/svg"
|
|
1775
1750
|
};
|
|
1776
1751
|
const Uploading = () => {
|
|
1777
|
-
var _state$droppedFile;
|
|
1778
1752
|
const intl = reactIntl.useIntl();
|
|
1779
1753
|
const _useImportResourcesCo = useImportResourcesContext(),
|
|
1780
1754
|
state = _useImportResourcesCo.state,
|
|
1781
1755
|
actions = _useImportResourcesCo.actions,
|
|
1782
1756
|
onClose = _useImportResourcesCo.onClose;
|
|
1783
|
-
if (
|
|
1757
|
+
if (state.droppedFile?.name) return jsxRuntime.jsx(applicationComponents.InfoDialog, {
|
|
1784
1758
|
size: 16,
|
|
1785
1759
|
isOpen: true,
|
|
1786
|
-
title: intl.formatMessage(sharedMessages[
|
|
1760
|
+
title: intl.formatMessage(sharedMessages[`modalTitle.${state.resourceType}`]),
|
|
1787
1761
|
onClose: () => onClose({
|
|
1788
1762
|
shouldDeleteImportContainer: true
|
|
1789
1763
|
}),
|
|
@@ -1865,7 +1839,7 @@ const resourceTypeToDisplayName = resourceType => {
|
|
|
1865
1839
|
case IMPORTABLE_RESOURCES.CATEGORY:
|
|
1866
1840
|
return messages$1.categories;
|
|
1867
1841
|
default:
|
|
1868
|
-
throw new Error(
|
|
1842
|
+
throw new Error(`Unknown resource type: ${resourceType}`);
|
|
1869
1843
|
}
|
|
1870
1844
|
};
|
|
1871
1845
|
const ResourceTypeSelection = () => {
|
|
@@ -1954,8 +1928,8 @@ const loadMessages = async locale => {
|
|
|
1954
1928
|
return i18n.parseChunkImport(chunkImport);
|
|
1955
1929
|
} catch (error) {
|
|
1956
1930
|
// eslint-disable-next-line no-console
|
|
1957
|
-
console.warn(
|
|
1958
|
-
sentry.reportErrorToSentry(new Error(
|
|
1931
|
+
console.warn(`Something went wrong while loading the import-resources-modal messages for ${locale}`, error);
|
|
1932
|
+
sentry.reportErrorToSentry(new Error(`Something went wrong while loading the import-resources-modal messages for ${locale}`), {
|
|
1959
1933
|
extra: error
|
|
1960
1934
|
});
|
|
1961
1935
|
return {};
|
|
@@ -2000,14 +1974,14 @@ const useAsyncIntlMessages = (locale, loader) => {
|
|
|
2000
1974
|
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; }
|
|
2001
1975
|
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; }
|
|
2002
1976
|
const ImportResourcesModal = props => {
|
|
2003
|
-
var
|
|
1977
|
+
var _context;
|
|
2004
1978
|
const _useApplicationContex = applicationShellConnectors.useApplicationContext(context => ({
|
|
2005
1979
|
locale: context.user && context.user.locale
|
|
2006
1980
|
})),
|
|
2007
1981
|
locale = _useApplicationContex.locale;
|
|
2008
1982
|
const messages = useAsyncIntlMessages(locale, loadMessages);
|
|
2009
1983
|
if (!props.isOpen || messages.isLoading) return null;
|
|
2010
|
-
if (!
|
|
1984
|
+
if (!props.resourceTypes?.length) {
|
|
2011
1985
|
console.error('No resource types provided for import resources modal');
|
|
2012
1986
|
return null;
|
|
2013
1987
|
}
|
|
@@ -2028,5 +2002,5 @@ ImportResourcesModal.displayName = 'ImportResourcesModal';
|
|
|
2028
2002
|
exports.EnabledDropArea = EnabledDropArea;
|
|
2029
2003
|
exports.FileDropped = FileDropped;
|
|
2030
2004
|
exports.ImportResourcesModal = ImportResourcesModal;
|
|
2031
|
-
exports.messages = messages$
|
|
2005
|
+
exports.messages = messages$5;
|
|
2032
2006
|
exports.useImportResourcesContext = useImportResourcesContext;
|