@commercetools-frontend-extensions/export-resources-modal 5.6.5 → 5.6.7

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.
@@ -103,12 +103,19 @@ var _styled__default = /*#__PURE__*/_interopDefault(_styled);
103
103
  var debounce__default = /*#__PURE__*/_interopDefault(debounce);
104
104
  var get__default = /*#__PURE__*/_interopDefault(get);
105
105
 
106
- function getBold(msg) {
106
+ function getBold(chunks) {
107
107
  return jsxRuntime.jsx(uiKit.Text.Body, {
108
108
  as: "span",
109
- isBold: true,
110
- children: msg
111
- }, `bold-${msg}`);
109
+ fontWeight: "bold",
110
+ children: chunks
111
+ }, crypto.randomUUID());
112
+ }
113
+ function getSmallBold(chunks) {
114
+ return jsxRuntime.jsx(uiKit.Text.Detail, {
115
+ as: "span",
116
+ fontWeight: "bold",
117
+ children: chunks
118
+ }, crypto.randomUUID());
112
119
  }
113
120
 
114
121
  function getNewLine() {
@@ -610,6 +617,11 @@ var messages = reactIntl.defineMessages({
610
617
  description: 'Incomplete field error',
611
618
  defaultMessage: 'Incomplete field'
612
619
  },
620
+ attributeLevelMismatch: {
621
+ id: 'ExportResourcesModal.attributeLevelMismatch',
622
+ description: 'Attribute level mismatch error',
623
+ defaultMessage: 'Attribute level mismatch'
624
+ },
613
625
  notSupportedFieldsTitle: {
614
626
  id: 'ExportResourcesModal.notSupportedFieldsTitle',
615
627
  description: 'Title for not supported fields error',
@@ -640,6 +652,16 @@ var messages = reactIntl.defineMessages({
640
652
  description: 'Title for field definitions not found error',
641
653
  defaultMessage: 'The following custom field(s) cannot be found in this project:'
642
654
  },
655
+ attributeLevelMismatchProductLevelTitle: {
656
+ id: 'ExportResourcesModal.attributeLevelMismatchProductLevelTitle',
657
+ description: 'Title for attribute level mismatch error when attribute needs to be at Product level',
658
+ defaultMessage: "Attribute needs to be defined at the Product level. Change the mapping by using this format <b>productAttributes.'{'nameOfAttribute'}'</b>."
659
+ },
660
+ attributeLevelMismatchVariantLevelTitle: {
661
+ id: 'ExportResourcesModal.attributeLevelMismatchVariantLevelTitle',
662
+ description: 'Title for attribute level mismatch error when attribute needs to be at Variant level',
663
+ defaultMessage: "Attribute needs to be defined at the Variant level. Change the mapping by using this format <b>attributes.'{'nameOfAttribute'}'</b>."
664
+ },
643
665
  unknownError: {
644
666
  id: 'ExportResourcesModal.unknownError',
645
667
  description: 'Unknown error',
@@ -1515,7 +1537,8 @@ function groupFieldValidationErrors(errors, intl) {
1515
1537
  var _context2, _context4;
1516
1538
  const errorsByCode = _reduceInstanceProperty__default["default"](errors).call(errors, (groups, error) => {
1517
1539
  var _context;
1518
- const group = groups[error.code] || {
1540
+ const groupKey = error.code === 'AttributeLevelMismatch' && error.actualLevel ? `${error.code}-${error.actualLevel}` : error.code;
1541
+ const group = groups[groupKey] || {
1519
1542
  code: error.code,
1520
1543
  originalErrors: [],
1521
1544
  fieldNames: []
@@ -1524,7 +1547,7 @@ function groupFieldValidationErrors(errors, intl) {
1524
1547
  group.fieldNames.push(error.field);
1525
1548
  }
1526
1549
  group.originalErrors.push(error);
1527
- groups[error.code] = group;
1550
+ groups[groupKey] = group;
1528
1551
  return groups;
1529
1552
  }, {});
1530
1553
  _forEachInstanceProperty__default["default"](_context2 = _Object$values__default["default"](errorsByCode)).call(_context2, group => {
@@ -1552,6 +1575,22 @@ function groupFieldValidationErrors(errors, intl) {
1552
1575
  case 'FieldDefinitionNotFound':
1553
1576
  messageTitle = intl.formatMessage(messages.fieldDefinitionNotFoundTitle);
1554
1577
  break;
1578
+ case 'AttributeLevelMismatch':
1579
+ {
1580
+ const referenceError = group.originalErrors[0];
1581
+ if (referenceError?.actualLevel === 'Product') {
1582
+ messageTitle = intl.formatMessage(messages.attributeLevelMismatchProductLevelTitle, {
1583
+ b: getSmallBold
1584
+ });
1585
+ } else if (referenceError?.actualLevel === 'Variant') {
1586
+ messageTitle = intl.formatMessage(messages.attributeLevelMismatchVariantLevelTitle, {
1587
+ b: getSmallBold
1588
+ });
1589
+ } else {
1590
+ messageTitle = referenceError?.message || intl.formatMessage(messages.unknownError);
1591
+ }
1592
+ break;
1593
+ }
1555
1594
  default:
1556
1595
  messageTitle = group.originalErrors[0]?.message || intl.formatMessage(messages.unknownError);
1557
1596
  }
@@ -3202,9 +3241,12 @@ const getColumns = () => [{
3202
3241
  const ErrorTable = props => {
3203
3242
  var _context;
3204
3243
  const intl = reactIntl.useIntl();
3205
- const rows = _mapInstanceProperty__default["default"](_context = props.errors).call(_context, row => _objectSpread$2(_objectSpread$2({}, row), {}, {
3206
- id: row.code
3207
- }));
3244
+ const rows = _mapInstanceProperty__default["default"](_context = props.errors).call(_context, row => {
3245
+ const id = row.code === 'AttributeLevelMismatch' && row.originalErrors[0]?.actualLevel ? `${row.code}-${row.originalErrors[0].actualLevel}` : row.code;
3246
+ return _objectSpread$2(_objectSpread$2({}, row), {}, {
3247
+ id
3248
+ });
3249
+ });
3208
3250
  return jsxRuntime.jsx(uiKit.Spacings.Stack, {
3209
3251
  scale: "l",
3210
3252
  children: jsxRuntime.jsx(uiKit.DataTable, {
@@ -3262,6 +3304,8 @@ function getErrorTypeLabel(errorCode, intl) {
3262
3304
  return intl.formatMessage(messages.fieldDefinitionNotFound);
3263
3305
  case 'IncompleteField':
3264
3306
  return intl.formatMessage(messages.incompleteField);
3307
+ case 'AttributeLevelMismatch':
3308
+ return intl.formatMessage(messages.attributeLevelMismatch);
3265
3309
  default:
3266
3310
  return errorCode;
3267
3311
  }
@@ -103,12 +103,19 @@ var _styled__default = /*#__PURE__*/_interopDefault(_styled);
103
103
  var debounce__default = /*#__PURE__*/_interopDefault(debounce);
104
104
  var get__default = /*#__PURE__*/_interopDefault(get);
105
105
 
106
- function getBold(msg) {
106
+ function getBold(chunks) {
107
107
  return jsxRuntime.jsx(uiKit.Text.Body, {
108
108
  as: "span",
109
- isBold: true,
110
- children: msg
111
- }, `bold-${msg}`);
109
+ fontWeight: "bold",
110
+ children: chunks
111
+ }, crypto.randomUUID());
112
+ }
113
+ function getSmallBold(chunks) {
114
+ return jsxRuntime.jsx(uiKit.Text.Detail, {
115
+ as: "span",
116
+ fontWeight: "bold",
117
+ children: chunks
118
+ }, crypto.randomUUID());
112
119
  }
113
120
 
114
121
  function getNewLine() {
@@ -610,6 +617,11 @@ var messages = reactIntl.defineMessages({
610
617
  description: 'Incomplete field error',
611
618
  defaultMessage: 'Incomplete field'
612
619
  },
620
+ attributeLevelMismatch: {
621
+ id: 'ExportResourcesModal.attributeLevelMismatch',
622
+ description: 'Attribute level mismatch error',
623
+ defaultMessage: 'Attribute level mismatch'
624
+ },
613
625
  notSupportedFieldsTitle: {
614
626
  id: 'ExportResourcesModal.notSupportedFieldsTitle',
615
627
  description: 'Title for not supported fields error',
@@ -640,6 +652,16 @@ var messages = reactIntl.defineMessages({
640
652
  description: 'Title for field definitions not found error',
641
653
  defaultMessage: 'The following custom field(s) cannot be found in this project:'
642
654
  },
655
+ attributeLevelMismatchProductLevelTitle: {
656
+ id: 'ExportResourcesModal.attributeLevelMismatchProductLevelTitle',
657
+ description: 'Title for attribute level mismatch error when attribute needs to be at Product level',
658
+ defaultMessage: "Attribute needs to be defined at the Product level. Change the mapping by using this format <b>productAttributes.'{'nameOfAttribute'}'</b>."
659
+ },
660
+ attributeLevelMismatchVariantLevelTitle: {
661
+ id: 'ExportResourcesModal.attributeLevelMismatchVariantLevelTitle',
662
+ description: 'Title for attribute level mismatch error when attribute needs to be at Variant level',
663
+ defaultMessage: "Attribute needs to be defined at the Variant level. Change the mapping by using this format <b>attributes.'{'nameOfAttribute'}'</b>."
664
+ },
643
665
  unknownError: {
644
666
  id: 'ExportResourcesModal.unknownError',
645
667
  description: 'Unknown error',
@@ -1515,7 +1537,8 @@ function groupFieldValidationErrors(errors, intl) {
1515
1537
  var _context2, _context4;
1516
1538
  const errorsByCode = _reduceInstanceProperty__default["default"](errors).call(errors, (groups, error) => {
1517
1539
  var _context;
1518
- const group = groups[error.code] || {
1540
+ const groupKey = error.code === 'AttributeLevelMismatch' && error.actualLevel ? `${error.code}-${error.actualLevel}` : error.code;
1541
+ const group = groups[groupKey] || {
1519
1542
  code: error.code,
1520
1543
  originalErrors: [],
1521
1544
  fieldNames: []
@@ -1524,7 +1547,7 @@ function groupFieldValidationErrors(errors, intl) {
1524
1547
  group.fieldNames.push(error.field);
1525
1548
  }
1526
1549
  group.originalErrors.push(error);
1527
- groups[error.code] = group;
1550
+ groups[groupKey] = group;
1528
1551
  return groups;
1529
1552
  }, {});
1530
1553
  _forEachInstanceProperty__default["default"](_context2 = _Object$values__default["default"](errorsByCode)).call(_context2, group => {
@@ -1552,6 +1575,22 @@ function groupFieldValidationErrors(errors, intl) {
1552
1575
  case 'FieldDefinitionNotFound':
1553
1576
  messageTitle = intl.formatMessage(messages.fieldDefinitionNotFoundTitle);
1554
1577
  break;
1578
+ case 'AttributeLevelMismatch':
1579
+ {
1580
+ const referenceError = group.originalErrors[0];
1581
+ if (referenceError?.actualLevel === 'Product') {
1582
+ messageTitle = intl.formatMessage(messages.attributeLevelMismatchProductLevelTitle, {
1583
+ b: getSmallBold
1584
+ });
1585
+ } else if (referenceError?.actualLevel === 'Variant') {
1586
+ messageTitle = intl.formatMessage(messages.attributeLevelMismatchVariantLevelTitle, {
1587
+ b: getSmallBold
1588
+ });
1589
+ } else {
1590
+ messageTitle = referenceError?.message || intl.formatMessage(messages.unknownError);
1591
+ }
1592
+ break;
1593
+ }
1555
1594
  default:
1556
1595
  messageTitle = group.originalErrors[0]?.message || intl.formatMessage(messages.unknownError);
1557
1596
  }
@@ -3169,9 +3208,12 @@ const getColumns = () => [{
3169
3208
  const ErrorTable = props => {
3170
3209
  var _context;
3171
3210
  const intl = reactIntl.useIntl();
3172
- const rows = _mapInstanceProperty__default["default"](_context = props.errors).call(_context, row => _objectSpread$2(_objectSpread$2({}, row), {}, {
3173
- id: row.code
3174
- }));
3211
+ const rows = _mapInstanceProperty__default["default"](_context = props.errors).call(_context, row => {
3212
+ const id = row.code === 'AttributeLevelMismatch' && row.originalErrors[0]?.actualLevel ? `${row.code}-${row.originalErrors[0].actualLevel}` : row.code;
3213
+ return _objectSpread$2(_objectSpread$2({}, row), {}, {
3214
+ id
3215
+ });
3216
+ });
3175
3217
  return jsxRuntime.jsx(uiKit.Spacings.Stack, {
3176
3218
  scale: "l",
3177
3219
  children: jsxRuntime.jsx(uiKit.DataTable, {
@@ -3229,6 +3271,8 @@ function getErrorTypeLabel(errorCode, intl) {
3229
3271
  return intl.formatMessage(messages.fieldDefinitionNotFound);
3230
3272
  case 'IncompleteField':
3231
3273
  return intl.formatMessage(messages.incompleteField);
3274
+ case 'AttributeLevelMismatch':
3275
+ return intl.formatMessage(messages.attributeLevelMismatch);
3232
3276
  default:
3233
3277
  return errorCode;
3234
3278
  }
@@ -60,12 +60,19 @@ import get from 'lodash/get';
60
60
  import { parseChunkImport, mapLocaleToIntlLocale } from '@commercetools-frontend/i18n';
61
61
  import { reportErrorToSentry } from '@commercetools-frontend/sentry';
62
62
 
63
- function getBold(msg) {
63
+ function getBold(chunks) {
64
64
  return jsx(Text.Body, {
65
65
  as: "span",
66
- isBold: true,
67
- children: msg
68
- }, `bold-${msg}`);
66
+ fontWeight: "bold",
67
+ children: chunks
68
+ }, crypto.randomUUID());
69
+ }
70
+ function getSmallBold(chunks) {
71
+ return jsx(Text.Detail, {
72
+ as: "span",
73
+ fontWeight: "bold",
74
+ children: chunks
75
+ }, crypto.randomUUID());
69
76
  }
70
77
 
71
78
  function getNewLine() {
@@ -567,6 +574,11 @@ var messages = defineMessages({
567
574
  description: 'Incomplete field error',
568
575
  defaultMessage: 'Incomplete field'
569
576
  },
577
+ attributeLevelMismatch: {
578
+ id: 'ExportResourcesModal.attributeLevelMismatch',
579
+ description: 'Attribute level mismatch error',
580
+ defaultMessage: 'Attribute level mismatch'
581
+ },
570
582
  notSupportedFieldsTitle: {
571
583
  id: 'ExportResourcesModal.notSupportedFieldsTitle',
572
584
  description: 'Title for not supported fields error',
@@ -597,6 +609,16 @@ var messages = defineMessages({
597
609
  description: 'Title for field definitions not found error',
598
610
  defaultMessage: 'The following custom field(s) cannot be found in this project:'
599
611
  },
612
+ attributeLevelMismatchProductLevelTitle: {
613
+ id: 'ExportResourcesModal.attributeLevelMismatchProductLevelTitle',
614
+ description: 'Title for attribute level mismatch error when attribute needs to be at Product level',
615
+ defaultMessage: "Attribute needs to be defined at the Product level. Change the mapping by using this format <b>productAttributes.'{'nameOfAttribute'}'</b>."
616
+ },
617
+ attributeLevelMismatchVariantLevelTitle: {
618
+ id: 'ExportResourcesModal.attributeLevelMismatchVariantLevelTitle',
619
+ description: 'Title for attribute level mismatch error when attribute needs to be at Variant level',
620
+ defaultMessage: "Attribute needs to be defined at the Variant level. Change the mapping by using this format <b>attributes.'{'nameOfAttribute'}'</b>."
621
+ },
600
622
  unknownError: {
601
623
  id: 'ExportResourcesModal.unknownError',
602
624
  description: 'Unknown error',
@@ -1472,7 +1494,8 @@ function groupFieldValidationErrors(errors, intl) {
1472
1494
  var _context2, _context4;
1473
1495
  const errorsByCode = _reduceInstanceProperty(errors).call(errors, (groups, error) => {
1474
1496
  var _context;
1475
- const group = groups[error.code] || {
1497
+ const groupKey = error.code === 'AttributeLevelMismatch' && error.actualLevel ? `${error.code}-${error.actualLevel}` : error.code;
1498
+ const group = groups[groupKey] || {
1476
1499
  code: error.code,
1477
1500
  originalErrors: [],
1478
1501
  fieldNames: []
@@ -1481,7 +1504,7 @@ function groupFieldValidationErrors(errors, intl) {
1481
1504
  group.fieldNames.push(error.field);
1482
1505
  }
1483
1506
  group.originalErrors.push(error);
1484
- groups[error.code] = group;
1507
+ groups[groupKey] = group;
1485
1508
  return groups;
1486
1509
  }, {});
1487
1510
  _forEachInstanceProperty(_context2 = _Object$values(errorsByCode)).call(_context2, group => {
@@ -1509,6 +1532,22 @@ function groupFieldValidationErrors(errors, intl) {
1509
1532
  case 'FieldDefinitionNotFound':
1510
1533
  messageTitle = intl.formatMessage(messages.fieldDefinitionNotFoundTitle);
1511
1534
  break;
1535
+ case 'AttributeLevelMismatch':
1536
+ {
1537
+ const referenceError = group.originalErrors[0];
1538
+ if (referenceError?.actualLevel === 'Product') {
1539
+ messageTitle = intl.formatMessage(messages.attributeLevelMismatchProductLevelTitle, {
1540
+ b: getSmallBold
1541
+ });
1542
+ } else if (referenceError?.actualLevel === 'Variant') {
1543
+ messageTitle = intl.formatMessage(messages.attributeLevelMismatchVariantLevelTitle, {
1544
+ b: getSmallBold
1545
+ });
1546
+ } else {
1547
+ messageTitle = referenceError?.message || intl.formatMessage(messages.unknownError);
1548
+ }
1549
+ break;
1550
+ }
1512
1551
  default:
1513
1552
  messageTitle = group.originalErrors[0]?.message || intl.formatMessage(messages.unknownError);
1514
1553
  }
@@ -3159,9 +3198,12 @@ const getColumns = () => [{
3159
3198
  const ErrorTable = props => {
3160
3199
  var _context;
3161
3200
  const intl = useIntl();
3162
- const rows = _mapInstanceProperty(_context = props.errors).call(_context, row => _objectSpread$2(_objectSpread$2({}, row), {}, {
3163
- id: row.code
3164
- }));
3201
+ const rows = _mapInstanceProperty(_context = props.errors).call(_context, row => {
3202
+ const id = row.code === 'AttributeLevelMismatch' && row.originalErrors[0]?.actualLevel ? `${row.code}-${row.originalErrors[0].actualLevel}` : row.code;
3203
+ return _objectSpread$2(_objectSpread$2({}, row), {}, {
3204
+ id
3205
+ });
3206
+ });
3165
3207
  return jsx(Spacings.Stack, {
3166
3208
  scale: "l",
3167
3209
  children: jsx(DataTable, {
@@ -3219,6 +3261,8 @@ function getErrorTypeLabel(errorCode, intl) {
3219
3261
  return intl.formatMessage(messages.fieldDefinitionNotFound);
3220
3262
  case 'IncompleteField':
3221
3263
  return intl.formatMessage(messages.incompleteField);
3264
+ case 'AttributeLevelMismatch':
3265
+ return intl.formatMessage(messages.attributeLevelMismatch);
3222
3266
  default:
3223
3267
  return errorCode;
3224
3268
  }
@@ -1 +1 @@
1
- export type FieldValidationErrorCode = 'DuplicateFields' | 'NotSupportedField' | 'FieldDefinitionNotFound' | 'AttributeDefinitionNotFound' | 'LocalizedFieldWithoutLocale' | 'IncompleteField';
1
+ export type FieldValidationErrorCode = 'DuplicateFields' | 'NotSupportedField' | 'FieldDefinitionNotFound' | 'AttributeDefinitionNotFound' | 'LocalizedFieldWithoutLocale' | 'IncompleteField' | 'AttributeLevelMismatch';
@@ -3,4 +3,6 @@ export type FieldValidationError = {
3
3
  code: FieldValidationErrorCode;
4
4
  message: string;
5
5
  field: string;
6
+ requestedLevel?: string;
7
+ actualLevel?: string;
6
8
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@commercetools-frontend-extensions/export-resources-modal",
3
3
  "description": "Shared export modal for exporting resources",
4
- "version": "5.6.5",
4
+ "version": "5.6.7",
5
5
  "license": "BSD-3-Clause",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -29,17 +29,17 @@
29
29
  "@commercetools-frontend-extensions/operations": "2.0.1"
30
30
  },
31
31
  "devDependencies": {
32
- "@commercetools-frontend/actions-global": "24.9.0",
33
- "@commercetools-frontend/application-components": "24.9.0",
34
- "@commercetools-frontend/application-shell": "24.9.0",
35
- "@commercetools-frontend/application-shell-connectors": "24.9.0",
36
- "@commercetools-frontend/constants": "24.9.0",
32
+ "@commercetools-frontend/actions-global": "24.11.0",
33
+ "@commercetools-frontend/application-components": "24.11.0",
34
+ "@commercetools-frontend/application-shell": "24.11.0",
35
+ "@commercetools-frontend/application-shell-connectors": "24.11.0",
36
+ "@commercetools-frontend/constants": "24.11.0",
37
37
  "@commercetools-frontend/fullstory": "4.0.1",
38
- "@commercetools-frontend/i18n": "24.9.0",
39
- "@commercetools-frontend/jest-preset-mc-app": "24.9.0",
40
- "@commercetools-frontend/l10n": "24.9.0",
41
- "@commercetools-frontend/sdk": "24.9.0",
42
- "@commercetools-frontend/sentry": "24.9.0",
38
+ "@commercetools-frontend/i18n": "24.11.0",
39
+ "@commercetools-frontend/jest-preset-mc-app": "24.11.0",
40
+ "@commercetools-frontend/l10n": "24.11.0",
41
+ "@commercetools-frontend/sdk": "24.11.0",
42
+ "@commercetools-frontend/sentry": "24.11.0",
43
43
  "@commercetools-frontend/ui-kit": "20.3.0",
44
44
  "@commercetools-uikit/design-system": "20.3.0",
45
45
  "@commercetools-uikit/icons": "20.3.0",