@commercetools-frontend-extensions/export-resources-modal 2.0.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +91 -57
- package/dist/commercetools-frontend-extensions-export-resources-modal.cjs.dev.js +783 -984
- package/dist/commercetools-frontend-extensions-export-resources-modal.cjs.prod.js +752 -948
- package/dist/commercetools-frontend-extensions-export-resources-modal.esm.js +1019 -0
- package/package.json +49 -32
|
@@ -0,0 +1,1019 @@
|
|
|
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 React, { useContext, createContext } from 'react';
|
|
11
|
+
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
|
12
|
+
import { InfoDialog } from '@commercetools-frontend/application-components';
|
|
13
|
+
import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/map';
|
|
14
|
+
import _flatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/flat';
|
|
15
|
+
import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
|
|
16
|
+
import { query } from 'gql-query-builder';
|
|
17
|
+
import _Reflect$construct from '@babel/runtime-corejs3/core-js-stable/reflect/construct';
|
|
18
|
+
import _createClass from '@babel/runtime-corejs3/helpers/esm/createClass';
|
|
19
|
+
import _classCallCheck from '@babel/runtime-corejs3/helpers/esm/classCallCheck';
|
|
20
|
+
import _inherits from '@babel/runtime-corejs3/helpers/esm/inherits';
|
|
21
|
+
import _possibleConstructorReturn from '@babel/runtime-corejs3/helpers/esm/possibleConstructorReturn';
|
|
22
|
+
import _getPrototypeOf from '@babel/runtime-corejs3/helpers/esm/getPrototypeOf';
|
|
23
|
+
import _wrapNativeSuper from '@babel/runtime-corejs3/helpers/esm/wrapNativeSuper';
|
|
24
|
+
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/esm/objectWithoutProperties';
|
|
25
|
+
import _Array$isArray from '@babel/runtime-corejs3/core-js-stable/array/is-array';
|
|
26
|
+
import _findInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/find';
|
|
27
|
+
import _Object$assign from '@babel/runtime-corejs3/core-js-stable/object/assign';
|
|
28
|
+
import { Link, TextInput, Text, Spacings, ExportIcon, SelectField, TextField, CheckboxInput, PrimaryButton, Card, Grid, customProperties, SecondaryButton } from '@commercetools-frontend/ui-kit';
|
|
29
|
+
import { jsx, jsxs } from '@emotion/react/jsx-runtime';
|
|
30
|
+
import _valuesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/values';
|
|
31
|
+
import omitEmpty from 'omit-empty-es';
|
|
32
|
+
import _findIndexInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/find-index';
|
|
33
|
+
import _spliceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/splice';
|
|
34
|
+
import '@commercetools-uikit/design-system';
|
|
35
|
+
import { useApplicationContext } from '@commercetools-frontend/application-shell-connectors';
|
|
36
|
+
import moment from 'moment';
|
|
37
|
+
import { actions, useAsyncDispatch } from '@commercetools-frontend/sdk';
|
|
38
|
+
import { useShowNotification, showApiErrorNotification } from '@commercetools-frontend/actions-global';
|
|
39
|
+
import { MC_API_PROXY_TARGETS, DOMAINS } from '@commercetools-frontend/constants';
|
|
40
|
+
import _styled from '@emotion/styled/base';
|
|
41
|
+
import _everyInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/every';
|
|
42
|
+
import _someInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/some';
|
|
43
|
+
import PropTypes from 'prop-types';
|
|
44
|
+
import _slicedToArray from '@babel/runtime-corejs3/helpers/esm/slicedToArray';
|
|
45
|
+
import { useFormik } from 'formik';
|
|
46
|
+
|
|
47
|
+
const EXPORT_OPERATION_STATES = {
|
|
48
|
+
PROCESSING: 'processing',
|
|
49
|
+
COMPLETED: 'completed',
|
|
50
|
+
FAILED: 'failed'
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const EXPORT_TYPES = {
|
|
54
|
+
ALL: 'all',
|
|
55
|
+
FILTERED: 'filtered',
|
|
56
|
+
SELECTED: 'selected'
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const EXPORTABLE_RESOURCES = {
|
|
60
|
+
CATEGORY: 'category',
|
|
61
|
+
PRODUCT: 'product',
|
|
62
|
+
DISCOUNT_CODE: 'discountCode'
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const OUTPUT_FORMATS = {
|
|
66
|
+
JSON: 'json',
|
|
67
|
+
CSV: 'csv'
|
|
68
|
+
};
|
|
69
|
+
const OUTPUT_FORMAT_OPTIONS = [{
|
|
70
|
+
value: OUTPUT_FORMATS.CSV,
|
|
71
|
+
label: 'CSV'
|
|
72
|
+
}, {
|
|
73
|
+
value: OUTPUT_FORMATS.JSON,
|
|
74
|
+
label: 'JSON'
|
|
75
|
+
}];
|
|
76
|
+
|
|
77
|
+
const COLUMN_DEFINITIONS_URLS = {
|
|
78
|
+
category: 'https://docs-proxy-sarm-product-import-csv.commercetools.vercel.app/merchant-center/import-categories#supported-headers-and-values'
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
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); }; }
|
|
82
|
+
function _isNativeReflectConstruct$3() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
83
|
+
let UnexpectedExportTypeError = /*#__PURE__*/function (_Error) {
|
|
84
|
+
_inherits(UnexpectedExportTypeError, _Error);
|
|
85
|
+
var _super = _createSuper$3(UnexpectedExportTypeError);
|
|
86
|
+
function UnexpectedExportTypeError(exportType) {
|
|
87
|
+
var _this;
|
|
88
|
+
_classCallCheck(this, UnexpectedExportTypeError);
|
|
89
|
+
_this = _super.call(this, "Unexpected export type: ".concat(exportType));
|
|
90
|
+
_this.name = 'UnexpectedExportTypeError';
|
|
91
|
+
return _this;
|
|
92
|
+
}
|
|
93
|
+
return _createClass(UnexpectedExportTypeError);
|
|
94
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
95
|
+
|
|
96
|
+
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); }; }
|
|
97
|
+
function _isNativeReflectConstruct$2() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
98
|
+
let MissingExportResourceProviderError = /*#__PURE__*/function (_Error) {
|
|
99
|
+
_inherits(MissingExportResourceProviderError, _Error);
|
|
100
|
+
var _super = _createSuper$2(MissingExportResourceProviderError);
|
|
101
|
+
function MissingExportResourceProviderError() {
|
|
102
|
+
var _this;
|
|
103
|
+
_classCallCheck(this, MissingExportResourceProviderError);
|
|
104
|
+
_this = _super.call(this, 'useExportResourcesContext must be used within ExportResourcesProvider');
|
|
105
|
+
_this.name = 'MissingExportResourceProviderError';
|
|
106
|
+
return _this;
|
|
107
|
+
}
|
|
108
|
+
return _createClass(MissingExportResourceProviderError);
|
|
109
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
110
|
+
|
|
111
|
+
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); }; }
|
|
112
|
+
function _isNativeReflectConstruct$1() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
113
|
+
let UnexpectedExportOperationStateError = /*#__PURE__*/function (_Error) {
|
|
114
|
+
_inherits(UnexpectedExportOperationStateError, _Error);
|
|
115
|
+
var _super = _createSuper$1(UnexpectedExportOperationStateError);
|
|
116
|
+
function UnexpectedExportOperationStateError(state) {
|
|
117
|
+
var _this;
|
|
118
|
+
_classCallCheck(this, UnexpectedExportOperationStateError);
|
|
119
|
+
_this = _super.call(this, "Unexpected export operation state \"".concat(state, "\""));
|
|
120
|
+
_this.name = 'UnexpectedExportOperationStateError';
|
|
121
|
+
return _this;
|
|
122
|
+
}
|
|
123
|
+
return _createClass(UnexpectedExportOperationStateError);
|
|
124
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
125
|
+
|
|
126
|
+
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); }; }
|
|
127
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
128
|
+
let UnexpectedResourceTypeError = /*#__PURE__*/function (_Error) {
|
|
129
|
+
_inherits(UnexpectedResourceTypeError, _Error);
|
|
130
|
+
var _super = _createSuper(UnexpectedResourceTypeError);
|
|
131
|
+
function UnexpectedResourceTypeError(resourceType) {
|
|
132
|
+
var _this;
|
|
133
|
+
_classCallCheck(this, UnexpectedResourceTypeError);
|
|
134
|
+
_this = _super.call(this, "Unexpected resource type: ".concat(resourceType));
|
|
135
|
+
_this.name = 'UnexpectedResourceTypeError';
|
|
136
|
+
return _this;
|
|
137
|
+
}
|
|
138
|
+
return _createClass(UnexpectedResourceTypeError);
|
|
139
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
140
|
+
|
|
141
|
+
const _excluded$1 = ["name"];
|
|
142
|
+
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; }
|
|
143
|
+
function _objectSpread$6(e) { for (var r = 1; r < arguments.length; r++) { var _context4, _context5; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context4 = ownKeys$6(Object(t), !0)).call(_context4, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context5 = ownKeys$6(Object(t))).call(_context5, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
144
|
+
function resourceTypeToPlural(_ref) {
|
|
145
|
+
let resourceType = _ref.resourceType,
|
|
146
|
+
_ref$isUpperCase = _ref.isUpperCase,
|
|
147
|
+
isUpperCase = _ref$isUpperCase === void 0 ? false : _ref$isUpperCase;
|
|
148
|
+
switch (resourceType) {
|
|
149
|
+
case EXPORTABLE_RESOURCES.CATEGORY:
|
|
150
|
+
return isUpperCase ? 'Categories' : 'categories';
|
|
151
|
+
case EXPORTABLE_RESOURCES.PRODUCT:
|
|
152
|
+
return isUpperCase ? 'Products' : 'products';
|
|
153
|
+
case EXPORTABLE_RESOURCES.DISCOUNT_CODE:
|
|
154
|
+
return isUpperCase ? 'Discount codes' : 'discount codes';
|
|
155
|
+
default:
|
|
156
|
+
throw UnexpectedResourceTypeError(resourceType);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
function resourceTypeToOperationName(resourceType) {
|
|
160
|
+
switch (resourceType) {
|
|
161
|
+
case EXPORTABLE_RESOURCES.CATEGORY:
|
|
162
|
+
return 'categories';
|
|
163
|
+
case EXPORTABLE_RESOURCES.PRODUCT:
|
|
164
|
+
return 'products';
|
|
165
|
+
case EXPORTABLE_RESOURCES.DISCOUNT_CODE:
|
|
166
|
+
return 'discountCodes';
|
|
167
|
+
default:
|
|
168
|
+
throw UnexpectedResourceTypeError(resourceType);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
function mapLocalesToOptions(locales) {
|
|
172
|
+
return _mapInstanceProperty(locales).call(locales, locale => ({
|
|
173
|
+
value: locale,
|
|
174
|
+
label: locale
|
|
175
|
+
}));
|
|
176
|
+
}
|
|
177
|
+
function replaceSpecialCharsWithUnderscore(string) {
|
|
178
|
+
return string.replace(/[^a-zA-Z0-9]/g, '_');
|
|
179
|
+
}
|
|
180
|
+
function isFilledArray(maybeArray) {
|
|
181
|
+
return _Array$isArray(maybeArray) && maybeArray.length;
|
|
182
|
+
}
|
|
183
|
+
function appendCsvOrJsonExtensionIfAbsent(fileName, fileFormat) {
|
|
184
|
+
var _context;
|
|
185
|
+
const extensionRegex = /\.(csv|json)$/i;
|
|
186
|
+
if (!extensionRegex.test(fileName)) return _concatInstanceProperty(_context = "".concat(fileName, ".")).call(_context, fileFormat);
|
|
187
|
+
return fileName;
|
|
188
|
+
}
|
|
189
|
+
function flattenNestedFields(fields) {
|
|
190
|
+
const result = (fields === null || fields === void 0 ? void 0 : _mapInstanceProperty(fields).call(fields, field => {
|
|
191
|
+
if (isFilledArray(field.fields)) {
|
|
192
|
+
var _context2;
|
|
193
|
+
return _mapInstanceProperty(_context2 = flattenNestedFields(field.fields)).call(_context2, nestedField => {
|
|
194
|
+
var _context3;
|
|
195
|
+
return _objectSpread$6(_objectSpread$6({}, nestedField), {}, {
|
|
196
|
+
name: _concatInstanceProperty(_context3 = "".concat(field.name, ".")).call(_context3, nestedField.name)
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
return field;
|
|
201
|
+
})) || [];
|
|
202
|
+
return _flatInstanceProperty(result).call(result);
|
|
203
|
+
}
|
|
204
|
+
function unflattenNestedFields(flattenedFields) {
|
|
205
|
+
const reconstructed = [];
|
|
206
|
+
_forEachInstanceProperty(flattenedFields).call(flattenedFields, field => {
|
|
207
|
+
const fieldNames = field.name.split('.');
|
|
208
|
+
let currentLevel = reconstructed;
|
|
209
|
+
_forEachInstanceProperty(fieldNames).call(fieldNames, (name, index) => {
|
|
210
|
+
let existingField = _findInstanceProperty(currentLevel).call(currentLevel, f => f.name === name);
|
|
211
|
+
if (!existingField) {
|
|
212
|
+
existingField = {
|
|
213
|
+
name,
|
|
214
|
+
fields: []
|
|
215
|
+
};
|
|
216
|
+
currentLevel.push(existingField);
|
|
217
|
+
}
|
|
218
|
+
if (index === fieldNames.length - 1) {
|
|
219
|
+
field.name;
|
|
220
|
+
const otherProps = _objectWithoutProperties(field, _excluded$1);
|
|
221
|
+
_Object$assign(existingField, otherProps);
|
|
222
|
+
} else {
|
|
223
|
+
currentLevel = existingField.fields;
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
return reconstructed;
|
|
228
|
+
}
|
|
229
|
+
function getSelectedFields(fields) {
|
|
230
|
+
return _filterInstanceProperty(fields).call(fields, field => field.isChecked);
|
|
231
|
+
}
|
|
232
|
+
function getFieldNames(fields) {
|
|
233
|
+
return _mapInstanceProperty(fields).call(fields, field => field.name);
|
|
234
|
+
}
|
|
235
|
+
function checkRequiredFields(fields) {
|
|
236
|
+
return _mapInstanceProperty(fields).call(fields, field => field.isRequired ? _objectSpread$6(_objectSpread$6({}, field), {}, {
|
|
237
|
+
isChecked: true
|
|
238
|
+
}) : field);
|
|
239
|
+
}
|
|
240
|
+
const getExportLogsLink = (projectKey, msg) => jsx(Link, {
|
|
241
|
+
to: "/".concat(projectKey, "/operations/export/logs"),
|
|
242
|
+
children: msg
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
/*
|
|
246
|
+
* This function is responsible for constructing the GraphQL query based on the export settings
|
|
247
|
+
*
|
|
248
|
+
* Depending on the type of export selection (all, selected, or filtered) it constructs different types of queries:
|
|
249
|
+
* - For 'all', it generates a query that fetches all fields and locales specified in the export settings.
|
|
250
|
+
* - For 'selected', it creates a query that fetches only the fields and locales of the selected resources. The ids of the selected resources are included in the query.
|
|
251
|
+
* - The 'filtered' case is a placeholder for future development where a query will be constructed based on certain filtering criteria using the `where` parameter.
|
|
252
|
+
*/
|
|
253
|
+
function buildGraphQuery(exportSettings) {
|
|
254
|
+
var _context;
|
|
255
|
+
const operation = resourceTypeToOperationName(exportSettings.resourceType);
|
|
256
|
+
switch (exportSettings.exportType) {
|
|
257
|
+
case EXPORT_TYPES.ALL:
|
|
258
|
+
return query({
|
|
259
|
+
operation,
|
|
260
|
+
fields: [{
|
|
261
|
+
results: buildFields({
|
|
262
|
+
fields: exportSettings.fields,
|
|
263
|
+
locales: exportSettings.locales
|
|
264
|
+
})
|
|
265
|
+
}],
|
|
266
|
+
variables: {}
|
|
267
|
+
});
|
|
268
|
+
case EXPORT_TYPES.SELECTED:
|
|
269
|
+
return query({
|
|
270
|
+
operation,
|
|
271
|
+
fields: [{
|
|
272
|
+
results: buildFields({
|
|
273
|
+
fields: exportSettings.fields,
|
|
274
|
+
locales: exportSettings.locales
|
|
275
|
+
})
|
|
276
|
+
}],
|
|
277
|
+
variables: {
|
|
278
|
+
where: "id in (".concat(_mapInstanceProperty(_context = exportSettings.selectedResourceIds).call(_context, id => "\"".concat(id, "\"")).join(', '), ")")
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
case EXPORT_TYPES.FILTERED:
|
|
282
|
+
// TODO: gql query for exporting filtered resources.
|
|
283
|
+
throw new UnexpectedExportTypeError(exportSettings.exportType);
|
|
284
|
+
default:
|
|
285
|
+
throw new UnexpectedExportTypeError(exportSettings.exportType);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/*
|
|
290
|
+
* This function builds the necessary field structure for our GraphQL queries, tt is specifically designed to handle different types of fields
|
|
291
|
+
*
|
|
292
|
+
* For fields whose values change depending on the locale aka localised fields, a unique request format is used
|
|
293
|
+
* This format combines the field and the locale, separated by '______'. This approach is adopted as our system disallows the use of hyphens `-` in these situations
|
|
294
|
+
*
|
|
295
|
+
* Fields that don't vary by locale but contain additional subfields (known as 'nested fields') are also addressed
|
|
296
|
+
* In these cases the function is used recursively on these subfields to generate the appropriate request.
|
|
297
|
+
*
|
|
298
|
+
* Overall, this function enables us to accurately request different types of data, including those varying by locale or containing subfields.
|
|
299
|
+
*
|
|
300
|
+
* More details can be found in the related PR: https://github.com/commercetools/commercetools-exporter/pull/103
|
|
301
|
+
*/
|
|
302
|
+
|
|
303
|
+
function buildFields(_ref) {
|
|
304
|
+
var _context2;
|
|
305
|
+
let fields = _ref.fields,
|
|
306
|
+
locales = _ref.locales;
|
|
307
|
+
return _flatInstanceProperty(_context2 = _mapInstanceProperty(fields).call(fields, field => {
|
|
308
|
+
if (field.isLocalized) return _mapInstanceProperty(locales).call(locales, locale => {
|
|
309
|
+
var _context3, _context4, _context5;
|
|
310
|
+
const alias = replaceSpecialCharsWithUnderscore(_concatInstanceProperty(_context3 = "".concat(field.name, "______")).call(_context3, locale));
|
|
311
|
+
return _concatInstanceProperty(_context4 = _concatInstanceProperty(_context5 = "".concat(alias, ": ")).call(_context5, field.name, "(locale: \"")).call(_context4, locale, "\")");
|
|
312
|
+
});else {
|
|
313
|
+
if (isFilledArray(field.fields)) {
|
|
314
|
+
return {
|
|
315
|
+
[field.name]: buildFields({
|
|
316
|
+
fields: field.fields,
|
|
317
|
+
locales
|
|
318
|
+
})
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
return field.name;
|
|
322
|
+
}
|
|
323
|
+
})).call(_context2);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
function validate(_ref) {
|
|
327
|
+
let values = _valuesInstanceProperty(_ref),
|
|
328
|
+
step = _ref.step;
|
|
329
|
+
const errors = {
|
|
330
|
+
fileName: {},
|
|
331
|
+
locales: {},
|
|
332
|
+
fields: {}
|
|
333
|
+
};
|
|
334
|
+
// Always validate these fields (first and second steps)
|
|
335
|
+
if (TextInput.isEmpty(values.fileName)) {
|
|
336
|
+
errors.fileName.missing = true;
|
|
337
|
+
} else if (!/^[a-zA-Z0-9-_.]+$/.test(values.fileName)) {
|
|
338
|
+
errors.fileName.invalidInput = true;
|
|
339
|
+
}
|
|
340
|
+
if (values.locales.length < 1) {
|
|
341
|
+
errors.locales.missing = true;
|
|
342
|
+
}
|
|
343
|
+
//
|
|
344
|
+
|
|
345
|
+
// Only validate these fields on the 2nd step
|
|
346
|
+
if (step === 2) {
|
|
347
|
+
var _context;
|
|
348
|
+
const checkedFields = _filterInstanceProperty(_context = values.fields).call(_context, field => field.isChecked);
|
|
349
|
+
if (checkedFields.length < 2) {
|
|
350
|
+
errors.fields.missing = true;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
return omitEmpty(errors);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
const categoryColumnExtension = columns => {
|
|
357
|
+
const extendedColumns = [...columns];
|
|
358
|
+
const parentKeyIndex = _findIndexInstanceProperty(columns).call(columns, column => column === 'parent.key');
|
|
359
|
+
if (parentKeyIndex !== -1) {
|
|
360
|
+
_spliceInstanceProperty(extendedColumns).call(extendedColumns, parentKeyIndex + 1, 0, 'parent.typeId');
|
|
361
|
+
}
|
|
362
|
+
return extendedColumns;
|
|
363
|
+
};
|
|
364
|
+
const defaultColumnExtension = columns => columns;
|
|
365
|
+
const columnExtensionByResourceType = {
|
|
366
|
+
default: defaultColumnExtension,
|
|
367
|
+
category: categoryColumnExtension
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
const extendColumns = (columns, resourceType) => {
|
|
371
|
+
const extensionFunction = columnExtensionByResourceType[resourceType] || columnExtensionByResourceType.default;
|
|
372
|
+
return extensionFunction(columns);
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
var messages = defineMessages({
|
|
376
|
+
modalTitle: {
|
|
377
|
+
id: 'ExportResourcesModal.modalTitle',
|
|
378
|
+
description: 'Label for the modal title',
|
|
379
|
+
defaultMessage: 'Export {resourceType}'
|
|
380
|
+
},
|
|
381
|
+
outputFormat: {
|
|
382
|
+
id: 'ExportResourcesModal.outputFormat',
|
|
383
|
+
description: 'File format like (csv, xls, ...etc)',
|
|
384
|
+
defaultMessage: 'File format'
|
|
385
|
+
},
|
|
386
|
+
fileName: {
|
|
387
|
+
id: 'ExportResourcesModal.fileName',
|
|
388
|
+
description: 'exported file name',
|
|
389
|
+
defaultMessage: 'File name'
|
|
390
|
+
},
|
|
391
|
+
locale: {
|
|
392
|
+
id: 'ExportResourcesModal.locale',
|
|
393
|
+
description: 'Locale',
|
|
394
|
+
defaultMessage: 'Locale'
|
|
395
|
+
},
|
|
396
|
+
exportSelection: {
|
|
397
|
+
id: 'ExportResourcesModal.exportSelection',
|
|
398
|
+
description: 'Export selection',
|
|
399
|
+
defaultMessage: 'Export selection'
|
|
400
|
+
},
|
|
401
|
+
exportAllResources: {
|
|
402
|
+
id: 'ExportResourcesModal.exportAllResources',
|
|
403
|
+
description: 'Export All selection',
|
|
404
|
+
defaultMessage: 'Export all {resourceType} ({count})'
|
|
405
|
+
},
|
|
406
|
+
exportOnlySelectedResources: {
|
|
407
|
+
id: 'ExportResourcesModal.exportOnlySelectedResources',
|
|
408
|
+
description: 'Export only selected resources',
|
|
409
|
+
defaultMessage: 'Export selected {resourceType} ({count})'
|
|
410
|
+
},
|
|
411
|
+
exportAllMessage: {
|
|
412
|
+
id: 'ExportResourcesModal.exportAllMessage',
|
|
413
|
+
description: 'All resources will be exported',
|
|
414
|
+
defaultMessage: 'All <b>{count}</b> {resourceType} will be exported.'
|
|
415
|
+
},
|
|
416
|
+
exportMatchingMessage: {
|
|
417
|
+
id: 'ExportResourcesModal.exportMatchingMessage',
|
|
418
|
+
description: 'resources will be exported',
|
|
419
|
+
defaultMessage: '<b>{count}</b> {resourceType} will be exported.'
|
|
420
|
+
},
|
|
421
|
+
exportSelectedMessage: {
|
|
422
|
+
id: 'ExportResourcesModal.exportSelectedMessage',
|
|
423
|
+
description: 'resources are selected and will be exported',
|
|
424
|
+
defaultMessage: '<b>{count}</b> {resourceType} are selected and will be exported.'
|
|
425
|
+
},
|
|
426
|
+
columnsMessage: {
|
|
427
|
+
id: 'ExportResourcesModal.columnsMessage',
|
|
428
|
+
description: 'Exported columns and attributes based on table settings',
|
|
429
|
+
defaultMessage: 'Exported columns/attributes based on table settings: {columnsCount}'
|
|
430
|
+
},
|
|
431
|
+
exportBasedOnMyViewsMessage: {
|
|
432
|
+
id: 'ExportResourcesModal.exportBasedOnMyViewsMessage',
|
|
433
|
+
description: 'Select Export setttings based on my views',
|
|
434
|
+
defaultMessage: 'Select export settings based on:'
|
|
435
|
+
},
|
|
436
|
+
propertiesPanelLabel: {
|
|
437
|
+
id: 'ExportResourcesModal.propertiesPanelLabel',
|
|
438
|
+
description: 'properties panel label',
|
|
439
|
+
defaultMessage: 'Properties'
|
|
440
|
+
},
|
|
441
|
+
exportOperationSuccessMessage: {
|
|
442
|
+
id: 'ExportResourcesModal.exportOperationSuccessMessage',
|
|
443
|
+
description: 'Success message',
|
|
444
|
+
defaultMessage: '<b>Your export has started.</b> <newline></newline><logsLink>Go to Export logs</logsLink> to view the progress and download the file.'
|
|
445
|
+
},
|
|
446
|
+
nothingApplied: {
|
|
447
|
+
id: 'ExportResourcesModal.nothingApplied',
|
|
448
|
+
description: 'Shown when there is no filter applied',
|
|
449
|
+
defaultMessage: 'nothing applied'
|
|
450
|
+
},
|
|
451
|
+
selectAllLocales: {
|
|
452
|
+
id: 'ExportResourcesModal.selectAllLocales',
|
|
453
|
+
description: 'label for "Select all locales" checkbox',
|
|
454
|
+
defaultMessage: 'Select all locales'
|
|
455
|
+
},
|
|
456
|
+
missingFileNameError: {
|
|
457
|
+
id: 'ExportResourcesModal.missingFileNameError',
|
|
458
|
+
description: 'Error when file name field is missing',
|
|
459
|
+
defaultMessage: 'Please enter a file name'
|
|
460
|
+
},
|
|
461
|
+
invalidFileNameError: {
|
|
462
|
+
id: 'ExportResourcesModal.invalidFileNameError',
|
|
463
|
+
description: 'Error when file name field is not valid',
|
|
464
|
+
defaultMessage: 'File name may only contain alphanumeric characters, hyphens and underscores'
|
|
465
|
+
},
|
|
466
|
+
missingLocaleError: {
|
|
467
|
+
id: 'ExportResourcesModal.missingLocaleError',
|
|
468
|
+
description: 'Error when no locale is selected',
|
|
469
|
+
defaultMessage: 'Please select at least one locale'
|
|
470
|
+
},
|
|
471
|
+
myViews: {
|
|
472
|
+
id: 'ExportResourcesModal.myViews',
|
|
473
|
+
description: 'Label for "My Views" Select Field',
|
|
474
|
+
defaultMessage: 'My Views'
|
|
475
|
+
},
|
|
476
|
+
selectColumnsToExport: {
|
|
477
|
+
id: 'ExportResourcesModal.selectColumnsToExport',
|
|
478
|
+
defaultMessage: 'Select columns to export'
|
|
479
|
+
},
|
|
480
|
+
back: {
|
|
481
|
+
id: 'ExportResourcesModal.back',
|
|
482
|
+
description: 'Label for "Back" button',
|
|
483
|
+
defaultMessage: 'Back'
|
|
484
|
+
},
|
|
485
|
+
startExport: {
|
|
486
|
+
id: 'ExportResourcesModal.startExport',
|
|
487
|
+
description: 'Label for "Start export" button',
|
|
488
|
+
defaultMessage: 'Start export'
|
|
489
|
+
},
|
|
490
|
+
continue: {
|
|
491
|
+
id: 'ExportResourcesModal.continue',
|
|
492
|
+
description: 'Label for "Continue" button',
|
|
493
|
+
defaultMessage: 'Continue'
|
|
494
|
+
},
|
|
495
|
+
columnDefinitions: {
|
|
496
|
+
id: 'ExportResourcesModal.columnDefinitions',
|
|
497
|
+
description: 'Label for "Column Definitions" link',
|
|
498
|
+
defaultMessage: 'Column definitions'
|
|
499
|
+
},
|
|
500
|
+
allGeneralFields: {
|
|
501
|
+
id: 'ExportResourcesModal.allGeneralFields',
|
|
502
|
+
description: 'Label for "All general fields" checkbox',
|
|
503
|
+
defaultMessage: 'All general fields'
|
|
504
|
+
}
|
|
505
|
+
});
|
|
506
|
+
|
|
507
|
+
function getBold(msg) {
|
|
508
|
+
return jsx(Text.Body, {
|
|
509
|
+
as: "span",
|
|
510
|
+
isBold: true,
|
|
511
|
+
children: msg
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
function getNewLine() {
|
|
516
|
+
return jsx("br", {});
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
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; }
|
|
520
|
+
function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys$5(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys$5(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
521
|
+
function renderFileNameError(key) {
|
|
522
|
+
switch (key) {
|
|
523
|
+
case 'missing':
|
|
524
|
+
return jsx(FormattedMessage, _objectSpread$5({}, messages.missingFileNameError));
|
|
525
|
+
case 'invalidInput':
|
|
526
|
+
return jsx(FormattedMessage, _objectSpread$5({}, messages.invalidFileNameError));
|
|
527
|
+
default:
|
|
528
|
+
return null;
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
function renderLocaleError(key) {
|
|
532
|
+
switch (key) {
|
|
533
|
+
case 'missing':
|
|
534
|
+
return jsx(FormattedMessage, _objectSpread$5({}, messages.missingLocaleError));
|
|
535
|
+
default:
|
|
536
|
+
return null;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
function useExportResourcesContext() {
|
|
541
|
+
const context = useContext(ExportResourcesContext);
|
|
542
|
+
if (!context) {
|
|
543
|
+
throw new MissingExportResourceProviderError();
|
|
544
|
+
}
|
|
545
|
+
return context;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
const _excluded = ["isSelectedByDefault"];
|
|
549
|
+
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; }
|
|
550
|
+
function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context3 = ownKeys$4(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context4 = ownKeys$4(Object(t))).call(_context4, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
551
|
+
const useInitialValues = props => {
|
|
552
|
+
var _context;
|
|
553
|
+
const todayFormatted = moment().format('DD-MM-YY_HH-mm');
|
|
554
|
+
const _useApplicationContex = useApplicationContext(applicationContext => ({
|
|
555
|
+
locale: applicationContext.dataLocale
|
|
556
|
+
})),
|
|
557
|
+
locale = _useApplicationContex.locale;
|
|
558
|
+
const fields = _mapInstanceProperty(_context = flattenNestedFields(props.fields)).call(_context, _ref => {
|
|
559
|
+
let isSelectedByDefault = _ref.isSelectedByDefault,
|
|
560
|
+
field = _objectWithoutProperties(_ref, _excluded);
|
|
561
|
+
return _objectSpread$4(_objectSpread$4({}, field), {}, {
|
|
562
|
+
isChecked: isSelectedByDefault !== null && isSelectedByDefault !== void 0 ? isSelectedByDefault : true
|
|
563
|
+
});
|
|
564
|
+
});
|
|
565
|
+
return React.useMemo(() => {
|
|
566
|
+
var _context2;
|
|
567
|
+
return {
|
|
568
|
+
outputFormat: props.outputFormat,
|
|
569
|
+
fileName: _concatInstanceProperty(_context2 = "".concat(resourceTypeToPlural({
|
|
570
|
+
resourceType: props.resourceType,
|
|
571
|
+
isUpperCase: true
|
|
572
|
+
}), "_Export_")).call(_context2, todayFormatted),
|
|
573
|
+
locales: [locale],
|
|
574
|
+
fields: checkRequiredFields(fields)
|
|
575
|
+
};
|
|
576
|
+
}, [props, locale, todayFormatted, fields]);
|
|
577
|
+
};
|
|
578
|
+
|
|
579
|
+
async function createExportOperation(_ref) {
|
|
580
|
+
let fileName = _ref.fileName,
|
|
581
|
+
fileFormat = _ref.fileFormat,
|
|
582
|
+
columns = _ref.columns,
|
|
583
|
+
locales = _ref.locales,
|
|
584
|
+
projectKey = _ref.projectKey,
|
|
585
|
+
graphQuery = _ref.graphQuery,
|
|
586
|
+
asyncDispatchFn = _ref.asyncDispatchFn;
|
|
587
|
+
const uri = "/proxy/export/".concat(projectKey, "/export-operations");
|
|
588
|
+
const response = await asyncDispatchFn(actions.post({
|
|
589
|
+
// FIXME: EXPORT is undefined
|
|
590
|
+
mcApiProxyTarget: MC_API_PROXY_TARGETS.EXPORT,
|
|
591
|
+
uri: uri,
|
|
592
|
+
headers: {
|
|
593
|
+
accept: 'application/json'
|
|
594
|
+
},
|
|
595
|
+
payload: {
|
|
596
|
+
fileName,
|
|
597
|
+
fileFormat,
|
|
598
|
+
columns,
|
|
599
|
+
locales,
|
|
600
|
+
query: graphQuery
|
|
601
|
+
}
|
|
602
|
+
}));
|
|
603
|
+
return response;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
const useStartExportOperation = props => {
|
|
607
|
+
const intl = useIntl();
|
|
608
|
+
const asyncDispatch = useAsyncDispatch();
|
|
609
|
+
const showNotification = useShowNotification();
|
|
610
|
+
const _useApplicationContex = useApplicationContext(applicationContext => {
|
|
611
|
+
var _applicationContext$p;
|
|
612
|
+
return {
|
|
613
|
+
locale: applicationContext.dataLocale,
|
|
614
|
+
projectKey: (_applicationContext$p = applicationContext.project) === null || _applicationContext$p === void 0 ? void 0 : _applicationContext$p.key
|
|
615
|
+
};
|
|
616
|
+
}),
|
|
617
|
+
projectKey = _useApplicationContex.projectKey;
|
|
618
|
+
const startExportOperation = async values => {
|
|
619
|
+
const graphQuery = buildGraphQuery({
|
|
620
|
+
resourceType: props.resourceType,
|
|
621
|
+
exportType: props.exportType,
|
|
622
|
+
selectedResourceIds: props.selectedResourceIds,
|
|
623
|
+
fields: unflattenNestedFields(getSelectedFields(values.fields)),
|
|
624
|
+
locales: values.locales
|
|
625
|
+
});
|
|
626
|
+
try {
|
|
627
|
+
const response = await createExportOperation({
|
|
628
|
+
fileName: appendCsvOrJsonExtensionIfAbsent(values.fileName, values.outputFormat),
|
|
629
|
+
fileFormat: values.outputFormat,
|
|
630
|
+
locales: values.locales,
|
|
631
|
+
columns: extendColumns(getFieldNames(getSelectedFields(values.fields)), props.resourceType),
|
|
632
|
+
projectKey,
|
|
633
|
+
graphQuery,
|
|
634
|
+
asyncDispatchFn: asyncDispatch
|
|
635
|
+
});
|
|
636
|
+
switch (response.state) {
|
|
637
|
+
case EXPORT_OPERATION_STATES.PROCESSING:
|
|
638
|
+
case EXPORT_OPERATION_STATES.COMPLETED:
|
|
639
|
+
showNotification({
|
|
640
|
+
kind: 'info',
|
|
641
|
+
domain: DOMAINS.SIDE,
|
|
642
|
+
text: intl.formatMessage(messages.exportOperationSuccessMessage, {
|
|
643
|
+
newline: getNewLine,
|
|
644
|
+
logsLink: msg => getExportLogsLink(projectKey, msg),
|
|
645
|
+
b: getBold
|
|
646
|
+
})
|
|
647
|
+
}, {
|
|
648
|
+
dismissAfter: 5000
|
|
649
|
+
});
|
|
650
|
+
if (typeof props.onExportSuccess === 'function') props.onExportSuccess();
|
|
651
|
+
break;
|
|
652
|
+
default:
|
|
653
|
+
throw new UnexpectedExportOperationStateError(response.state);
|
|
654
|
+
}
|
|
655
|
+
} catch (errors) {
|
|
656
|
+
// TODO: custom error messages for each error type
|
|
657
|
+
showApiErrorNotification({
|
|
658
|
+
errors
|
|
659
|
+
});
|
|
660
|
+
} finally {
|
|
661
|
+
if (typeof props.onClose === 'function') props.onClose();
|
|
662
|
+
}
|
|
663
|
+
};
|
|
664
|
+
return {
|
|
665
|
+
startExportOperation
|
|
666
|
+
};
|
|
667
|
+
};
|
|
668
|
+
|
|
669
|
+
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; }
|
|
670
|
+
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys$3(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys$3(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
671
|
+
function ExportTextMessage() {
|
|
672
|
+
const _useExportResourcesCo = useExportResourcesContext(),
|
|
673
|
+
resourceType = _useExportResourcesCo.resourceType,
|
|
674
|
+
totalResourcesCount = _useExportResourcesCo.totalResourcesCount,
|
|
675
|
+
selectedResourceIds = _useExportResourcesCo.selectedResourceIds,
|
|
676
|
+
exportType = _useExportResourcesCo.exportType;
|
|
677
|
+
const resourceTypePlural = resourceTypeToPlural({
|
|
678
|
+
resourceType: resourceType
|
|
679
|
+
});
|
|
680
|
+
let message;
|
|
681
|
+
let count;
|
|
682
|
+
switch (exportType) {
|
|
683
|
+
case EXPORT_TYPES.ALL:
|
|
684
|
+
message = messages.exportAllMessage;
|
|
685
|
+
count = totalResourcesCount;
|
|
686
|
+
break;
|
|
687
|
+
case EXPORT_TYPES.SELECTED:
|
|
688
|
+
message = messages.exportSelectedMessage;
|
|
689
|
+
count = selectedResourceIds.length;
|
|
690
|
+
break;
|
|
691
|
+
default:
|
|
692
|
+
throw new UnexpectedExportTypeError(exportType);
|
|
693
|
+
}
|
|
694
|
+
return jsx(Text.Body, {
|
|
695
|
+
"data-testid": "export-description",
|
|
696
|
+
intlMessage: _objectSpread$3(_objectSpread$3({}, message), {}, {
|
|
697
|
+
values: {
|
|
698
|
+
count: count,
|
|
699
|
+
resourceType: resourceTypePlural,
|
|
700
|
+
b: getBold
|
|
701
|
+
}
|
|
702
|
+
})
|
|
703
|
+
});
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
const ExportFileSettingsStep = () => {
|
|
707
|
+
const intl = useIntl();
|
|
708
|
+
const _useExportResourcesCo = useExportResourcesContext(),
|
|
709
|
+
formik = _useExportResourcesCo.formik;
|
|
710
|
+
const _useApplicationContex = useApplicationContext(applicationContext => {
|
|
711
|
+
var _applicationContext$p;
|
|
712
|
+
return {
|
|
713
|
+
locale: applicationContext.dataLocale,
|
|
714
|
+
locales: ((_applicationContext$p = applicationContext.project) === null || _applicationContext$p === void 0 ? void 0 : _applicationContext$p.languages) || []
|
|
715
|
+
};
|
|
716
|
+
}),
|
|
717
|
+
locales = _useApplicationContex.locales,
|
|
718
|
+
locale = _useApplicationContex.locale;
|
|
719
|
+
const areAllLocalesChecked = _valuesInstanceProperty(formik).locales.length === locales.length;
|
|
720
|
+
return jsxs(Spacings.Stack, {
|
|
721
|
+
scale: "xxxl",
|
|
722
|
+
children: [jsxs(Spacings.Stack, {
|
|
723
|
+
scale: "l",
|
|
724
|
+
children: [jsxs(Spacings.Inline, {
|
|
725
|
+
alignItems: "center",
|
|
726
|
+
children: [jsx(ExportIcon, {
|
|
727
|
+
size: "medium",
|
|
728
|
+
color: "neutral60"
|
|
729
|
+
}), jsx(ExportTextMessage, {})]
|
|
730
|
+
}), jsxs(Spacings.Stack, {
|
|
731
|
+
scale: "m",
|
|
732
|
+
children: [jsx(SelectField, {
|
|
733
|
+
name: "outputFormat",
|
|
734
|
+
onChange: formik.handleChange,
|
|
735
|
+
onBlur: formik.handleBlur,
|
|
736
|
+
value: _valuesInstanceProperty(formik).outputFormat,
|
|
737
|
+
title: intl.formatMessage(messages.outputFormat),
|
|
738
|
+
options: OUTPUT_FORMAT_OPTIONS
|
|
739
|
+
}), jsx(TextField, {
|
|
740
|
+
name: "fileName",
|
|
741
|
+
onChange: formik.handleChange,
|
|
742
|
+
onBlur: formik.handleBlur,
|
|
743
|
+
value: _valuesInstanceProperty(formik).fileName,
|
|
744
|
+
title: intl.formatMessage(messages.fileName),
|
|
745
|
+
touched: formik.touched.fileName,
|
|
746
|
+
errors: formik.errors.fileName,
|
|
747
|
+
renderError: renderFileNameError
|
|
748
|
+
}), jsxs(Spacings.Stack, {
|
|
749
|
+
scale: "xs",
|
|
750
|
+
children: [jsx(SelectField, {
|
|
751
|
+
id: "locales",
|
|
752
|
+
name: "locales",
|
|
753
|
+
value: _valuesInstanceProperty(formik).locales,
|
|
754
|
+
title: intl.formatMessage(messages.locale),
|
|
755
|
+
options: mapLocalesToOptions(locales),
|
|
756
|
+
isMulti: true,
|
|
757
|
+
onChange: formik.handleChange,
|
|
758
|
+
onBlur: formik.handleBlur,
|
|
759
|
+
touched: formik.touched.locales,
|
|
760
|
+
errors: formik.errors.locales,
|
|
761
|
+
renderError: renderLocaleError
|
|
762
|
+
}), jsx(CheckboxInput, {
|
|
763
|
+
isChecked: areAllLocalesChecked,
|
|
764
|
+
onChange: e => {
|
|
765
|
+
if (e.target.checked) formik.setFieldValue('locales', locales);else formik.setFieldValue('locales', [locale]);
|
|
766
|
+
},
|
|
767
|
+
children: intl.formatMessage(messages.selectAllLocales)
|
|
768
|
+
})]
|
|
769
|
+
})]
|
|
770
|
+
})]
|
|
771
|
+
}), jsx(Spacings.Inline, {
|
|
772
|
+
justifyContent: "flex-end",
|
|
773
|
+
children: jsx(PrimaryButton, {
|
|
774
|
+
label: intl.formatMessage(messages.continue),
|
|
775
|
+
onClick: formik.submitForm,
|
|
776
|
+
isDisabled: !formik.isValid
|
|
777
|
+
})
|
|
778
|
+
})]
|
|
779
|
+
});
|
|
780
|
+
};
|
|
781
|
+
|
|
782
|
+
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; }
|
|
783
|
+
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var _context6, _context7; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context6 = ownKeys$2(Object(t), !0)).call(_context6, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context7 = ownKeys$2(Object(t))).call(_context7, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
784
|
+
function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
|
|
785
|
+
const StyledCard = /*#__PURE__*/_styled(Card, process.env.NODE_ENV === "production" ? {
|
|
786
|
+
target: "e1ocu3bb2"
|
|
787
|
+
} : {
|
|
788
|
+
target: "e1ocu3bb2",
|
|
789
|
+
label: "StyledCard"
|
|
790
|
+
})(process.env.NODE_ENV === "production" ? {
|
|
791
|
+
name: "1jtoq3b",
|
|
792
|
+
styles: "border-radius:4px 0px 0px 4px;&>div{height:490px;overflow-y:auto;}"
|
|
793
|
+
} : {
|
|
794
|
+
name: "1jtoq3b",
|
|
795
|
+
styles: "border-radius:4px 0px 0px 4px;&>div{height:490px;overflow-y:auto;}",
|
|
796
|
+
map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImV4cG9ydC1maWVsZHMtc2VsZWN0aW9uLXN0ZXAuanN4Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQW1CK0IiLCJmaWxlIjoiZXhwb3J0LWZpZWxkcy1zZWxlY3Rpb24tc3RlcC5qc3giLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvc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luaXRpb25zfVxuICAgICAgICAgICAgdG89e0NPTFVNTl9ERUZJTklUSU9OU19VUkxTW3Jlc291cmNlVHlwZV19XG4gICAgICAgICAgLz5cbiAgICAgICAgPC9TcGFjaW5ncy5JbmxpbmU+XG4gICAgICAgIDxHcmlkXG4gICAgICAgICAgZ3JpZEF1dG9GbG93PVwiY29sdW1uXCJcbiAgICAgICAgICBncmlkVGVtcGxhdGVDb2x1bW5zPXtgJHtjdXN0b21Qcm9wZXJ0aWVzLmNvbnN0cmFpbnQ1fSBhdXRvYH1cbiAgICAgICAgPlxuICAgICAgICAgIDxHcmlkLkl0ZW0+XG4gICAgICAgICAgICA8U3R5bGVkQ2FyZExlZnQgaW5zZXRTY2FsZT1cImxcIj5cbiAgICAgICAgICAgICAgPENoZWNrYm94SW5wdXRcbiAgICAgICAgICAgICAgICBpc0luZGV0ZXJtaW5hdGU9e1xuICAgICAgICAgICAgICAgICAgIWFyZUFsbEZpZWxkc0NoZWNrZWQgJiYgaXNBdExlYXN0T25lRmllbGRDaGVja2VkXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlzQ2hlY2tlZD17YXJlQWxsRmllbGRzQ2hlY2tlZH1cbiAgICAgICAgICAgICAgICBvbkNoYW5nZT17KGUpID0+IHtcbiAgICAgICAgICAgICAgICAgIGZvcm1pay5zZXRGaWVsZFZhbHVlKFxuICAgICAgICAgICAgICAgICAgICAnZmllbGRzJyxcbiAgICAgICAgICAgICAgICAgICAgZm9ybWlrLnZhbHVlcy5maWVsZHMubWFwKChmaWVsZCkgPT4gKHtcbiAgICAgICAgICAgICAgICAgICAgICAuLi5maWVsZCxcbiAgICAgICAgICAgICAgICAgICAgICBpc0NoZWNrZWQ6IGZpZWxkLmlzUmVxdWlyZWQgPyB0cnVlIDogZS50YXJnZXQuY2hlY2tlZCxcbiAgICAgICAgICAgICAgICAgICAgfSkpXG4gICAgICAgICAgICAgICAgICApXG4gICAgICAgICAgICAgICAgfX1cbiAgICAgICAgICAgICAgPlxuICAgICAgICAgICAgICAgIDxUZXh0LkJvZHkgaW50bE1lc3NhZ2U9e21lc3NhZ2VzLmFsbEdlbmVyYWxGaWVsZHN9IC8+XG4gICAgICAgICAgICAgIDwvQ2hlY2tib3hJbnB1dD5cbiAgICAgICAgICAgIDwvU3R5bGVkQ2FyZExlZnQ+XG4gICAgICAgICAgPC9HcmlkLkl0ZW0+XG4gICAgICAgICAgPEdyaWQuSXRlbT5cbiAgICAgICAgICAgIDxTdHlsZWRDYXJkUmlnaHQgaW5zZXRTY2FsZT1cImxcIj5cbiAgICAgICAgICAgICAge2Zvcm1pay52YWx1ZXMuZmllbGRzLm1hcCgoZmllbGQpID0+IChcbiAgICAgICAgICAgICAgICA8Q2hlY2tib3hJbnB1dFxuICAgICAgICAgICAgICAgICAga2V5PXtmaWVsZC5uYW1lfVxuICAgICAgICAgICAgICAgICAgaXNSZWFkT25seT17ZmllbGQuaXNSZXF1aXJlZH1cbiAgICAgICAgICAgICAgICAgIGlzQ2hlY2tlZD17ZmllbGQuaXNDaGVja2VkfVxuICAgICAgICAgICAgICAgICAgb25DaGFuZ2U9eyhlKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgIGZvcm1pay5zZXRGaWVsZFZhbHVlKFxuICAgICAgICAgICAgICAgICAgICAgICdmaWVsZHMnLFxuICAgICAgICAgICAgICAgICAgICAgIGZvcm1pay52YWx1ZXMuZmllbGRzLm1hcCgoX2ZpZWxkKSA9PlxuICAgICAgICAgICAgICAgICAgICAgICAgZmllbGQubmFtZSA9PT0gX2ZpZWxkLm5hbWVcbiAgICAgICAgICAgICAgICAgICAgICAgICAgPyB7IC4uLl9maWVsZCwgaXNDaGVja2VkOiBlLnRhcmdldC5jaGVja2VkIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgOiBfZmllbGRcbiAgICAgICAgICAgICAgICAgICAgICApXG4gICAgICAgICAgICAgICAgICAgIClcbiAgICAgICAgICAgICAgICAgIH19XG4gICAgICAgICAgICAgICAgPlxuICAgICAgICAgICAgICAgICAgPFRleHQuQm9keT5cbiAgICAgICAgICAgICAgICAgICAge2ZpZWxkLmxhYmVsfSB7ZmllbGQuaXNSZXF1aXJlZCAmJiAnKid9XG4gICAgICAgICAgICAgICAgICA8L1RleHQuQm9keT5cbiAgICAgICAgICAgICAgICA8L0NoZWNrYm94SW5wdXQ+XG4gICAgICAgICAgICAgICkpfVxuICAgICAgICAgICAgPC9TdHlsZWRDYXJkUmlnaHQ+XG4gICAgICAgICAgPC9HcmlkLkl0ZW0+XG4gICAgICAgIDwvR3JpZD5cbiAgICAgIDwvU3BhY2luZ3MuU3RhY2s+XG4gICAgICA8U3BhY2luZ3MuSW5saW5lIHNjYWxlPVwibVwiIGp1c3RpZnlDb250ZW50PVwiZmxleC1lbmRcIj5cbiAgICAgICAgPFNlY29uZGFyeUJ1dHRvblxuICAgICAgICAgIGxhYmVsPXtpbnRsLmZvcm1hdE1lc3NhZ2UobWVzc2FnZXMuYmFjayl9XG4gICAgICAgICAgb25DbGljaz17KCkgPT4gc2V0Q3VycmVudFN0ZXAoMSl9XG4gICAgICAgIC8+XG4gICAgICAgIDxQcmltYXJ5QnV0dG9uXG4gICAgICAgICAgbGFiZWw9e2ludGwuZm9ybWF0TWVzc2FnZShtZXNzYWdlcy5zdGFydEV4cG9ydCl9XG4gICAgICAgICAgb25DbGljaz17Zm9ybWlrLnN1Ym1pdEZvcm19XG4gICAgICAgICAgaXNEaXNhYmxlZD17IWZvcm1pay5pc1ZhbGlkfVxuICAgICAgICAvPlxuICAgICAgPC9TcGFjaW5ncy5JbmxpbmU+XG4gICAgPC9TcGFjaW5ncy5TdGFjaz5cbiAgKVxufVxuIl19 */",
|
|
797
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
798
|
+
});
|
|
799
|
+
const StyledCardLeft = /*#__PURE__*/_styled(StyledCard, process.env.NODE_ENV === "production" ? {
|
|
800
|
+
target: "e1ocu3bb1"
|
|
801
|
+
} : {
|
|
802
|
+
target: "e1ocu3bb1",
|
|
803
|
+
label: "StyledCardLeft"
|
|
804
|
+
})(process.env.NODE_ENV === "production" ? {
|
|
805
|
+
name: "65buvr",
|
|
806
|
+
styles: "background-color:#f9f9fb"
|
|
807
|
+
} : {
|
|
808
|
+
name: "65buvr",
|
|
809
|
+
styles: "background-color:#f9f9fb",
|
|
810
|
+
map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImV4cG9ydC1maWVsZHMtc2VsZWN0aW9uLXN0ZXAuanN4Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQTBCeUMiLCJmaWxlIjoiZXhwb3J0LWZpZWxkcy1zZWxlY3Rpb24tc3RlcC5qc3giLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgUmVhY3QgZnJvbSAncmVhY3QnXG5pbXBvcnQgeyB1c2VJbnRsIH0gZnJvbSAncmVhY3QtaW50bCdcbmltcG9ydCBzdHlsZWQgZnJvbSAnQGVtb3Rpb24vc3R5bGVkJ1xuaW1wb3J0IHtcbiAgQ2FyZCxcbiAgQ2hlY2tib3hJbnB1dCxcbiAgR3JpZCxcbiAgTGluayxcbiAgUHJpbWFyeUJ1dHRvbixcbiAgU2Vjb25kYXJ5QnV0dG9uLFxuICBTcGFjaW5ncyxcbiAgVGV4dCxcbiAgY3VzdG9tUHJvcGVydGllcyxcbn0gZnJvbSAnQGNvbW1lcmNldG9vbHMtZnJvbnRlbmQvdWkta2l0J1xuaW1wb3J0IG1lc3NhZ2VzIGZyb20gJy4uL21lc3NhZ2VzJ1xuaW1wb3J0IHsgdXNlRXhwb3J0UmVzb3VyY2VzQ29udGV4dCB9IGZyb20gJy4uL0Bob29rcydcbmltcG9ydCB7IENPTFVNTl9ERUZJTklUSU9OU19VUkxTIH0gZnJvbSAnLi4vQGNvbnN0YW50cydcblxuLy8gVE9ETzogUmVtb3ZlIHRoZXNlIHN0eWxlZCBjb21wb25lbnRzIG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bGRzQ2hlY2tlZH1cbiAgICAgICAgICAgICAgICBvbkNoYW5nZT17KGUpID0+IHtcbiAgICAgICAgICAgICAgICAgIGZvcm1pay5zZXRGaWVsZFZhbHVlKFxuICAgICAgICAgICAgICAgICAgICAnZmllbGRzJyxcbiAgICAgICAgICAgICAgICAgICAgZm9ybWlrLnZhbHVlcy5maWVsZHMubWFwKChmaWVsZCkgPT4gKHtcbiAgICAgICAgICAgICAgICAgICAgICAuLi5maWVsZCxcbiAgICAgICAgICAgICAgICAgICAgICBpc0NoZWNrZWQ6IGZpZWxkLmlzUmVxdWlyZWQgPyB0cnVlIDogZS50YXJnZXQuY2hlY2tlZCxcbiAgICAgICAgICAgICAgICAgICAgfSkpXG4gICAgICAgICAgICAgICAgICApXG4gICAgICAgICAgICAgICAgfX1cbiAgICAgICAgICAgICAgPlxuICAgICAgICAgICAgICAgIDxUZXh0LkJvZHkgaW50bE1lc3NhZ2U9e21lc3NhZ2VzLmFsbEdlbmVyYWxGaWVsZHN9IC8+XG4gICAgICAgICAgICAgIDwvQ2hlY2tib3hJbnB1dD5cbiAgICAgICAgICAgIDwvU3R5bGVkQ2FyZExlZnQ+XG4gICAgICAgICAgPC9HcmlkLkl0ZW0+XG4gICAgICAgICAgPEdyaWQuSXRlbT5cbiAgICAgICAgICAgIDxTdHlsZWRDYXJkUmlnaHQgaW5zZXRTY2FsZT1cImxcIj5cbiAgICAgICAgICAgICAge2Zvcm1pay52YWx1ZXMuZmllbGRzLm1hcCgoZmllbGQpID0+IChcbiAgICAgICAgICAgICAgICA8Q2hlY2tib3hJbnB1dFxuICAgICAgICAgICAgICAgICAga2V5PXtmaWVsZC5uYW1lfVxuICAgICAgICAgICAgICAgICAgaXNSZWFkT25seT17ZmllbGQuaXNSZXF1aXJlZH1cbiAgICAgICAgICAgICAgICAgIGlzQ2hlY2tlZD17ZmllbGQuaXNDaGVja2VkfVxuICAgICAgICAgICAgICAgICAgb25DaGFuZ2U9eyhlKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgIGZvcm1pay5zZXRGaWVsZFZhbHVlKFxuICAgICAgICAgICAgICAgICAgICAgICdmaWVsZHMnLFxuICAgICAgICAgICAgICAgICAgICAgIGZvcm1pay52YWx1ZXMuZmllbGRzLm1hcCgoX2ZpZWxkKSA9PlxuICAgICAgICAgICAgICAgICAgICAgICAgZmllbGQubmFtZSA9PT0gX2ZpZWxkLm5hbWVcbiAgICAgICAgICAgICAgICAgICAgICAgICAgPyB7IC4uLl9maWVsZCwgaXNDaGVja2VkOiBlLnRhcmdldC5jaGVja2VkIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgOiBfZmllbGRcbiAgICAgICAgICAgICAgICAgICAgICApXG4gICAgICAgICAgICAgICAgICAgIClcbiAgICAgICAgICAgICAgICAgIH19XG4gICAgICAgICAgICAgICAgPlxuICAgICAgICAgICAgICAgICAgPFRleHQuQm9keT5cbiAgICAgICAgICAgICAgICAgICAge2ZpZWxkLmxhYmVsfSB7ZmllbGQuaXNSZXF1aXJlZCAmJiAnKid9XG4gICAgICAgICAgICAgICAgICA8L1RleHQuQm9keT5cbiAgICAgICAgICAgICAgICA8L0NoZWNrYm94SW5wdXQ+XG4gICAgICAgICAgICAgICkpfVxuICAgICAgICAgICAgPC9TdHlsZWRDYXJkUmlnaHQ+XG4gICAgICAgICAgPC9HcmlkLkl0ZW0+XG4gICAgICAgIDwvR3JpZD5cbiAgICAgIDwvU3BhY2luZ3MuU3RhY2s+XG4gICAgICA8U3BhY2luZ3MuSW5saW5lIHNjYWxlPVwibVwiIGp1c3RpZnlDb250ZW50PVwiZmxleC1lbmRcIj5cbiAgICAgICAgPFNlY29uZGFyeUJ1dHRvblxuICAgICAgICAgIGxhYmVsPXtpbnRsLmZvcm1hdE1lc3NhZ2UobWVzc2FnZXMuYmFjayl9XG4gICAgICAgICAgb25DbGljaz17KCkgPT4gc2V0Q3VycmVudFN0ZXAoMSl9XG4gICAgICAgIC8+XG4gICAgICAgIDxQcmltYXJ5QnV0dG9uXG4gICAgICAgICAgbGFiZWw9e2ludGwuZm9ybWF0TWVzc2FnZShtZXNzYWdlcy5zdGFydEV4cG9ydCl9XG4gICAgICAgICAgb25DbGljaz17Zm9ybWlrLnN1Ym1pdEZvcm19XG4gICAgICAgICAgaXNEaXNhYmxlZD17IWZvcm1pay5pc1ZhbGlkfVxuICAgICAgICAvPlxuICAgICAgPC9TcGFjaW5ncy5JbmxpbmU+XG4gICAgPC9TcGFjaW5ncy5TdGFjaz5cbiAgKVxufVxuIl19 */",
|
|
811
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
812
|
+
});
|
|
813
|
+
const StyledCardRight = /*#__PURE__*/_styled(StyledCard, process.env.NODE_ENV === "production" ? {
|
|
814
|
+
target: "e1ocu3bb0"
|
|
815
|
+
} : {
|
|
816
|
+
target: "e1ocu3bb0",
|
|
817
|
+
label: "StyledCardRight"
|
|
818
|
+
})(process.env.NODE_ENV === "production" ? {
|
|
819
|
+
name: "1oktwfs",
|
|
820
|
+
styles: "border-radius:0px 4px 4px 0px;border-left:0"
|
|
821
|
+
} : {
|
|
822
|
+
name: "1oktwfs",
|
|
823
|
+
styles: "border-radius:0px 4px 4px 0px;border-left:0",
|
|
824
|
+
map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImV4cG9ydC1maWVsZHMtc2VsZWN0aW9uLXN0ZXAuanN4Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQTZCMEMiLCJmaWxlIjoiZXhwb3J0LWZpZWxkcy1zZWxlY3Rpb24tc3RlcC5qc3giLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgUmVhY3QgZnJvbSAncmVhY3QnXG5pbXBvcnQgeyB1c2VJbnRsIH0gZnJvbSAncmVhY3QtaW50bCdcbmltcG9ydCBzdHlsZWQgZnJvbSAnQGVtb3Rpb24vc3R5bGVkJ1xuaW1wb3J0IHtcbiAgQ2FyZCxcb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ICAgZ3JpZEF1dG9GbG93PVwiY29sdW1uXCJcbiAgICAgICAgICBncmlkVGVtcGxhdGVDb2x1bW5zPXtgJHtjdXN0b21Qcm9wZXJ0aWVzLmNvbnN0cmFpbnQ1fSBhdXRvYH1cbiAgICAgICAgPlxuICAgICAgICAgIDxHcmlkLkl0ZW0+XG4gICAgICAgICAgICA8U3R5bGVkQ2FyZExlZnQgaW5zZXRTY2FsZT1cImxcIj5cbiAgICAgICAgICAgICAgPENoZWNrYm94SW5wdXRcbiAgICAgICAgICAgICAgICBpc0luZGV0ZXJtaW5hdGU9e1xuICAgICAgICAgICAgICAgICAgIWFyZUFsbEZpZWxkc0NoZWNrZWQgJiYgaXNBdExlYXN0T25lRmllbGRDaGVja2VkXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlzQ2hlY2tlZD17YXJlQWxsRmllbGRzQ2hlY2tlZH1cbiAgICAgICAgICAgICAgICBvbkNoYW5nZT17KGUpID0+IHtcbiAgICAgICAgICAgICAgICAgIGZvcm1pay5zZXRGaWVsZFZhbHVlKFxuICAgICAgICAgICAgICAgICAgICAnZmllbGRzJyxcbiAgICAgICAgICAgICAgICAgICAgZm9ybWlrLnZhbHVlcy5maWVsZHMubWFwKChmaWVsZCkgPT4gKHtcbiAgICAgICAgICAgICAgICAgICAgICAuLi5maWVsZCxcbiAgICAgICAgICAgICAgICAgICAgICBpc0NoZWNrZWQ6IGZpZWxkLmlzUmVxdWlyZWQgPyB0cnVlIDogZS50YXJnZXQuY2hlY2tlZCxcbiAgICAgICAgICAgICAgICAgICAgfSkpXG4gICAgICAgICAgICAgICAgICApXG4gICAgICAgICAgICAgICAgfX1cbiAgICAgICAgICAgICAgPlxuICAgICAgICAgICAgICAgIDxUZXh0LkJvZHkgaW50bE1lc3NhZ2U9e21lc3NhZ2VzLmFsbEdlbmVyYWxGaWVsZHN9IC8+XG4gICAgICAgICAgICAgIDwvQ2hlY2tib3hJbnB1dD5cbiAgICAgICAgICAgIDwvU3R5bGVkQ2FyZExlZnQ+XG4gICAgICAgICAgPC9HcmlkLkl0ZW0+XG4gICAgICAgICAgPEdyaWQuSXRlbT5cbiAgICAgICAgICAgIDxTdHlsZWRDYXJkUmlnaHQgaW5zZXRTY2FsZT1cImxcIj5cbiAgICAgICAgICAgICAge2Zvcm1pay52YWx1ZXMuZmllbGRzLm1hcCgoZmllbGQpID0+IChcbiAgICAgICAgICAgICAgICA8Q2hlY2tib3hJbnB1dFxuICAgICAgICAgICAgICAgICAga2V5PXtmaWVsZC5uYW1lfVxuICAgICAgICAgICAgICAgICAgaXNSZWFkT25seT17ZmllbGQuaXNSZXF1aXJlZH1cbiAgICAgICAgICAgICAgICAgIGlzQ2hlY2tlZD17ZmllbGQuaXNDaGVja2VkfVxuICAgICAgICAgICAgICAgICAgb25DaGFuZ2U9eyhlKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgIGZvcm1pay5zZXRGaWVsZFZhbHVlKFxuICAgICAgICAgICAgICAgICAgICAgICdmaWVsZHMnLFxuICAgICAgICAgICAgICAgICAgICAgIGZvcm1pay52YWx1ZXMuZmllbGRzLm1hcCgoX2ZpZWxkKSA9PlxuICAgICAgICAgICAgICAgICAgICAgICAgZmllbGQubmFtZSA9PT0gX2ZpZWxkLm5hbWVcbiAgICAgICAgICAgICAgICAgICAgICAgICAgPyB7IC4uLl9maWVsZCwgaXNDaGVja2VkOiBlLnRhcmdldC5jaGVja2VkIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgOiBfZmllbGRcbiAgICAgICAgICAgICAgICAgICAgICApXG4gICAgICAgICAgICAgICAgICAgIClcbiAgICAgICAgICAgICAgICAgIH19XG4gICAgICAgICAgICAgICAgPlxuICAgICAgICAgICAgICAgICAgPFRleHQuQm9keT5cbiAgICAgICAgICAgICAgICAgICAge2ZpZWxkLmxhYmVsfSB7ZmllbGQuaXNSZXF1aXJlZCAmJiAnKid9XG4gICAgICAgICAgICAgICAgICA8L1RleHQuQm9keT5cbiAgICAgICAgICAgICAgICA8L0NoZWNrYm94SW5wdXQ+XG4gICAgICAgICAgICAgICkpfVxuICAgICAgICAgICAgPC9TdHlsZWRDYXJkUmlnaHQ+XG4gICAgICAgICAgPC9HcmlkLkl0ZW0+XG4gICAgICAgIDwvR3JpZD5cbiAgICAgIDwvU3BhY2luZ3MuU3RhY2s+XG4gICAgICA8U3BhY2luZ3MuSW5saW5lIHNjYWxlPVwibVwiIGp1c3RpZnlDb250ZW50PVwiZmxleC1lbmRcIj5cbiAgICAgICAgPFNlY29uZGFyeUJ1dHRvblxuICAgICAgICAgIGxhYmVsPXtpbnRsLmZvcm1hdE1lc3NhZ2UobWVzc2FnZXMuYmFjayl9XG4gICAgICAgICAgb25DbGljaz17KCkgPT4gc2V0Q3VycmVudFN0ZXAoMSl9XG4gICAgICAgIC8+XG4gICAgICAgIDxQcmltYXJ5QnV0dG9uXG4gICAgICAgICAgbGFiZWw9e2ludGwuZm9ybWF0TWVzc2FnZShtZXNzYWdlcy5zdGFydEV4cG9ydCl9XG4gICAgICAgICAgb25DbGljaz17Zm9ybWlrLnN1Ym1pdEZvcm19XG4gICAgICAgICAgaXNEaXNhYmxlZD17IWZvcm1pay5pc1ZhbGlkfVxuICAgICAgICAvPlxuICAgICAgPC9TcGFjaW5ncy5JbmxpbmU+XG4gICAgPC9TcGFjaW5ncy5TdGFjaz5cbiAgKVxufVxuIl19 */",
|
|
825
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
826
|
+
});
|
|
827
|
+
const ExportFieldsSelectionStep = () => {
|
|
828
|
+
var _context, _context2, _context4;
|
|
829
|
+
const intl = useIntl();
|
|
830
|
+
const _useExportResourcesCo = useExportResourcesContext(),
|
|
831
|
+
formik = _useExportResourcesCo.formik,
|
|
832
|
+
setCurrentStep = _useExportResourcesCo.setCurrentStep,
|
|
833
|
+
resourceType = _useExportResourcesCo.resourceType;
|
|
834
|
+
const areAllFieldsChecked = _everyInstanceProperty(_context = _valuesInstanceProperty(formik).fields).call(_context, field => field.isChecked);
|
|
835
|
+
const isAtLeastOneFieldChecked = _someInstanceProperty(_context2 = _valuesInstanceProperty(formik).fields).call(_context2, field => field.isChecked);
|
|
836
|
+
return jsxs(Spacings.Stack, {
|
|
837
|
+
scale: "xl",
|
|
838
|
+
children: [jsxs(Spacings.Stack, {
|
|
839
|
+
scale: "m",
|
|
840
|
+
children: [jsxs(Spacings.Inline, {
|
|
841
|
+
justifyContent: "space-between",
|
|
842
|
+
children: [jsx(Text.Body, {
|
|
843
|
+
intlMessage: messages.selectColumnsToExport
|
|
844
|
+
}), jsx(Link, {
|
|
845
|
+
isExternal: true,
|
|
846
|
+
tone: "secondary",
|
|
847
|
+
intlMessage: messages.columnDefinitions,
|
|
848
|
+
to: COLUMN_DEFINITIONS_URLS[resourceType]
|
|
849
|
+
})]
|
|
850
|
+
}), jsxs(Grid, {
|
|
851
|
+
gridAutoFlow: "column",
|
|
852
|
+
gridTemplateColumns: "".concat(customProperties.constraint5, " auto"),
|
|
853
|
+
children: [jsx(Grid.Item, {
|
|
854
|
+
children: jsx(StyledCardLeft, {
|
|
855
|
+
insetScale: "l",
|
|
856
|
+
children: jsx(CheckboxInput, {
|
|
857
|
+
isIndeterminate: !areAllFieldsChecked && isAtLeastOneFieldChecked,
|
|
858
|
+
isChecked: areAllFieldsChecked,
|
|
859
|
+
onChange: e => {
|
|
860
|
+
var _context3;
|
|
861
|
+
formik.setFieldValue('fields', _mapInstanceProperty(_context3 = _valuesInstanceProperty(formik).fields).call(_context3, field => _objectSpread$2(_objectSpread$2({}, field), {}, {
|
|
862
|
+
isChecked: field.isRequired ? true : e.target.checked
|
|
863
|
+
})));
|
|
864
|
+
},
|
|
865
|
+
children: jsx(Text.Body, {
|
|
866
|
+
intlMessage: messages.allGeneralFields
|
|
867
|
+
})
|
|
868
|
+
})
|
|
869
|
+
})
|
|
870
|
+
}), jsx(Grid.Item, {
|
|
871
|
+
children: jsx(StyledCardRight, {
|
|
872
|
+
insetScale: "l",
|
|
873
|
+
children: _mapInstanceProperty(_context4 = _valuesInstanceProperty(formik).fields).call(_context4, field => jsx(CheckboxInput, {
|
|
874
|
+
isReadOnly: field.isRequired,
|
|
875
|
+
isChecked: field.isChecked,
|
|
876
|
+
onChange: e => {
|
|
877
|
+
var _context5;
|
|
878
|
+
formik.setFieldValue('fields', _mapInstanceProperty(_context5 = _valuesInstanceProperty(formik).fields).call(_context5, _field => field.name === _field.name ? _objectSpread$2(_objectSpread$2({}, _field), {}, {
|
|
879
|
+
isChecked: e.target.checked
|
|
880
|
+
}) : _field));
|
|
881
|
+
},
|
|
882
|
+
children: jsxs(Text.Body, {
|
|
883
|
+
children: [field.label, " ", field.isRequired && '*']
|
|
884
|
+
})
|
|
885
|
+
}, field.name))
|
|
886
|
+
})
|
|
887
|
+
})]
|
|
888
|
+
})]
|
|
889
|
+
}), jsxs(Spacings.Inline, {
|
|
890
|
+
scale: "m",
|
|
891
|
+
justifyContent: "flex-end",
|
|
892
|
+
children: [jsx(SecondaryButton, {
|
|
893
|
+
label: intl.formatMessage(messages.back),
|
|
894
|
+
onClick: () => setCurrentStep(1)
|
|
895
|
+
}), jsx(PrimaryButton, {
|
|
896
|
+
label: intl.formatMessage(messages.startExport),
|
|
897
|
+
onClick: formik.submitForm,
|
|
898
|
+
isDisabled: !formik.isValid
|
|
899
|
+
})]
|
|
900
|
+
})]
|
|
901
|
+
});
|
|
902
|
+
};
|
|
903
|
+
|
|
904
|
+
process.env.NODE_ENV !== "production" ? {
|
|
905
|
+
renderProperties: PropTypes.func
|
|
906
|
+
} : {};
|
|
907
|
+
|
|
908
|
+
const ExportResourcesContext = /*#__PURE__*/createContext();
|
|
909
|
+
|
|
910
|
+
const ExportResourcesModalShape = PropTypes.shape({
|
|
911
|
+
isOpen: PropTypes.bool,
|
|
912
|
+
resourceType: PropTypes.string.isRequired,
|
|
913
|
+
outputFormat: PropTypes.string,
|
|
914
|
+
onClose: PropTypes.func,
|
|
915
|
+
onExportSuccess: PropTypes.func,
|
|
916
|
+
totalResourcesCount: PropTypes.number.isRequired,
|
|
917
|
+
selectedResourceIds: PropTypes.array,
|
|
918
|
+
// TODO: Circular reference
|
|
919
|
+
fields: PropTypes.arrayOf(PropTypes.shape({
|
|
920
|
+
name: PropTypes.string.isRequired,
|
|
921
|
+
label: PropTypes.string,
|
|
922
|
+
isLocalized: PropTypes.bool,
|
|
923
|
+
fields: PropTypes.arrayOf(PropTypes.shape({
|
|
924
|
+
name: PropTypes.string.isRequired,
|
|
925
|
+
label: PropTypes.string,
|
|
926
|
+
isLocalized: PropTypes.bool,
|
|
927
|
+
isSelectedByDefault: PropTypes.bool,
|
|
928
|
+
isRequired: PropTypes.bool
|
|
929
|
+
}))
|
|
930
|
+
})).isRequired,
|
|
931
|
+
exportType: PropTypes.string,
|
|
932
|
+
renderProperties: PropTypes.func
|
|
933
|
+
}).isRequired;
|
|
934
|
+
|
|
935
|
+
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; }
|
|
936
|
+
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; }
|
|
937
|
+
const ExportResourcesProvider = props => {
|
|
938
|
+
const _useStartExportOperat = useStartExportOperation(props),
|
|
939
|
+
startExportOperation = _useStartExportOperat.startExportOperation;
|
|
940
|
+
const initialValues = useInitialValues(props);
|
|
941
|
+
const _React$useState = React.useState(1),
|
|
942
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
943
|
+
currentStep = _React$useState2[0],
|
|
944
|
+
setCurrentStep = _React$useState2[1];
|
|
945
|
+
const onSubmit = async values => {
|
|
946
|
+
if (currentStep === 1) {
|
|
947
|
+
setCurrentStep(2);
|
|
948
|
+
} else {
|
|
949
|
+
startExportOperation(values);
|
|
950
|
+
}
|
|
951
|
+
};
|
|
952
|
+
const formik = useFormik({
|
|
953
|
+
initialValues,
|
|
954
|
+
validate: values => validate({
|
|
955
|
+
values,
|
|
956
|
+
step: currentStep
|
|
957
|
+
}),
|
|
958
|
+
onSubmit
|
|
959
|
+
});
|
|
960
|
+
React.useEffect(() => {
|
|
961
|
+
formik.validateForm();
|
|
962
|
+
}, [currentStep]);
|
|
963
|
+
return jsx(ExportResourcesContext.Provider, {
|
|
964
|
+
value: {
|
|
965
|
+
currentStep,
|
|
966
|
+
setCurrentStep,
|
|
967
|
+
formik,
|
|
968
|
+
resourceType: props.resourceType,
|
|
969
|
+
exportType: props.exportType,
|
|
970
|
+
totalResourcesCount: props.totalResourcesCount,
|
|
971
|
+
selectedResourceIds: props.selectedResourceIds
|
|
972
|
+
},
|
|
973
|
+
children: props.children
|
|
974
|
+
});
|
|
975
|
+
};
|
|
976
|
+
ExportResourcesProvider.displayName = 'ExportResourcesProvider';
|
|
977
|
+
ExportResourcesProvider.propTypes = process.env.NODE_ENV !== "production" ? _objectSpread$1(_objectSpread$1({}, ExportResourcesModalShape), {}, {
|
|
978
|
+
children: PropTypes.node
|
|
979
|
+
}) : {};
|
|
980
|
+
|
|
981
|
+
const CurrentStep = () => {
|
|
982
|
+
const _useExportResourcesCo = useExportResourcesContext(),
|
|
983
|
+
currentStep = _useExportResourcesCo.currentStep;
|
|
984
|
+
const steps = {
|
|
985
|
+
1: jsx(ExportFileSettingsStep, {}),
|
|
986
|
+
2: jsx(ExportFieldsSelectionStep, {})
|
|
987
|
+
};
|
|
988
|
+
return steps[currentStep] || null;
|
|
989
|
+
};
|
|
990
|
+
|
|
991
|
+
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; }
|
|
992
|
+
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; }
|
|
993
|
+
const ExportResourcesModal = props => {
|
|
994
|
+
const intl = useIntl();
|
|
995
|
+
const resourceTypePlural = resourceTypeToPlural({
|
|
996
|
+
resourceType: props.resourceType
|
|
997
|
+
});
|
|
998
|
+
return jsx(ExportResourcesProvider, _objectSpread(_objectSpread({}, props), {}, {
|
|
999
|
+
children: jsx(InfoDialog, {
|
|
1000
|
+
isOpen: props.isOpen,
|
|
1001
|
+
title: intl.formatMessage(messages.modalTitle, {
|
|
1002
|
+
resourceType: resourceTypePlural
|
|
1003
|
+
}),
|
|
1004
|
+
onClose: props.onClose,
|
|
1005
|
+
size: 16,
|
|
1006
|
+
children: jsx(CurrentStep, {})
|
|
1007
|
+
})
|
|
1008
|
+
}));
|
|
1009
|
+
};
|
|
1010
|
+
ExportResourcesModal.displayName = 'ExportResourcesModal';
|
|
1011
|
+
ExportResourcesModal.propTypes = process.env.NODE_ENV !== "production" ? ExportResourcesModalShape : {};
|
|
1012
|
+
ExportResourcesModal.defaultProps = {
|
|
1013
|
+
isOpen: false,
|
|
1014
|
+
selectedResourceIds: [],
|
|
1015
|
+
exportType: EXPORT_TYPES.ALL,
|
|
1016
|
+
outputFormat: OUTPUT_FORMATS.CSV
|
|
1017
|
+
};
|
|
1018
|
+
|
|
1019
|
+
export { EXPORTABLE_RESOURCES, EXPORT_TYPES, ExportResourcesModal as default };
|