@commercetools-frontend-extensions/export-resources-modal 3.7.0 → 4.0.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 +166 -138
- package/dist/commercetools-frontend-extensions-export-resources-modal.cjs.dev.js +425 -400
- package/dist/commercetools-frontend-extensions-export-resources-modal.cjs.prod.js +424 -396
- package/dist/commercetools-frontend-extensions-export-resources-modal.esm.js +417 -393
- 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/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/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/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/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 +30 -18
|
@@ -11,14 +11,13 @@ var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-
|
|
|
11
11
|
var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
|
|
12
12
|
var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
|
|
13
13
|
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
14
|
-
var
|
|
14
|
+
var reactIntl = require('react-intl');
|
|
15
|
+
var applicationShellConnectors = require('@commercetools-frontend/application-shell-connectors');
|
|
15
16
|
var uiKit = require('@commercetools-frontend/ui-kit');
|
|
16
17
|
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
17
18
|
require('@commercetools-uikit/design-system');
|
|
18
|
-
var reactIntl = require('react-intl');
|
|
19
19
|
var _valuesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/values');
|
|
20
20
|
var applicationComponents = require('@commercetools-frontend/application-components');
|
|
21
|
-
var applicationShellConnectors = require('@commercetools-frontend/application-shell-connectors');
|
|
22
21
|
var _Reflect$construct = require('@babel/runtime-corejs3/core-js-stable/reflect/construct');
|
|
23
22
|
var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
|
|
24
23
|
var _classCallCheck = require('@babel/runtime-corejs3/helpers/classCallCheck');
|
|
@@ -26,31 +25,37 @@ var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
|
|
|
26
25
|
var _possibleConstructorReturn = require('@babel/runtime-corejs3/helpers/possibleConstructorReturn');
|
|
27
26
|
var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
|
|
28
27
|
var _wrapNativeSuper = require('@babel/runtime-corejs3/helpers/wrapNativeSuper');
|
|
28
|
+
var React = require('react');
|
|
29
29
|
var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
|
|
30
30
|
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
31
31
|
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
32
32
|
var moment = require('moment');
|
|
33
|
+
var _someInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/some');
|
|
33
34
|
var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
|
|
34
35
|
var omitEmpty = require('omit-empty-es');
|
|
35
36
|
var _Array$isArray = require('@babel/runtime-corejs3/core-js-stable/array/is-array');
|
|
36
37
|
var _flatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/flat');
|
|
37
|
-
var _flatMapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/flat-map');
|
|
38
38
|
var _Set = require('@babel/runtime-corejs3/core-js-stable/set');
|
|
39
39
|
var _sortInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/sort');
|
|
40
|
-
|
|
41
|
-
var
|
|
40
|
+
require('@babel/runtime-corejs3/core-js-stable/instance/starts-with');
|
|
41
|
+
var _indexOfInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/index-of');
|
|
42
|
+
var shared = require('@commercetools-local/shared');
|
|
42
43
|
var sdk = require('@commercetools-frontend/sdk');
|
|
43
44
|
var actionsGlobal = require('@commercetools-frontend/actions-global');
|
|
44
45
|
var constants = require('@commercetools-frontend/constants');
|
|
45
46
|
var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
46
47
|
var _styled = require('@emotion/styled/base');
|
|
47
48
|
var _everyInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/every');
|
|
48
|
-
var
|
|
49
|
+
var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/includes');
|
|
49
50
|
var _trimInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/trim');
|
|
51
|
+
var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
|
|
50
52
|
var throttle = require('lodash/throttle');
|
|
51
53
|
var react = require('@emotion/react');
|
|
52
|
-
var
|
|
54
|
+
var get = require('lodash/get');
|
|
55
|
+
require('prop-types');
|
|
53
56
|
var formik = require('formik');
|
|
57
|
+
var sentry = require('@commercetools-frontend/sentry');
|
|
58
|
+
var i18n = require('@commercetools-frontend/i18n');
|
|
54
59
|
|
|
55
60
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
56
61
|
|
|
@@ -62,27 +67,27 @@ var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachIns
|
|
|
62
67
|
var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
|
|
63
68
|
var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
|
|
64
69
|
var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
|
|
65
|
-
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
66
70
|
var _valuesInstanceProperty__default = /*#__PURE__*/_interopDefault(_valuesInstanceProperty);
|
|
67
71
|
var _Reflect$construct__default = /*#__PURE__*/_interopDefault(_Reflect$construct);
|
|
72
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
68
73
|
var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
|
|
69
74
|
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
70
75
|
var moment__default = /*#__PURE__*/_interopDefault(moment);
|
|
76
|
+
var _someInstanceProperty__default = /*#__PURE__*/_interopDefault(_someInstanceProperty);
|
|
71
77
|
var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInstanceProperty);
|
|
72
78
|
var omitEmpty__default = /*#__PURE__*/_interopDefault(omitEmpty);
|
|
73
79
|
var _Array$isArray__default = /*#__PURE__*/_interopDefault(_Array$isArray);
|
|
74
80
|
var _flatInstanceProperty__default = /*#__PURE__*/_interopDefault(_flatInstanceProperty);
|
|
75
|
-
var _flatMapInstanceProperty__default = /*#__PURE__*/_interopDefault(_flatMapInstanceProperty);
|
|
76
81
|
var _Set__default = /*#__PURE__*/_interopDefault(_Set);
|
|
77
82
|
var _sortInstanceProperty__default = /*#__PURE__*/_interopDefault(_sortInstanceProperty);
|
|
78
|
-
var
|
|
79
|
-
var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
|
|
83
|
+
var _indexOfInstanceProperty__default = /*#__PURE__*/_interopDefault(_indexOfInstanceProperty);
|
|
80
84
|
var _styled__default = /*#__PURE__*/_interopDefault(_styled);
|
|
81
85
|
var _everyInstanceProperty__default = /*#__PURE__*/_interopDefault(_everyInstanceProperty);
|
|
82
|
-
var
|
|
86
|
+
var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
|
|
83
87
|
var _trimInstanceProperty__default = /*#__PURE__*/_interopDefault(_trimInstanceProperty);
|
|
88
|
+
var _findInstanceProperty__default = /*#__PURE__*/_interopDefault(_findInstanceProperty);
|
|
84
89
|
var throttle__default = /*#__PURE__*/_interopDefault(throttle);
|
|
85
|
-
var
|
|
90
|
+
var get__default = /*#__PURE__*/_interopDefault(get);
|
|
86
91
|
|
|
87
92
|
function getBold(msg) {
|
|
88
93
|
return jsxRuntime.jsx(uiKit.Text.Body, {
|
|
@@ -216,21 +221,6 @@ var messages = reactIntl.defineMessages({
|
|
|
216
221
|
description: 'Label for "Field definitions" link',
|
|
217
222
|
defaultMessage: 'Field definitions'
|
|
218
223
|
},
|
|
219
|
-
allGeneralFields: {
|
|
220
|
-
id: 'ExportResourcesModal.allGeneralFields',
|
|
221
|
-
description: 'Label for "All general fields" checkbox',
|
|
222
|
-
defaultMessage: 'All general fields'
|
|
223
|
-
},
|
|
224
|
-
allCustomFields: {
|
|
225
|
-
id: 'ExportResourcesModal.allCustomFields',
|
|
226
|
-
description: 'Label for "All custom fields" checkbox',
|
|
227
|
-
defaultMessage: 'All custom fields'
|
|
228
|
-
},
|
|
229
|
-
customTypeKeyAndTypeId: {
|
|
230
|
-
id: 'ExportResourcesModal.customTypeKeyAndTypeId',
|
|
231
|
-
description: 'Label for "Custom type key and typeId" checkbox',
|
|
232
|
-
defaultMessage: 'Custom type key and typeId'
|
|
233
|
-
},
|
|
234
224
|
unexpectedError: {
|
|
235
225
|
id: 'ExportResourcesModal.unexpectedError',
|
|
236
226
|
description: 'Generic notification message when starting export process fails',
|
|
@@ -263,14 +253,14 @@ var messages = reactIntl.defineMessages({
|
|
|
263
253
|
}
|
|
264
254
|
});
|
|
265
255
|
|
|
266
|
-
function ownKeys$
|
|
267
|
-
function _objectSpread$
|
|
256
|
+
function ownKeys$6(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
257
|
+
function _objectSpread$6(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$6(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$6(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
268
258
|
function renderFileNameError(key) {
|
|
269
259
|
switch (key) {
|
|
270
260
|
case 'missing':
|
|
271
|
-
return jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$
|
|
261
|
+
return jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$6({}, messages.missingFileNameError));
|
|
272
262
|
case 'invalidInput':
|
|
273
|
-
return jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$
|
|
263
|
+
return jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$6({}, messages.invalidFileNameError));
|
|
274
264
|
default:
|
|
275
265
|
return null;
|
|
276
266
|
}
|
|
@@ -278,7 +268,7 @@ function renderFileNameError(key) {
|
|
|
278
268
|
function renderLocaleError(key) {
|
|
279
269
|
switch (key) {
|
|
280
270
|
case 'missing':
|
|
281
|
-
return jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$
|
|
271
|
+
return jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$6({}, messages.missingLocaleError));
|
|
282
272
|
default:
|
|
283
273
|
return null;
|
|
284
274
|
}
|
|
@@ -320,11 +310,11 @@ const FIELD_DEFINITIONS_URLS = {
|
|
|
320
310
|
category: 'https://docs.commercetools.com/merchant-center/import-categories#supported-headers-and-values'
|
|
321
311
|
};
|
|
322
312
|
|
|
323
|
-
function _createSuper$
|
|
324
|
-
function _isNativeReflectConstruct$
|
|
313
|
+
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__default["default"](Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
314
|
+
function _isNativeReflectConstruct$2() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$2 = function () { return !!t; })(); }
|
|
325
315
|
let UnexpectedExportTypeError = /*#__PURE__*/function (_Error) {
|
|
326
316
|
_inherits(UnexpectedExportTypeError, _Error);
|
|
327
|
-
var _super = _createSuper$
|
|
317
|
+
var _super = _createSuper$2(UnexpectedExportTypeError);
|
|
328
318
|
function UnexpectedExportTypeError(exportType) {
|
|
329
319
|
var _this;
|
|
330
320
|
_classCallCheck(this, UnexpectedExportTypeError);
|
|
@@ -335,11 +325,11 @@ let UnexpectedExportTypeError = /*#__PURE__*/function (_Error) {
|
|
|
335
325
|
return _createClass(UnexpectedExportTypeError);
|
|
336
326
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
337
327
|
|
|
338
|
-
function _createSuper$
|
|
339
|
-
function _isNativeReflectConstruct$
|
|
328
|
+
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__default["default"](Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
329
|
+
function _isNativeReflectConstruct$1() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$1 = function () { return !!t; })(); }
|
|
340
330
|
let MissingExportResourceProviderError = /*#__PURE__*/function (_Error) {
|
|
341
331
|
_inherits(MissingExportResourceProviderError, _Error);
|
|
342
|
-
var _super = _createSuper$
|
|
332
|
+
var _super = _createSuper$1(MissingExportResourceProviderError);
|
|
343
333
|
function MissingExportResourceProviderError() {
|
|
344
334
|
var _this;
|
|
345
335
|
_classCallCheck(this, MissingExportResourceProviderError);
|
|
@@ -350,11 +340,11 @@ let MissingExportResourceProviderError = /*#__PURE__*/function (_Error) {
|
|
|
350
340
|
return _createClass(MissingExportResourceProviderError);
|
|
351
341
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
352
342
|
|
|
353
|
-
function _createSuper
|
|
354
|
-
function _isNativeReflectConstruct
|
|
343
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct__default["default"](Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
344
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); }
|
|
355
345
|
let UnexpectedExportOperationStateError = /*#__PURE__*/function (_Error) {
|
|
356
346
|
_inherits(UnexpectedExportOperationStateError, _Error);
|
|
357
|
-
var _super = _createSuper
|
|
347
|
+
var _super = _createSuper(UnexpectedExportOperationStateError);
|
|
358
348
|
function UnexpectedExportOperationStateError(state) {
|
|
359
349
|
var _this;
|
|
360
350
|
_classCallCheck(this, UnexpectedExportOperationStateError);
|
|
@@ -365,36 +355,6 @@ let UnexpectedExportOperationStateError = /*#__PURE__*/function (_Error) {
|
|
|
365
355
|
return _createClass(UnexpectedExportOperationStateError);
|
|
366
356
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
367
357
|
|
|
368
|
-
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__default["default"](Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
369
|
-
function _isNativeReflectConstruct$1() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$1 = function () { return !!t; })(); }
|
|
370
|
-
let UnexpectedResourceTypeError = /*#__PURE__*/function (_Error) {
|
|
371
|
-
_inherits(UnexpectedResourceTypeError, _Error);
|
|
372
|
-
var _super = _createSuper$1(UnexpectedResourceTypeError);
|
|
373
|
-
function UnexpectedResourceTypeError(resourceType) {
|
|
374
|
-
var _this;
|
|
375
|
-
_classCallCheck(this, UnexpectedResourceTypeError);
|
|
376
|
-
_this = _super.call(this, "Unexpected resource type: ".concat(resourceType));
|
|
377
|
-
_this.name = 'UnexpectedResourceTypeError';
|
|
378
|
-
return _this;
|
|
379
|
-
}
|
|
380
|
-
return _createClass(UnexpectedResourceTypeError);
|
|
381
|
-
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
382
|
-
|
|
383
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct__default["default"](Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
384
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); }
|
|
385
|
-
let InvalidResponseError = /*#__PURE__*/function (_Error) {
|
|
386
|
-
_inherits(InvalidResponseError, _Error);
|
|
387
|
-
var _super = _createSuper(InvalidResponseError);
|
|
388
|
-
function InvalidResponseError(message) {
|
|
389
|
-
var _this;
|
|
390
|
-
_classCallCheck(this, InvalidResponseError);
|
|
391
|
-
_this = _super.call(this, message);
|
|
392
|
-
_this.name = 'InvalidResponseError';
|
|
393
|
-
return _this;
|
|
394
|
-
}
|
|
395
|
-
return _createClass(InvalidResponseError);
|
|
396
|
-
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
397
|
-
|
|
398
358
|
function useExportResourcesContext() {
|
|
399
359
|
const context = React.useContext(ExportResourcesContext);
|
|
400
360
|
if (!context) {
|
|
@@ -403,41 +363,52 @@ function useExportResourcesContext() {
|
|
|
403
363
|
return context;
|
|
404
364
|
}
|
|
405
365
|
|
|
366
|
+
function checkAtLeastOneFieldChecked$1(fields) {
|
|
367
|
+
return _someInstanceProperty__default["default"](fields).call(fields, field => {
|
|
368
|
+
if (field.fields) {
|
|
369
|
+
return field.isChecked || checkAtLeastOneFieldChecked$1(field.fields);
|
|
370
|
+
}
|
|
371
|
+
return field.isChecked;
|
|
372
|
+
});
|
|
373
|
+
}
|
|
406
374
|
function validate(_ref) {
|
|
407
375
|
let values = _valuesInstanceProperty__default["default"](_ref),
|
|
408
376
|
step = _ref.step;
|
|
409
377
|
const fileName = values.fileName,
|
|
410
378
|
locales = values.locales,
|
|
411
|
-
|
|
412
|
-
customFields = values.customFields;
|
|
379
|
+
groups = values.groups;
|
|
413
380
|
const errors = {
|
|
414
381
|
fileName: {},
|
|
415
382
|
locales: {},
|
|
416
383
|
fields: {}
|
|
417
384
|
};
|
|
418
385
|
if (uiKit.TextInput.isEmpty(fileName)) {
|
|
386
|
+
// @ts-ignore
|
|
419
387
|
errors.fileName.missing = true;
|
|
420
388
|
} else if (!/^[a-zA-Z0-9-_.]+$/.test(fileName)) {
|
|
389
|
+
// @ts-ignore
|
|
421
390
|
errors.fileName.invalidInput = true;
|
|
422
391
|
}
|
|
423
392
|
if (locales.length < 1) {
|
|
393
|
+
// @ts-ignore
|
|
424
394
|
errors.locales.missing = true;
|
|
425
395
|
}
|
|
426
396
|
if (step === 2) {
|
|
427
|
-
const
|
|
428
|
-
const
|
|
429
|
-
|
|
430
|
-
return
|
|
431
|
-
}
|
|
432
|
-
if (
|
|
397
|
+
const allFields = _reduceInstanceProperty__default["default"](groups).call(groups, (acc, group) => _concatInstanceProperty__default["default"](acc).call(acc, group.fields), []);
|
|
398
|
+
const checkedFieldsCount = _filterInstanceProperty__default["default"](allFields).call(allFields, field => {
|
|
399
|
+
if (field.fields) return checkAtLeastOneFieldChecked$1(field.fields);
|
|
400
|
+
return !field.isRequired && !field.isReadOnly && field.isChecked;
|
|
401
|
+
}).length;
|
|
402
|
+
if (checkedFieldsCount < 1) {
|
|
403
|
+
// @ts-ignore
|
|
433
404
|
errors.fields.missing = true;
|
|
434
405
|
}
|
|
435
406
|
}
|
|
436
407
|
return omitEmpty__default["default"](errors);
|
|
437
408
|
}
|
|
438
409
|
|
|
439
|
-
function ownKeys$
|
|
440
|
-
function _objectSpread$
|
|
410
|
+
function ownKeys$5(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
411
|
+
function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var _context5, _context6; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context5 = ownKeys$5(Object(t), !0)).call(_context5, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context6 = ownKeys$5(Object(t))).call(_context6, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
441
412
|
function resourceTypeToDisplayName(_ref) {
|
|
442
413
|
let resourceType = _ref.resourceType,
|
|
443
414
|
_ref$isUpperCase = _ref.isUpperCase,
|
|
@@ -456,7 +427,7 @@ function resourceTypeToDisplayName(_ref) {
|
|
|
456
427
|
displayName = isPlural ? 'Discount codes' : 'Discount code';
|
|
457
428
|
break;
|
|
458
429
|
default:
|
|
459
|
-
throw UnexpectedResourceTypeError(resourceType);
|
|
430
|
+
throw shared.UnexpectedResourceTypeError(resourceType);
|
|
460
431
|
}
|
|
461
432
|
return isUpperCase ? displayName : displayName.toLowerCase();
|
|
462
433
|
}
|
|
@@ -481,7 +452,7 @@ function flattenNestedFields(fields) {
|
|
|
481
452
|
var _context2;
|
|
482
453
|
return _mapInstanceProperty__default["default"](_context2 = flattenNestedFields(field.fields)).call(_context2, nestedField => {
|
|
483
454
|
var _context3;
|
|
484
|
-
return _objectSpread$
|
|
455
|
+
return _objectSpread$5(_objectSpread$5({}, nestedField), {}, {
|
|
485
456
|
name: _concatInstanceProperty__default["default"](_context3 = "".concat(field.name, ".")).call(_context3, nestedField.name)
|
|
486
457
|
});
|
|
487
458
|
});
|
|
@@ -490,19 +461,8 @@ function flattenNestedFields(fields) {
|
|
|
490
461
|
})) || [];
|
|
491
462
|
return _flatInstanceProperty__default["default"](result).call(result);
|
|
492
463
|
}
|
|
493
|
-
function getSelectedGeneralFields(fields) {
|
|
494
|
-
return _filterInstanceProperty__default["default"](fields).call(fields, field => field.isChecked);
|
|
495
|
-
}
|
|
496
|
-
function getSelectedCustomFields(customFields) {
|
|
497
|
-
return _mapInstanceProperty__default["default"](customFields).call(customFields, customType => {
|
|
498
|
-
var _context4;
|
|
499
|
-
return _objectSpread$4(_objectSpread$4({}, customType), {}, {
|
|
500
|
-
fields: _filterInstanceProperty__default["default"](_context4 = customType.fields).call(_context4, field => field.isChecked)
|
|
501
|
-
});
|
|
502
|
-
});
|
|
503
|
-
}
|
|
504
464
|
function checkRequiredFields(fields) {
|
|
505
|
-
return _mapInstanceProperty__default["default"](fields).call(fields, field => field.isRequired ? _objectSpread$
|
|
465
|
+
return _mapInstanceProperty__default["default"](fields).call(fields, field => field.isRequired ? _objectSpread$5(_objectSpread$5({}, field), {}, {
|
|
506
466
|
isChecked: true
|
|
507
467
|
}) : field);
|
|
508
468
|
}
|
|
@@ -514,45 +474,38 @@ function getExportLogsLink(projectKey, msg) {
|
|
|
514
474
|
}
|
|
515
475
|
function setInitialCheckedStateForCustomFields(customFields) {
|
|
516
476
|
return _mapInstanceProperty__default["default"](customFields).call(customFields, customType => {
|
|
517
|
-
var
|
|
518
|
-
return _objectSpread$
|
|
519
|
-
fields: _mapInstanceProperty__default["default"](
|
|
477
|
+
var _context4;
|
|
478
|
+
return _objectSpread$5(_objectSpread$5({}, customType), {}, {
|
|
479
|
+
fields: _mapInstanceProperty__default["default"](_context4 = customType.fields).call(_context4, field => _objectSpread$5(_objectSpread$5({}, field), {}, {
|
|
520
480
|
isChecked: false
|
|
521
481
|
}))
|
|
522
482
|
});
|
|
523
483
|
});
|
|
524
484
|
}
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
const fields = _flatMapInstanceProperty__default["default"](customFields).call(customFields, customType => {
|
|
530
|
-
var _context6;
|
|
531
|
-
return _flatMapInstanceProperty__default["default"](_context6 = customType.fields).call(_context6, field => {
|
|
532
|
-
return getCustomFieldNameWithPrefix(field, customType.type.resourceTypeIds);
|
|
533
|
-
});
|
|
534
|
-
});
|
|
535
|
-
return [...new _Set__default["default"](fields)];
|
|
536
|
-
}
|
|
537
|
-
function getCustomFieldNameWithPrefix(field, resourceTypeIds) {
|
|
538
|
-
const prefixes = _mapInstanceProperty__default["default"](resourceTypeIds).call(resourceTypeIds, type => {
|
|
539
|
-
switch (type) {
|
|
540
|
-
case 'asset':
|
|
541
|
-
return 'assets.custom.fields.';
|
|
542
|
-
default:
|
|
543
|
-
return 'custom.fields.';
|
|
485
|
+
const extractFieldNamesAndAdditionalFieldExtensions = fields => {
|
|
486
|
+
const result = _reduceInstanceProperty__default["default"](fields).call(fields, (acc, field) => {
|
|
487
|
+
if (field.additionalFieldExtensions) {
|
|
488
|
+
return [...acc, ...field.additionalFieldExtensions, field.name];
|
|
544
489
|
}
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
490
|
+
return [...acc, field.name];
|
|
491
|
+
}, []);
|
|
492
|
+
return [...new _Set__default["default"](result)];
|
|
493
|
+
};
|
|
494
|
+
function sortFieldsByFieldOrder(_ref2) {
|
|
495
|
+
let fields = _ref2.fields,
|
|
496
|
+
fieldOrder = _ref2.fieldOrder;
|
|
497
|
+
if (isFilledArray(fieldOrder)) {
|
|
498
|
+
return _sortInstanceProperty__default["default"](fields).call(fields, (a, b) => {
|
|
499
|
+
let orderA = _indexOfInstanceProperty__default["default"](fieldOrder).call(fieldOrder, a) !== -1 ? _indexOfInstanceProperty__default["default"](fieldOrder).call(fieldOrder, a) : _indexOfInstanceProperty__default["default"](fieldOrder).call(fieldOrder, a.split('.')[0]);
|
|
500
|
+
let orderB = _indexOfInstanceProperty__default["default"](fieldOrder).call(fieldOrder, b) !== -1 ? _indexOfInstanceProperty__default["default"](fieldOrder).call(fieldOrder, b) : _indexOfInstanceProperty__default["default"](fieldOrder).call(fieldOrder, b.split('.')[0]);
|
|
551
501
|
|
|
552
|
-
//
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
502
|
+
// If a field is not 'custom',then consider it as '*'
|
|
503
|
+
orderA = orderA === -1 ? _indexOfInstanceProperty__default["default"](fieldOrder).call(fieldOrder, '*') : orderA;
|
|
504
|
+
orderB = orderB === -1 ? _indexOfInstanceProperty__default["default"](fieldOrder).call(fieldOrder, '*') : orderB;
|
|
505
|
+
return orderA - orderB;
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
return fields;
|
|
556
509
|
}
|
|
557
510
|
|
|
558
511
|
// TODO: remove this function when filters are passed directly from parent views
|
|
@@ -565,38 +518,47 @@ function tmpBuildFilters(selectedResourceIds) {
|
|
|
565
518
|
return ["id in (".concat(formattedIds, ")")];
|
|
566
519
|
}
|
|
567
520
|
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
const
|
|
571
|
-
const
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
default: defaultFieldExtension,
|
|
592
|
-
category: categoryFieldExtension
|
|
521
|
+
function ownKeys$4(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
522
|
+
function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$4(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$4(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
523
|
+
const updateFieldGroupsWithIsCheckedValue = groups => {
|
|
524
|
+
const updateFields = (fields, parentChecked) => {
|
|
525
|
+
return _mapInstanceProperty__default["default"](fields).call(fields, field => {
|
|
526
|
+
var _field$isRequired;
|
|
527
|
+
let isChecked = ((_field$isRequired = field.isRequired) !== null && _field$isRequired !== void 0 ? _field$isRequired : !field.isReadOnly && field.isSelectedByDefault) || parentChecked;
|
|
528
|
+
if (field.fields) {
|
|
529
|
+
const updatedFields = updateFields(field.fields, isChecked);
|
|
530
|
+
isChecked = false;
|
|
531
|
+
field.fields = updatedFields;
|
|
532
|
+
}
|
|
533
|
+
return _objectSpread$4(_objectSpread$4({}, field), {}, {
|
|
534
|
+
isChecked
|
|
535
|
+
});
|
|
536
|
+
});
|
|
537
|
+
};
|
|
538
|
+
return _mapInstanceProperty__default["default"](groups).call(groups, group => {
|
|
539
|
+
const updatedFields = updateFields(group.fields, false);
|
|
540
|
+
return _objectSpread$4(_objectSpread$4({}, group), {}, {
|
|
541
|
+
fields: updatedFields
|
|
542
|
+
});
|
|
543
|
+
});
|
|
593
544
|
};
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
545
|
+
const updateFieldGroupWithAdditionalFieldExtensions = groups => {
|
|
546
|
+
function updateAdditionalFieldExtensions(fields, additionalFieldExtensions) {
|
|
547
|
+
return _mapInstanceProperty__default["default"](fields).call(fields, field => {
|
|
548
|
+
const updatedAdditionalFieldExtensions = [...additionalFieldExtensions, ...(field.additionalFieldExtensions || [])];
|
|
549
|
+
if (field.fields) {
|
|
550
|
+
field.fields = updateAdditionalFieldExtensions(field.fields, updatedAdditionalFieldExtensions);
|
|
551
|
+
}
|
|
552
|
+
return _objectSpread$4(_objectSpread$4({}, field), {}, {
|
|
553
|
+
additionalFieldExtensions: updatedAdditionalFieldExtensions
|
|
554
|
+
});
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
return _mapInstanceProperty__default["default"](groups).call(groups, group => {
|
|
558
|
+
return _objectSpread$4(_objectSpread$4({}, group), {}, {
|
|
559
|
+
fields: updateAdditionalFieldExtensions(group.fields, group.additionalFieldExtensions || [])
|
|
560
|
+
});
|
|
561
|
+
});
|
|
600
562
|
};
|
|
601
563
|
|
|
602
564
|
const _excluded = ["isSelectedByDefault"];
|
|
@@ -616,6 +578,7 @@ const useInitialValues = props => {
|
|
|
616
578
|
isChecked: isSelectedByDefault !== null && isSelectedByDefault !== void 0 ? isSelectedByDefault : true
|
|
617
579
|
});
|
|
618
580
|
});
|
|
581
|
+
const groups = updateFieldGroupsWithIsCheckedValue(props.fieldGroups);
|
|
619
582
|
return React__default["default"].useMemo(() => {
|
|
620
583
|
var _context2;
|
|
621
584
|
return {
|
|
@@ -627,9 +590,10 @@ const useInitialValues = props => {
|
|
|
627
590
|
}), "_Export_")).call(_context2, todayFormatted),
|
|
628
591
|
locales: [locale],
|
|
629
592
|
fields: checkRequiredFields(fields),
|
|
630
|
-
customFields: setInitialCheckedStateForCustomFields(props.customFields)
|
|
593
|
+
customFields: setInitialCheckedStateForCustomFields(props.customFields),
|
|
594
|
+
groups: updateFieldGroupWithAdditionalFieldExtensions(groups)
|
|
631
595
|
};
|
|
632
|
-
}, [props, locale, todayFormatted, fields]);
|
|
596
|
+
}, [props, locale, todayFormatted, fields, groups]);
|
|
633
597
|
};
|
|
634
598
|
|
|
635
599
|
async function createExportOperation(_ref) {
|
|
@@ -658,7 +622,7 @@ async function createExportOperation(_ref) {
|
|
|
658
622
|
filters
|
|
659
623
|
}
|
|
660
624
|
}));
|
|
661
|
-
if (!response.state) throw new InvalidResponseError('Invalid response');
|
|
625
|
+
if (!response.state) throw new shared.InvalidResponseError('Invalid response');
|
|
662
626
|
return response;
|
|
663
627
|
}
|
|
664
628
|
|
|
@@ -674,12 +638,29 @@ const useStartExportOperation = props => {
|
|
|
674
638
|
};
|
|
675
639
|
}),
|
|
676
640
|
projectKey = _useApplicationContex.projectKey;
|
|
641
|
+
const extractFieldsFromGroups = groups => {
|
|
642
|
+
let selectedGeneralFields = [];
|
|
643
|
+
const getSelectedFields = fields => {
|
|
644
|
+
return _filterInstanceProperty__default["default"](fields).call(fields, field => {
|
|
645
|
+
var _field$isChecked;
|
|
646
|
+
if (field.fields) {
|
|
647
|
+
return getSelectedFields(field.fields);
|
|
648
|
+
}
|
|
649
|
+
if (field.isChecked) selectedGeneralFields.push(field);
|
|
650
|
+
return (_field$isChecked = field.isChecked) !== null && _field$isChecked !== void 0 ? _field$isChecked : false;
|
|
651
|
+
});
|
|
652
|
+
};
|
|
653
|
+
_forEachInstanceProperty__default["default"](groups).call(groups, group => {
|
|
654
|
+
getSelectedFields(group.fields);
|
|
655
|
+
});
|
|
656
|
+
return sortFieldsByFieldOrder({
|
|
657
|
+
fields: extractFieldNamesAndAdditionalFieldExtensions(selectedGeneralFields),
|
|
658
|
+
fieldOrder: props.fieldOrder
|
|
659
|
+
});
|
|
660
|
+
};
|
|
677
661
|
const startExportOperation = async values => {
|
|
678
662
|
try {
|
|
679
|
-
const
|
|
680
|
-
const selectedCustomFields = getSelectedCustomFields(values.customFields);
|
|
681
|
-
const generalFields = extractGeneralFieldNames(selectedGeneralFields);
|
|
682
|
-
const customFields = sortCustomFields(extractCustomFieldNamesWithPrefix(selectedCustomFields));
|
|
663
|
+
const fields = extractFieldsFromGroups(values.groups);
|
|
683
664
|
const filters = tmpBuildFilters(props.selectedResourceIds);
|
|
684
665
|
const response = await createExportOperation({
|
|
685
666
|
projectKey,
|
|
@@ -687,10 +668,7 @@ const useStartExportOperation = props => {
|
|
|
687
668
|
fileName: appendCsvOrJsonExtensionIfAbsent(values.fileName, values.outputFormat),
|
|
688
669
|
fileFormat: values.outputFormat,
|
|
689
670
|
locales: values.locales,
|
|
690
|
-
fields
|
|
691
|
-
resourceType: props.resourceType,
|
|
692
|
-
fields: [...generalFields, ...customFields]
|
|
693
|
-
}),
|
|
671
|
+
fields,
|
|
694
672
|
filters,
|
|
695
673
|
asyncDispatchFn: asyncDispatch
|
|
696
674
|
});
|
|
@@ -700,6 +678,7 @@ const useStartExportOperation = props => {
|
|
|
700
678
|
showNotification({
|
|
701
679
|
kind: 'info',
|
|
702
680
|
domain: constants.DOMAINS.SIDE,
|
|
681
|
+
// @ts-ignore
|
|
703
682
|
text: intl.formatMessage(messages.exportOperationSuccessMessage, {
|
|
704
683
|
newline: getNewLine,
|
|
705
684
|
logsLink: msg => getExportLogsLink(projectKey, msg),
|
|
@@ -888,13 +867,154 @@ const NoSearchResults = () => {
|
|
|
888
867
|
};
|
|
889
868
|
|
|
890
869
|
function ownKeys$1(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
891
|
-
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
870
|
+
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var _context7, _context8; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context7 = ownKeys$1(Object(t), !0)).call(_context7, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context8 = ownKeys$1(Object(t))).call(_context8, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
892
871
|
const StyledGroupCard = /*#__PURE__*/_styled__default["default"](uiKit.Card, {
|
|
893
|
-
target: "
|
|
872
|
+
target: "e3xiyhb1"
|
|
894
873
|
} )("border-right:", uiKit.designTokens.borderWidth1, " solid ", uiKit.designTokens.colorNeutral90, ";background-color:", uiKit.designTokens.colorNeutral98, ";height:100%;border-radius:0;", props => props.showTopBorder && /*#__PURE__*/react.css("border-top:", uiKit.designTokens.borderWidth1, " solid ", uiKit.designTokens.colorNeutral90, ";" + ("" ), "" ), ";" + ("" ));
|
|
895
874
|
const StyledFieldsCard = /*#__PURE__*/_styled__default["default"](uiKit.Card, {
|
|
896
|
-
target: "
|
|
875
|
+
target: "e3xiyhb0"
|
|
897
876
|
} )("border-radius:0;", props => props.showTopBorder && /*#__PURE__*/react.css("border-top:", uiKit.designTokens.borderWidth1, " solid ", uiKit.designTokens.colorNeutral90, ";" + ("" ), "" ), ";" + ("" ));
|
|
877
|
+
const FieldSections = _ref => {
|
|
878
|
+
let fields = _ref.fields,
|
|
879
|
+
parentKeys = _ref.parentKeys,
|
|
880
|
+
formik = _ref.formik,
|
|
881
|
+
isAnySiblingChecked = _ref.isAnySiblingChecked;
|
|
882
|
+
return jsxRuntime.jsx(uiKit.Spacings.Stack, {
|
|
883
|
+
scale: "s",
|
|
884
|
+
children: fields === null || fields === void 0 ? void 0 : _mapInstanceProperty__default["default"](fields).call(fields, (field, index) => {
|
|
885
|
+
var _context, _field$fields3;
|
|
886
|
+
const isAtleastOneChildChecked = () => {
|
|
887
|
+
function checkAtLeastOneFieldChecked(fields) {
|
|
888
|
+
return fields === null || fields === void 0 ? void 0 : _someInstanceProperty__default["default"](fields).call(fields, field => {
|
|
889
|
+
if (field.fields) {
|
|
890
|
+
return field.isChecked || checkAtLeastOneFieldChecked(field.fields);
|
|
891
|
+
}
|
|
892
|
+
return field.isChecked;
|
|
893
|
+
});
|
|
894
|
+
}
|
|
895
|
+
return checkAtLeastOneFieldChecked(field.fields);
|
|
896
|
+
};
|
|
897
|
+
const isAnyOfTheChildFieldsChecked = isAtleastOneChildChecked();
|
|
898
|
+
if (field.isHidden) return null;
|
|
899
|
+
return jsxRuntime.jsxs(React__default["default"].Fragment, {
|
|
900
|
+
children: [jsxRuntime.jsxs(uiKit.CheckboxInput, {
|
|
901
|
+
isChecked: field.isReadOnly ? isAnySiblingChecked : isAnyOfTheChildFieldsChecked || field.isChecked,
|
|
902
|
+
isReadOnly: field.isReadOnly || field.isRequired,
|
|
903
|
+
onChange: e => {
|
|
904
|
+
var _context2, _field$fields2;
|
|
905
|
+
const path = _concatInstanceProperty__default["default"](_context2 = "".concat(parentKeys.join('.'), ".fields[")).call(_context2, index, "]");
|
|
906
|
+
// Update all child fields
|
|
907
|
+
const updateAllChildFieldsChecked = (path, checked) => {
|
|
908
|
+
const item = get__default["default"](_valuesInstanceProperty__default["default"](formik), path);
|
|
909
|
+
if (item && item.fields) {
|
|
910
|
+
var _context3;
|
|
911
|
+
_forEachInstanceProperty__default["default"](_context3 = item.fields).call(_context3, (field, i) => {
|
|
912
|
+
var _context4, _field$fields;
|
|
913
|
+
const fieldPath = _concatInstanceProperty__default["default"](_context4 = "".concat(path, ".fields[")).call(_context4, i, "]");
|
|
914
|
+
if (!((_field$fields = field.fields) !== null && _field$fields !== void 0 && _field$fields.length)) {
|
|
915
|
+
formik.setFieldValue("".concat(fieldPath, ".isChecked"), checked,
|
|
916
|
+
// pass `false` to avoid revalidating the form with intermediate values
|
|
917
|
+
false);
|
|
918
|
+
}
|
|
919
|
+
updateAllChildFieldsChecked(fieldPath, checked);
|
|
920
|
+
});
|
|
921
|
+
}
|
|
922
|
+
};
|
|
923
|
+
if (!((_field$fields2 = field.fields) !== null && _field$fields2 !== void 0 && _field$fields2.length)) {
|
|
924
|
+
formik.setFieldValue("".concat(path, ".isChecked"), e.target.checked,
|
|
925
|
+
// pass `false` to avoid revalidating the form with intermediate values
|
|
926
|
+
false);
|
|
927
|
+
}
|
|
928
|
+
updateAllChildFieldsChecked(path, e.target.checked);
|
|
929
|
+
},
|
|
930
|
+
children: [field.label, " ", field.isRequired && '*']
|
|
931
|
+
}), field.fields && ((_field$fields3 = field.fields) === null || _field$fields3 === void 0 ? void 0 : _field$fields3.length) > 0 && jsxRuntime.jsxs(uiKit.Spacings.Inline, {
|
|
932
|
+
scale: "l",
|
|
933
|
+
children: [jsxRuntime.jsx("div", {}), jsxRuntime.jsx(FieldSections, {
|
|
934
|
+
fields: field.fields,
|
|
935
|
+
formik: formik,
|
|
936
|
+
parentKeys: [...parentKeys, "fields[".concat(index, "]")],
|
|
937
|
+
isAnySiblingChecked: isAnySiblingChecked
|
|
938
|
+
})]
|
|
939
|
+
})]
|
|
940
|
+
}, _concatInstanceProperty__default["default"](_context = "".concat(field.name, "-")).call(_context, index));
|
|
941
|
+
})
|
|
942
|
+
});
|
|
943
|
+
};
|
|
944
|
+
function checkAllFieldsSelected(fields) {
|
|
945
|
+
return _everyInstanceProperty__default["default"](fields).call(fields, field => {
|
|
946
|
+
if (field.fields) {
|
|
947
|
+
return checkAllFieldsSelected(field.fields);
|
|
948
|
+
}
|
|
949
|
+
return field.isChecked || field.isRequired || field.isReadOnly;
|
|
950
|
+
});
|
|
951
|
+
}
|
|
952
|
+
function checkAtLeastOneFieldChecked(fields) {
|
|
953
|
+
return _someInstanceProperty__default["default"](fields).call(fields, field => {
|
|
954
|
+
if (field.fields) {
|
|
955
|
+
return field.isChecked || checkAtLeastOneFieldChecked(field.fields);
|
|
956
|
+
}
|
|
957
|
+
return field.isChecked;
|
|
958
|
+
});
|
|
959
|
+
}
|
|
960
|
+
const FieldGroupSection = _ref2 => {
|
|
961
|
+
let group = _ref2.group,
|
|
962
|
+
index = _ref2.index,
|
|
963
|
+
formik = _ref2.formik;
|
|
964
|
+
const allAllFieldsSelected = React__default["default"].useMemo(() => checkAllFieldsSelected(group.fields), [group.fields]);
|
|
965
|
+
const isAtleastOneFieldChecked = React__default["default"].useMemo(() => checkAtLeastOneFieldChecked(group.fields), [group.fields]);
|
|
966
|
+
const parentKey = "groups[".concat(index, "]");
|
|
967
|
+
const handleChangeAllFields = e => {
|
|
968
|
+
const item = get__default["default"](_valuesInstanceProperty__default["default"](formik), parentKey);
|
|
969
|
+
function updateAllFields(fields, checked) {
|
|
970
|
+
return _mapInstanceProperty__default["default"](fields).call(fields, field => {
|
|
971
|
+
if (field.fields) {
|
|
972
|
+
return _objectSpread$1(_objectSpread$1({}, field), {}, {
|
|
973
|
+
fields: updateAllFields(field.fields, checked)
|
|
974
|
+
});
|
|
975
|
+
}
|
|
976
|
+
if (field.isReadOnly || field.isRequired) return field;
|
|
977
|
+
return _objectSpread$1(_objectSpread$1({}, field), {}, {
|
|
978
|
+
isChecked: checked
|
|
979
|
+
});
|
|
980
|
+
});
|
|
981
|
+
}
|
|
982
|
+
formik.setFieldValue(parentKey, _objectSpread$1(_objectSpread$1({}, item), {}, {
|
|
983
|
+
fields: updateAllFields(item.fields, e.target.checked)
|
|
984
|
+
}));
|
|
985
|
+
};
|
|
986
|
+
if (group.isHidden) return null;
|
|
987
|
+
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
988
|
+
children: [jsxRuntime.jsx(uiKit.Grid.Item, {
|
|
989
|
+
children: jsxRuntime.jsx(StyledGroupCard, {
|
|
990
|
+
type: "flat",
|
|
991
|
+
insetScale: "l",
|
|
992
|
+
showTopBorder: true,
|
|
993
|
+
children: jsxRuntime.jsx(uiKit.CheckboxInput, {
|
|
994
|
+
isIndeterminate: !allAllFieldsSelected && isAtleastOneFieldChecked,
|
|
995
|
+
isChecked: allAllFieldsSelected,
|
|
996
|
+
onChange: handleChangeAllFields,
|
|
997
|
+
children: group.groupLabel
|
|
998
|
+
})
|
|
999
|
+
})
|
|
1000
|
+
}), jsxRuntime.jsx(uiKit.Grid.Item, {
|
|
1001
|
+
children: jsxRuntime.jsx(StyledFieldsCard, {
|
|
1002
|
+
type: "flat",
|
|
1003
|
+
insetScale: "l",
|
|
1004
|
+
showTopBorder: true,
|
|
1005
|
+
children: jsxRuntime.jsx(uiKit.Spacings.Stack, {
|
|
1006
|
+
scale: "s",
|
|
1007
|
+
children: jsxRuntime.jsx(FieldSections, {
|
|
1008
|
+
fields: group.fields,
|
|
1009
|
+
formik: formik,
|
|
1010
|
+
parentKeys: [parentKey],
|
|
1011
|
+
isAnySiblingChecked: isAtleastOneFieldChecked
|
|
1012
|
+
})
|
|
1013
|
+
})
|
|
1014
|
+
})
|
|
1015
|
+
})]
|
|
1016
|
+
});
|
|
1017
|
+
};
|
|
898
1018
|
const ExportFieldsSelectionStep = () => {
|
|
899
1019
|
const intl = reactIntl.useIntl();
|
|
900
1020
|
const _React$useState = React__default["default"].useState(''),
|
|
@@ -910,47 +1030,44 @@ const ExportFieldsSelectionStep = () => {
|
|
|
910
1030
|
resourceType: resourceType,
|
|
911
1031
|
isPlural: true
|
|
912
1032
|
});
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
}, [_valuesInstanceProperty__default["default"](formik).
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
return _includesInstanceProperty__default["default"](_context5 = field.label.toLowerCase()).call(_context5, _trimInstanceProperty__default["default"](fieldSearchTerm).call(fieldSearchTerm).toLowerCase());
|
|
936
|
-
});
|
|
937
|
-
}, [_valuesInstanceProperty__default["default"](formik).fields, fieldSearchTerm]);
|
|
938
|
-
const filteredCustomFields = React__default["default"].useMemo(() => {
|
|
939
|
-
var _context6, _context7;
|
|
940
|
-
return _filterInstanceProperty__default["default"](_context6 = _mapInstanceProperty__default["default"](_context7 = _valuesInstanceProperty__default["default"](formik).customFields).call(_context7, customType => {
|
|
941
|
-
var _context8, _context9;
|
|
942
|
-
return _objectSpread$1(_objectSpread$1({}, customType), {}, {
|
|
943
|
-
fields: _includesInstanceProperty__default["default"](_context8 = customType.type.label.toLowerCase()).call(_context8, _trimInstanceProperty__default["default"](fieldSearchTerm).call(fieldSearchTerm).toLowerCase()) ? customType.fields : _filterInstanceProperty__default["default"](_context9 = customType.fields).call(_context9, field => {
|
|
944
|
-
var _context10;
|
|
945
|
-
return _includesInstanceProperty__default["default"](_context10 = field.label.toLowerCase()).call(_context10, _trimInstanceProperty__default["default"](fieldSearchTerm).call(fieldSearchTerm).toLowerCase());
|
|
946
|
-
})
|
|
1033
|
+
React__default["default"].useEffect(() => {
|
|
1034
|
+
formik.validateForm();
|
|
1035
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1036
|
+
}, [_valuesInstanceProperty__default["default"](formik).groups]);
|
|
1037
|
+
// adds `isHidden` property to each field based on search term
|
|
1038
|
+
const filteredGroups = React__default["default"].useMemo(() => {
|
|
1039
|
+
var _fieldSearchTerm$trim, _context6;
|
|
1040
|
+
const updateFields = (fields, parentMatches) => {
|
|
1041
|
+
return _mapInstanceProperty__default["default"](fields).call(fields, field => {
|
|
1042
|
+
var _context5;
|
|
1043
|
+
const matches = _includesInstanceProperty__default["default"](_context5 = field.label.toLowerCase()).call(_context5, fieldSearchTerm.toLowerCase());
|
|
1044
|
+
let isHidden = !matches && !parentMatches;
|
|
1045
|
+
if (field.fields) {
|
|
1046
|
+
const updatedFields = updateFields(field.fields, matches);
|
|
1047
|
+
isHidden = isHidden && _everyInstanceProperty__default["default"](updatedFields).call(updatedFields, f => f.isHidden);
|
|
1048
|
+
field = _objectSpread$1(_objectSpread$1({}, field), {}, {
|
|
1049
|
+
fields: updatedFields
|
|
1050
|
+
});
|
|
1051
|
+
}
|
|
1052
|
+
return _objectSpread$1(_objectSpread$1({}, field), {}, {
|
|
1053
|
+
isHidden
|
|
1054
|
+
});
|
|
947
1055
|
});
|
|
948
|
-
}
|
|
949
|
-
|
|
1056
|
+
};
|
|
1057
|
+
if (!(fieldSearchTerm !== null && fieldSearchTerm !== void 0 && (_fieldSearchTerm$trim = _trimInstanceProperty__default["default"](fieldSearchTerm).call(fieldSearchTerm)) !== null && _fieldSearchTerm$trim !== void 0 && _fieldSearchTerm$trim.length)) return _valuesInstanceProperty__default["default"](formik).groups;
|
|
1058
|
+
return _mapInstanceProperty__default["default"](_context6 = _valuesInstanceProperty__default["default"](formik).groups).call(_context6, group => {
|
|
1059
|
+
const updatedFields = updateFields(group.fields, false);
|
|
1060
|
+
const isHidden = _everyInstanceProperty__default["default"](updatedFields).call(updatedFields, field => field.isHidden);
|
|
1061
|
+
return _objectSpread$1(_objectSpread$1({}, group), {}, {
|
|
1062
|
+
fields: updatedFields,
|
|
1063
|
+
isHidden
|
|
1064
|
+
});
|
|
1065
|
+
});
|
|
1066
|
+
}, [_valuesInstanceProperty__default["default"](formik).groups, fieldSearchTerm]);
|
|
950
1067
|
const onSearchChange = React__default["default"].useCallback(event => {
|
|
951
1068
|
setFieldSearchTerm(event.target.value);
|
|
952
1069
|
}, [setFieldSearchTerm]);
|
|
953
|
-
const hasResults =
|
|
1070
|
+
const hasResults = Boolean(_findInstanceProperty__default["default"](filteredGroups).call(filteredGroups, group => !group.isHidden));
|
|
954
1071
|
const onSearchChangeThrottled = React__default["default"].useMemo(() => throttle__default["default"](onSearchChange, 300), [onSearchChange]);
|
|
955
1072
|
const onSearchReset = () => {
|
|
956
1073
|
setFieldSearchTerm('');
|
|
@@ -986,194 +1103,28 @@ const ExportFieldsSelectionStep = () => {
|
|
|
986
1103
|
value: fieldSearchTerm,
|
|
987
1104
|
onChange: onSearchChangeThrottled,
|
|
988
1105
|
onReset: onSearchReset
|
|
989
|
-
|
|
1106
|
+
// TODO: `SearchTextInput` props to be improved. The `onSubmit` callback shouldn't be mandatory
|
|
1107
|
+
,
|
|
1108
|
+
onSubmit: () => {}
|
|
1109
|
+
}), hasResults ? jsxRuntime.jsx(uiKit.Card, {
|
|
990
1110
|
insetScale: "none",
|
|
991
|
-
children: jsxRuntime.
|
|
1111
|
+
children: jsxRuntime.jsx(uiKit.Grid, {
|
|
992
1112
|
gridAutoFlow: "row",
|
|
993
1113
|
gridTemplateColumns: "".concat(uiKit.designTokens.constraint5, " auto"),
|
|
994
|
-
children: [
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
children: jsxRuntime.jsx(uiKit.CheckboxInput, {
|
|
1000
|
-
isIndeterminate: !areAllGeneralFieldsChecked && isAtLeastOneGeneralFieldChecked,
|
|
1001
|
-
isChecked: areAllGeneralFieldsChecked,
|
|
1002
|
-
onChange: e => {
|
|
1003
|
-
var _context11;
|
|
1004
|
-
formik.setFieldValue('fields', _mapInstanceProperty__default["default"](_context11 = _valuesInstanceProperty__default["default"](formik).fields).call(_context11, field => _objectSpread$1(_objectSpread$1({}, field), {}, {
|
|
1005
|
-
isChecked: field.isRequired ? true : e.target.checked
|
|
1006
|
-
})));
|
|
1007
|
-
},
|
|
1008
|
-
children: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$1({}, messages.allGeneralFields))
|
|
1009
|
-
})
|
|
1010
|
-
})
|
|
1011
|
-
}), jsxRuntime.jsx(uiKit.Grid.Item, {
|
|
1012
|
-
children: jsxRuntime.jsx(StyledFieldsCard, {
|
|
1013
|
-
type: "flat",
|
|
1014
|
-
insetScale: "l",
|
|
1015
|
-
children: jsxRuntime.jsx(uiKit.Spacings.Stack, {
|
|
1016
|
-
scale: "s",
|
|
1017
|
-
children: jsxRuntime.jsx(GeneralFieldsSelection, {
|
|
1018
|
-
fields: filteredGeneralFields,
|
|
1019
|
-
formik: formik
|
|
1020
|
-
})
|
|
1021
|
-
})
|
|
1022
|
-
})
|
|
1023
|
-
})]
|
|
1024
|
-
}), filteredCustomFields.length > 0 && jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1025
|
-
children: [jsxRuntime.jsx(uiKit.Grid.Item, {
|
|
1026
|
-
children: jsxRuntime.jsx(StyledGroupCard, {
|
|
1027
|
-
type: "flat",
|
|
1028
|
-
insetScale: "l",
|
|
1029
|
-
showTopBorder: filteredGeneralFields.length > 0,
|
|
1030
|
-
children: jsxRuntime.jsx(uiKit.CheckboxInput, {
|
|
1031
|
-
isIndeterminate: !areAllCustomFieldsChecked && isAtLeastOneCustomFieldChecked,
|
|
1032
|
-
isChecked: areAllCustomFieldsChecked,
|
|
1033
|
-
onChange: e => {
|
|
1034
|
-
var _context12;
|
|
1035
|
-
formik.setFieldValue('customFields', _mapInstanceProperty__default["default"](_context12 = _valuesInstanceProperty__default["default"](formik).customFields).call(_context12, customType => {
|
|
1036
|
-
var _context13;
|
|
1037
|
-
return _objectSpread$1(_objectSpread$1({}, customType), {}, {
|
|
1038
|
-
fields: _mapInstanceProperty__default["default"](_context13 = customType.fields).call(_context13, field => _objectSpread$1(_objectSpread$1({}, field), {}, {
|
|
1039
|
-
isChecked: e.target.checked
|
|
1040
|
-
}))
|
|
1041
|
-
});
|
|
1042
|
-
}));
|
|
1043
|
-
},
|
|
1044
|
-
children: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$1({}, messages.allCustomFields))
|
|
1045
|
-
})
|
|
1046
|
-
})
|
|
1047
|
-
}), jsxRuntime.jsx(uiKit.Grid.Item, {
|
|
1048
|
-
children: jsxRuntime.jsx(StyledFieldsCard, {
|
|
1049
|
-
type: "flat",
|
|
1050
|
-
insetScale: "l",
|
|
1051
|
-
showTopBorder: filteredGeneralFields.length > 0,
|
|
1052
|
-
children: jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
1053
|
-
scale: "s",
|
|
1054
|
-
children: [jsxRuntime.jsxs(uiKit.CheckboxInput, {
|
|
1055
|
-
isReadOnly: true,
|
|
1056
|
-
onChange: () => {},
|
|
1057
|
-
isChecked: isAtLeastOneCustomFieldChecked,
|
|
1058
|
-
children: [jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$1({}, messages.customTypeKeyAndTypeId)), ' ', "*"]
|
|
1059
|
-
}), jsxRuntime.jsx(CustomFieldsSelection, {
|
|
1060
|
-
customFields: filteredCustomFields,
|
|
1061
|
-
formik: formik
|
|
1062
|
-
})]
|
|
1063
|
-
})
|
|
1064
|
-
})
|
|
1065
|
-
})]
|
|
1066
|
-
})]
|
|
1114
|
+
children: _mapInstanceProperty__default["default"](filteredGroups).call(filteredGroups, (group, index) => jsxRuntime.jsx(FieldGroupSection, {
|
|
1115
|
+
group: group,
|
|
1116
|
+
index: index,
|
|
1117
|
+
formik: formik
|
|
1118
|
+
}, group.groupLabel))
|
|
1067
1119
|
})
|
|
1068
|
-
})]
|
|
1120
|
+
}) : jsxRuntime.jsx(NoSearchResults, {})]
|
|
1069
1121
|
})
|
|
1070
1122
|
})
|
|
1071
1123
|
});
|
|
1072
1124
|
};
|
|
1073
|
-
const GeneralFieldsSelection = _ref => {
|
|
1074
|
-
let fields = _ref.fields,
|
|
1075
|
-
formik = _ref.formik;
|
|
1076
|
-
return _mapInstanceProperty__default["default"](fields).call(fields, field => jsxRuntime.jsxs(uiKit.CheckboxInput, {
|
|
1077
|
-
isChecked: field.isChecked,
|
|
1078
|
-
isReadOnly: field.isRequired,
|
|
1079
|
-
onChange: e => {
|
|
1080
|
-
var _context14;
|
|
1081
|
-
formik.setFieldValue('fields', _mapInstanceProperty__default["default"](_context14 = _valuesInstanceProperty__default["default"](formik).fields).call(_context14, _field => field.name === _field.name ? _objectSpread$1(_objectSpread$1({}, _field), {}, {
|
|
1082
|
-
isChecked: e.target.checked
|
|
1083
|
-
}) : _field));
|
|
1084
|
-
},
|
|
1085
|
-
children: [field.label, " ", field.isRequired && '*']
|
|
1086
|
-
}, field.name));
|
|
1087
|
-
};
|
|
1088
|
-
const CustomFieldsSelection = _ref2 => {
|
|
1089
|
-
let customFields = _ref2.customFields,
|
|
1090
|
-
formik = _ref2.formik;
|
|
1091
|
-
return _mapInstanceProperty__default["default"](customFields).call(customFields, customType => {
|
|
1092
|
-
var _context15, _context16, _context19;
|
|
1093
|
-
const areAllFieldsChecked = _everyInstanceProperty__default["default"](_context15 = customType.fields).call(_context15, field => field.isChecked);
|
|
1094
|
-
const isAtLeastOneFieldChecked = _someInstanceProperty__default["default"](_context16 = customType.fields).call(_context16, field => field.isChecked);
|
|
1095
|
-
return jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
1096
|
-
scale: "s",
|
|
1097
|
-
children: [jsxRuntime.jsx(uiKit.CheckboxInput, {
|
|
1098
|
-
isIndeterminate: !areAllFieldsChecked && isAtLeastOneFieldChecked,
|
|
1099
|
-
isChecked: areAllFieldsChecked,
|
|
1100
|
-
onChange: e => {
|
|
1101
|
-
var _context17;
|
|
1102
|
-
formik.setFieldValue('customFields', _mapInstanceProperty__default["default"](_context17 = _valuesInstanceProperty__default["default"](formik).customFields).call(_context17, _customType => {
|
|
1103
|
-
var _context18;
|
|
1104
|
-
return _customType.type.key === customType.type.key ? _objectSpread$1(_objectSpread$1({}, _customType), {}, {
|
|
1105
|
-
fields: _mapInstanceProperty__default["default"](_context18 = _customType.fields).call(_context18, field => _objectSpread$1(_objectSpread$1({}, field), {}, {
|
|
1106
|
-
isChecked: e.target.checked
|
|
1107
|
-
}))
|
|
1108
|
-
}) : _customType;
|
|
1109
|
-
}));
|
|
1110
|
-
},
|
|
1111
|
-
children: jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1112
|
-
children: customType.type.label
|
|
1113
|
-
})
|
|
1114
|
-
}), jsxRuntime.jsxs(uiKit.Spacings.Inline, {
|
|
1115
|
-
scale: "l",
|
|
1116
|
-
children: [jsxRuntime.jsx("div", {}), jsxRuntime.jsx(uiKit.Spacings.Stack, {
|
|
1117
|
-
scale: "s",
|
|
1118
|
-
children: _mapInstanceProperty__default["default"](_context19 = customType.fields).call(_context19, field => jsxRuntime.jsx(uiKit.CheckboxInput, {
|
|
1119
|
-
isChecked: field.isChecked,
|
|
1120
|
-
onChange: e => {
|
|
1121
|
-
var _context20;
|
|
1122
|
-
formik.setFieldValue('customFields', _mapInstanceProperty__default["default"](_context20 = _valuesInstanceProperty__default["default"](formik).customFields).call(_context20, _customType => {
|
|
1123
|
-
var _context21;
|
|
1124
|
-
return _customType.type.key === customType.type.key ? _objectSpread$1(_objectSpread$1({}, _customType), {}, {
|
|
1125
|
-
fields: _mapInstanceProperty__default["default"](_context21 = _customType.fields).call(_context21, _field => _field.name === field.name ? _objectSpread$1(_objectSpread$1({}, _field), {}, {
|
|
1126
|
-
isChecked: e.target.checked
|
|
1127
|
-
}) : _field)
|
|
1128
|
-
}) : _customType;
|
|
1129
|
-
}));
|
|
1130
|
-
},
|
|
1131
|
-
children: jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1132
|
-
children: field.label
|
|
1133
|
-
})
|
|
1134
|
-
}, field.name))
|
|
1135
|
-
})]
|
|
1136
|
-
})]
|
|
1137
|
-
}, customType.type.key);
|
|
1138
|
-
});
|
|
1139
|
-
};
|
|
1140
1125
|
|
|
1141
1126
|
const ExportResourcesContext = /*#__PURE__*/React.createContext();
|
|
1142
1127
|
|
|
1143
|
-
PropTypes__default["default"].shape({
|
|
1144
|
-
isOpen: PropTypes__default["default"].bool,
|
|
1145
|
-
resourceType: PropTypes__default["default"].string.isRequired,
|
|
1146
|
-
outputFormat: PropTypes__default["default"].string,
|
|
1147
|
-
onClose: PropTypes__default["default"].func,
|
|
1148
|
-
onExportSuccess: PropTypes__default["default"].func,
|
|
1149
|
-
totalResourcesCount: PropTypes__default["default"].number.isRequired,
|
|
1150
|
-
selectedResourceIds: PropTypes__default["default"].array,
|
|
1151
|
-
// TODO: Circular reference
|
|
1152
|
-
fields: PropTypes__default["default"].arrayOf(PropTypes__default["default"].shape({
|
|
1153
|
-
name: PropTypes__default["default"].string.isRequired,
|
|
1154
|
-
label: PropTypes__default["default"].string,
|
|
1155
|
-
fields: PropTypes__default["default"].arrayOf(PropTypes__default["default"].shape({
|
|
1156
|
-
name: PropTypes__default["default"].string.isRequired,
|
|
1157
|
-
label: PropTypes__default["default"].string,
|
|
1158
|
-
isSelectedByDefault: PropTypes__default["default"].bool,
|
|
1159
|
-
isRequired: PropTypes__default["default"].bool
|
|
1160
|
-
}))
|
|
1161
|
-
})).isRequired,
|
|
1162
|
-
customFields: PropTypes__default["default"].shape({
|
|
1163
|
-
type: PropTypes__default["default"].shape({
|
|
1164
|
-
key: PropTypes__default["default"].string.isRequired,
|
|
1165
|
-
label: PropTypes__default["default"].string.isRequired,
|
|
1166
|
-
resourceTypeIds: PropTypes__default["default"].arrayOf(PropTypes__default["default"].string)
|
|
1167
|
-
}).isRequired,
|
|
1168
|
-
fields: PropTypes__default["default"].arrayOf(PropTypes__default["default"].shape({
|
|
1169
|
-
name: PropTypes__default["default"].string.isRequired,
|
|
1170
|
-
label: PropTypes__default["default"].string
|
|
1171
|
-
})).isRequired
|
|
1172
|
-
}),
|
|
1173
|
-
exportType: PropTypes__default["default"].string,
|
|
1174
|
-
renderProperties: PropTypes__default["default"].func
|
|
1175
|
-
}).isRequired;
|
|
1176
|
-
|
|
1177
1128
|
const ExportResourcesProvider = props => {
|
|
1178
1129
|
const initialValues = useInitialValues(props);
|
|
1179
1130
|
const _useStartExportOperat = useStartExportOperation(props),
|
|
@@ -1214,8 +1165,6 @@ const ExportResourcesProvider = props => {
|
|
|
1214
1165
|
children: props.children
|
|
1215
1166
|
});
|
|
1216
1167
|
};
|
|
1217
|
-
ExportResourcesProvider.displayName = 'ExportResourcesProvider';
|
|
1218
|
-
ExportResourcesProvider.propTypes = {};
|
|
1219
1168
|
|
|
1220
1169
|
const CurrentStep = () => {
|
|
1221
1170
|
const _useExportResourcesCo = useExportResourcesContext(),
|
|
@@ -1227,22 +1176,101 @@ const CurrentStep = () => {
|
|
|
1227
1176
|
return steps[currentStep] || null;
|
|
1228
1177
|
};
|
|
1229
1178
|
|
|
1179
|
+
const loadMessages = locale => {
|
|
1180
|
+
const intlLocale = i18n.mapLocaleToIntlLocale(locale);
|
|
1181
|
+
switch (intlLocale) {
|
|
1182
|
+
case 'de':
|
|
1183
|
+
return Promise.resolve().then(function () { return require( /* webpackChunkName: "export-resources-modal-i18n-de" */'./de-d954fe3d.cjs.prod.js'); });
|
|
1184
|
+
case 'es':
|
|
1185
|
+
return Promise.resolve().then(function () { return require( /* webpackChunkName: "export-resources-modal-i18n-es" */'./es-042343bd.cjs.prod.js'); });
|
|
1186
|
+
case 'fr-FR':
|
|
1187
|
+
return Promise.resolve().then(function () { return require( /* webpackChunkName: "export-resources-modal-i18n-fr-FR" */'./fr-FR-fce1ca96.cjs.prod.js'); });
|
|
1188
|
+
case 'zh-CN':
|
|
1189
|
+
return Promise.resolve().then(function () { return require( /* webpackChunkName: "export-resources-modal-i18n-zh-CN" */'./zh-CN-52baa549.cjs.prod.js'); });
|
|
1190
|
+
case 'ja':
|
|
1191
|
+
return Promise.resolve().then(function () { return require( /* webpackChunkName: "export-resources-modal-i18n-ja" */'./ja-37632763.cjs.prod.js'); });
|
|
1192
|
+
case 'pt-BR':
|
|
1193
|
+
return Promise.resolve().then(function () { return require( /* webpackChunkName: "change-history-i18n-pt-BR" */'./pt-BR-ec2a1a11.cjs.prod.js'); });
|
|
1194
|
+
default:
|
|
1195
|
+
return Promise.resolve().then(function () { return require( /* webpackChunkName: "export-resources-modal-i18n-en" */'./en-c7757448.cjs.prod.js'); });
|
|
1196
|
+
}
|
|
1197
|
+
};
|
|
1198
|
+
|
|
1199
|
+
// eslint-disable-next-line import/prefer-default-export
|
|
1200
|
+
const loadI18n = async locale => {
|
|
1201
|
+
try {
|
|
1202
|
+
const messages = await loadMessages(locale);
|
|
1203
|
+
return messages.default || messages;
|
|
1204
|
+
} catch (error) {
|
|
1205
|
+
// eslint-disable-next-line no-console
|
|
1206
|
+
console.warn("Something went wrong while loading the export-resources-modal messages for ".concat(locale), error);
|
|
1207
|
+
sentry.reportErrorToSentry(new Error("Something went wrong while loading the export-resources-modal messages for ".concat(locale)), {
|
|
1208
|
+
extra: error
|
|
1209
|
+
});
|
|
1210
|
+
return {};
|
|
1211
|
+
}
|
|
1212
|
+
};
|
|
1213
|
+
|
|
1214
|
+
const useAsyncIntlMessages = (locale, loader) => {
|
|
1215
|
+
const _useState = React.useState({
|
|
1216
|
+
isLoading: true,
|
|
1217
|
+
messages: undefined,
|
|
1218
|
+
error: undefined
|
|
1219
|
+
}),
|
|
1220
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1221
|
+
state = _useState2[0],
|
|
1222
|
+
setState = _useState2[1];
|
|
1223
|
+
React.useEffect(() => {
|
|
1224
|
+
let _isUnmounting = false;
|
|
1225
|
+
async function load() {
|
|
1226
|
+
try {
|
|
1227
|
+
if (!_isUnmounting) {
|
|
1228
|
+
const messages = await loader(locale);
|
|
1229
|
+
setState({
|
|
1230
|
+
isLoading: false,
|
|
1231
|
+
messages
|
|
1232
|
+
});
|
|
1233
|
+
}
|
|
1234
|
+
} catch (error) {
|
|
1235
|
+
setState({
|
|
1236
|
+
isLoading: false,
|
|
1237
|
+
error
|
|
1238
|
+
});
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
if (locale) load();
|
|
1242
|
+
return () => {
|
|
1243
|
+
_isUnmounting = true;
|
|
1244
|
+
};
|
|
1245
|
+
}, [locale, loader]);
|
|
1246
|
+
return state;
|
|
1247
|
+
};
|
|
1248
|
+
|
|
1230
1249
|
function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1231
1250
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
1232
1251
|
const ExportResourcesModal = props => {
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1252
|
+
const _useApplicationContex = applicationShellConnectors.useApplicationContext(context => ({
|
|
1253
|
+
locale: context.user && context.user.locale
|
|
1254
|
+
})),
|
|
1255
|
+
locale = _useApplicationContex.locale;
|
|
1256
|
+
const messages = useAsyncIntlMessages('en', loadI18n);
|
|
1257
|
+
if (!props.isOpen || messages.isLoading) return null;
|
|
1258
|
+
return jsxRuntime.jsx(reactIntl.IntlProvider, {
|
|
1259
|
+
locale: locale,
|
|
1260
|
+
messages: messages.messages,
|
|
1261
|
+
children: jsxRuntime.jsx(ExportResourcesProvider, _objectSpread(_objectSpread({}, props), {}, {
|
|
1262
|
+
children: jsxRuntime.jsx(CurrentStep, {})
|
|
1263
|
+
}))
|
|
1264
|
+
});
|
|
1237
1265
|
};
|
|
1238
1266
|
ExportResourcesModal.displayName = 'ExportResourcesModal';
|
|
1239
|
-
ExportResourcesModal.propTypes = {};
|
|
1240
1267
|
ExportResourcesModal.defaultProps = {
|
|
1241
1268
|
isOpen: false,
|
|
1242
1269
|
selectedResourceIds: [],
|
|
1243
1270
|
exportType: EXPORT_TYPES.ALL,
|
|
1244
1271
|
outputFormat: OUTPUT_FORMATS.CSV,
|
|
1245
|
-
customFields: []
|
|
1272
|
+
customFields: [],
|
|
1273
|
+
fieldGroups: []
|
|
1246
1274
|
};
|
|
1247
1275
|
|
|
1248
1276
|
exports.EXPORTABLE_RESOURCES = EXPORTABLE_RESOURCES;
|