@commercetools-frontend-extensions/export-resources-modal 3.2.1 → 3.4.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.
@@ -29,12 +29,16 @@ var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWit
29
29
  var _Array$isArray = require('@babel/runtime-corejs3/core-js-stable/array/is-array');
30
30
  var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
31
31
  var _Object$assign = require('@babel/runtime-corejs3/core-js-stable/object/assign');
32
+ var _flatMapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/flat-map');
33
+ var _Set = require('@babel/runtime-corejs3/core-js-stable/set');
32
34
  var uiKit = require('@commercetools-frontend/ui-kit');
33
35
  var jsxRuntime = require('@emotion/react/jsx-runtime');
34
36
  var _valuesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/values');
37
+ var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
35
38
  var omitEmpty = require('omit-empty-es');
36
39
  var _findIndexInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find-index');
37
40
  var _spliceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/splice');
41
+ var _startsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/starts-with');
38
42
  require('@commercetools-uikit/design-system');
39
43
  var applicationShellConnectors = require('@commercetools-frontend/application-shell-connectors');
40
44
  var moment = require('moment');
@@ -66,10 +70,14 @@ var _Reflect$construct__default = /*#__PURE__*/_interopDefault(_Reflect$construc
66
70
  var _Array$isArray__default = /*#__PURE__*/_interopDefault(_Array$isArray);
67
71
  var _findInstanceProperty__default = /*#__PURE__*/_interopDefault(_findInstanceProperty);
68
72
  var _Object$assign__default = /*#__PURE__*/_interopDefault(_Object$assign);
73
+ var _flatMapInstanceProperty__default = /*#__PURE__*/_interopDefault(_flatMapInstanceProperty);
74
+ var _Set__default = /*#__PURE__*/_interopDefault(_Set);
69
75
  var _valuesInstanceProperty__default = /*#__PURE__*/_interopDefault(_valuesInstanceProperty);
76
+ var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInstanceProperty);
70
77
  var omitEmpty__default = /*#__PURE__*/_interopDefault(omitEmpty);
71
78
  var _findIndexInstanceProperty__default = /*#__PURE__*/_interopDefault(_findIndexInstanceProperty);
72
79
  var _spliceInstanceProperty__default = /*#__PURE__*/_interopDefault(_spliceInstanceProperty);
80
+ var _startsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_startsWithInstanceProperty);
73
81
  var moment__default = /*#__PURE__*/_interopDefault(moment);
74
82
  var _styled__default = /*#__PURE__*/_interopDefault(_styled);
75
83
  var _everyInstanceProperty__default = /*#__PURE__*/_interopDefault(_everyInstanceProperty);
@@ -106,7 +114,7 @@ const OUTPUT_FORMAT_OPTIONS = [{
106
114
  label: 'JSON'
107
115
  }];
108
116
 
109
- const COLUMN_DEFINITIONS_URLS = {
117
+ const FIELD_DEFINITIONS_URLS = {
110
118
  category: 'https://docs-proxy-sarm-product-import-csv.commercetools.vercel.app/merchant-center/import-categories#supported-headers-and-values'
111
119
  };
112
120
 
@@ -172,21 +180,28 @@ let UnexpectedResourceTypeError = /*#__PURE__*/function (_Error) {
172
180
 
173
181
  const _excluded$1 = ["name"];
174
182
  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; }
175
- function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var _context4, _context5; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context4 = ownKeys$5(Object(t), !0)).call(_context4, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context5 = ownKeys$5(Object(t))).call(_context5, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
176
- function resourceTypeToPlural(_ref) {
183
+ function _objectSpread$5(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$5(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$5(Object(t))).call(_context8, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
184
+ function resourceTypeToDisplayName(_ref) {
177
185
  let resourceType = _ref.resourceType,
178
186
  _ref$isUpperCase = _ref.isUpperCase,
179
- isUpperCase = _ref$isUpperCase === void 0 ? false : _ref$isUpperCase;
187
+ isUpperCase = _ref$isUpperCase === void 0 ? false : _ref$isUpperCase,
188
+ _ref$isPlural = _ref.isPlural,
189
+ isPlural = _ref$isPlural === void 0 ? false : _ref$isPlural;
190
+ let displayName;
180
191
  switch (resourceType) {
181
192
  case EXPORTABLE_RESOURCES.CATEGORY:
182
- return isUpperCase ? 'Categories' : 'categories';
193
+ displayName = isPlural ? 'Categories' : 'Category';
194
+ break;
183
195
  case EXPORTABLE_RESOURCES.PRODUCT:
184
- return isUpperCase ? 'Products' : 'products';
196
+ displayName = isPlural ? 'Products' : 'Product';
197
+ break;
185
198
  case EXPORTABLE_RESOURCES.DISCOUNT_CODE:
186
- return isUpperCase ? 'Discount codes' : 'discount codes';
199
+ displayName = isPlural ? 'Discount codes' : 'Discount code';
200
+ break;
187
201
  default:
188
202
  throw UnexpectedResourceTypeError(resourceType);
189
203
  }
204
+ return isUpperCase ? displayName : displayName.toLowerCase();
190
205
  }
191
206
  function resourceTypeToOperationName(resourceType) {
192
207
  switch (resourceType) {
@@ -258,21 +273,51 @@ function unflattenNestedFields(flattenedFields) {
258
273
  });
259
274
  return reconstructed;
260
275
  }
261
- function getSelectedFields(fields) {
276
+ function getSelectedGeneralFields(fields) {
262
277
  return _filterInstanceProperty__default["default"](fields).call(fields, field => field.isChecked);
263
278
  }
264
- function getFieldNames(fields) {
265
- return _mapInstanceProperty__default["default"](fields).call(fields, field => field.name);
279
+ function getSelectedCustomFields(customFields) {
280
+ return _mapInstanceProperty__default["default"](customFields).call(customFields, customType => {
281
+ var _context4;
282
+ return _objectSpread$5(_objectSpread$5({}, customType), {}, {
283
+ fields: _filterInstanceProperty__default["default"](_context4 = customType.fields).call(_context4, field => field.isChecked)
284
+ });
285
+ });
286
+ }
287
+ function flattenCustomFields(customFields) {
288
+ return _flatMapInstanceProperty__default["default"](customFields).call(customFields, customType => customType.fields);
266
289
  }
267
290
  function checkRequiredFields(fields) {
268
291
  return _mapInstanceProperty__default["default"](fields).call(fields, field => field.isRequired ? _objectSpread$5(_objectSpread$5({}, field), {}, {
269
292
  isChecked: true
270
293
  }) : field);
271
294
  }
272
- const getExportLogsLink = (projectKey, msg) => jsxRuntime.jsx(uiKit.Link, {
273
- to: "/".concat(projectKey, "/operations/export/logs"),
274
- children: msg
275
- });
295
+ function getExportLogsLink(projectKey, msg) {
296
+ return jsxRuntime.jsx(uiKit.Link, {
297
+ to: "/".concat(projectKey, "/operations/export/logs"),
298
+ children: msg
299
+ });
300
+ }
301
+ function setInitialCheckedStateForCustomFields(customFields) {
302
+ return _mapInstanceProperty__default["default"](customFields).call(customFields, customType => {
303
+ var _context5;
304
+ return _objectSpread$5(_objectSpread$5({}, customType), {}, {
305
+ fields: _mapInstanceProperty__default["default"](_context5 = customType.fields).call(_context5, field => _objectSpread$5(_objectSpread$5({}, field), {}, {
306
+ isChecked: false
307
+ }))
308
+ });
309
+ });
310
+ }
311
+ function buildGeneralFieldColumns(generalFields) {
312
+ return _mapInstanceProperty__default["default"](generalFields).call(generalFields, field => field.name);
313
+ }
314
+ function buildCustomFieldColumns(customFields) {
315
+ const columns = _flatMapInstanceProperty__default["default"](customFields).call(customFields, customType => {
316
+ var _context6;
317
+ return _mapInstanceProperty__default["default"](_context6 = customType.fields).call(_context6, field => "custom.fields.".concat(field.name));
318
+ });
319
+ return [...new _Set__default["default"](columns)];
320
+ }
276
321
 
277
322
  /*
278
323
  * This function is responsible for constructing the GraphQL query based on the export settings
@@ -282,18 +327,28 @@ const getExportLogsLink = (projectKey, msg) => jsxRuntime.jsx(uiKit.Link, {
282
327
  * - 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.
283
328
  * - The 'filtered' case is a placeholder for future development where a query will be constructed based on certain filtering criteria using the `where` parameter.
284
329
  */
285
- function buildGraphQuery(exportSettings) {
330
+ function buildGraphQLQuery(exportSettings) {
286
331
  var _context;
287
332
  const operation = resourceTypeToOperationName(exportSettings.resourceType);
333
+ const generalFields = buildGeneralFieldsForGraphQLQuery({
334
+ fields: exportSettings.fields,
335
+ locales: exportSettings.locales
336
+ });
337
+ const results = [...generalFields];
338
+ if (exportSettings.customFields && exportSettings.customFields.length > 0) {
339
+ const customFields = buildCustomFieldsForGraphQLQuery({
340
+ customFields: exportSettings.customFields
341
+ });
342
+ results.push({
343
+ custom: customFields
344
+ });
345
+ }
288
346
  switch (exportSettings.exportType) {
289
347
  case EXPORT_TYPES.ALL:
290
348
  return gqlQueryBuilder.query({
291
349
  operation,
292
350
  fields: [{
293
- results: buildFields({
294
- fields: exportSettings.fields,
295
- locales: exportSettings.locales
296
- })
351
+ results
297
352
  }],
298
353
  variables: {}
299
354
  });
@@ -301,10 +356,7 @@ function buildGraphQuery(exportSettings) {
301
356
  return gqlQueryBuilder.query({
302
357
  operation,
303
358
  fields: [{
304
- results: buildFields({
305
- fields: exportSettings.fields,
306
- locales: exportSettings.locales
307
- })
359
+ results
308
360
  }],
309
361
  variables: {
310
362
  where: "id in (".concat(_mapInstanceProperty__default["default"](_context = exportSettings.selectedResourceIds).call(_context, id => "\"".concat(id, "\"")).join(', '), ")")
@@ -332,7 +384,7 @@ function buildGraphQuery(exportSettings) {
332
384
  * More details can be found in the related PR: https://github.com/commercetools/commercetools-exporter/pull/103
333
385
  */
334
386
 
335
- function buildFields(_ref) {
387
+ function buildGeneralFieldsForGraphQLQuery(_ref) {
336
388
  var _context2;
337
389
  let fields = _ref.fields,
338
390
  locales = _ref.locales;
@@ -344,7 +396,7 @@ function buildFields(_ref) {
344
396
  });else {
345
397
  if (isFilledArray(field.fields)) {
346
398
  return {
347
- [field.name]: buildFields({
399
+ [field.name]: buildGeneralFieldsForGraphQLQuery({
348
400
  fields: field.fields,
349
401
  locales
350
402
  })
@@ -354,31 +406,48 @@ function buildFields(_ref) {
354
406
  }
355
407
  })).call(_context2);
356
408
  }
409
+ function buildCustomFieldsForGraphQLQuery(_ref2) {
410
+ _ref2.customFields;
411
+ // const customFieldNames = customFields.map((customField) => customField.name)
412
+ return [{
413
+ type: ['key']
414
+ }, {
415
+ operation: 'customFieldsRaw',
416
+ fields: ['name', 'value'],
417
+ // TODO: Add custom fields filter to the variables when they are supported on the Export API side
418
+ variables: {
419
+ // includeNames: customFieldNames,
420
+ }
421
+ }];
422
+ }
357
423
 
358
424
  function validate(_ref) {
359
425
  let values = _valuesInstanceProperty__default["default"](_ref),
360
426
  step = _ref.step;
427
+ const fileName = values.fileName,
428
+ locales = values.locales,
429
+ fields = values.fields,
430
+ customFields = values.customFields;
361
431
  const errors = {
362
432
  fileName: {},
363
433
  locales: {},
364
434
  fields: {}
365
435
  };
366
- // Always validate these fields (first and second steps)
367
- if (uiKit.TextInput.isEmpty(values.fileName)) {
436
+ if (uiKit.TextInput.isEmpty(fileName)) {
368
437
  errors.fileName.missing = true;
369
- } else if (!/^[a-zA-Z0-9-_.]+$/.test(values.fileName)) {
438
+ } else if (!/^[a-zA-Z0-9-_.]+$/.test(fileName)) {
370
439
  errors.fileName.invalidInput = true;
371
440
  }
372
- if (values.locales.length < 1) {
441
+ if (locales.length < 1) {
373
442
  errors.locales.missing = true;
374
443
  }
375
- //
376
-
377
- // Only validate these fields on the 2nd step
378
444
  if (step === 2) {
379
- var _context;
380
- const checkedFields = _filterInstanceProperty__default["default"](_context = values.fields).call(_context, field => field.isChecked);
381
- if (checkedFields.length < 2) {
445
+ const checkedGeneralFieldsCount = _filterInstanceProperty__default["default"](fields).call(fields, field => field.isChecked).length;
446
+ const checkedCustomFieldsCount = _reduceInstanceProperty__default["default"](customFields).call(customFields, (count, customType) => {
447
+ var _context;
448
+ return count + _filterInstanceProperty__default["default"](_context = customType.fields).call(_context, field => field.isChecked).length;
449
+ }, 0);
450
+ if (checkedGeneralFieldsCount + checkedCustomFieldsCount < 2) {
382
451
  errors.fields.missing = true;
383
452
  }
384
453
  }
@@ -391,6 +460,10 @@ const categoryColumnExtension = columns => {
391
460
  if (parentKeyIndex !== -1) {
392
461
  _spliceInstanceProperty__default["default"](extendedColumns).call(extendedColumns, parentKeyIndex + 1, 0, 'parent.typeId');
393
462
  }
463
+ const firstCustomFieldIndex = _findIndexInstanceProperty__default["default"](extendedColumns).call(extendedColumns, column => _startsWithInstanceProperty__default["default"](column).call(column, 'custom.fields.'));
464
+ if (firstCustomFieldIndex !== -1) {
465
+ _spliceInstanceProperty__default["default"](extendedColumns).call(extendedColumns, firstCustomFieldIndex, 0, 'custom.type.key', 'custom.type.typeId');
466
+ }
394
467
  return extendedColumns;
395
468
  };
396
469
  const defaultColumnExtension = columns => columns;
@@ -399,7 +472,9 @@ const columnExtensionByResourceType = {
399
472
  category: categoryColumnExtension
400
473
  };
401
474
 
402
- const extendColumns = (columns, resourceType) => {
475
+ const extendColumns = _ref => {
476
+ let resourceType = _ref.resourceType,
477
+ columns = _ref.columns;
403
478
  const extensionFunction = columnExtensionByResourceType[resourceType] || columnExtensionByResourceType.default;
404
479
  return extensionFunction(columns);
405
480
  };
@@ -455,11 +530,6 @@ var messages = reactIntl.defineMessages({
455
530
  description: 'resources are selected and will be exported',
456
531
  defaultMessage: '<b>{count}</b> {resourceType} are selected and will be exported.'
457
532
  },
458
- columnsMessage: {
459
- id: 'ExportResourcesModal.columnsMessage',
460
- description: 'Exported columns and attributes based on table settings',
461
- defaultMessage: 'Exported columns/attributes based on table settings: {columnsCount}'
462
- },
463
533
  exportBasedOnMyViewsMessage: {
464
534
  id: 'ExportResourcesModal.exportBasedOnMyViewsMessage',
465
535
  description: 'Select Export setttings based on my views',
@@ -505,9 +575,9 @@ var messages = reactIntl.defineMessages({
505
575
  description: 'Label for "My Views" Select Field',
506
576
  defaultMessage: 'My Views'
507
577
  },
508
- selectColumnsToExport: {
509
- id: 'ExportResourcesModal.selectColumnsToExport',
510
- defaultMessage: 'Select columns to export'
578
+ selectFieldsToExport: {
579
+ id: 'ExportResourcesModal.selectFieldsToExport',
580
+ defaultMessage: 'Select fields to export'
511
581
  },
512
582
  back: {
513
583
  id: 'ExportResourcesModal.back',
@@ -524,15 +594,25 @@ var messages = reactIntl.defineMessages({
524
594
  description: 'Label for "Continue" button',
525
595
  defaultMessage: 'Continue'
526
596
  },
527
- columnDefinitions: {
528
- id: 'ExportResourcesModal.columnDefinitions',
529
- description: 'Label for "Column Definitions" link',
530
- defaultMessage: 'Column definitions'
597
+ fieldDefinitions: {
598
+ id: 'ExportResourcesModal.fieldDefinitions',
599
+ description: 'Label for "Field definitions" link',
600
+ defaultMessage: 'Field definitions'
531
601
  },
532
602
  allGeneralFields: {
533
603
  id: 'ExportResourcesModal.allGeneralFields',
534
604
  description: 'Label for "All general fields" checkbox',
535
605
  defaultMessage: 'All general fields'
606
+ },
607
+ allCustomFields: {
608
+ id: 'ExportResourcesModal.allCustomFields',
609
+ description: 'Label for "All custom fields" checkbox',
610
+ defaultMessage: 'All custom fields'
611
+ },
612
+ customTypeKeyAndTypeId: {
613
+ id: 'ExportResourcesModal.customTypeKeyAndTypeId',
614
+ description: 'Label for "Custom type key and typeId" checkbox',
615
+ defaultMessage: 'Custom type key and typeId'
536
616
  }
537
617
  });
538
618
 
@@ -598,12 +678,14 @@ const useInitialValues = props => {
598
678
  var _context2;
599
679
  return {
600
680
  outputFormat: props.outputFormat,
601
- fileName: _concatInstanceProperty__default["default"](_context2 = "".concat(resourceTypeToPlural({
681
+ fileName: _concatInstanceProperty__default["default"](_context2 = "".concat(resourceTypeToDisplayName({
602
682
  resourceType: props.resourceType,
603
- isUpperCase: true
683
+ isUpperCase: true,
684
+ isPlural: true
604
685
  }), "_Export_")).call(_context2, todayFormatted),
605
686
  locales: [locale],
606
- fields: checkRequiredFields(fields)
687
+ fields: checkRequiredFields(fields),
688
+ customFields: setInitialCheckedStateForCustomFields(props.customFields)
607
689
  };
608
690
  }, [props, locale, todayFormatted, fields]);
609
691
  };
@@ -648,19 +730,27 @@ const useStartExportOperation = props => {
648
730
  }),
649
731
  projectKey = _useApplicationContex.projectKey;
650
732
  const startExportOperation = async values => {
651
- const graphQuery = buildGraphQuery({
652
- resourceType: props.resourceType,
653
- exportType: props.exportType,
654
- selectedResourceIds: props.selectedResourceIds,
655
- fields: unflattenNestedFields(getSelectedFields(values.fields)),
656
- locales: values.locales
657
- });
658
733
  try {
734
+ const selectedGeneralFields = getSelectedGeneralFields(values.fields);
735
+ const selectedCustomFields = getSelectedCustomFields(values.customFields);
736
+ const generalColumns = buildGeneralFieldColumns(selectedGeneralFields);
737
+ const customColumns = buildCustomFieldColumns(selectedCustomFields);
738
+ const graphQuery = buildGraphQLQuery({
739
+ resourceType: props.resourceType,
740
+ exportType: props.exportType,
741
+ selectedResourceIds: props.selectedResourceIds,
742
+ fields: unflattenNestedFields(selectedGeneralFields),
743
+ customFields: flattenCustomFields(selectedCustomFields),
744
+ locales: values.locales
745
+ });
659
746
  const response = await createExportOperation({
660
747
  fileName: appendCsvOrJsonExtensionIfAbsent(values.fileName, values.outputFormat),
661
748
  fileFormat: values.outputFormat,
662
749
  locales: values.locales,
663
- columns: extendColumns(getFieldNames(getSelectedFields(values.fields)), props.resourceType),
750
+ columns: extendColumns({
751
+ resourceType: props.resourceType,
752
+ columns: [...generalColumns, ...customColumns]
753
+ }),
664
754
  projectKey,
665
755
  graphQuery,
666
756
  asyncDispatchFn: asyncDispatch
@@ -701,13 +791,15 @@ const useStartExportOperation = props => {
701
791
  function ownKeys$2(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
702
792
  function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$2(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$2(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
703
793
  function ExportTextMessage() {
794
+ const intl = reactIntl.useIntl();
704
795
  const _useExportResourcesCo = useExportResourcesContext(),
705
796
  resourceType = _useExportResourcesCo.resourceType,
706
797
  totalResourcesCount = _useExportResourcesCo.totalResourcesCount,
707
798
  selectedResourceIds = _useExportResourcesCo.selectedResourceIds,
708
799
  exportType = _useExportResourcesCo.exportType;
709
- const resourceTypePlural = resourceTypeToPlural({
710
- resourceType: resourceType
800
+ const resourceTypePlural = resourceTypeToDisplayName({
801
+ resourceType: resourceType,
802
+ isPlural: true
711
803
  });
712
804
  let message;
713
805
  let count;
@@ -727,7 +819,7 @@ function ExportTextMessage() {
727
819
  "data-testid": "export-description",
728
820
  intlMessage: _objectSpread$2(_objectSpread$2({}, message), {}, {
729
821
  values: {
730
- count: count,
822
+ count: intl.formatNumber(count),
731
823
  resourceType: resourceTypePlural,
732
824
  b: getBold
733
825
  }
@@ -812,34 +904,43 @@ const ExportFileSettingsStep = () => {
812
904
  };
813
905
 
814
906
  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; }
815
- function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var _context6, _context7; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context6 = ownKeys$1(Object(t), !0)).call(_context6, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context7 = ownKeys$1(Object(t))).call(_context7, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
907
+ function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var _context12, _context13; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context12 = ownKeys$1(Object(t), !0)).call(_context12, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context13 = ownKeys$1(Object(t))).call(_context13, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
816
908
  const StyledCard = /*#__PURE__*/_styled__default["default"](uiKit.Card, {
817
909
  target: "e1ocu3bb2"
818
910
  } )({
819
- name: "1jtoq3b",
820
- styles: "border-radius:4px 0px 0px 4px;&>div{height:490px;overflow-y:auto;}"
911
+ name: "yqmzw4",
912
+ styles: "&>div{height:490px;overflow-y:auto;}"
821
913
  } );
822
914
  const StyledCardLeft = /*#__PURE__*/_styled__default["default"](StyledCard, {
823
915
  target: "e1ocu3bb1"
824
- } )({
825
- name: "65buvr",
826
- styles: "background-color:#f9f9fb"
827
- } );
916
+ } )("background-color:#f9f9fb;border-top:", _ref => {
917
+ let isTopRow = _ref.isTopRow;
918
+ return isTopRow ? uiKit.designTokens.borderForCardWhenRaised : 'none';
919
+ }, ";border-radius:", _ref2 => {
920
+ let isTopRow = _ref2.isTopRow;
921
+ return isTopRow ? '4px 0px 0px 0px' : '0px 0px 0px 4px';
922
+ }, ";" + ("" ));
828
923
  const StyledCardRight = /*#__PURE__*/_styled__default["default"](StyledCard, {
829
924
  target: "e1ocu3bb0"
830
- } )({
831
- name: "1oktwfs",
832
- styles: "border-radius:0px 4px 4px 0px;border-left:0"
833
- } );
925
+ } )("border-left:0;border-top:", _ref3 => {
926
+ let isTopRow = _ref3.isTopRow;
927
+ return isTopRow ? uiKit.designTokens.borderForCardWhenRaised : 'none';
928
+ }, ";border-radius:", _ref4 => {
929
+ let isTopRow = _ref4.isTopRow;
930
+ return isTopRow ? '0px 4px 0px 0px' : '0px 0px 4px 0px';
931
+ }, ";" + ("" ));
834
932
  const ExportFieldsSelectionStep = () => {
835
- var _context, _context2, _context4;
933
+ var _context, _context2, _context3, _formik$values$custom;
836
934
  const intl = reactIntl.useIntl();
837
935
  const _useExportResourcesCo = useExportResourcesContext(),
838
936
  formik = _useExportResourcesCo.formik,
839
937
  setCurrentStep = _useExportResourcesCo.setCurrentStep,
840
938
  resourceType = _useExportResourcesCo.resourceType;
841
- const areAllFieldsChecked = _everyInstanceProperty__default["default"](_context = _valuesInstanceProperty__default["default"](formik).fields).call(_context, field => field.isChecked);
842
- const isAtLeastOneFieldChecked = _someInstanceProperty__default["default"](_context2 = _valuesInstanceProperty__default["default"](formik).fields).call(_context2, field => field.isChecked);
939
+ const areAllGeneralFieldsChecked = _everyInstanceProperty__default["default"](_context = _valuesInstanceProperty__default["default"](formik).fields).call(_context, field => field.isChecked);
940
+ const isAtLeastOneGeneralFieldChecked = _someInstanceProperty__default["default"](_context2 = _valuesInstanceProperty__default["default"](formik).fields).call(_context2, field => field.isChecked);
941
+ const allCustomFields = _flatMapInstanceProperty__default["default"](_context3 = _valuesInstanceProperty__default["default"](formik).customFields).call(_context3, customType => customType.fields);
942
+ const areAllCustomFieldsChecked = _everyInstanceProperty__default["default"](allCustomFields).call(allCustomFields, field => field.isChecked);
943
+ const isAtLeastOneCustomFieldChecked = _someInstanceProperty__default["default"](allCustomFields).call(allCustomFields, field => field.isChecked);
843
944
  return jsxRuntime.jsxs(uiKit.Spacings.Stack, {
844
945
  scale: "xl",
845
946
  children: [jsxRuntime.jsxs(uiKit.Spacings.Stack, {
@@ -847,25 +948,26 @@ const ExportFieldsSelectionStep = () => {
847
948
  children: [jsxRuntime.jsxs(uiKit.Spacings.Inline, {
848
949
  justifyContent: "space-between",
849
950
  children: [jsxRuntime.jsx(uiKit.Text.Body, {
850
- intlMessage: messages.selectColumnsToExport
951
+ intlMessage: messages.selectFieldsToExport
851
952
  }), jsxRuntime.jsx(uiKit.Link, {
852
953
  isExternal: true,
853
954
  tone: "secondary",
854
- intlMessage: messages.columnDefinitions,
855
- to: COLUMN_DEFINITIONS_URLS[resourceType]
955
+ intlMessage: messages.fieldDefinitions,
956
+ to: FIELD_DEFINITIONS_URLS[resourceType]
856
957
  })]
857
958
  }), jsxRuntime.jsxs(uiKit.Grid, {
858
- gridAutoFlow: "column",
859
- gridTemplateColumns: "".concat(uiKit.customProperties.constraint5, " auto"),
959
+ gridAutoFlow: "row",
960
+ gridTemplateColumns: "".concat(uiKit.designTokens.constraint5, " auto"),
860
961
  children: [jsxRuntime.jsx(uiKit.Grid.Item, {
861
962
  children: jsxRuntime.jsx(StyledCardLeft, {
963
+ isTopRow: true,
862
964
  insetScale: "l",
863
965
  children: jsxRuntime.jsx(uiKit.CheckboxInput, {
864
- isIndeterminate: !areAllFieldsChecked && isAtLeastOneFieldChecked,
865
- isChecked: areAllFieldsChecked,
966
+ isIndeterminate: !areAllGeneralFieldsChecked && isAtLeastOneGeneralFieldChecked,
967
+ isChecked: areAllGeneralFieldsChecked,
866
968
  onChange: e => {
867
- var _context3;
868
- formik.setFieldValue('fields', _mapInstanceProperty__default["default"](_context3 = _valuesInstanceProperty__default["default"](formik).fields).call(_context3, field => _objectSpread$1(_objectSpread$1({}, field), {}, {
969
+ var _context4;
970
+ formik.setFieldValue('fields', _mapInstanceProperty__default["default"](_context4 = _valuesInstanceProperty__default["default"](formik).fields).call(_context4, field => _objectSpread$1(_objectSpread$1({}, field), {}, {
869
971
  isChecked: field.isRequired ? true : e.target.checked
870
972
  })));
871
973
  },
@@ -876,21 +978,58 @@ const ExportFieldsSelectionStep = () => {
876
978
  })
877
979
  }), jsxRuntime.jsx(uiKit.Grid.Item, {
878
980
  children: jsxRuntime.jsx(StyledCardRight, {
981
+ isTopRow: true,
879
982
  insetScale: "l",
880
- children: _mapInstanceProperty__default["default"](_context4 = _valuesInstanceProperty__default["default"](formik).fields).call(_context4, field => jsxRuntime.jsx(uiKit.CheckboxInput, {
881
- isReadOnly: field.isRequired,
882
- isChecked: field.isChecked,
883
- onChange: e => {
884
- var _context5;
885
- formik.setFieldValue('fields', _mapInstanceProperty__default["default"](_context5 = _valuesInstanceProperty__default["default"](formik).fields).call(_context5, _field => field.name === _field.name ? _objectSpread$1(_objectSpread$1({}, _field), {}, {
886
- isChecked: e.target.checked
887
- }) : _field));
888
- },
889
- children: jsxRuntime.jsxs(uiKit.Text.Body, {
890
- children: [field.label, " ", field.isRequired && '*']
983
+ children: jsxRuntime.jsx(uiKit.Spacings.Stack, {
984
+ scale: "s",
985
+ children: jsxRuntime.jsx(GeneralFieldsSelection, {
986
+ fields: _valuesInstanceProperty__default["default"](formik).fields,
987
+ setFieldValue: formik.setFieldValue
891
988
  })
892
- }, field.name))
989
+ })
893
990
  })
991
+ }), ((_formik$values$custom = _valuesInstanceProperty__default["default"](formik).customFields) === null || _formik$values$custom === void 0 ? void 0 : _formik$values$custom.length) > 0 && jsxRuntime.jsxs(jsxRuntime.Fragment, {
992
+ children: [jsxRuntime.jsx(uiKit.Grid.Item, {
993
+ children: jsxRuntime.jsx(StyledCardLeft, {
994
+ insetScale: "l",
995
+ children: jsxRuntime.jsx(uiKit.CheckboxInput, {
996
+ isIndeterminate: !areAllCustomFieldsChecked && isAtLeastOneCustomFieldChecked,
997
+ isChecked: areAllCustomFieldsChecked,
998
+ onChange: e => {
999
+ var _context5;
1000
+ formik.setFieldValue('customFields', _mapInstanceProperty__default["default"](_context5 = _valuesInstanceProperty__default["default"](formik).customFields).call(_context5, customType => {
1001
+ var _context6;
1002
+ return _objectSpread$1(_objectSpread$1({}, customType), {}, {
1003
+ fields: _mapInstanceProperty__default["default"](_context6 = customType.fields).call(_context6, field => _objectSpread$1(_objectSpread$1({}, field), {}, {
1004
+ isChecked: e.target.checked
1005
+ }))
1006
+ });
1007
+ }));
1008
+ },
1009
+ children: jsxRuntime.jsx(uiKit.Text.Body, {
1010
+ intlMessage: messages.allCustomFields
1011
+ })
1012
+ })
1013
+ })
1014
+ }), jsxRuntime.jsx(uiKit.Grid.Item, {
1015
+ children: jsxRuntime.jsx(StyledCardRight, {
1016
+ insetScale: "l",
1017
+ children: jsxRuntime.jsxs(uiKit.Spacings.Stack, {
1018
+ scale: "s",
1019
+ children: [jsxRuntime.jsx(uiKit.CheckboxInput, {
1020
+ isReadOnly: true,
1021
+ onChange: () => {},
1022
+ isChecked: isAtLeastOneCustomFieldChecked,
1023
+ children: jsxRuntime.jsxs(uiKit.Text.Body, {
1024
+ children: [intl.formatMessage(messages.customTypeKeyAndTypeId), " *"]
1025
+ })
1026
+ }), jsxRuntime.jsx(CustomFieldsSelection, {
1027
+ customFields: _valuesInstanceProperty__default["default"](formik).customFields,
1028
+ setFieldValue: formik.setFieldValue
1029
+ })]
1030
+ })
1031
+ })
1032
+ })]
894
1033
  })]
895
1034
  })]
896
1035
  }), jsxRuntime.jsxs(uiKit.Spacings.Inline, {
@@ -907,6 +1046,72 @@ const ExportFieldsSelectionStep = () => {
907
1046
  })]
908
1047
  });
909
1048
  };
1049
+ const GeneralFieldsSelection = _ref5 => {
1050
+ let fields = _ref5.fields,
1051
+ setFieldValue = _ref5.setFieldValue;
1052
+ return _mapInstanceProperty__default["default"](fields).call(fields, field => jsxRuntime.jsx(uiKit.CheckboxInput, {
1053
+ isChecked: field.isChecked,
1054
+ isReadOnly: field.isRequired,
1055
+ onChange: e => {
1056
+ setFieldValue('fields', _mapInstanceProperty__default["default"](fields).call(fields, _field => field.name === _field.name ? _objectSpread$1(_objectSpread$1({}, _field), {}, {
1057
+ isChecked: e.target.checked
1058
+ }) : _field));
1059
+ },
1060
+ children: jsxRuntime.jsxs(uiKit.Text.Body, {
1061
+ children: [field.label, " ", field.isRequired && '*']
1062
+ })
1063
+ }, field.name));
1064
+ };
1065
+ const CustomFieldsSelection = _ref6 => {
1066
+ let customFields = _ref6.customFields,
1067
+ setFieldValue = _ref6.setFieldValue;
1068
+ return _mapInstanceProperty__default["default"](customFields).call(customFields, customType => {
1069
+ var _context7, _context8, _context10;
1070
+ const areAllFieldsChecked = _everyInstanceProperty__default["default"](_context7 = customType.fields).call(_context7, field => field.isChecked);
1071
+ const isAtLeastOneFieldChecked = _someInstanceProperty__default["default"](_context8 = customType.fields).call(_context8, field => field.isChecked);
1072
+ return jsxRuntime.jsxs(uiKit.Spacings.Stack, {
1073
+ scale: "s",
1074
+ children: [jsxRuntime.jsx(uiKit.CheckboxInput, {
1075
+ isIndeterminate: !areAllFieldsChecked && isAtLeastOneFieldChecked,
1076
+ isChecked: areAllFieldsChecked,
1077
+ onChange: e => {
1078
+ setFieldValue('customFields', _mapInstanceProperty__default["default"](customFields).call(customFields, _customType => {
1079
+ var _context9;
1080
+ return _customType.type.key === customType.type.key ? _objectSpread$1(_objectSpread$1({}, _customType), {}, {
1081
+ fields: _mapInstanceProperty__default["default"](_context9 = _customType.fields).call(_context9, field => _objectSpread$1(_objectSpread$1({}, field), {}, {
1082
+ isChecked: e.target.checked
1083
+ }))
1084
+ }) : _customType;
1085
+ }));
1086
+ },
1087
+ children: jsxRuntime.jsx(uiKit.Text.Body, {
1088
+ children: customType.type.label
1089
+ })
1090
+ }), jsxRuntime.jsxs(uiKit.Spacings.Inline, {
1091
+ scale: "l",
1092
+ children: [jsxRuntime.jsx("div", {}), jsxRuntime.jsx(uiKit.Spacings.Stack, {
1093
+ scale: "s",
1094
+ children: _mapInstanceProperty__default["default"](_context10 = customType.fields).call(_context10, field => jsxRuntime.jsx(uiKit.CheckboxInput, {
1095
+ isChecked: field.isChecked,
1096
+ onChange: e => {
1097
+ setFieldValue('customFields', _mapInstanceProperty__default["default"](customFields).call(customFields, _customType => {
1098
+ var _context11;
1099
+ return _customType.type.key === customType.type.key ? _objectSpread$1(_objectSpread$1({}, _customType), {}, {
1100
+ fields: _mapInstanceProperty__default["default"](_context11 = _customType.fields).call(_context11, _field => _field.name === field.name ? _objectSpread$1(_objectSpread$1({}, _field), {}, {
1101
+ isChecked: e.target.checked
1102
+ }) : _field)
1103
+ }) : _customType;
1104
+ }));
1105
+ },
1106
+ children: jsxRuntime.jsx(uiKit.Text.Body, {
1107
+ children: field.label
1108
+ })
1109
+ }, field.name))
1110
+ })]
1111
+ })]
1112
+ }, customType.type.key);
1113
+ });
1114
+ };
910
1115
 
911
1116
  const ExportResourcesContext = /*#__PURE__*/React.createContext();
912
1117
 
@@ -931,14 +1136,24 @@ PropTypes__default["default"].shape({
931
1136
  isRequired: PropTypes__default["default"].bool
932
1137
  }))
933
1138
  })).isRequired,
1139
+ customFields: PropTypes__default["default"].shape({
1140
+ type: PropTypes__default["default"].shape({
1141
+ key: PropTypes__default["default"].string.isRequired,
1142
+ label: PropTypes__default["default"].string.isRequired
1143
+ }).isRequired,
1144
+ fields: PropTypes__default["default"].arrayOf(PropTypes__default["default"].shape({
1145
+ name: PropTypes__default["default"].string.isRequired,
1146
+ label: PropTypes__default["default"].string
1147
+ })).isRequired
1148
+ }),
934
1149
  exportType: PropTypes__default["default"].string,
935
1150
  renderProperties: PropTypes__default["default"].func
936
1151
  }).isRequired;
937
1152
 
938
1153
  const ExportResourcesProvider = props => {
1154
+ const initialValues = useInitialValues(props);
939
1155
  const _useStartExportOperat = useStartExportOperation(props),
940
1156
  startExportOperation = _useStartExportOperat.startExportOperation;
941
- const initialValues = useInitialValues(props);
942
1157
  const _React$useState = React__default["default"].useState(1),
943
1158
  _React$useState2 = _slicedToArray(_React$useState, 2),
944
1159
  currentStep = _React$useState2[0],
@@ -994,8 +1209,9 @@ function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Objec
994
1209
  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; }
995
1210
  const ExportResourcesModal = props => {
996
1211
  const intl = reactIntl.useIntl();
997
- const resourceTypePlural = resourceTypeToPlural({
998
- resourceType: props.resourceType
1212
+ const resourceTypePlural = resourceTypeToDisplayName({
1213
+ resourceType: props.resourceType,
1214
+ isPlural: true
999
1215
  });
1000
1216
  return jsxRuntime.jsx(ExportResourcesProvider, _objectSpread(_objectSpread({}, props), {}, {
1001
1217
  children: jsxRuntime.jsx(applicationComponents.InfoDialog, {
@@ -1015,7 +1231,8 @@ ExportResourcesModal.defaultProps = {
1015
1231
  isOpen: false,
1016
1232
  selectedResourceIds: [],
1017
1233
  exportType: EXPORT_TYPES.ALL,
1018
- outputFormat: OUTPUT_FORMATS.CSV
1234
+ outputFormat: OUTPUT_FORMATS.CSV,
1235
+ customFields: []
1019
1236
  };
1020
1237
 
1021
1238
  exports.EXPORTABLE_RESOURCES = EXPORTABLE_RESOURCES;