@commercetools-frontend-extensions/import-resources-modal 0.0.0-canary-20240529140709
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/LICENSE +29 -0
- package/README.md +76 -0
- package/dist/active-drag-drop-area-06cef014.esm.js +60 -0
- package/dist/active-drag-drop-area-be3680ab.cjs.prod.js +62 -0
- package/dist/active-drag-drop-area-fae899bd.cjs.dev.js +62 -0
- package/dist/commercetools-frontend-extensions-import-resources-modal.cjs.d.ts +3 -0
- package/dist/commercetools-frontend-extensions-import-resources-modal.cjs.dev.js +60 -0
- package/dist/commercetools-frontend-extensions-import-resources-modal.cjs.js +7 -0
- package/dist/commercetools-frontend-extensions-import-resources-modal.cjs.prod.js +60 -0
- package/dist/commercetools-frontend-extensions-import-resources-modal.esm.js +52 -0
- package/dist/de-a34c5dd4.cjs.dev.js +6 -0
- package/dist/de-cd6c45d3.esm.js +4 -0
- package/dist/de-d954fe3d.cjs.prod.js +6 -0
- package/dist/declarations/src/@types/api.d.ts +13 -0
- package/dist/declarations/src/@types/basic-error-data-type.d.ts +5 -0
- package/dist/declarations/src/@types/file-upload.d.ts +52 -0
- package/dist/declarations/src/@types/import-container.d.ts +20 -0
- package/dist/declarations/src/@types/import-resources-modal-props.d.ts +7 -0
- package/dist/declarations/src/@types/import-states.d.ts +9 -0
- package/dist/declarations/src/@types/import-summary.d.ts +8 -0
- package/dist/declarations/src/@types/index.d.ts +9 -0
- package/dist/declarations/src/@types/resource-type.d.ts +1 -0
- package/dist/declarations/src/@types/shared.d.ts +7 -0
- package/dist/declarations/src/import-resources-modal.d.ts +6 -0
- package/dist/declarations/src/index.d.ts +2 -0
- package/dist/disabled-drop-area-2c088477.esm.js +37 -0
- package/dist/disabled-drop-area-99c1fa0b.cjs.prod.js +50 -0
- package/dist/disabled-drop-area-aa78075b.cjs.dev.js +50 -0
- package/dist/en-3a9aa2d4.esm.js +4 -0
- package/dist/en-6b3694f6.cjs.dev.js +6 -0
- package/dist/en-c7757448.cjs.prod.js +6 -0
- package/dist/enabled-drop-area-32e0dc61.cjs.prod.js +123 -0
- package/dist/enabled-drop-area-56d860b6.cjs.dev.js +123 -0
- package/dist/enabled-drop-area-69507fae.esm.js +110 -0
- package/dist/es-042343bd.cjs.prod.js +6 -0
- package/dist/es-8b3ecab1.cjs.dev.js +6 -0
- package/dist/es-e544023d.esm.js +4 -0
- package/dist/file-dropped-area-6acf82c0.cjs.dev.js +83 -0
- package/dist/file-dropped-area-6f365e02.esm.js +81 -0
- package/dist/file-dropped-area-e856a71f.cjs.prod.js +83 -0
- package/dist/fr-FR-9d9081ee.esm.js +4 -0
- package/dist/fr-FR-e7126fcc.cjs.dev.js +6 -0
- package/dist/fr-FR-fce1ca96.cjs.prod.js +6 -0
- package/dist/index-a4665b30.esm.js +1854 -0
- package/dist/index-bb7f975c.cjs.dev.js +1889 -0
- package/dist/index-d79bbd8e.cjs.prod.js +1883 -0
- package/dist/ja-37632763.cjs.prod.js +6 -0
- package/dist/ja-73c088a7.esm.js +4 -0
- package/dist/ja-9bd5f452.cjs.dev.js +6 -0
- package/dist/pt-BR-b37d730b.esm.js +4 -0
- package/dist/pt-BR-ea6b3251.cjs.dev.js +6 -0
- package/dist/pt-BR-ec2a1a11.cjs.prod.js +6 -0
- package/dist/zh-CN-4780d88e.esm.js +4 -0
- package/dist/zh-CN-52baa549.cjs.prod.js +6 -0
- package/dist/zh-CN-d4bc6d26.cjs.dev.js +6 -0
- package/package.json +88 -0
|
@@ -0,0 +1,1854 @@
|
|
|
1
|
+
import _Object$keys from '@babel/runtime-corejs3/core-js-stable/object/keys';
|
|
2
|
+
import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols';
|
|
3
|
+
import _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/filter';
|
|
4
|
+
import _Object$getOwnPropertyDescriptor from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor';
|
|
5
|
+
import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/for-each';
|
|
6
|
+
import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors';
|
|
7
|
+
import _Object$defineProperties from '@babel/runtime-corejs3/core-js-stable/object/define-properties';
|
|
8
|
+
import _Object$defineProperty from '@babel/runtime-corejs3/core-js-stable/object/define-property';
|
|
9
|
+
import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
|
|
10
|
+
import { defineMessages, useIntl, FormattedMessage, IntlProvider } from 'react-intl';
|
|
11
|
+
import { useApplicationContext } from '@commercetools-frontend/application-shell-connectors';
|
|
12
|
+
import _slicedToArray from '@babel/runtime-corejs3/helpers/esm/slicedToArray';
|
|
13
|
+
import React, { useContext, lazy, useState, useEffect } from 'react';
|
|
14
|
+
import { actions, useAsyncDispatch } from '@commercetools-frontend/sdk';
|
|
15
|
+
import { MC_API_PROXY_TARGETS, DOMAINS } from '@commercetools-frontend/constants';
|
|
16
|
+
import _everyInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/every';
|
|
17
|
+
import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
|
|
18
|
+
import { plural } from 'pluralize';
|
|
19
|
+
import _Promise from '@babel/runtime-corejs3/core-js-stable/promise';
|
|
20
|
+
import _Array$isArray from '@babel/runtime-corejs3/core-js-stable/array/is-array';
|
|
21
|
+
import _flatMapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/flat-map';
|
|
22
|
+
import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/map';
|
|
23
|
+
import _findInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/find';
|
|
24
|
+
import _includesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/includes';
|
|
25
|
+
import Papa from 'papaparse';
|
|
26
|
+
import _reduceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/reduce';
|
|
27
|
+
import _JSON$stringify from '@babel/runtime-corejs3/core-js-stable/json/stringify';
|
|
28
|
+
import _someInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/some';
|
|
29
|
+
import '@babel/runtime-corejs3/core-js-stable/instance/starts-with';
|
|
30
|
+
import 'querystring';
|
|
31
|
+
import 'ramda';
|
|
32
|
+
import { executeHttpClientRequest, buildApiUrl } from '@commercetools-frontend/application-shell';
|
|
33
|
+
import _Reflect$construct from '@babel/runtime-corejs3/core-js-stable/reflect/construct';
|
|
34
|
+
import _createClass from '@babel/runtime-corejs3/helpers/esm/createClass';
|
|
35
|
+
import _classCallCheck from '@babel/runtime-corejs3/helpers/esm/classCallCheck';
|
|
36
|
+
import _inherits from '@babel/runtime-corejs3/helpers/esm/inherits';
|
|
37
|
+
import _possibleConstructorReturn from '@babel/runtime-corejs3/helpers/esm/possibleConstructorReturn';
|
|
38
|
+
import _getPrototypeOf from '@babel/runtime-corejs3/helpers/esm/getPrototypeOf';
|
|
39
|
+
import _wrapNativeSuper from '@babel/runtime-corejs3/helpers/esm/wrapNativeSuper';
|
|
40
|
+
import { jsx, jsxs, Fragment } from '@emotion/react/jsx-runtime';
|
|
41
|
+
import { FormDialog, PageContentNarrow, ConfirmationDialog, InfoDialog } from '@commercetools-frontend/application-components';
|
|
42
|
+
import { customProperties, Constraints, Spacings, Text, Link, Card, CheckBoldIcon, EyeCrossedIcon, usePaginationState, PageNavigator, Stamp, SecondaryButton, PrimaryButton, ImportIcon, ProgressBar } from '@commercetools-frontend/ui-kit';
|
|
43
|
+
import { useShowNotification } from '@commercetools-frontend/actions-global';
|
|
44
|
+
import { reportErrorToSentry } from '@commercetools-frontend/sentry';
|
|
45
|
+
import { useDropzone } from 'react-dropzone';
|
|
46
|
+
import _styled from '@emotion/styled/base';
|
|
47
|
+
import { css } from '@emotion/react';
|
|
48
|
+
import _sliceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/slice';
|
|
49
|
+
import DataTable from '@commercetools-uikit/data-table';
|
|
50
|
+
import truncate$1 from 'lodash.truncate';
|
|
51
|
+
import { parseChunkImport, mapLocaleToIntlLocale } from '@commercetools-frontend/i18n';
|
|
52
|
+
|
|
53
|
+
const EnabledResourceType = {
|
|
54
|
+
category: true,
|
|
55
|
+
product: true
|
|
56
|
+
};
|
|
57
|
+
function isResourceType(maybeResourceType) {
|
|
58
|
+
return typeof maybeResourceType === 'string' && maybeResourceType in EnabledResourceType;
|
|
59
|
+
}
|
|
60
|
+
function assertResourceType(maybeResourceType) {
|
|
61
|
+
if (isResourceType(maybeResourceType)) return;
|
|
62
|
+
throw new Error("Invalid value: ".concat(maybeResourceType));
|
|
63
|
+
}
|
|
64
|
+
function isError(maybeError) {
|
|
65
|
+
if (maybeError instanceof Error) return true;
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
70
|
+
function hasOwnProperty(obj, prop) {
|
|
71
|
+
return typeof obj === 'object' && obj !== null && obj.hasOwnProperty(prop);
|
|
72
|
+
}
|
|
73
|
+
function hasRequiredFields(maybeValidObject, requiredFields) {
|
|
74
|
+
return typeof maybeValidObject === 'object' && maybeValidObject !== null && _everyInstanceProperty(requiredFields).call(requiredFields, property => hasOwnProperty(maybeValidObject, property));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
var _context;
|
|
78
|
+
const DEFAULT_DELIMITER = ',';
|
|
79
|
+
const INITIAL_COLUMN_DISPLAY_COUNT = 8;
|
|
80
|
+
const IMPORT_TAG_KEYS = {
|
|
81
|
+
source: 'source'
|
|
82
|
+
};
|
|
83
|
+
const IMPORT_TAG_VALUES = {
|
|
84
|
+
fileUpload: 'file-upload'
|
|
85
|
+
};
|
|
86
|
+
const TAG_KEY_SOURCE_FILE_UPLOAD = _concatInstanceProperty(_context = "".concat(IMPORT_TAG_KEYS.source, ":")).call(_context, IMPORT_TAG_VALUES.fileUpload);
|
|
87
|
+
|
|
88
|
+
const FILE_SIZE_LIMITS_MB = {
|
|
89
|
+
category: 10,
|
|
90
|
+
product: 35
|
|
91
|
+
};
|
|
92
|
+
const ROW_LIMITS = {
|
|
93
|
+
category: 5000,
|
|
94
|
+
product: 70000
|
|
95
|
+
};
|
|
96
|
+
const RESOURCE_TYPE_TEMPLATE_DOWNLOAD_LINKS = {
|
|
97
|
+
category: 'https://docs.commercetools.com/merchant-center/downloads/category_import_template.csv',
|
|
98
|
+
product: 'https://docs.commercetools.com/merchant-center/import-data#create-a-csv-file'
|
|
99
|
+
};
|
|
100
|
+
const RESOURCE_TYPE_DOCUMENTATION_LINKS = {
|
|
101
|
+
category: 'https://docs.commercetools.com/merchant-center/import-categories#supported-headers-and-values',
|
|
102
|
+
product: 'https://docs.commercetools.com/merchant-center/import-products#supported-headers-and-values'
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
function ownKeys$f(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
106
|
+
function _objectSpread$f(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context2 = ownKeys$f(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context3 = ownKeys$f(Object(t))).call(_context3, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* This function checks if the provided `expectedDelimiter` is used consistently in the first 10 lines of a CSV file.
|
|
110
|
+
* Returns a Promise that resolves to an object containing a boolean `isValid` property and the detected delimiter `delimiter`.
|
|
111
|
+
*
|
|
112
|
+
* @param {File} file - The CSV file to check.
|
|
113
|
+
* @param {string} [expectedDelimiter=DEFAULT_DELIMITER] - The expected delimiter to check for in the file.
|
|
114
|
+
* @returns {Promise<DelimiterCheck>} A Promise that resolves to a DelimiterCheck object.
|
|
115
|
+
*/
|
|
116
|
+
const checkDelimiter = function (file) {
|
|
117
|
+
let expectedDelimiter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_DELIMITER;
|
|
118
|
+
return new _Promise(resolve => {
|
|
119
|
+
let lineCount = 0;
|
|
120
|
+
let correctDelimiterCount = 0;
|
|
121
|
+
let detectedDelimiter = null;
|
|
122
|
+
Papa.parse(file, {
|
|
123
|
+
step: (results, parser) => {
|
|
124
|
+
lineCount++;
|
|
125
|
+
if (detectedDelimiter === null) {
|
|
126
|
+
detectedDelimiter = results.meta.delimiter;
|
|
127
|
+
}
|
|
128
|
+
if (results.meta.delimiter === expectedDelimiter) {
|
|
129
|
+
correctDelimiterCount++;
|
|
130
|
+
}
|
|
131
|
+
if (lineCount >= 10) {
|
|
132
|
+
parser.abort();
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
complete: () => {
|
|
136
|
+
const isValid = correctDelimiterCount === lineCount;
|
|
137
|
+
resolve({
|
|
138
|
+
isValid,
|
|
139
|
+
delimiter: detectedDelimiter
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
const mapUploadFileErrorsResponseToUploadFileErrorRows = uploadFileErrorsResponse => {
|
|
146
|
+
if (!uploadFileErrorsResponse || !_Array$isArray(uploadFileErrorsResponse)) return [];
|
|
147
|
+
let idCounter = 1;
|
|
148
|
+
return _flatMapInstanceProperty(uploadFileErrorsResponse).call(uploadFileErrorsResponse, rowErrorsResponse => {
|
|
149
|
+
var _context;
|
|
150
|
+
return _mapInstanceProperty(_context = rowErrorsResponse.errors).call(_context, rowError => ({
|
|
151
|
+
// DataTable component requires unique `id` field
|
|
152
|
+
id: String(idCounter++),
|
|
153
|
+
row: rowErrorsResponse.row,
|
|
154
|
+
field: rowError.field,
|
|
155
|
+
code: rowError.code,
|
|
156
|
+
validationMessage: rowError.message
|
|
157
|
+
}));
|
|
158
|
+
});
|
|
159
|
+
};
|
|
160
|
+
const mapUploadFileClientSideErrorsToUploadFileErrorRows = uploadFileClientSideErrors => {
|
|
161
|
+
let idCounter = 1;
|
|
162
|
+
return _mapInstanceProperty(uploadFileClientSideErrors).call(uploadFileClientSideErrors, uploadFileClientSideError => _objectSpread$f(_objectSpread$f({}, uploadFileClientSideError), {}, {
|
|
163
|
+
id: String(idCounter++)
|
|
164
|
+
}));
|
|
165
|
+
};
|
|
166
|
+
const extractErrorDescriptionFromValidationMessage = message => {
|
|
167
|
+
return message.split('"').pop();
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Returns the number of rows in a CSV file excluding the header
|
|
172
|
+
* @param file The CSV file to process.
|
|
173
|
+
* @returns A promise that resolves to the number of rows
|
|
174
|
+
*/
|
|
175
|
+
const getRowCount = file => {
|
|
176
|
+
return new _Promise(resolve => {
|
|
177
|
+
let lineCount = 0;
|
|
178
|
+
Papa.parse(file, {
|
|
179
|
+
step: _ref => {
|
|
180
|
+
let data = _ref.data;
|
|
181
|
+
// empty lines at the end of the file should not be counted
|
|
182
|
+
if (_Array$isArray(data) && _findInstanceProperty(data).call(data, Boolean)) lineCount++;
|
|
183
|
+
},
|
|
184
|
+
complete: () => {
|
|
185
|
+
// Subtract 1 for the header row
|
|
186
|
+
// We use Math.max to make sure the count is not less than 0, this is needed for empty files
|
|
187
|
+
resolve(Math.max(0, lineCount - 1));
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
};
|
|
192
|
+
const toBytes = megabytes => megabytes * 1024 * 1024;
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Returns columns from the provided `columns` excluding those specified in the `ignoredColumns`
|
|
196
|
+
*/
|
|
197
|
+
const getValidatedColumns = (columns, ignoredColumns) => {
|
|
198
|
+
return _filterInstanceProperty(columns).call(columns, column => !_includesInstanceProperty(ignoredColumns).call(ignoredColumns, column));
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
function getFileUploadErrorsCount(errors) {
|
|
202
|
+
if (!errors || !_Array$isArray(errors)) return 0;
|
|
203
|
+
return _reduceInstanceProperty(errors).call(errors, (acc, curr) => acc += curr.errors.length, 0);
|
|
204
|
+
}
|
|
205
|
+
function convertFileSizeToKB(sizeInBytes) {
|
|
206
|
+
return sizeInBytes / 1000;
|
|
207
|
+
}
|
|
208
|
+
function isAbortError(error) {
|
|
209
|
+
return error instanceof DOMException && error.name === 'AbortError';
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const encodeFileNameWithTimestampToContainerKey = fileName => {
|
|
213
|
+
return btoa(_JSON$stringify({
|
|
214
|
+
timestamp: new Date().getTime(),
|
|
215
|
+
fileName
|
|
216
|
+
})).replace(/=+$/g, '');
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
function getCreateImportContainerURL(projectKey) {
|
|
220
|
+
return "/".concat(projectKey, "/import-containers");
|
|
221
|
+
}
|
|
222
|
+
function getDeleteImportContainerURL(projectKey, containerKey) {
|
|
223
|
+
var _context6;
|
|
224
|
+
return _concatInstanceProperty(_context6 = "/".concat(projectKey, "/import-containers/")).call(_context6, containerKey);
|
|
225
|
+
}
|
|
226
|
+
function getFileUploadURL(projectKey, resourceType, containerKey) {
|
|
227
|
+
var _context8, _context9;
|
|
228
|
+
return _concatInstanceProperty(_context8 = _concatInstanceProperty(_context9 = "/".concat(projectKey, "/")).call(_context9, plural(resourceType), "/import-containers/")).call(_context8, containerKey, "/file-upload");
|
|
229
|
+
}
|
|
230
|
+
function getProccessFileURL(projectKey, resourceType, containerKey) {
|
|
231
|
+
var _context10, _context11;
|
|
232
|
+
return _concatInstanceProperty(_context10 = _concatInstanceProperty(_context11 = "/".concat(projectKey, "/")).call(_context11, plural(resourceType), "/import-containers/")).call(_context10, containerKey, "/process-file");
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function _createSuper$3(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$3(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
236
|
+
function _isNativeReflectConstruct$3() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$3 = function () { return !!t; })(); }
|
|
237
|
+
let UnexpectedResourceTypeError = /*#__PURE__*/function (_Error) {
|
|
238
|
+
_inherits(UnexpectedResourceTypeError, _Error);
|
|
239
|
+
var _super = _createSuper$3(UnexpectedResourceTypeError);
|
|
240
|
+
function UnexpectedResourceTypeError(resourceType) {
|
|
241
|
+
var _this;
|
|
242
|
+
_classCallCheck(this, UnexpectedResourceTypeError);
|
|
243
|
+
_this = _super.call(this, "Unexpected resource type \"".concat(resourceType, "\""));
|
|
244
|
+
_this.name = 'UnexpectedResourceTypeError';
|
|
245
|
+
return _this;
|
|
246
|
+
}
|
|
247
|
+
return _createClass(UnexpectedResourceTypeError);
|
|
248
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
249
|
+
|
|
250
|
+
function _createSuper$2(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$2(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
251
|
+
function _isNativeReflectConstruct$2() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$2 = function () { return !!t; })(); }
|
|
252
|
+
let MissingImportResourceProviderError = /*#__PURE__*/function (_Error) {
|
|
253
|
+
_inherits(MissingImportResourceProviderError, _Error);
|
|
254
|
+
var _super = _createSuper$2(MissingImportResourceProviderError);
|
|
255
|
+
function MissingImportResourceProviderError() {
|
|
256
|
+
var _this;
|
|
257
|
+
_classCallCheck(this, MissingImportResourceProviderError);
|
|
258
|
+
_this = _super.call(this, 'useImportResourcesContext must be used within ImportResourcesProvider');
|
|
259
|
+
_this.name = 'MissingImportResourceProviderError';
|
|
260
|
+
return _this;
|
|
261
|
+
}
|
|
262
|
+
return _createClass(MissingImportResourceProviderError);
|
|
263
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
264
|
+
|
|
265
|
+
function _createSuper$1(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
266
|
+
function _isNativeReflectConstruct$1() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$1 = function () { return !!t; })(); }
|
|
267
|
+
let UnexpectedColumnError = /*#__PURE__*/function (_Error) {
|
|
268
|
+
_inherits(UnexpectedColumnError, _Error);
|
|
269
|
+
var _super = _createSuper$1(UnexpectedColumnError);
|
|
270
|
+
function UnexpectedColumnError(columnName) {
|
|
271
|
+
var _this;
|
|
272
|
+
_classCallCheck(this, UnexpectedColumnError);
|
|
273
|
+
_this = _super.call(this, "Unexpected column \"".concat(columnName, "\""));
|
|
274
|
+
_this.name = 'UnexpectedColumnError';
|
|
275
|
+
return _this;
|
|
276
|
+
}
|
|
277
|
+
return _createClass(UnexpectedColumnError);
|
|
278
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
279
|
+
|
|
280
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
281
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); }
|
|
282
|
+
let HttpError = /*#__PURE__*/function (_Error) {
|
|
283
|
+
_inherits(HttpError, _Error);
|
|
284
|
+
var _super = _createSuper(HttpError);
|
|
285
|
+
function HttpError(statusCode, statusText, errorData) {
|
|
286
|
+
var _context;
|
|
287
|
+
var _this;
|
|
288
|
+
_classCallCheck(this, HttpError);
|
|
289
|
+
_this = _super.call(this, _concatInstanceProperty(_context = "HTTP Error! Status code: ".concat(statusCode, ", message: \"")).call(_context, statusText ? statusText : '', "\""));
|
|
290
|
+
_this.statusCode = void 0;
|
|
291
|
+
_this.errorData = void 0;
|
|
292
|
+
_this.name = 'HttpError';
|
|
293
|
+
_this.statusCode = statusCode;
|
|
294
|
+
_this.errorData = errorData;
|
|
295
|
+
return _this;
|
|
296
|
+
}
|
|
297
|
+
return _createClass(HttpError);
|
|
298
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
299
|
+
|
|
300
|
+
function ownKeys$e(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
301
|
+
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(_context2 = ownKeys$e(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context3 = ownKeys$e(Object(t))).call(_context3, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
302
|
+
const addProxyPrefixToUrl = (uri, proxy) => {
|
|
303
|
+
var _context;
|
|
304
|
+
return proxy ? _concatInstanceProperty(_context = "/proxy/".concat(proxy)).call(_context, uri) : uri;
|
|
305
|
+
};
|
|
306
|
+
const fetcher = async _ref => {
|
|
307
|
+
let url = _ref.url,
|
|
308
|
+
payload = _ref.payload,
|
|
309
|
+
config = _ref.config;
|
|
310
|
+
const data = await executeHttpClientRequest(async options => {
|
|
311
|
+
const res = await fetch(buildApiUrl(addProxyPrefixToUrl(url, config === null || config === void 0 ? void 0 : config.proxy)), _objectSpread$e(_objectSpread$e({}, options), {}, {
|
|
312
|
+
method: config === null || config === void 0 ? void 0 : config.method,
|
|
313
|
+
body: payload,
|
|
314
|
+
signal: config === null || config === void 0 ? void 0 : config.abortSignal
|
|
315
|
+
}));
|
|
316
|
+
if (!res.ok) {
|
|
317
|
+
const errorData = await res.json();
|
|
318
|
+
throw new HttpError(res.status, res.statusText, errorData);
|
|
319
|
+
}
|
|
320
|
+
const data = res.json();
|
|
321
|
+
return {
|
|
322
|
+
data,
|
|
323
|
+
statusCode: res.status,
|
|
324
|
+
getHeader: key => res.headers.get(key)
|
|
325
|
+
};
|
|
326
|
+
}, {
|
|
327
|
+
headers: _objectSpread$e({
|
|
328
|
+
'Content-Type': 'application/json'
|
|
329
|
+
}, config === null || config === void 0 ? void 0 : config.headers)
|
|
330
|
+
});
|
|
331
|
+
return data;
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
async function uploadFileForImport(_ref) {
|
|
335
|
+
let projectKey = _ref.projectKey,
|
|
336
|
+
containerKey = _ref.containerKey,
|
|
337
|
+
resourceType = _ref.resourceType,
|
|
338
|
+
file = _ref.file,
|
|
339
|
+
abortSignal = _ref.abortSignal;
|
|
340
|
+
const uri = getFileUploadURL(projectKey, resourceType, containerKey);
|
|
341
|
+
const formData = new FormData();
|
|
342
|
+
formData.append('file', file, file.name);
|
|
343
|
+
const response = await fetcher({
|
|
344
|
+
url: uri,
|
|
345
|
+
payload: formData,
|
|
346
|
+
config: {
|
|
347
|
+
abortSignal,
|
|
348
|
+
proxy: MC_API_PROXY_TARGETS.IMPORT,
|
|
349
|
+
method: 'POST',
|
|
350
|
+
headers: {
|
|
351
|
+
'Content-Type': null
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
});
|
|
355
|
+
return response;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
function ownKeys$d(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
359
|
+
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(_context2 = ownKeys$d(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context3 = ownKeys$d(Object(t))).call(_context3, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
360
|
+
function createImportContainerForFileUpload(importContainerDraft, projectKey, asyncDispatch) {
|
|
361
|
+
return asyncDispatch(actions.post({
|
|
362
|
+
mcApiProxyTarget: MC_API_PROXY_TARGETS.IMPORT,
|
|
363
|
+
uri: getCreateImportContainerURL(projectKey),
|
|
364
|
+
headers: {
|
|
365
|
+
accept: 'application/json',
|
|
366
|
+
'Content-Type': 'application/json'
|
|
367
|
+
},
|
|
368
|
+
payload: _JSON$stringify(_objectSpread$d(_objectSpread$d({}, importContainerDraft), {}, {
|
|
369
|
+
tags: [TAG_KEY_SOURCE_FILE_UPLOAD]
|
|
370
|
+
}))
|
|
371
|
+
}));
|
|
372
|
+
}
|
|
373
|
+
function deleteImportContainer(projectKey, containerKey, asyncDispatch) {
|
|
374
|
+
return asyncDispatch(actions.del({
|
|
375
|
+
mcApiProxyTarget: MC_API_PROXY_TARGETS.IMPORT,
|
|
376
|
+
uri: getDeleteImportContainerURL(projectKey, containerKey),
|
|
377
|
+
headers: {
|
|
378
|
+
accept: 'application/json'
|
|
379
|
+
}
|
|
380
|
+
}));
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
async function processUploadedFile(_ref) {
|
|
384
|
+
let projectKey = _ref.projectKey,
|
|
385
|
+
containerKey = _ref.containerKey,
|
|
386
|
+
resourceType = _ref.resourceType,
|
|
387
|
+
asyncDispatch = _ref.asyncDispatch;
|
|
388
|
+
const uri = getProccessFileURL(projectKey, resourceType, containerKey);
|
|
389
|
+
const response = await asyncDispatch(actions.post({
|
|
390
|
+
mcApiProxyTarget: MC_API_PROXY_TARGETS.IMPORT,
|
|
391
|
+
uri: uri,
|
|
392
|
+
headers: {
|
|
393
|
+
accept: 'application/json',
|
|
394
|
+
'Content-Type': 'application/json'
|
|
395
|
+
},
|
|
396
|
+
payload: {}
|
|
397
|
+
}));
|
|
398
|
+
assertProcessFileResponse(response);
|
|
399
|
+
return response;
|
|
400
|
+
}
|
|
401
|
+
function assertProcessFileResponse(maybeProcessFileResponse) {
|
|
402
|
+
const requiredFields = ['message'];
|
|
403
|
+
if (hasRequiredFields(maybeProcessFileResponse, requiredFields)) return;
|
|
404
|
+
throw new Error('Invalid response');
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
function ownKeys$c(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
408
|
+
function _objectSpread$c(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys$c(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys$c(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
409
|
+
function reducer(state, action) {
|
|
410
|
+
if (action.type === 'setCurrentStep') return _objectSpread$c(_objectSpread$c({}, state), {}, {
|
|
411
|
+
currentStep: action.currentStep
|
|
412
|
+
});
|
|
413
|
+
if (action.type === 'setUploadFileResponse') return _objectSpread$c(_objectSpread$c({}, state), {}, {
|
|
414
|
+
uploadFileResponse: action.uploadFileResponse
|
|
415
|
+
});
|
|
416
|
+
if (action.type === 'setResourceType') return _objectSpread$c(_objectSpread$c({}, state), {}, {
|
|
417
|
+
resourceType: action.resourceType
|
|
418
|
+
});
|
|
419
|
+
if (action.type === 'setContainerKey') return _objectSpread$c(_objectSpread$c({}, state), {}, {
|
|
420
|
+
containerKey: action.containerKey
|
|
421
|
+
});
|
|
422
|
+
if (action.type === 'cancelImport') return _objectSpread$c(_objectSpread$c({}, state), {}, {
|
|
423
|
+
currentStep: 1,
|
|
424
|
+
containerKey: undefined,
|
|
425
|
+
fileUploadClientSideErrors: [],
|
|
426
|
+
uploadFileResponse: undefined,
|
|
427
|
+
droppedFile: undefined,
|
|
428
|
+
dropAreaState: 'disabled'
|
|
429
|
+
});
|
|
430
|
+
if (action.type === 'uploadNewFile') return _objectSpread$c(_objectSpread$c({}, state), {}, {
|
|
431
|
+
currentStep: 1,
|
|
432
|
+
containerKey: undefined,
|
|
433
|
+
fileUploadClientSideErrors: [],
|
|
434
|
+
uploadFileResponse: undefined,
|
|
435
|
+
droppedFile: undefined,
|
|
436
|
+
dropAreaState: 'ready-for-drop'
|
|
437
|
+
});
|
|
438
|
+
if (action.type === 'setDroppedFile') {
|
|
439
|
+
return _objectSpread$c(_objectSpread$c({}, state), {}, {
|
|
440
|
+
droppedFile: action.droppedFile
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
if (action.type === 'setFileUploadClientSideErrors') {
|
|
444
|
+
return _objectSpread$c(_objectSpread$c({}, state), {}, {
|
|
445
|
+
fileUploadClientSideErrors: action.fileUploadClientSideErrors
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
if (action.type === 'setAbortController') {
|
|
449
|
+
return _objectSpread$c(_objectSpread$c({}, state), {}, {
|
|
450
|
+
abortController: action.abortController
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
throw new Error(getUnknownActionError(action));
|
|
454
|
+
}
|
|
455
|
+
function getUnknownActionError(actionType) {
|
|
456
|
+
return "Unkown type: ".concat(actionType);
|
|
457
|
+
}
|
|
458
|
+
const initialState = {
|
|
459
|
+
currentStep: 1,
|
|
460
|
+
abortController: new AbortController(),
|
|
461
|
+
dropAreaState: 'disabled',
|
|
462
|
+
uploadFileResponse: undefined,
|
|
463
|
+
fileUploadClientSideErrors: [],
|
|
464
|
+
resourceType: 'category',
|
|
465
|
+
containerKey: undefined
|
|
466
|
+
};
|
|
467
|
+
|
|
468
|
+
function ownKeys$b(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
469
|
+
function _objectSpread$b(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys$b(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys$b(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
470
|
+
const ImportResourcesContext = /*#__PURE__*/React.createContext();
|
|
471
|
+
const ImportResourcesProvider = props => {
|
|
472
|
+
const _useApplicationContex = useApplicationContext(context => {
|
|
473
|
+
var _context$project;
|
|
474
|
+
return {
|
|
475
|
+
projectKey: (_context$project = context.project) === null || _context$project === void 0 ? void 0 : _context$project.key
|
|
476
|
+
};
|
|
477
|
+
}),
|
|
478
|
+
projectKey = _useApplicationContex.projectKey;
|
|
479
|
+
const asyncDispatch = useAsyncDispatch();
|
|
480
|
+
const _React$useReducer = React.useReducer(reducer, _objectSpread$b(_objectSpread$b({}, initialState), {}, {
|
|
481
|
+
resourceType: props.resourceType
|
|
482
|
+
})),
|
|
483
|
+
_React$useReducer2 = _slicedToArray(_React$useReducer, 2),
|
|
484
|
+
state = _React$useReducer2[0],
|
|
485
|
+
dispatch = _React$useReducer2[1];
|
|
486
|
+
const setCurrentStep = currentStep => dispatch({
|
|
487
|
+
type: 'setCurrentStep',
|
|
488
|
+
currentStep
|
|
489
|
+
});
|
|
490
|
+
const setUploadFileResponse = _uploadFileResponse => dispatch({
|
|
491
|
+
type: 'setUploadFileResponse',
|
|
492
|
+
uploadFileResponse: _uploadFileResponse
|
|
493
|
+
});
|
|
494
|
+
const setResourceType = nextResourceType => dispatch({
|
|
495
|
+
type: 'setResourceType',
|
|
496
|
+
resourceType: nextResourceType
|
|
497
|
+
});
|
|
498
|
+
const setContainerKey = containerKey => dispatch({
|
|
499
|
+
type: 'setContainerKey',
|
|
500
|
+
containerKey
|
|
501
|
+
});
|
|
502
|
+
const cancelImport = () => dispatch({
|
|
503
|
+
type: 'cancelImport'
|
|
504
|
+
});
|
|
505
|
+
const uploadNewFile = () => dispatch({
|
|
506
|
+
type: 'uploadNewFile'
|
|
507
|
+
});
|
|
508
|
+
const setDroppedFile = nextDroppedFile => dispatch({
|
|
509
|
+
type: 'setDroppedFile',
|
|
510
|
+
droppedFile: nextDroppedFile
|
|
511
|
+
});
|
|
512
|
+
const setAbortController = nextAbortController => dispatch({
|
|
513
|
+
type: 'setAbortController',
|
|
514
|
+
abortController: nextAbortController
|
|
515
|
+
});
|
|
516
|
+
const setFileUploadClientSideErrors = nextFileUploadClientSideErrors => dispatch({
|
|
517
|
+
type: 'setFileUploadClientSideErrors',
|
|
518
|
+
fileUploadClientSideErrors: nextFileUploadClientSideErrors
|
|
519
|
+
});
|
|
520
|
+
const handleClose = function () {
|
|
521
|
+
let _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
522
|
+
shouldDeleteImportContainer = _ref.shouldDeleteImportContainer;
|
|
523
|
+
if (state.abortController) state.abortController.abort();
|
|
524
|
+
if (typeof props.onClose === 'function') props.onClose();
|
|
525
|
+
// Removes the associated import container when the import is closed
|
|
526
|
+
if (shouldDeleteImportContainer && projectKey && state.containerKey) deleteImportContainer(projectKey, state.containerKey, asyncDispatch);
|
|
527
|
+
};
|
|
528
|
+
const handleStartImportSuccess = () => {
|
|
529
|
+
if (typeof props.onStartImportSuccess === 'function') props.onStartImportSuccess();
|
|
530
|
+
};
|
|
531
|
+
return jsx(ImportResourcesContext.Provider, {
|
|
532
|
+
value: {
|
|
533
|
+
state,
|
|
534
|
+
onClose: handleClose,
|
|
535
|
+
onStartImportSuccess: handleStartImportSuccess,
|
|
536
|
+
actions: {
|
|
537
|
+
setCurrentStep,
|
|
538
|
+
cancelImport,
|
|
539
|
+
uploadNewFile,
|
|
540
|
+
setUploadFileResponse,
|
|
541
|
+
setResourceType,
|
|
542
|
+
setDroppedFile,
|
|
543
|
+
setContainerKey,
|
|
544
|
+
setAbortController,
|
|
545
|
+
setFileUploadClientSideErrors
|
|
546
|
+
}
|
|
547
|
+
},
|
|
548
|
+
children: props.children
|
|
549
|
+
});
|
|
550
|
+
};
|
|
551
|
+
|
|
552
|
+
function useImportResourcesContext() {
|
|
553
|
+
const context = useContext(ImportResourcesContext);
|
|
554
|
+
if (!context) {
|
|
555
|
+
throw new MissingImportResourceProviderError();
|
|
556
|
+
}
|
|
557
|
+
return context;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
var messages$3 = defineMessages({
|
|
561
|
+
fileSizeExceededTitle: {
|
|
562
|
+
id: 'ImportResourcesModal.sizeExceededTitle',
|
|
563
|
+
defaultMessage: 'File size exceeded'
|
|
564
|
+
},
|
|
565
|
+
fileSizeExceededDescription: {
|
|
566
|
+
id: 'ImportResourcesModal.sizeExceededDescription',
|
|
567
|
+
description: 'Error description when the file size exceeds the allowable limit',
|
|
568
|
+
defaultMessage: 'The file exceeds the maximum allowed size of {fileSizeLimit} MB'
|
|
569
|
+
},
|
|
570
|
+
rowLimitExceededTitle: {
|
|
571
|
+
id: 'ImportResourcesModal.rowLimitExceededTitle',
|
|
572
|
+
defaultMessage: 'Row limit exceeded'
|
|
573
|
+
},
|
|
574
|
+
rowLimitExceededDescription: {
|
|
575
|
+
id: 'ImportResourcesModal.rowLimitExceededDescription',
|
|
576
|
+
description: 'Error description when the file contains more rows than the allowable maximum',
|
|
577
|
+
defaultMessage: 'The file contains more than the allowable maximum of {rowLimit} rows'
|
|
578
|
+
},
|
|
579
|
+
dropAreaWrongDelimiterTitle: {
|
|
580
|
+
id: 'ImportResourcesModal.wrongDelimiterTitle',
|
|
581
|
+
defaultMessage: 'Wrong delimiter'
|
|
582
|
+
},
|
|
583
|
+
dropAreaWrongDelimiterDescription: {
|
|
584
|
+
id: 'ImportResourcesModal.wrongDelimiterDescription',
|
|
585
|
+
description: 'Message within the drop area when a CSV file uses an unexpected delimiter',
|
|
586
|
+
defaultMessage: 'The file is using the wrong delimiter "{delimiter}"'
|
|
587
|
+
},
|
|
588
|
+
dropAreaNotEnoughRowsTitle: {
|
|
589
|
+
id: 'ImportResourcesModal.dropAreaNotEnoughRowsTitle',
|
|
590
|
+
description: 'Error title shown when the uploaded CSV file does not contain a header and at least one row of data',
|
|
591
|
+
defaultMessage: 'Invalid CSV file'
|
|
592
|
+
},
|
|
593
|
+
dropAreaNotEnoughRowsDescription: {
|
|
594
|
+
id: 'ImportResourcesModal.dropAreaNotEnoughRowsDescription',
|
|
595
|
+
description: 'Error description shown when the uploaded CSV file does not contain a header and at least one row of data',
|
|
596
|
+
defaultMessage: 'Make sure the file contains a header and at least one row of data'
|
|
597
|
+
},
|
|
598
|
+
unexpectedError: {
|
|
599
|
+
id: 'ImportResourcesModal.unexpectedError',
|
|
600
|
+
description: 'Generic notification message when file upload fails',
|
|
601
|
+
defaultMessage: 'An unexpected error occurred during the file upload. Please try again, or contact support if this error occurs again.'
|
|
602
|
+
}
|
|
603
|
+
});
|
|
604
|
+
|
|
605
|
+
const useUpload = () => {
|
|
606
|
+
const intl = useIntl();
|
|
607
|
+
const projectKey = useApplicationContext(context => {
|
|
608
|
+
var _context$project;
|
|
609
|
+
return (_context$project = context.project) === null || _context$project === void 0 ? void 0 : _context$project.key;
|
|
610
|
+
});
|
|
611
|
+
const _useImportResourcesCo = useImportResourcesContext(),
|
|
612
|
+
state = _useImportResourcesCo.state,
|
|
613
|
+
actions = _useImportResourcesCo.actions;
|
|
614
|
+
const asyncDispatch = useAsyncDispatch();
|
|
615
|
+
const showNotification = useShowNotification();
|
|
616
|
+
React.useEffect(() => {
|
|
617
|
+
return () => {
|
|
618
|
+
if (state.abortController) state.abortController.abort();
|
|
619
|
+
};
|
|
620
|
+
}, [state.abortController]);
|
|
621
|
+
const isFileValid = async file => {
|
|
622
|
+
const errors = [];
|
|
623
|
+
const delimiterCheck = await checkDelimiter(file);
|
|
624
|
+
if (!delimiterCheck.isValid) errors.push({
|
|
625
|
+
title: intl.formatMessage(messages$3.dropAreaWrongDelimiterTitle),
|
|
626
|
+
description: intl.formatMessage(messages$3.dropAreaWrongDelimiterDescription, {
|
|
627
|
+
delimiter: delimiterCheck.delimiter
|
|
628
|
+
})
|
|
629
|
+
});
|
|
630
|
+
const rowCount = await getRowCount(file);
|
|
631
|
+
if (rowCount < 1) errors.push({
|
|
632
|
+
title: intl.formatMessage(messages$3.dropAreaNotEnoughRowsTitle),
|
|
633
|
+
description: intl.formatMessage(messages$3.dropAreaNotEnoughRowsDescription)
|
|
634
|
+
});
|
|
635
|
+
if (state.resourceType && file.size > toBytes(FILE_SIZE_LIMITS_MB[state.resourceType])) errors.push({
|
|
636
|
+
title: intl.formatMessage(messages$3.fileSizeExceededTitle),
|
|
637
|
+
description: intl.formatMessage(messages$3.fileSizeExceededDescription, {
|
|
638
|
+
fileSizeLimit: intl.formatNumber(FILE_SIZE_LIMITS_MB[state.resourceType])
|
|
639
|
+
})
|
|
640
|
+
});
|
|
641
|
+
if (state.resourceType && rowCount > ROW_LIMITS[state.resourceType]) errors.push({
|
|
642
|
+
title: intl.formatMessage(messages$3.rowLimitExceededTitle),
|
|
643
|
+
description: intl.formatMessage(messages$3.rowLimitExceededDescription, {
|
|
644
|
+
rowLimit: intl.formatNumber(ROW_LIMITS[state.resourceType])
|
|
645
|
+
})
|
|
646
|
+
});
|
|
647
|
+
if (errors.length > 0) {
|
|
648
|
+
actions.setFileUploadClientSideErrors(errors);
|
|
649
|
+
actions.setCurrentStep(3);
|
|
650
|
+
return false;
|
|
651
|
+
}
|
|
652
|
+
return true;
|
|
653
|
+
};
|
|
654
|
+
const handleUploadError = error => {
|
|
655
|
+
if (isAbortError(error)) {
|
|
656
|
+
actions.cancelImport();
|
|
657
|
+
return;
|
|
658
|
+
}
|
|
659
|
+
if (error instanceof HttpError) {
|
|
660
|
+
var _error$errorData, _error$errorData2;
|
|
661
|
+
if (((_error$errorData = error.errorData) === null || _error$errorData === void 0 ? void 0 : _error$errorData.code) === 'MISSING_KEY_ERROR') {
|
|
662
|
+
actions.cancelImport();
|
|
663
|
+
showNotification({
|
|
664
|
+
kind: 'error',
|
|
665
|
+
domain: DOMAINS.PAGE,
|
|
666
|
+
text: error.errorData.message
|
|
667
|
+
});
|
|
668
|
+
} else if (((_error$errorData2 = error.errorData) === null || _error$errorData2 === void 0 ? void 0 : _error$errorData2.invalid) > 0) {
|
|
669
|
+
actions.setUploadFileResponse(error.errorData);
|
|
670
|
+
} else {
|
|
671
|
+
actions.cancelImport();
|
|
672
|
+
showNotification({
|
|
673
|
+
kind: 'error',
|
|
674
|
+
domain: DOMAINS.PAGE,
|
|
675
|
+
text: intl.formatMessage(messages$3.unexpectedError)
|
|
676
|
+
});
|
|
677
|
+
}
|
|
678
|
+
} else {
|
|
679
|
+
var _state$droppedFile;
|
|
680
|
+
actions.cancelImport();
|
|
681
|
+
showNotification({
|
|
682
|
+
kind: 'error',
|
|
683
|
+
domain: DOMAINS.PAGE,
|
|
684
|
+
text: isError(error) ? error.toString() : String(error)
|
|
685
|
+
});
|
|
686
|
+
reportErrorToSentry(new Error('Upload File Error: An unexpected issue occurred while uploading the file'), {
|
|
687
|
+
extra: {
|
|
688
|
+
error,
|
|
689
|
+
projectKey,
|
|
690
|
+
containerKey: state.containerKey,
|
|
691
|
+
resourceType: state.resourceType,
|
|
692
|
+
fileSizeInBytes: (_state$droppedFile = state.droppedFile) === null || _state$droppedFile === void 0 ? void 0 : _state$droppedFile.size
|
|
693
|
+
}
|
|
694
|
+
});
|
|
695
|
+
}
|
|
696
|
+
};
|
|
697
|
+
const handleUploadAndValidation = async () => {
|
|
698
|
+
if (!projectKey || !state.droppedFile || !state.resourceType) return;
|
|
699
|
+
const canUpload = await isFileValid(state.droppedFile);
|
|
700
|
+
if (!canUpload) return;
|
|
701
|
+
actions.setCurrentStep(2);
|
|
702
|
+
const containerKey = encodeFileNameWithTimestampToContainerKey(state.droppedFile.name);
|
|
703
|
+
actions.setContainerKey(containerKey);
|
|
704
|
+
const newAbortController = new AbortController();
|
|
705
|
+
actions.setAbortController(newAbortController);
|
|
706
|
+
try {
|
|
707
|
+
await createImportContainerForFileUpload({
|
|
708
|
+
key: containerKey,
|
|
709
|
+
resourceType: state.resourceType
|
|
710
|
+
}, projectKey, asyncDispatch);
|
|
711
|
+
const fileUploadResponse = await uploadFileForImport({
|
|
712
|
+
projectKey,
|
|
713
|
+
containerKey,
|
|
714
|
+
resourceType: state.resourceType,
|
|
715
|
+
file: state.droppedFile,
|
|
716
|
+
abortSignal: newAbortController.signal
|
|
717
|
+
});
|
|
718
|
+
actions.setUploadFileResponse(fileUploadResponse);
|
|
719
|
+
} catch (error) {
|
|
720
|
+
deleteImportContainer(projectKey, containerKey, asyncDispatch);
|
|
721
|
+
handleUploadError(error);
|
|
722
|
+
} finally {
|
|
723
|
+
actions.setCurrentStep(3);
|
|
724
|
+
}
|
|
725
|
+
};
|
|
726
|
+
return {
|
|
727
|
+
handleUploadAndValidation
|
|
728
|
+
};
|
|
729
|
+
};
|
|
730
|
+
|
|
731
|
+
function resourceTypeToDisplayName(_ref) {
|
|
732
|
+
let resourceType = _ref.resourceType,
|
|
733
|
+
_ref$isUpperCase = _ref.isUpperCase,
|
|
734
|
+
isUpperCase = _ref$isUpperCase === void 0 ? false : _ref$isUpperCase,
|
|
735
|
+
_ref$isPlural = _ref.isPlural,
|
|
736
|
+
isPlural = _ref$isPlural === void 0 ? false : _ref$isPlural;
|
|
737
|
+
let displayName;
|
|
738
|
+
switch (resourceType) {
|
|
739
|
+
case 'category':
|
|
740
|
+
displayName = isPlural ? 'Categories' : 'Category';
|
|
741
|
+
break;
|
|
742
|
+
case 'product':
|
|
743
|
+
displayName = isPlural ? 'Products' : 'Product';
|
|
744
|
+
break;
|
|
745
|
+
default:
|
|
746
|
+
throw new UnexpectedResourceTypeError(resourceType);
|
|
747
|
+
}
|
|
748
|
+
return isUpperCase ? displayName : displayName.toLowerCase();
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
const getBorderColor = state => {
|
|
752
|
+
const borderColors = {
|
|
753
|
+
default: '#909dbc',
|
|
754
|
+
error: '#e60050',
|
|
755
|
+
active: customProperties.colorPrimary
|
|
756
|
+
};
|
|
757
|
+
return borderColors[state] || borderColors.default;
|
|
758
|
+
};
|
|
759
|
+
const getDashedBorder = function () {
|
|
760
|
+
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default';
|
|
761
|
+
const color = getBorderColor(state);
|
|
762
|
+
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 ");
|
|
763
|
+
return "data:image/svg+xml,".concat(encodeURIComponent(svgContent));
|
|
764
|
+
};
|
|
765
|
+
const base = /*#__PURE__*/css("border-radius:", customProperties.borderRadius6, ";min-height:136px;display:flex;justify-content:center;align-items:center;" + (process.env.NODE_ENV === "production" ? "" : ";label:base;"), process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0eWxlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUF5QmdCIiwiZmlsZSI6InN0eWxlcy50cyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IGNzcyB9IGZyb20gJ0BlbW90aW9uL3JlYWN0J1xuaW1wb3J0IHsgY3VzdG9tUHJvcGVydGllcyB9IGZyb20gJ0Bjb21tZXJjZXRvb2xzLWZyb250ZW5kL3VpLWtpdCdcblxudHlwZSBEcm9wQXJlYVN0YXRlID0gJ2RlZmF1bHQnIHwgJ2Vycm9yJyB8ICdhY3RpdmUnXG5cbmNvbnN0IGdldEJvcmRlckNvbG9yID0gKHN0YXRlOiBEcm9wQXJlYVN0YXRlKSA9PiB7XG4gIGNvbnN0IGJvcmRlckNvbG9ycyA9IHtcbiAgICBkZWZhdWx0OiAnIzkwOWRiYycsXG4gICAgZXJyb3I6ICcjZTYwMDUwJyx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Rm9yRHJvcCA9IGNzc2BcbiAgYmFja2dyb3VuZC1pbWFnZTogdXJsKFxcXCIke2dldERhc2hlZEJvcmRlcigpfVxcXCIpO1xuICBiYWNrZ3JvdW5kLWNvbG9yOiAke2N1c3RvbVByb3BlcnRpZXMuY29sb3JTdXJmYWNlfTtcbmBcbmNvbnN0IGFjdGl2ZURyYWcgPSBjc3NgXG4gIGJhY2tncm91bmQtaW1hZ2U6IHVybChcXFwiJHtnZXREYXNoZWRCb3JkZXIoJ2FjdGl2ZScpfVxcXCIpO1xuICBiYWNrZ3JvdW5kLWNvbG9yOiAke2N1c3RvbVByb3BlcnRpZXMuY29sb3JQcmltYXJ5OTV9O1xuICBwYWRkaW5nOiAke2N1c3RvbVByb3BlcnRpZXMuc3BhY2luZzUwfSAxMDBweDtcbmBcbmNvbnN0IGZpbGVEcm9wcGVkID0gY3NzYFxuICBiYWNrZ3JvdW5kLWltYWdlOiB1cmwoXFxcIiR7Z2V0RGFzaGVkQm9yZGVyKCl9XFxcIik7XG4gIGJhY2tncm91bmQtY29sb3I6ICR7Y3VzdG9tUHJvcGVydGllcy5jb2xvclN1cmZhY2V9O1xuICBwYWRkaW5nOiAke2N1c3RvbVByb3BlcnRpZXMuc3BhY2luZzUwfSAxMDBweDtcbmBcblxuZXhwb3J0IGNvbnN0IHN0eWxlcyA9IHtcbiAgYmFzZSxcbiAgcmVhZHlGb3JEcm9wLFxuICBmaWxlRHJvcHBlZCxcbiAgZGlzYWJsZWQsXG4gIGFjdGl2ZURyYWcsXG59XG4iXX0= */");
|
|
766
|
+
const disabled = /*#__PURE__*/css(process.env.NODE_ENV === "production" ? "" : ";label:disabled;", process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0eWxlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFnQ29CIiwiZmlsZSI6InN0eWxlcy50cyIsInNvdXJjZX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SAxMDBweDtcbmBcblxuZXhwb3J0IGNvbnN0IHN0eWxlcyA9IHtcbiAgYmFzZSxcbiAgcmVhZHlGb3JEcm9wLFxuICBmaWxlRHJvcHBlZCxcbiAgZGlzYWJsZWQsXG4gIGFjdGl2ZURyYWcsXG59XG4iXX0= */");
|
|
767
|
+
const readyForDrop = /*#__PURE__*/css("background-image:url(\"", getDashedBorder(), "\");background-color:", customProperties.colorSurface, ";" + (process.env.NODE_ENV === "production" ? "" : ";label:readyForDrop;"), process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0eWxlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFpQ3dCIiwiZmlsZSI6InN0eWxlcy50cyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IGNzcyB9IGZyb20gJ0BlbW90aW9uL3JlYWN0J1xuaW1wb3J0IHsgY3VzdG9tUHJvcGVydGllcyB9IGZyb20gJ0Bjb21tZXJjZXRvb2xzLWZyb250ZW5kL3VpLWtpdCdcblxudHlwZSBEcm9wQXJlYVN0YXRlID0gJ2RlZmF1bHQnIHwgJ2Vycm9yJyB8ICdhY3RpdmUnXG5cbmNvbnN0IGdldEJvcmRlckNvbG9yID0gKHN0YXRlOiBEcm9wQXJlYVN0YXRlKSA9PiB7XG4gIGNvbnN0IGJvcmRlckNvbG9ycyA9IHtcbiAgICBkZWZhdWx0OiAnIzkwOWRiYycsXG4gICAgZXJyb3I6ICcjZTYwMDUwJyxcbiAgICBhY3RpdmU6IGN1c3RvbVByb3BlcnRpZXMuY29sb3JQcmltYXJ5LFxuICB9XG5cbiAgcmV0dXJuIGJvcmRlckNvbG9yc1tzdGF0ZV0gfHwgYm9yZGVyQ29sb3JzLmRlZmF1bHRcbn1cblxuY29uc3QgZ2V0RGFzaGVkQm9yZGVyID0gKHN0YXRlOiBEcm9wQXJlYVN0YXRlID0gJ2RlZ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QtaW1hZ2U6IHVybChcXFwiJHtnZXREYXNoZWRCb3JkZXIoJ2FjdGl2ZScpfVxcXCIpO1xuICBiYWNrZ3JvdW5kLWNvbG9yOiAke2N1c3RvbVByb3BlcnRpZXMuY29sb3JQcmltYXJ5OTV9O1xuICBwYWRkaW5nOiAke2N1c3RvbVByb3BlcnRpZXMuc3BhY2luZzUwfSAxMDBweDtcbmBcbmNvbnN0IGZpbGVEcm9wcGVkID0gY3NzYFxuICBiYWNrZ3JvdW5kLWltYWdlOiB1cmwoXFxcIiR7Z2V0RGFzaGVkQm9yZGVyKCl9XFxcIik7XG4gIGJhY2tncm91bmQtY29sb3I6ICR7Y3VzdG9tUHJvcGVydGllcy5jb2xvclN1cmZhY2V9O1xuICBwYWRkaW5nOiAke2N1c3RvbVByb3BlcnRpZXMuc3BhY2luZzUwfSAxMDBweDtcbmBcblxuZXhwb3J0IGNvbnN0IHN0eWxlcyA9IHtcbiAgYmFzZSxcbiAgcmVhZHlGb3JEcm9wLFxuICBmaWxlRHJvcHBlZCxcbiAgZGlzYWJsZWQsXG4gIGFjdGl2ZURyYWcsXG59XG4iXX0= */");
|
|
768
|
+
const activeDrag = /*#__PURE__*/css("background-image:url(\"", getDashedBorder('active'), "\");background-color:", customProperties.colorPrimary95, ";padding:", customProperties.spacing50, " 100px;" + (process.env.NODE_ENV === "production" ? "" : ";label:activeDrag;"), process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0eWxlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFxQ3NCIiwiZmlsZSI6InN0eWxlcy50cyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IGNzcyB9IGZyb20gJ0BlbW90aW9uL3JlYWN0J1xuaW1wb3J0IHsgY3VzdG9tUHJvcGVydGllcyB9IGZyb20gJ0Bjb21tZXJjZXRvb2xzLWZyb250ZW5kL3VpLWt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G59XG4iXX0= */");
|
|
769
|
+
const fileDropped = /*#__PURE__*/css("background-image:url(\"", getDashedBorder(), "\");background-color:", customProperties.colorSurface, ";padding:", customProperties.spacing50, " 100px;" + (process.env.NODE_ENV === "production" ? "" : ";label:fileDropped;"), process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0eWxlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUEwQ3VCIiwiZmlsZSI6InN0eWxlcy50cyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IGNzcyB9IGZyb20gJ0BlbW90aW9uL3JlYWN0J1xuaW1wb3J0IHsgY3VzdG9tUHJvcGVydGllcyB9IGZyb20gJ0Bjb21tZXJjZXRvb2xzLWZyb250ZW5kL3VpLWtpdCdcblxudHlwZSBEcm9wQXJlYVN0YXRlID0gJ2RlZmF1bHQnIHwgJ2Vycm9yJyB8ICdhY3RpdmUnXG5cbmNvbnN0IGdldEJvcmRlckNvbG9yID0gKHN0YXRlOiBEcm9wQXJlYVN0YXRlKSA9PiB7XG4gIGNvbnN0IGJvcmRlckNvbG9ycyA9IHtcbiAgICBkZWZhdWx0OiAnIzkwOWRiYycsXG4gICAgZXJyb3I6ICcjZTYwMDUwJyxcbiAgICBhY3RpdmU6IGN1c3RvbVByb3BlcnRpZXMuY29sb3JQcmltYXJ5LFxuICB9XG5cbiAgcmV0dXJuIGJvcmRlckNvbG9yc1tzdGF0ZV0gfHwgYm9yZGVyQ29sb3JzLmRlZmF1bHRcbn1cblxuY29uc3QgZ2V0RGFzaGVkQm9yZGVyID0gKHN0YXRlOiBEcm9wQXJlYVN0YXRlID0gJ2RlZmF1bHQnKSA9PiB7XG4gIGNvbnN0IGNvbG9yID0gZ2V0Qm9yZGVyQ29sb3Ioc3RhdGUpXG4gIGNvbnN0IHN2Z0NvbnRlbnQgPSBgXG4gICAgPHN2ZyB3aWR0aD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JQcmltYXJ5OTV9O1xuICBwYWRkaW5nOiAke2N1c3RvbVByb3BlcnRpZXMuc3BhY2luZzUwfSAxMDBweDtcbmBcbmNvbnN0IGZpbGVEcm9wcGVkID0gY3NzYFxuICBiYWNrZ3JvdW5kLWltYWdlOiB1cmwoXFxcIiR7Z2V0RGFzaGVkQm9yZGVyKCl9XFxcIik7XG4gIGJhY2tncm91bmQtY29sb3I6ICR7Y3VzdG9tUHJvcGVydGllcy5jb2xvclN1cmZhY2V9O1xuICBwYWRkaW5nOiAke2N1c3RvbVByb3BlcnRpZXMuc3BhY2luZzUwfSAxMDBweDtcbmBcblxuZXhwb3J0IGNvbnN0IHN0eWxlcyA9IHtcbiAgYmFzZSxcbiAgcmVhZHlGb3JEcm9wLFxuICBmaWxlRHJvcHBlZCxcbiAgZGlzYWJsZWQsXG4gIGFjdGl2ZURyYWcsXG59XG4iXX0= */");
|
|
770
|
+
const styles = {
|
|
771
|
+
base,
|
|
772
|
+
readyForDrop,
|
|
773
|
+
fileDropped,
|
|
774
|
+
disabled,
|
|
775
|
+
activeDrag
|
|
776
|
+
};
|
|
777
|
+
|
|
778
|
+
const DropWrapper = /*#__PURE__*/_styled("div", process.env.NODE_ENV === "production" ? {
|
|
779
|
+
target: "ef0z5en0"
|
|
780
|
+
} : {
|
|
781
|
+
target: "ef0z5en0",
|
|
782
|
+
label: "DropWrapper"
|
|
783
|
+
})(styles.base, " ", props => {
|
|
784
|
+
if (props.dropAreaState === 'disabled') {
|
|
785
|
+
return styles.disabled;
|
|
786
|
+
}
|
|
787
|
+
if (props.dropAreaState === 'ready-for-drop') {
|
|
788
|
+
return styles.readyForDrop;
|
|
789
|
+
}
|
|
790
|
+
if (props.dropAreaState === 'active-drag') {
|
|
791
|
+
return styles.activeDrag;
|
|
792
|
+
}
|
|
793
|
+
if (props.dropAreaState === 'file-dropped') {
|
|
794
|
+
return styles.fileDropped;
|
|
795
|
+
}
|
|
796
|
+
return getDefaultDropWrapperStyles(props.dropAreaState);
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UtZHJhZycpIHtcbiAgICAgIHJldHVybiBzdHlsZXMuYWN0aXZlRHJhZ1xuICAgIH1cbiAgICBpZiAocHJvcHMuZHJvcEFyZWFTdGF0ZSA9PT0gJ2ZpbGUtZHJvcHBlZCcpIHtcbiAgICAgIHJldHVybiBzdHlsZXMuZmlsZURyb3BwZWRcbiAgICB9XG4gICAgcmV0dXJuIGdldERlZmF1bHREcm9wV3JhcHBlclN0eWxlcyhwcm9wcy5kcm9wQXJlYVN0YXRlKVxuICB9fVxuYFxuZnVuY3Rpb24gZ2V0RGVmYXVsdERyb3BXcmFwcGVyU3R5bGVzKF9kcm9wQXJlYVN0YXRlOiBuZXZlcikge1xuICByZXR1cm4gY3NzYGBcbn1cbiJdfQ== */"));
|
|
798
|
+
function getDefaultDropWrapperStyles(_dropAreaState) {
|
|
799
|
+
return /*#__PURE__*/css(process.env.NODE_ENV === "production" ? "" : ";label:getDefaultDropWrapperStyles;", process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImRyb3AtYXJlYS13cmFwcGVyLnRzeCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUE0QlkiLCJmaWxlIjoiZHJvcC1hcmVhLXdyYXBwZXIudHN4Iiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHN0eWxlZCBmcm9tICdAZW1vdGlvbi9zdHlsZWQnXG5pbXBvcnQgeyBjc3MgfSBmcm9tICdAZW1vdGlvbi9yZWFjdCdcbmltcG9ydCB7IHR5cGUgRHJvcHpvbmVSb290UHJvcHMgfSBmcm9tICdyZWFjdC1kcm9wem9uZSdcbmltcG9ydCB7IHN0eWxlcyB9IGZyb20gJy4vc3R5bGVzJ1xuaW1wb3J0IHsgdHlwZSBEcm9wQXJlYVN0YXRlIH0gZnJvbSAnQHR5cGVzJ1xuXG5pbnRlcmZhY2UgRHJvcFdyYXBwZXJQcm9wcyBleHRlbmRzIERyb3B6b25lUm9vdFByb3BzIHtcbiAgZHJvcEFyZWFTdGF0ZTogRHJvcEFyZWFTdGF0ZVxufVxuZXhwb3J0IGNvbnN0IERyb3BXcmFwcGVyID0gc3R5bGVkLmRpdjxEcm9wV3JhcHBlclByb3BzPmBcbiAgJHtzdHlsZXMuYmFzZX1cbiAgJHsocHJvcHMpID0+IHtcbiAgICBpZiAocHJvcHMuZHJvcEFyZWFTdGF0ZSA9PT0gJ2Rpc2FibGVkJykge1xuICAgICAgcmV0dXJuIHN0eWxlcy5kaXNhYmxlZFxuICAgIH1cbiAgICBpZiAocHJvcHMuZHJvcEFyZWFTdGF0ZSA9PT0gJ3JlYWR5LWZvci1kcm9wJykge1xuICAgICAgcmV0dXJuIHN0eWxlcy5yZWFkeUZvckRyb3BcbiAgICB9XG4gICAgaWYgKHByb3BzLmRyb3BBcmVhU3RhdGUgPT09ICdhY3RpdmUtZHJhZycpIHtcbiAgICAgIHJldHVybiBzdHlsZXMuYWN0aXZlRHJhZ1xuICAgIH1cbiAgICBpZiAocHJvcHMuZHJvcEFyZWFTdGF0ZSA9PT0gJ2ZpbGUtZHJvcHBlZCcpIHtcbiAgICAgIHJldHVybiBzdHlsZXMuZmlsZURyb3BwZWRcbiAgICB9XG4gICAgcmV0dXJuIGdldERlZmF1bHREcm9wV3JhcHBlclN0eWxlcyhwcm9wcy5kcm9wQXJlYVN0YXRlKVxuICB9fVxuYFxuZnVuY3Rpb24gZ2V0RGVmYXVsdERyb3BXcmFwcGVyU3R5bGVzKF9kcm9wQXJlYVN0YXRlOiBuZXZlcikge1xuICByZXR1cm4gY3NzYGBcbn1cbiJdfQ== */");
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
var ActiveDragDropArea = /*#__PURE__*/lazy(() => import('./active-drag-drop-area-06cef014.esm.js' /* webpackChunkName: "active-drag-drop-area" */));
|
|
803
|
+
|
|
804
|
+
var DisabledDropArea = /*#__PURE__*/lazy(() => import('./disabled-drop-area-2c088477.esm.js' /* webpackChunkName: "disabled-drop-area" */));
|
|
805
|
+
|
|
806
|
+
var EnabledDropArea = /*#__PURE__*/lazy(() => import('./enabled-drop-area-69507fae.esm.js' /* webpackChunkName: "enabled-drop-area" */));
|
|
807
|
+
|
|
808
|
+
var FileDropped = /*#__PURE__*/lazy(() => import('./file-dropped-area-6f365e02.esm.js' /* webpackChunkName: "filed-dropped-area" */));
|
|
809
|
+
|
|
810
|
+
function getDropArea(_ref) {
|
|
811
|
+
let dropAreaState = _ref.dropAreaState,
|
|
812
|
+
resourceType = _ref.resourceType,
|
|
813
|
+
isFileDropped = _ref.isFileDropped;
|
|
814
|
+
if (dropAreaState === 'file-dropped') {
|
|
815
|
+
return jsx(FileDropped, {});
|
|
816
|
+
}
|
|
817
|
+
if (dropAreaState === 'disabled' || !resourceType) {
|
|
818
|
+
return jsx(DisabledDropArea, {});
|
|
819
|
+
}
|
|
820
|
+
if (dropAreaState === 'ready-for-drop') {
|
|
821
|
+
return jsx(EnabledDropArea, {});
|
|
822
|
+
}
|
|
823
|
+
if (dropAreaState === 'active-drag') {
|
|
824
|
+
return jsx(ActiveDragDropArea, {
|
|
825
|
+
isFileDropped: isFileDropped
|
|
826
|
+
});
|
|
827
|
+
}
|
|
828
|
+
return fallbackDropArea();
|
|
829
|
+
}
|
|
830
|
+
function fallbackDropArea(_invalidDropAreaState) {
|
|
831
|
+
return jsx(DisabledDropArea, {});
|
|
832
|
+
}
|
|
833
|
+
function getDropAreaState(flags) {
|
|
834
|
+
if (flags.isDragActive) {
|
|
835
|
+
return 'active-drag';
|
|
836
|
+
}
|
|
837
|
+
if (flags.hasResourceType) {
|
|
838
|
+
return 'disabled';
|
|
839
|
+
}
|
|
840
|
+
if (flags.isReady) {
|
|
841
|
+
return 'file-dropped';
|
|
842
|
+
}
|
|
843
|
+
return 'ready-for-drop';
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
var messages$2 = defineMessages({
|
|
847
|
+
modalDescription: {
|
|
848
|
+
id: 'ImportResourcesModal.modalDescription',
|
|
849
|
+
description: 'Label for the modal category description',
|
|
850
|
+
defaultMessage: 'Maximum file size is {fileSize} MB with a limit of {rowLimit} rows. Download <csvTemplateLink>the CSV template</csvTemplateLink> or refer to <documentationLink>the documentation</documentationLink>.'
|
|
851
|
+
},
|
|
852
|
+
dragAndDropCSV: {
|
|
853
|
+
id: 'ImportResourcesModal.dragAndDropCSV',
|
|
854
|
+
description: 'The message telling the user to drag and drop CSV file in the file drop area',
|
|
855
|
+
defaultMessage: 'Drag and drop CSV'
|
|
856
|
+
},
|
|
857
|
+
or: {
|
|
858
|
+
id: 'ImportResourcesModal.or',
|
|
859
|
+
description: 'The word "or" in the drag and drop message',
|
|
860
|
+
defaultMessage: 'or'
|
|
861
|
+
},
|
|
862
|
+
browseButton: {
|
|
863
|
+
id: 'ImportResourcesModal.browseFile',
|
|
864
|
+
defaultMessage: 'Browse file'
|
|
865
|
+
},
|
|
866
|
+
uploadFile: {
|
|
867
|
+
id: 'ImportResourcesModal.uploadFile',
|
|
868
|
+
description: 'Label for a button on the file upload page, shown on active drop area state',
|
|
869
|
+
defaultMessage: 'Upload file'
|
|
870
|
+
},
|
|
871
|
+
chooseFile: {
|
|
872
|
+
id: 'ImportResourcesModal.chooseFile',
|
|
873
|
+
description: 'Label for a button on the file upload page, shown on ready to upload state',
|
|
874
|
+
defaultMessage: 'Choose file'
|
|
875
|
+
},
|
|
876
|
+
fileUploadFailed: {
|
|
877
|
+
id: 'ImportResourcesModal.fileUploadFailed',
|
|
878
|
+
description: 'A title on the file upload page, shown on file upload error state',
|
|
879
|
+
defaultMessage: 'File upload failed'
|
|
880
|
+
},
|
|
881
|
+
fileFormatNotSupported: {
|
|
882
|
+
id: 'ImportResourcesModal.fileFormatNotSupported',
|
|
883
|
+
description: 'Error message displayed when a user drags and drops a non-CSV file',
|
|
884
|
+
defaultMessage: 'Invalid file format: The file is not in CSV format and cannot be processed.'
|
|
885
|
+
},
|
|
886
|
+
tooManyFilesError: {
|
|
887
|
+
id: 'ImportResourcesModal.tooManyFilesError',
|
|
888
|
+
description: 'Error message displayed when a user drags and drops multiple files at once',
|
|
889
|
+
defaultMessage: 'Multiple files detected: You can only drag and drop one file at a time.'
|
|
890
|
+
},
|
|
891
|
+
genericError: {
|
|
892
|
+
id: 'ImportResourcesModal.genericError',
|
|
893
|
+
description: 'Default error message for unexpected file upload issues (for unhandled cases)',
|
|
894
|
+
defaultMessage: 'Error occurred: Please try uploading the file again or contact our support team for assistance.'
|
|
895
|
+
}
|
|
896
|
+
});
|
|
897
|
+
|
|
898
|
+
function ownKeys$a(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
899
|
+
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(_context3 = ownKeys$a(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context4 = ownKeys$a(Object(t))).call(_context4, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
900
|
+
const FileDropArea = () => {
|
|
901
|
+
const intl = useIntl();
|
|
902
|
+
const _useImportResourcesCo = useImportResourcesContext(),
|
|
903
|
+
state = _useImportResourcesCo.state,
|
|
904
|
+
actions = _useImportResourcesCo.actions;
|
|
905
|
+
const isResourceTypeSelected = Boolean(state.resourceType);
|
|
906
|
+
const showNotification = useShowNotification();
|
|
907
|
+
const onDrop = React.useCallback(_ref => {
|
|
908
|
+
let _ref2 = _slicedToArray(_ref, 1),
|
|
909
|
+
file = _ref2[0];
|
|
910
|
+
if (!file) return;
|
|
911
|
+
assertResourceType(state.resourceType);
|
|
912
|
+
actions.setDroppedFile(file);
|
|
913
|
+
}, [state.resourceType]);
|
|
914
|
+
const _useDropzone = useDropzone({
|
|
915
|
+
onDrop,
|
|
916
|
+
multiple: false,
|
|
917
|
+
disabled: !isResourceTypeSelected,
|
|
918
|
+
accept: {
|
|
919
|
+
'text/csv': ['.csv']
|
|
920
|
+
},
|
|
921
|
+
onDropRejected: _ref3 => {
|
|
922
|
+
var _context, _context2;
|
|
923
|
+
let _ref4 = _slicedToArray(_ref3, 1),
|
|
924
|
+
rejectedFile = _ref4[0];
|
|
925
|
+
if (_someInstanceProperty(_context = rejectedFile.errors).call(_context, error => error.code === 'too-many-files')) {
|
|
926
|
+
showNotification({
|
|
927
|
+
kind: 'error',
|
|
928
|
+
domain: DOMAINS.PAGE,
|
|
929
|
+
text: intl.formatMessage(messages$2.tooManyFilesError)
|
|
930
|
+
});
|
|
931
|
+
return;
|
|
932
|
+
}
|
|
933
|
+
if (_someInstanceProperty(_context2 = rejectedFile.errors).call(_context2, error => error.code === 'file-invalid-type')) {
|
|
934
|
+
showNotification({
|
|
935
|
+
kind: 'error',
|
|
936
|
+
domain: DOMAINS.PAGE,
|
|
937
|
+
text: intl.formatMessage(messages$2.fileFormatNotSupported)
|
|
938
|
+
});
|
|
939
|
+
} else {
|
|
940
|
+
showNotification({
|
|
941
|
+
kind: 'error',
|
|
942
|
+
domain: DOMAINS.PAGE,
|
|
943
|
+
text: intl.formatMessage(messages$2.genericError)
|
|
944
|
+
});
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
}),
|
|
948
|
+
getRootProps = _useDropzone.getRootProps,
|
|
949
|
+
getInputProps = _useDropzone.getInputProps,
|
|
950
|
+
isDragActive = _useDropzone.isDragActive;
|
|
951
|
+
const dropAreaState = React.useMemo(() => getDropAreaState({
|
|
952
|
+
isReady: Boolean(state.droppedFile),
|
|
953
|
+
hasResourceType: !state.resourceType,
|
|
954
|
+
isDragActive
|
|
955
|
+
}), [state.resourceType, state.droppedFile, isDragActive]);
|
|
956
|
+
const dropArea = getDropArea({
|
|
957
|
+
dropAreaState,
|
|
958
|
+
resourceType: 'category',
|
|
959
|
+
isFileDropped: Boolean(state.droppedFile)
|
|
960
|
+
});
|
|
961
|
+
return jsxs(DropWrapper, _objectSpread$a(_objectSpread$a({
|
|
962
|
+
role: "presentation"
|
|
963
|
+
}, getRootProps()), {}, {
|
|
964
|
+
dropAreaState: dropAreaState,
|
|
965
|
+
children: [jsx("input", _objectSpread$a({
|
|
966
|
+
"data-testid": "file-input"
|
|
967
|
+
}, getInputProps())), jsx(Constraints.Horizontal, {
|
|
968
|
+
children: dropArea
|
|
969
|
+
})]
|
|
970
|
+
}));
|
|
971
|
+
};
|
|
972
|
+
|
|
973
|
+
var sharedMessages = defineMessages({
|
|
974
|
+
modalTitle: {
|
|
975
|
+
id: 'ImportResourcesModal.modalTitle',
|
|
976
|
+
description: 'Label for the modal title',
|
|
977
|
+
defaultMessage: 'Import {resourceType} by CSV'
|
|
978
|
+
},
|
|
979
|
+
uploadButton: {
|
|
980
|
+
id: 'ImportResourcesModal.uploadButton',
|
|
981
|
+
description: 'Label for the upload button',
|
|
982
|
+
defaultMessage: 'Upload and preview'
|
|
983
|
+
},
|
|
984
|
+
cancel: {
|
|
985
|
+
id: 'ImportResourcesModal.cancel',
|
|
986
|
+
description: 'Label for the cancel button',
|
|
987
|
+
defaultMessage: 'Cancel'
|
|
988
|
+
},
|
|
989
|
+
close: {
|
|
990
|
+
id: 'ImportResourcesModal.close',
|
|
991
|
+
description: 'Label for the close button',
|
|
992
|
+
defaultMessage: 'Close'
|
|
993
|
+
}
|
|
994
|
+
});
|
|
995
|
+
|
|
996
|
+
function ownKeys$9(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
997
|
+
function _objectSpread$9(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys$9(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys$9(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
998
|
+
const Upload = () => {
|
|
999
|
+
const _useImportResourcesCo = useImportResourcesContext(),
|
|
1000
|
+
state = _useImportResourcesCo.state,
|
|
1001
|
+
onClose = _useImportResourcesCo.onClose;
|
|
1002
|
+
const intl = useIntl();
|
|
1003
|
+
const resourceTypePlural = resourceTypeToDisplayName({
|
|
1004
|
+
resourceType: state.resourceType,
|
|
1005
|
+
isPlural: true
|
|
1006
|
+
});
|
|
1007
|
+
const _useUpload = useUpload(),
|
|
1008
|
+
handleUploadAndValidation = _useUpload.handleUploadAndValidation;
|
|
1009
|
+
const templateLink = RESOURCE_TYPE_TEMPLATE_DOWNLOAD_LINKS[state.resourceType];
|
|
1010
|
+
const documentationLink = RESOURCE_TYPE_DOCUMENTATION_LINKS[state.resourceType];
|
|
1011
|
+
return jsx(FormDialog, {
|
|
1012
|
+
size: 16,
|
|
1013
|
+
isOpen: true,
|
|
1014
|
+
title: intl.formatMessage(sharedMessages.modalTitle, {
|
|
1015
|
+
resourceType: resourceTypePlural
|
|
1016
|
+
}),
|
|
1017
|
+
labelPrimary: intl.formatMessage(sharedMessages.uploadButton),
|
|
1018
|
+
onPrimaryButtonClick: handleUploadAndValidation,
|
|
1019
|
+
isPrimaryButtonDisabled: !Boolean(state.droppedFile),
|
|
1020
|
+
onSecondaryButtonClick: () => onClose({
|
|
1021
|
+
shouldDeleteImportContainer: true
|
|
1022
|
+
}),
|
|
1023
|
+
onClose: () => onClose({
|
|
1024
|
+
shouldDeleteImportContainer: true
|
|
1025
|
+
}),
|
|
1026
|
+
children: jsxs(Spacings.Stack, {
|
|
1027
|
+
scale: "l",
|
|
1028
|
+
children: [jsx(Text.Body, {
|
|
1029
|
+
intlMessage: _objectSpread$9(_objectSpread$9({}, messages$2.modalDescription), {}, {
|
|
1030
|
+
values: {
|
|
1031
|
+
fileSize: intl.formatNumber(FILE_SIZE_LIMITS_MB[state.resourceType]),
|
|
1032
|
+
rowLimit: intl.formatNumber(ROW_LIMITS[state.resourceType]),
|
|
1033
|
+
csvTemplateLink: msg => jsx(Link, {
|
|
1034
|
+
tone: "secondary",
|
|
1035
|
+
isExternal: true,
|
|
1036
|
+
to: templateLink,
|
|
1037
|
+
children: msg
|
|
1038
|
+
}),
|
|
1039
|
+
documentationLink: msg => jsx(Link, {
|
|
1040
|
+
tone: "secondary",
|
|
1041
|
+
isExternal: true,
|
|
1042
|
+
to: documentationLink,
|
|
1043
|
+
children: msg
|
|
1044
|
+
})
|
|
1045
|
+
}
|
|
1046
|
+
})
|
|
1047
|
+
}), jsx(FileDropArea, {})]
|
|
1048
|
+
})
|
|
1049
|
+
});
|
|
1050
|
+
};
|
|
1051
|
+
|
|
1052
|
+
var messages$1 = defineMessages({
|
|
1053
|
+
startImportButton: {
|
|
1054
|
+
id: 'ImportResourcesModal.startImportButton',
|
|
1055
|
+
description: 'Label for the modal Start import button',
|
|
1056
|
+
defaultMessage: 'Start import'
|
|
1057
|
+
},
|
|
1058
|
+
BodyText: {
|
|
1059
|
+
id: 'ImportResourcesModal.BodyText',
|
|
1060
|
+
description: 'Confirmation dialog text',
|
|
1061
|
+
defaultMessage: 'You are about to import <bold>{count}</bold> rows to the project: <bold>{projectName}</bold>.'
|
|
1062
|
+
},
|
|
1063
|
+
BodyNote: {
|
|
1064
|
+
id: 'ImportResourcesModal.BodyNote',
|
|
1065
|
+
description: 'Confirmation dialog text',
|
|
1066
|
+
defaultMessage: 'Please be aware that existing values with the same keys will be overwritten by the data included in the CSV.'
|
|
1067
|
+
},
|
|
1068
|
+
BodyQuestion: {
|
|
1069
|
+
id: 'ImportResourcesModal.BodyQuestion',
|
|
1070
|
+
description: 'Confirmation question',
|
|
1071
|
+
defaultMessage: 'Proceed with the import?'
|
|
1072
|
+
},
|
|
1073
|
+
uploadNotificationSuccessMessage: {
|
|
1074
|
+
id: 'ImportResourcesModal.successMessage',
|
|
1075
|
+
description: 'Notification success message',
|
|
1076
|
+
defaultMessage: '<b>Your import has started.</b><newline></newline> <logsLink>Go to Import logs</logsLink> to view the progress.'
|
|
1077
|
+
},
|
|
1078
|
+
previewOfYourImport: {
|
|
1079
|
+
id: 'ImportResourcesModal.previewOfYourImport',
|
|
1080
|
+
description: 'Label for modal path',
|
|
1081
|
+
defaultMessage: "Here's a preview of your import"
|
|
1082
|
+
},
|
|
1083
|
+
rowsToBeImported: {
|
|
1084
|
+
id: 'ImportResourcesModal.rowsToBeImported',
|
|
1085
|
+
description: 'This message indicates the number of rows that are ready to be imported into the system.',
|
|
1086
|
+
defaultMessage: '<b>{rowCount}</b> rows to be imported'
|
|
1087
|
+
},
|
|
1088
|
+
columnsToBeImported: {
|
|
1089
|
+
id: 'ImportResourcesModal.columnsToBeImported',
|
|
1090
|
+
description: 'This message indicates the number of columns that are ready to be imported into the system.',
|
|
1091
|
+
defaultMessage: '<b>{columnCount}</b> columns to be imported'
|
|
1092
|
+
},
|
|
1093
|
+
columnsToBeIgnored: {
|
|
1094
|
+
id: 'ImportResourcesModal.columnsToBeIgnored',
|
|
1095
|
+
description: "This message indicates the number of columns that will be deliberately skipped during the import because they can't be imported",
|
|
1096
|
+
defaultMessage: "We will intentionally ignore <b>{columnCount}</b> columns as they can't be imported"
|
|
1097
|
+
},
|
|
1098
|
+
showMore: {
|
|
1099
|
+
id: 'ImportResourcesModal.showMore',
|
|
1100
|
+
description: 'A button label for expanding the import preview to show more details.',
|
|
1101
|
+
defaultMessage: 'Show more'
|
|
1102
|
+
},
|
|
1103
|
+
showLess: {
|
|
1104
|
+
id: 'ImportResourcesModal.showLess',
|
|
1105
|
+
description: 'A button label for collapsing the import preview to show fewer details.',
|
|
1106
|
+
defaultMessage: 'Show less'
|
|
1107
|
+
},
|
|
1108
|
+
continue: {
|
|
1109
|
+
id: 'ImportResourcesModal.continue',
|
|
1110
|
+
description: 'Confirmation dialog continue button',
|
|
1111
|
+
defaultMessage: 'Continue'
|
|
1112
|
+
},
|
|
1113
|
+
confirmationBodyText: {
|
|
1114
|
+
id: 'ImportResourcesModal.confirmationBodyText',
|
|
1115
|
+
description: 'Confirmation dialog text',
|
|
1116
|
+
defaultMessage: 'You are about to import <bold>{count}</bold> rows to the project: <bold>{projectName}</bold>.'
|
|
1117
|
+
},
|
|
1118
|
+
confirmationBodyNote: {
|
|
1119
|
+
id: 'ImportResourcesModal.confirmationBodyNote',
|
|
1120
|
+
description: 'Confirmation dialog text',
|
|
1121
|
+
defaultMessage: 'Please be aware that existing values with the same keys will be overwritten by the data included in the CSV.'
|
|
1122
|
+
},
|
|
1123
|
+
confirmationBodyQuestion: {
|
|
1124
|
+
id: 'ImportResourcesModal.confirmationBodyQuestion',
|
|
1125
|
+
description: 'Confirmation question',
|
|
1126
|
+
defaultMessage: 'Proceed with the import?'
|
|
1127
|
+
}
|
|
1128
|
+
});
|
|
1129
|
+
|
|
1130
|
+
function ownKeys$8(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1131
|
+
function _objectSpread$8(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys$8(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys$8(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1132
|
+
const truncate = (isExpanded, columns, columnsCount) => {
|
|
1133
|
+
return isExpanded ? columns.join(' | ') : _sliceInstanceProperty(columns).call(columns, 0, columnsCount).join(' | ') + (columns.length > columnsCount ? '...' : '');
|
|
1134
|
+
};
|
|
1135
|
+
const SpacedLink = /*#__PURE__*/_styled("span", process.env.NODE_ENV === "production" ? {
|
|
1136
|
+
target: "e1amawj90"
|
|
1137
|
+
} : {
|
|
1138
|
+
target: "e1amawj90",
|
|
1139
|
+
label: "SpacedLink"
|
|
1140
|
+
})("margin-left:", customProperties.spacingS, ";" + (process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImNvbHVtbi1saXN0LnRzeCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUEyQnFDIiwiZmlsZSI6ImNvbHVtbi1saXN0LnRzeCIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBSZWFjdCBmcm9tICdyZWFjdCdcbmltcG9ydCB7IEZvcm1hdHRlZE1lc3NhZ2UgfSBmcm9tICdyZWFjdC1pbnRsJ1xuaW1wb3J0IHN0eWxlZCBmcm9tICdAZW1vdGlvbi9zdHlsZWQnXG5pbXBvcnQge1xuICBMaW5rLFxuICBTcGFjaW5ncyxcbiAgVGV4dCxcbiAgY3VzdG9tUHJvcGVydGllcyxcbn0gZnJvbSAnQGNvbW1lcmNldG9vbHMtZnJvbnRlbmQvdWkta2l0J1xuaW1wb3J0IHsgSU5JVElBTF9DT0xVTU5fRElTUExBWV9DT1VOVCB9IGZyb20gJ0Bjb25zdGFudHMnXG5pbXBvcnQgbWVzc2FnZXMgZnJvbSAnLi9tZXNzYWdlcydcblxuaW50ZXJmYWNlIFByb3BzIHtcbiAgY29sdW1uczogQXJyYXk8c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TF9DT0xVTU5fRElTUExBWV9DT1VOVCl9XG4gICAgICAgICAge3Nob3VsZFNob3dFeHBhbmRCdXR0b24gJiYgKFxuICAgICAgICAgICAgPFNwYWNlZExpbms+XG4gICAgICAgICAgICAgIDxMaW5rXG4gICAgICAgICAgICAgICAgdG89XCJcIlxuICAgICAgICAgICAgICAgIHRvbmU9XCJzZWNvbmRhcnlcIlxuICAgICAgICAgICAgICAgIG9uQ2xpY2s9eyhlKSA9PiB7XG4gICAgICAgICAgICAgICAgICBlLnByZXZlbnREZWZhdWx0KClcbiAgICAgICAgICAgICAgICAgIHNldElzRXhwYW5kZWQoIWlzRXhwYW5kZWQpXG4gICAgICAgICAgICAgICAgfX1cbiAgICAgICAgICAgICAgPlxuICAgICAgICAgICAgICAgIHtpc0V4cGFuZGVkID8gKFxuICAgICAgICAgICAgICAgICAgPEZvcm1hdHRlZE1lc3NhZ2Ugey4uLm1lc3NhZ2VzLnNob3dMZXNzfSAvPlxuICAgICAgICAgICAgICAgICkgOiAoXG4gICAgICAgICAgICAgICAgICA8Rm9ybWF0dGVkTWVzc2FnZSB7Li4ubWVzc2FnZXMuc2hvd01vcmV9IC8+XG4gICAgICAgICAgICAgICAgKX1cbiAgICAgICAgICAgICAgPC9MaW5rPlxuICAgICAgICAgICAgPC9TcGFjZWRMaW5rPlxuICAgICAgICAgICl9XG4gICAgICAgIDwvVGV4dC5Cb2R5PlxuICAgICAgPC8+XG4gICAgPC9TcGFjaW5ncy5JbmxpbmU+XG4gIClcbn1cbiJdfQ== */"));
|
|
1141
|
+
const ColumnList = props => {
|
|
1142
|
+
const _React$useState = React.useState(false),
|
|
1143
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
1144
|
+
isExpanded = _React$useState2[0],
|
|
1145
|
+
setIsExpanded = _React$useState2[1];
|
|
1146
|
+
const shouldShowExpandButton = props.columns.length > INITIAL_COLUMN_DISPLAY_COUNT;
|
|
1147
|
+
return jsxs(Spacings.Inline, {
|
|
1148
|
+
scale: "xl",
|
|
1149
|
+
children: [jsx("div", {}), jsx(Fragment, {
|
|
1150
|
+
children: jsxs(Text.Body, {
|
|
1151
|
+
tone: "secondary",
|
|
1152
|
+
children: [truncate(isExpanded, props.columns, INITIAL_COLUMN_DISPLAY_COUNT), shouldShowExpandButton && jsx(SpacedLink, {
|
|
1153
|
+
children: jsx(Link, {
|
|
1154
|
+
to: "",
|
|
1155
|
+
tone: "secondary",
|
|
1156
|
+
onClick: e => {
|
|
1157
|
+
e.preventDefault();
|
|
1158
|
+
setIsExpanded(!isExpanded);
|
|
1159
|
+
},
|
|
1160
|
+
children: isExpanded ? jsx(FormattedMessage, _objectSpread$8({}, messages$1.showLess)) : jsx(FormattedMessage, _objectSpread$8({}, messages$1.showMore))
|
|
1161
|
+
})
|
|
1162
|
+
})]
|
|
1163
|
+
})
|
|
1164
|
+
})]
|
|
1165
|
+
});
|
|
1166
|
+
};
|
|
1167
|
+
|
|
1168
|
+
function ownKeys$7(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1169
|
+
function _objectSpread$7(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys$7(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys$7(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1170
|
+
function UploadPreviewModal() {
|
|
1171
|
+
const _useImportResourcesCo = useImportResourcesContext(),
|
|
1172
|
+
state = _useImportResourcesCo.state;
|
|
1173
|
+
const intl = useIntl();
|
|
1174
|
+
const _useImportResourcesCo2 = useImportResourcesContext(),
|
|
1175
|
+
actions = _useImportResourcesCo2.actions,
|
|
1176
|
+
onClose = _useImportResourcesCo2.onClose;
|
|
1177
|
+
if (!state.resourceType || !state.uploadFileResponse) return null;
|
|
1178
|
+
const ignoredColumns = state.uploadFileResponse.ignoredColumns;
|
|
1179
|
+
const validatedColumns = getValidatedColumns(state.uploadFileResponse.columns, ignoredColumns);
|
|
1180
|
+
return jsx(FormDialog, {
|
|
1181
|
+
size: 16,
|
|
1182
|
+
isOpen: true,
|
|
1183
|
+
title: intl.formatMessage(sharedMessages.modalTitle, {
|
|
1184
|
+
resourceType: state.resourceType
|
|
1185
|
+
}),
|
|
1186
|
+
labelPrimary: intl.formatMessage(messages$1.continue),
|
|
1187
|
+
onSecondaryButtonClick: () => onClose({
|
|
1188
|
+
shouldDeleteImportContainer: true
|
|
1189
|
+
}),
|
|
1190
|
+
onPrimaryButtonClick: () => {
|
|
1191
|
+
actions.setCurrentStep(4);
|
|
1192
|
+
},
|
|
1193
|
+
onClose: () => onClose({
|
|
1194
|
+
shouldDeleteImportContainer: true
|
|
1195
|
+
}),
|
|
1196
|
+
children: jsx(PageContentNarrow, {
|
|
1197
|
+
children: jsx(Spacings.Stack, {
|
|
1198
|
+
scale: "xxxl",
|
|
1199
|
+
children: jsx(Spacings.Stack, {
|
|
1200
|
+
scale: "xl",
|
|
1201
|
+
children: jsxs(Spacings.Stack, {
|
|
1202
|
+
scale: "m",
|
|
1203
|
+
children: [jsx("div", {}), jsx(Text.Body, {
|
|
1204
|
+
intlMessage: messages$1.previewOfYourImport
|
|
1205
|
+
}), jsx(Card, {
|
|
1206
|
+
insetScale: "xl",
|
|
1207
|
+
children: jsxs(Spacings.Stack, {
|
|
1208
|
+
scale: "xs",
|
|
1209
|
+
children: [jsxs(Spacings.Inline, {
|
|
1210
|
+
alignItems: "center",
|
|
1211
|
+
children: [jsx(CheckBoldIcon, {
|
|
1212
|
+
color: "success"
|
|
1213
|
+
}), jsx(Text.Body, {
|
|
1214
|
+
intlMessage: _objectSpread$7(_objectSpread$7({}, messages$1.rowsToBeImported), {}, {
|
|
1215
|
+
values: {
|
|
1216
|
+
rowCount: intl.formatNumber(state.uploadFileResponse.rowsCount),
|
|
1217
|
+
b: getBold$3
|
|
1218
|
+
}
|
|
1219
|
+
})
|
|
1220
|
+
})]
|
|
1221
|
+
}), jsxs(Spacings.Inline, {
|
|
1222
|
+
alignItems: "center",
|
|
1223
|
+
children: [jsx(CheckBoldIcon, {
|
|
1224
|
+
color: "success"
|
|
1225
|
+
}), jsx(Text.Body, {
|
|
1226
|
+
intlMessage: _objectSpread$7(_objectSpread$7({}, messages$1.columnsToBeImported), {}, {
|
|
1227
|
+
values: {
|
|
1228
|
+
columnCount: intl.formatNumber(validatedColumns.length),
|
|
1229
|
+
b: getBold$3
|
|
1230
|
+
}
|
|
1231
|
+
})
|
|
1232
|
+
})]
|
|
1233
|
+
}), jsx(ColumnList, {
|
|
1234
|
+
columns: validatedColumns
|
|
1235
|
+
})]
|
|
1236
|
+
})
|
|
1237
|
+
}), ignoredColumns.length > 0 && jsx(Card, {
|
|
1238
|
+
insetScale: "xl",
|
|
1239
|
+
children: jsxs(Spacings.Stack, {
|
|
1240
|
+
scale: "xs",
|
|
1241
|
+
children: [jsxs(Spacings.Inline, {
|
|
1242
|
+
alignItems: "center",
|
|
1243
|
+
children: [jsx(EyeCrossedIcon, {
|
|
1244
|
+
color: "neutral60"
|
|
1245
|
+
}), jsx(Text.Body, {
|
|
1246
|
+
intlMessage: _objectSpread$7(_objectSpread$7({}, messages$1.columnsToBeIgnored), {}, {
|
|
1247
|
+
values: {
|
|
1248
|
+
columnCount: intl.formatNumber(ignoredColumns.length),
|
|
1249
|
+
b: getBold$3
|
|
1250
|
+
}
|
|
1251
|
+
})
|
|
1252
|
+
})]
|
|
1253
|
+
}), jsx(ColumnList, {
|
|
1254
|
+
columns: ignoredColumns
|
|
1255
|
+
})]
|
|
1256
|
+
})
|
|
1257
|
+
})]
|
|
1258
|
+
})
|
|
1259
|
+
})
|
|
1260
|
+
})
|
|
1261
|
+
})
|
|
1262
|
+
});
|
|
1263
|
+
}
|
|
1264
|
+
function getBold$3(msg) {
|
|
1265
|
+
return jsx(Text.Body, {
|
|
1266
|
+
as: "span",
|
|
1267
|
+
isBold: true,
|
|
1268
|
+
children: msg
|
|
1269
|
+
});
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
function ownKeys$6(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1273
|
+
function _objectSpread$6(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys$6(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys$6(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1274
|
+
const getNewLine = () => jsx("br", {});
|
|
1275
|
+
const getImportLogsLink = (msg, projectKey) => jsx(Link, {
|
|
1276
|
+
to: "/".concat(projectKey, "/operations/import/logs"),
|
|
1277
|
+
children: msg
|
|
1278
|
+
});
|
|
1279
|
+
const ImportConfirmationModal = () => {
|
|
1280
|
+
var _state$uploadFileResp;
|
|
1281
|
+
const intl = useIntl();
|
|
1282
|
+
const _useImportResourcesCo = useImportResourcesContext(),
|
|
1283
|
+
state = _useImportResourcesCo.state,
|
|
1284
|
+
onStartImportSuccess = _useImportResourcesCo.onStartImportSuccess,
|
|
1285
|
+
onClose = _useImportResourcesCo.onClose;
|
|
1286
|
+
const _useApplicationContex = useApplicationContext(context => {
|
|
1287
|
+
var _context$project, _context$project2;
|
|
1288
|
+
return {
|
|
1289
|
+
projectKey: (_context$project = context.project) === null || _context$project === void 0 ? void 0 : _context$project.key,
|
|
1290
|
+
projectName: (_context$project2 = context.project) === null || _context$project2 === void 0 ? void 0 : _context$project2.name
|
|
1291
|
+
};
|
|
1292
|
+
}),
|
|
1293
|
+
projectKey = _useApplicationContex.projectKey,
|
|
1294
|
+
projectName = _useApplicationContex.projectName;
|
|
1295
|
+
const asyncDispatch = useAsyncDispatch();
|
|
1296
|
+
const showNotification = useShowNotification();
|
|
1297
|
+
const ImportRunningTextNotification = () => jsx(Text.Body, {
|
|
1298
|
+
intlMessage: _objectSpread$6(_objectSpread$6({}, messages$1.uploadNotificationSuccessMessage), {}, {
|
|
1299
|
+
values: {
|
|
1300
|
+
newline: getNewLine,
|
|
1301
|
+
logsLink: msg => getImportLogsLink(msg, projectKey),
|
|
1302
|
+
b: getBold$2
|
|
1303
|
+
}
|
|
1304
|
+
})
|
|
1305
|
+
});
|
|
1306
|
+
return jsx(ConfirmationDialog, {
|
|
1307
|
+
title: intl.formatMessage(sharedMessages.modalTitle, {
|
|
1308
|
+
resourceType: resourceTypeToDisplayName({
|
|
1309
|
+
resourceType: state.resourceType,
|
|
1310
|
+
isPlural: true
|
|
1311
|
+
})
|
|
1312
|
+
}),
|
|
1313
|
+
labelPrimary: intl.formatMessage(messages$1.startImportButton),
|
|
1314
|
+
isOpen: true,
|
|
1315
|
+
onClose: () => onClose({
|
|
1316
|
+
shouldDeleteImportContainer: true
|
|
1317
|
+
}),
|
|
1318
|
+
onCancel: () => onClose({
|
|
1319
|
+
shouldDeleteImportContainer: true
|
|
1320
|
+
}),
|
|
1321
|
+
dataAttributesPrimaryButton: {
|
|
1322
|
+
'data-test-id': 'confirmation-dialog-confirm'
|
|
1323
|
+
},
|
|
1324
|
+
dataAttributesSecondaryButton: {
|
|
1325
|
+
'data-test-id': 'confirmation-dialog-cancel'
|
|
1326
|
+
},
|
|
1327
|
+
onConfirm: async () => {
|
|
1328
|
+
try {
|
|
1329
|
+
var _state$droppedFile;
|
|
1330
|
+
const canConfirm = projectKey && state.containerKey && ((_state$droppedFile = state.droppedFile) === null || _state$droppedFile === void 0 ? void 0 : _state$droppedFile.name) && state.resourceType;
|
|
1331
|
+
if (!canConfirm) return;
|
|
1332
|
+
onClose();
|
|
1333
|
+
await processUploadedFile({
|
|
1334
|
+
projectKey,
|
|
1335
|
+
containerKey: state.containerKey,
|
|
1336
|
+
resourceType: state.resourceType,
|
|
1337
|
+
asyncDispatch
|
|
1338
|
+
});
|
|
1339
|
+
onStartImportSuccess();
|
|
1340
|
+
showNotification({
|
|
1341
|
+
kind: 'info',
|
|
1342
|
+
domain: DOMAINS.SIDE,
|
|
1343
|
+
// @ts-ignore
|
|
1344
|
+
text: jsx(ImportRunningTextNotification, {})
|
|
1345
|
+
}, {
|
|
1346
|
+
dismissAfter: 5000
|
|
1347
|
+
});
|
|
1348
|
+
} catch (error) {
|
|
1349
|
+
onClose({
|
|
1350
|
+
shouldDeleteImportContainer: true
|
|
1351
|
+
});
|
|
1352
|
+
showNotification({
|
|
1353
|
+
kind: 'error',
|
|
1354
|
+
domain: DOMAINS.PAGE,
|
|
1355
|
+
text: isError(error) ? error.toString() : String(error)
|
|
1356
|
+
});
|
|
1357
|
+
}
|
|
1358
|
+
},
|
|
1359
|
+
size: 16,
|
|
1360
|
+
children: jsxs(Spacings.Stack, {
|
|
1361
|
+
scale: "xl",
|
|
1362
|
+
children: [jsxs("div", {
|
|
1363
|
+
children: [jsx(Text.Body, {
|
|
1364
|
+
intlMessage: _objectSpread$6(_objectSpread$6({}, messages$1.confirmationBodyText), {}, {
|
|
1365
|
+
values: {
|
|
1366
|
+
projectName: projectName,
|
|
1367
|
+
count: intl.formatNumber((state === null || state === void 0 || (_state$uploadFileResp = state.uploadFileResponse) === null || _state$uploadFileResp === void 0 ? void 0 : _state$uploadFileResp.rowsCount) || 0),
|
|
1368
|
+
bold: getBold$2
|
|
1369
|
+
}
|
|
1370
|
+
})
|
|
1371
|
+
}), jsx(Text.Body, {
|
|
1372
|
+
intlMessage: messages$1.confirmationBodyNote
|
|
1373
|
+
})]
|
|
1374
|
+
}), jsx(Text.Body, {
|
|
1375
|
+
intlMessage: messages$1.confirmationBodyQuestion
|
|
1376
|
+
})]
|
|
1377
|
+
})
|
|
1378
|
+
});
|
|
1379
|
+
};
|
|
1380
|
+
function getBold$2(msg) {
|
|
1381
|
+
return jsx(Text.Body, {
|
|
1382
|
+
as: "span",
|
|
1383
|
+
isBold: true,
|
|
1384
|
+
children: msg
|
|
1385
|
+
});
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
var messages = defineMessages({
|
|
1389
|
+
row: {
|
|
1390
|
+
id: 'ImportResourcesModal.row',
|
|
1391
|
+
description: 'In Upload file error modal - "Row" column',
|
|
1392
|
+
defaultMessage: 'Row'
|
|
1393
|
+
},
|
|
1394
|
+
errorType: {
|
|
1395
|
+
id: 'ImportResourcesModal.errorType',
|
|
1396
|
+
description: 'In Upload file error modal - "Error type" column',
|
|
1397
|
+
defaultMessage: 'Error type'
|
|
1398
|
+
},
|
|
1399
|
+
details: {
|
|
1400
|
+
id: 'ImportResourcesModal.details',
|
|
1401
|
+
description: 'In Upload file error modal - "Details" column',
|
|
1402
|
+
defaultMessage: 'Details'
|
|
1403
|
+
},
|
|
1404
|
+
uploadingError: {
|
|
1405
|
+
id: 'ImportResourcesModal.uploadingError',
|
|
1406
|
+
description: 'Title when errors detected while uploading file',
|
|
1407
|
+
defaultMessage: 'There are <b>{errorsCount}</b> errors detected while uploading the file <b>{fileName}</b>.'
|
|
1408
|
+
},
|
|
1409
|
+
supportedValuesDocumentation: {
|
|
1410
|
+
id: 'ImportResourcesModal.supportedValuesDocumentation',
|
|
1411
|
+
description: 'Link to the documentation for supported values',
|
|
1412
|
+
defaultMessage: '<documentationLink>View the documentation</documentationLink> for supported values.'
|
|
1413
|
+
},
|
|
1414
|
+
uploadNewFile: {
|
|
1415
|
+
id: 'ImportResourcesModal.uploadNewFile',
|
|
1416
|
+
description: 'Upload new file button',
|
|
1417
|
+
defaultMessage: 'Upload new file'
|
|
1418
|
+
}
|
|
1419
|
+
});
|
|
1420
|
+
|
|
1421
|
+
function ownKeys$5(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1422
|
+
function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context2 = ownKeys$5(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context3 = ownKeys$5(Object(t))).call(_context3, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1423
|
+
const getColumns$1 = () => [{
|
|
1424
|
+
key: 'errorType',
|
|
1425
|
+
label: jsx(FormattedMessage, _objectSpread$5({}, messages.errorType)),
|
|
1426
|
+
width: 'max-content'
|
|
1427
|
+
}, {
|
|
1428
|
+
key: 'details',
|
|
1429
|
+
label: jsx(FormattedMessage, _objectSpread$5({}, messages.details))
|
|
1430
|
+
}];
|
|
1431
|
+
const UploadClientSideErrorTable = props => {
|
|
1432
|
+
var _context;
|
|
1433
|
+
const pagination = usePaginationState({
|
|
1434
|
+
perPage: 10
|
|
1435
|
+
});
|
|
1436
|
+
const startIndex = (pagination.page.value - 1) * pagination.perPage.value;
|
|
1437
|
+
const endIndex = startIndex + pagination.perPage.value;
|
|
1438
|
+
const currentPageRows = _sliceInstanceProperty(_context = props.rows).call(_context, startIndex, endIndex);
|
|
1439
|
+
const shouldShowPagination = props.rows.length > pagination.perPage.value;
|
|
1440
|
+
return jsxs(Spacings.Stack, {
|
|
1441
|
+
scale: "l",
|
|
1442
|
+
children: [jsx(DataTable, {
|
|
1443
|
+
verticalCellAlignment: "center",
|
|
1444
|
+
isCondensed: true,
|
|
1445
|
+
rows: currentPageRows,
|
|
1446
|
+
columns: getColumns$1(),
|
|
1447
|
+
itemRenderer: itemRenderer$1
|
|
1448
|
+
}), shouldShowPagination && jsx(PageNavigator, {
|
|
1449
|
+
onPageChange: pagination.page.onChange,
|
|
1450
|
+
page: pagination.page.value,
|
|
1451
|
+
totalPages: Math.ceil(props.rows.length / pagination.perPage.value)
|
|
1452
|
+
})]
|
|
1453
|
+
});
|
|
1454
|
+
};
|
|
1455
|
+
function itemRenderer$1(item, column) {
|
|
1456
|
+
switch (column.key) {
|
|
1457
|
+
case 'errorType':
|
|
1458
|
+
return jsx(Stamp, {
|
|
1459
|
+
isCondensed: true,
|
|
1460
|
+
label: item.title,
|
|
1461
|
+
tone: "critical"
|
|
1462
|
+
});
|
|
1463
|
+
case 'details':
|
|
1464
|
+
return jsx(Text.Body, {
|
|
1465
|
+
children: item.description
|
|
1466
|
+
});
|
|
1467
|
+
default:
|
|
1468
|
+
throw new UnexpectedColumnError(column.key);
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
function ownKeys$4(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1473
|
+
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(_context = ownKeys$4(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys$4(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1474
|
+
const UploadClientSideErrorsModal = () => {
|
|
1475
|
+
var _state$droppedFile;
|
|
1476
|
+
const intl = useIntl();
|
|
1477
|
+
const _useImportResourcesCo = useImportResourcesContext(),
|
|
1478
|
+
state = _useImportResourcesCo.state,
|
|
1479
|
+
actions = _useImportResourcesCo.actions,
|
|
1480
|
+
onClose = _useImportResourcesCo.onClose;
|
|
1481
|
+
const errorsCount = state.fileUploadClientSideErrors.length;
|
|
1482
|
+
return jsx(InfoDialog, {
|
|
1483
|
+
size: 16,
|
|
1484
|
+
isOpen: true,
|
|
1485
|
+
title: intl.formatMessage(sharedMessages.modalTitle, {
|
|
1486
|
+
resourceType: resourceTypeToDisplayName({
|
|
1487
|
+
resourceType: state.resourceType,
|
|
1488
|
+
isPlural: true
|
|
1489
|
+
})
|
|
1490
|
+
}),
|
|
1491
|
+
onClose: () => onClose(),
|
|
1492
|
+
children: jsxs(Spacings.Stack, {
|
|
1493
|
+
scale: "l",
|
|
1494
|
+
children: [jsx(Text.Body, {
|
|
1495
|
+
intlMessage: _objectSpread$4(_objectSpread$4({}, messages.uploadingError), {}, {
|
|
1496
|
+
values: {
|
|
1497
|
+
fileName: (_state$droppedFile = state.droppedFile) === null || _state$droppedFile === void 0 ? void 0 : _state$droppedFile.name,
|
|
1498
|
+
errorsCount: intl.formatNumber(errorsCount),
|
|
1499
|
+
b: getBold$1
|
|
1500
|
+
}
|
|
1501
|
+
})
|
|
1502
|
+
}), jsx(UploadClientSideErrorTable, {
|
|
1503
|
+
rows: mapUploadFileClientSideErrorsToUploadFileErrorRows(state.fileUploadClientSideErrors)
|
|
1504
|
+
}), jsxs(Spacings.Inline, {
|
|
1505
|
+
scale: "m",
|
|
1506
|
+
justifyContent: "flex-end",
|
|
1507
|
+
children: [jsx(SecondaryButton, {
|
|
1508
|
+
label: intl.formatMessage(sharedMessages.close),
|
|
1509
|
+
onClick: () => onClose()
|
|
1510
|
+
}), jsx(PrimaryButton, {
|
|
1511
|
+
iconLeft: jsx(ImportIcon, {}),
|
|
1512
|
+
label: intl.formatMessage(messages.uploadNewFile),
|
|
1513
|
+
onClick: () => actions.uploadNewFile()
|
|
1514
|
+
})]
|
|
1515
|
+
})]
|
|
1516
|
+
})
|
|
1517
|
+
});
|
|
1518
|
+
};
|
|
1519
|
+
function getBold$1(msg) {
|
|
1520
|
+
return jsx(Text.Body, {
|
|
1521
|
+
as: "span",
|
|
1522
|
+
isBold: true,
|
|
1523
|
+
children: msg
|
|
1524
|
+
});
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1527
|
+
function ownKeys$3(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1528
|
+
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context2 = ownKeys$3(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context3 = ownKeys$3(Object(t))).call(_context3, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1529
|
+
const getColumns = () => [{
|
|
1530
|
+
key: 'row',
|
|
1531
|
+
label: jsx(FormattedMessage, _objectSpread$3({}, messages.row)),
|
|
1532
|
+
width: 'max-content'
|
|
1533
|
+
}, {
|
|
1534
|
+
key: 'errorType',
|
|
1535
|
+
label: jsx(FormattedMessage, _objectSpread$3({}, messages.errorType)),
|
|
1536
|
+
width: 'max-content'
|
|
1537
|
+
}, {
|
|
1538
|
+
key: 'details',
|
|
1539
|
+
label: jsx(FormattedMessage, _objectSpread$3({}, messages.details))
|
|
1540
|
+
}];
|
|
1541
|
+
const UploadServerSideErrorTable = props => {
|
|
1542
|
+
var _context;
|
|
1543
|
+
const pagination = usePaginationState({
|
|
1544
|
+
perPage: 10
|
|
1545
|
+
});
|
|
1546
|
+
const startIndex = (pagination.page.value - 1) * pagination.perPage.value;
|
|
1547
|
+
const endIndex = startIndex + pagination.perPage.value;
|
|
1548
|
+
const currentPageRows = _sliceInstanceProperty(_context = props.rows).call(_context, startIndex, endIndex);
|
|
1549
|
+
const shouldShowPagination = props.rows.length > pagination.perPage.value;
|
|
1550
|
+
return jsxs(Spacings.Stack, {
|
|
1551
|
+
scale: "l",
|
|
1552
|
+
children: [jsx(DataTable, {
|
|
1553
|
+
verticalCellAlignment: "center",
|
|
1554
|
+
isCondensed: true,
|
|
1555
|
+
rows: currentPageRows,
|
|
1556
|
+
columns: getColumns(),
|
|
1557
|
+
itemRenderer: itemRenderer
|
|
1558
|
+
}), shouldShowPagination && jsx(PageNavigator, {
|
|
1559
|
+
onPageChange: pagination.page.onChange,
|
|
1560
|
+
page: pagination.page.value,
|
|
1561
|
+
totalPages: Math.ceil(props.rows.length / pagination.perPage.value)
|
|
1562
|
+
})]
|
|
1563
|
+
});
|
|
1564
|
+
};
|
|
1565
|
+
function itemRenderer(item, column) {
|
|
1566
|
+
switch (column.key) {
|
|
1567
|
+
case 'row':
|
|
1568
|
+
return item.row;
|
|
1569
|
+
case 'errorType':
|
|
1570
|
+
return jsx(Stamp, {
|
|
1571
|
+
isCondensed: true,
|
|
1572
|
+
label: item.code,
|
|
1573
|
+
tone: "critical"
|
|
1574
|
+
});
|
|
1575
|
+
case 'details':
|
|
1576
|
+
return jsxs(Spacings.Inline, {
|
|
1577
|
+
scale: "xs",
|
|
1578
|
+
children: [jsx(Text.Body, {
|
|
1579
|
+
tone: "information",
|
|
1580
|
+
children: item.field
|
|
1581
|
+
}), jsx(Text.Body, {
|
|
1582
|
+
children: extractErrorDescriptionFromValidationMessage(item.validationMessage)
|
|
1583
|
+
})]
|
|
1584
|
+
});
|
|
1585
|
+
default:
|
|
1586
|
+
throw new UnexpectedColumnError(column.key);
|
|
1587
|
+
}
|
|
1588
|
+
}
|
|
1589
|
+
|
|
1590
|
+
function ownKeys$2(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1591
|
+
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys$2(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys$2(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1592
|
+
const UploadServerSideErrorsModal = () => {
|
|
1593
|
+
var _state$uploadFileResp, _state$droppedFile, _state$uploadFileResp2;
|
|
1594
|
+
const intl = useIntl();
|
|
1595
|
+
const _useImportResourcesCo = useImportResourcesContext(),
|
|
1596
|
+
state = _useImportResourcesCo.state,
|
|
1597
|
+
actions = _useImportResourcesCo.actions,
|
|
1598
|
+
onClose = _useImportResourcesCo.onClose;
|
|
1599
|
+
const errorsCount = getFileUploadErrorsCount((_state$uploadFileResp = state.uploadFileResponse) === null || _state$uploadFileResp === void 0 ? void 0 : _state$uploadFileResp.results);
|
|
1600
|
+
const documentationLink = RESOURCE_TYPE_DOCUMENTATION_LINKS[state.resourceType];
|
|
1601
|
+
return jsx(InfoDialog, {
|
|
1602
|
+
size: 16,
|
|
1603
|
+
isOpen: true,
|
|
1604
|
+
title: intl.formatMessage(sharedMessages.modalTitle, {
|
|
1605
|
+
resourceType: resourceTypeToDisplayName({
|
|
1606
|
+
resourceType: state.resourceType,
|
|
1607
|
+
isPlural: true
|
|
1608
|
+
})
|
|
1609
|
+
}),
|
|
1610
|
+
onClose: onClose,
|
|
1611
|
+
children: jsxs(Spacings.Stack, {
|
|
1612
|
+
scale: "l",
|
|
1613
|
+
children: [jsxs(Spacings.Stack, {
|
|
1614
|
+
scale: "xs",
|
|
1615
|
+
children: [jsx(Text.Body, {
|
|
1616
|
+
intlMessage: _objectSpread$2(_objectSpread$2({}, messages.uploadingError), {}, {
|
|
1617
|
+
values: {
|
|
1618
|
+
fileName: (_state$droppedFile = state.droppedFile) === null || _state$droppedFile === void 0 ? void 0 : _state$droppedFile.name,
|
|
1619
|
+
errorsCount: intl.formatNumber(errorsCount),
|
|
1620
|
+
b: getBold
|
|
1621
|
+
}
|
|
1622
|
+
})
|
|
1623
|
+
}), jsx(Text.Body, {
|
|
1624
|
+
intlMessage: _objectSpread$2(_objectSpread$2({}, messages.supportedValuesDocumentation), {}, {
|
|
1625
|
+
values: {
|
|
1626
|
+
documentationLink: msg => jsx(Link, {
|
|
1627
|
+
tone: "secondary",
|
|
1628
|
+
isExternal: true,
|
|
1629
|
+
to: documentationLink,
|
|
1630
|
+
children: msg
|
|
1631
|
+
})
|
|
1632
|
+
}
|
|
1633
|
+
})
|
|
1634
|
+
})]
|
|
1635
|
+
}), jsx(UploadServerSideErrorTable, {
|
|
1636
|
+
rows: mapUploadFileErrorsResponseToUploadFileErrorRows((_state$uploadFileResp2 = state.uploadFileResponse) === null || _state$uploadFileResp2 === void 0 ? void 0 : _state$uploadFileResp2.results)
|
|
1637
|
+
}), jsxs(Spacings.Inline, {
|
|
1638
|
+
scale: "m",
|
|
1639
|
+
justifyContent: "flex-end",
|
|
1640
|
+
children: [jsx(SecondaryButton, {
|
|
1641
|
+
label: intl.formatMessage(sharedMessages.close),
|
|
1642
|
+
onClick: () => onClose()
|
|
1643
|
+
}), jsx(PrimaryButton, {
|
|
1644
|
+
iconLeft: jsx(ImportIcon, {}),
|
|
1645
|
+
label: intl.formatMessage(messages.uploadNewFile),
|
|
1646
|
+
onClick: () => actions.uploadNewFile()
|
|
1647
|
+
})]
|
|
1648
|
+
})]
|
|
1649
|
+
})
|
|
1650
|
+
});
|
|
1651
|
+
};
|
|
1652
|
+
function getBold(msg) {
|
|
1653
|
+
return jsx(Text.Body, {
|
|
1654
|
+
as: "span",
|
|
1655
|
+
isBold: true,
|
|
1656
|
+
children: msg
|
|
1657
|
+
});
|
|
1658
|
+
}
|
|
1659
|
+
|
|
1660
|
+
const UploadResult = () => {
|
|
1661
|
+
var _state$uploadFileResp;
|
|
1662
|
+
const _useImportResourcesCo = useImportResourcesContext(),
|
|
1663
|
+
state = _useImportResourcesCo.state;
|
|
1664
|
+
if (state.fileUploadClientSideErrors.length > 0) return jsx(UploadClientSideErrorsModal, {});
|
|
1665
|
+
if (((_state$uploadFileResp = state.uploadFileResponse) === null || _state$uploadFileResp === void 0 ? void 0 : _state$uploadFileResp.invalid) > 0) return jsx(UploadServerSideErrorsModal, {});
|
|
1666
|
+
return jsx(UploadPreviewModal, {});
|
|
1667
|
+
};
|
|
1668
|
+
|
|
1669
|
+
function ownKeys$1(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1670
|
+
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys$1(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys$1(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1671
|
+
var FileIcon = function FileIcon(props) {
|
|
1672
|
+
return jsxs("svg", _objectSpread$1(_objectSpread$1({}, props), {}, {
|
|
1673
|
+
children: [jsx("mask", {
|
|
1674
|
+
id: "a",
|
|
1675
|
+
style: {
|
|
1676
|
+
maskType: "alpha"
|
|
1677
|
+
},
|
|
1678
|
+
maskUnits: "userSpaceOnUse",
|
|
1679
|
+
x: "0",
|
|
1680
|
+
y: "0",
|
|
1681
|
+
width: "32",
|
|
1682
|
+
height: "32",
|
|
1683
|
+
children: jsx("path", {
|
|
1684
|
+
fill: "#D9D9D9",
|
|
1685
|
+
d: "M0 0h32v32H0z"
|
|
1686
|
+
})
|
|
1687
|
+
}), jsx("g", {
|
|
1688
|
+
mask: "url(#a)",
|
|
1689
|
+
children: jsx("path", {
|
|
1690
|
+
d: "M14.667 25.333h2.666v-5.566l2.134 2.133 1.866-1.9L16 14.667 10.667 20l1.9 1.867 2.1-2.1v5.566Zm-6.667 4a2.568 2.568 0 0 1-1.883-.783 2.568 2.568 0 0 1-.784-1.883V5.333c0-.733.261-1.36.784-1.883A2.568 2.568 0 0 1 8 2.667h10.667l8 8v16c0 .733-.261 1.36-.784 1.883a2.568 2.568 0 0 1-1.883.783H8ZM17.333 12H24l-6.667-6.667V12Z",
|
|
1691
|
+
fill: "#B1ACFF"
|
|
1692
|
+
})
|
|
1693
|
+
})]
|
|
1694
|
+
}));
|
|
1695
|
+
};
|
|
1696
|
+
FileIcon.defaultProps = {
|
|
1697
|
+
width: "32",
|
|
1698
|
+
height: "32",
|
|
1699
|
+
fill: "none",
|
|
1700
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
1701
|
+
};
|
|
1702
|
+
const Uploading = () => {
|
|
1703
|
+
var _state$droppedFile;
|
|
1704
|
+
const intl = useIntl();
|
|
1705
|
+
const _useImportResourcesCo = useImportResourcesContext(),
|
|
1706
|
+
state = _useImportResourcesCo.state,
|
|
1707
|
+
onClose = _useImportResourcesCo.onClose;
|
|
1708
|
+
const resourceTypePlural = resourceTypeToDisplayName({
|
|
1709
|
+
resourceType: state.resourceType,
|
|
1710
|
+
isPlural: true
|
|
1711
|
+
});
|
|
1712
|
+
if ((_state$droppedFile = state.droppedFile) !== null && _state$droppedFile !== void 0 && _state$droppedFile.name) return jsx(InfoDialog, {
|
|
1713
|
+
size: 16,
|
|
1714
|
+
isOpen: true,
|
|
1715
|
+
title: intl.formatMessage(sharedMessages.modalTitle, {
|
|
1716
|
+
resourceType: resourceTypePlural
|
|
1717
|
+
}),
|
|
1718
|
+
onClose: () => onClose({
|
|
1719
|
+
shouldDeleteImportContainer: true
|
|
1720
|
+
}),
|
|
1721
|
+
children: jsxs(Spacings.Stack, {
|
|
1722
|
+
scale: "m",
|
|
1723
|
+
children: [jsxs(Spacings.Inline, {
|
|
1724
|
+
alignItems: "center",
|
|
1725
|
+
justifyContent: "space-between",
|
|
1726
|
+
children: [jsxs(Spacings.Inline, {
|
|
1727
|
+
alignItems: "center",
|
|
1728
|
+
children: [jsx(FileIcon, {}), jsx(Text.Body, {
|
|
1729
|
+
isBold: true,
|
|
1730
|
+
children: truncate$1(state.droppedFile.name, {
|
|
1731
|
+
length: 40
|
|
1732
|
+
})
|
|
1733
|
+
}), jsxs(Text.Body, {
|
|
1734
|
+
tone: "secondary",
|
|
1735
|
+
children: [intl.formatNumber(convertFileSizeToKB(state.droppedFile.size)), ' ', "KB"]
|
|
1736
|
+
})]
|
|
1737
|
+
}), jsx(SecondaryButton, {
|
|
1738
|
+
tone: "secondary",
|
|
1739
|
+
size: "medium",
|
|
1740
|
+
label: intl.formatMessage(sharedMessages.cancel),
|
|
1741
|
+
onClick: () => {
|
|
1742
|
+
state.abortController.abort();
|
|
1743
|
+
}
|
|
1744
|
+
})]
|
|
1745
|
+
}), jsx(ProgressBar, {
|
|
1746
|
+
barWidth: "scale",
|
|
1747
|
+
height: "10",
|
|
1748
|
+
progress: 100
|
|
1749
|
+
}), jsx("div", {})]
|
|
1750
|
+
})
|
|
1751
|
+
});
|
|
1752
|
+
return null;
|
|
1753
|
+
};
|
|
1754
|
+
|
|
1755
|
+
const CurrentStep = () => {
|
|
1756
|
+
const _useImportResourcesCo = useImportResourcesContext(),
|
|
1757
|
+
state = _useImportResourcesCo.state;
|
|
1758
|
+
const steps = {
|
|
1759
|
+
1: jsx(Upload, {}),
|
|
1760
|
+
2: jsx(Uploading, {}),
|
|
1761
|
+
3: jsx(UploadResult, {}),
|
|
1762
|
+
4: jsx(ImportConfirmationModal, {})
|
|
1763
|
+
};
|
|
1764
|
+
return steps[state.currentStep] || null;
|
|
1765
|
+
};
|
|
1766
|
+
|
|
1767
|
+
const getChunkImport = locale => {
|
|
1768
|
+
const intlLocale = mapLocaleToIntlLocale(locale);
|
|
1769
|
+
switch (intlLocale) {
|
|
1770
|
+
case 'de':
|
|
1771
|
+
return import( /* webpackChunkName: "import-resources-modal-i18n-de" */'./de-cd6c45d3.esm.js');
|
|
1772
|
+
case 'es':
|
|
1773
|
+
return import( /* webpackChunkName: "import-resources-modal-i18n-es" */'./es-e544023d.esm.js');
|
|
1774
|
+
case 'fr-FR':
|
|
1775
|
+
return import( /* webpackChunkName: "import-resources-modal-i18n-fr-FR" */'./fr-FR-9d9081ee.esm.js');
|
|
1776
|
+
case 'zh-CN':
|
|
1777
|
+
return import( /* webpackChunkName: "import-resources-modal-i18n-zh-CN" */'./zh-CN-4780d88e.esm.js');
|
|
1778
|
+
case 'ja':
|
|
1779
|
+
return import( /* webpackChunkName: "import-resources-modal-i18n-ja" */'./ja-73c088a7.esm.js');
|
|
1780
|
+
case 'pt-BR':
|
|
1781
|
+
return import( /* webpackChunkName: "change-history-i18n-pt-BR" */'./pt-BR-b37d730b.esm.js');
|
|
1782
|
+
default:
|
|
1783
|
+
return import( /* webpackChunkName: "import-resources-modal-i18n-en" */'./en-3a9aa2d4.esm.js');
|
|
1784
|
+
}
|
|
1785
|
+
};
|
|
1786
|
+
const loadMessages = async locale => {
|
|
1787
|
+
try {
|
|
1788
|
+
const chunkImport = await getChunkImport(locale);
|
|
1789
|
+
return parseChunkImport(chunkImport);
|
|
1790
|
+
} catch (error) {
|
|
1791
|
+
// eslint-disable-next-line no-console
|
|
1792
|
+
console.warn("Something went wrong while loading the import-resources-modal messages for ".concat(locale), error);
|
|
1793
|
+
reportErrorToSentry(new Error("Something went wrong while loading the import-resources-modal messages for ".concat(locale)), {
|
|
1794
|
+
extra: error
|
|
1795
|
+
});
|
|
1796
|
+
return {};
|
|
1797
|
+
}
|
|
1798
|
+
};
|
|
1799
|
+
|
|
1800
|
+
const useAsyncIntlMessages = (locale, loader) => {
|
|
1801
|
+
const _useState = useState({
|
|
1802
|
+
isLoading: true,
|
|
1803
|
+
messages: undefined,
|
|
1804
|
+
error: undefined
|
|
1805
|
+
}),
|
|
1806
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1807
|
+
state = _useState2[0],
|
|
1808
|
+
setState = _useState2[1];
|
|
1809
|
+
useEffect(() => {
|
|
1810
|
+
let _isUnmounting = false;
|
|
1811
|
+
async function load() {
|
|
1812
|
+
try {
|
|
1813
|
+
if (!_isUnmounting) {
|
|
1814
|
+
const messages = await loader(locale);
|
|
1815
|
+
setState({
|
|
1816
|
+
isLoading: false,
|
|
1817
|
+
messages
|
|
1818
|
+
});
|
|
1819
|
+
}
|
|
1820
|
+
} catch (error) {
|
|
1821
|
+
setState({
|
|
1822
|
+
isLoading: false,
|
|
1823
|
+
error
|
|
1824
|
+
});
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
1827
|
+
if (locale) load();
|
|
1828
|
+
return () => {
|
|
1829
|
+
_isUnmounting = true;
|
|
1830
|
+
};
|
|
1831
|
+
}, [locale, loader]);
|
|
1832
|
+
return state;
|
|
1833
|
+
};
|
|
1834
|
+
|
|
1835
|
+
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1836
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1837
|
+
const ImportResourcesModal = props => {
|
|
1838
|
+
const _useApplicationContex = useApplicationContext(context => ({
|
|
1839
|
+
locale: context.user && context.user.locale
|
|
1840
|
+
})),
|
|
1841
|
+
locale = _useApplicationContex.locale;
|
|
1842
|
+
const messages = useAsyncIntlMessages(locale, loadMessages);
|
|
1843
|
+
if (!props.isOpen || messages.isLoading) return null;
|
|
1844
|
+
return jsx(IntlProvider, {
|
|
1845
|
+
locale: locale,
|
|
1846
|
+
messages: messages.messages,
|
|
1847
|
+
children: jsx(ImportResourcesProvider, _objectSpread(_objectSpread({}, props), {}, {
|
|
1848
|
+
children: jsx(CurrentStep, {})
|
|
1849
|
+
}))
|
|
1850
|
+
});
|
|
1851
|
+
};
|
|
1852
|
+
ImportResourcesModal.displayName = 'ImportResourcesModal';
|
|
1853
|
+
|
|
1854
|
+
export { EnabledDropArea as E, FileDropped as F, ImportResourcesModal as I, messages$2 as m, useImportResourcesContext as u };
|