@commercetools-frontend-extensions/import-resources-modal 2.1.0 → 2.3.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.
@@ -77,7 +77,12 @@ function reducer(state, action) {
77
77
  uploadFileResponse: action.uploadFileResponse
78
78
  });
79
79
  if (action.type === 'setResourceType') return _objectSpread$a(_objectSpread$a({}, state), {}, {
80
- resourceType: action.resourceType
80
+ resourceType: action.resourceType,
81
+ // Reset the publish setting so it doesn't carry over between resource
82
+ // types (for example, from Products to Tailored Products).
83
+ settings: _objectSpread$a(_objectSpread$a({}, state.settings), {}, {
84
+ publish: undefined
85
+ })
81
86
  });
82
87
  if (action.type === 'setContainerKey') return _objectSpread$a(_objectSpread$a({}, state), {}, {
83
88
  containerKey: action.containerKey
@@ -442,6 +447,11 @@ var messages$6 = reactIntl.defineMessages({
442
447
  description: 'Label for the publish products checkbox',
443
448
  defaultMessage: 'Publish all products in the file'
444
449
  },
450
+ publishTailoredProducts: {
451
+ id: 'ImportResourcesModal.settings.publishTailoredProducts',
452
+ description: 'Label for the publish tailored products checkbox',
453
+ defaultMessage: 'Publish all tailored products in the file'
454
+ },
445
455
  separatorTitle: {
446
456
  id: 'ImportResourcesModal.uploadSeparator.separatorTitle',
447
457
  description: 'Title for the separator selection',
@@ -579,6 +589,7 @@ const IMPORTABLE_RESOURCES = {
579
589
  ORDER: 'order',
580
590
  PRODUCT_TYPE: 'product-type',
581
591
  BUSINESS_UNIT: 'business-unit',
592
+ PRODUCT_TAILORING: 'product-tailoring',
582
593
  STANDALONE_PRICE: 'standalone-price'
583
594
  };
584
595
 
@@ -623,6 +634,11 @@ var sharedMessages = reactIntl.defineMessages({
623
634
  description: 'Label for the product type modal title',
624
635
  defaultMessage: 'Import product types by CSV'
625
636
  },
637
+ [`modalTitle.${IMPORTABLE_RESOURCES.PRODUCT_TAILORING}`]: {
638
+ id: 'ImportResourcesModal.modalTitle.productTailoring',
639
+ description: 'Label for the product tailorings modal title',
640
+ defaultMessage: 'Import tailored products by CSV'
641
+ },
626
642
  [`modalTitle.${IMPORTABLE_RESOURCES.STANDALONE_PRICE}`]: {
627
643
  id: 'ImportResourcesModal.modalTitle.standalonePrice',
628
644
  description: 'Label for the standalone prices modal title',
@@ -829,6 +845,16 @@ var sharedMessages = reactIntl.defineMessages({
829
845
  description: 'Label for the business-units resource type',
830
846
  defaultMessage: 'Business units'
831
847
  },
848
+ 'product-tailoring': {
849
+ id: 'ImportResourcesModal.product-tailoring',
850
+ description: 'Label for the product-tailoring resource type',
851
+ defaultMessage: 'Tailored product'
852
+ },
853
+ 'product-tailorings': {
854
+ id: 'ImportResourcesModal.product-tailorings',
855
+ description: 'Label for the product-tailorings resource type',
856
+ defaultMessage: 'Tailored products'
857
+ },
832
858
  unknownResourceType: {
833
859
  id: 'ImportResourcesModal.unknown-resource-type',
834
860
  description: 'Label for the unknown resource type',
@@ -1056,7 +1082,7 @@ const useUpload = () => {
1056
1082
  const abortController = new AbortController();
1057
1083
  actions.setAbortController(abortController);
1058
1084
  actions.setCurrentStep(CurrentStep$1.Uploading);
1059
- const shouldApplyPublishSettings = state.resourceType === 'product';
1085
+ const shouldApplyPublishSettings = operations.isPublishableResourceType(state.resourceType);
1060
1086
  const uploadSettings = _objectSpread$8({
1061
1087
  format: 'CSV',
1062
1088
  decimalSeparator: state.settings?.decimalSeparator
@@ -1192,6 +1218,7 @@ const useImportPermission = () => {
1192
1218
  canImportInventories: canManageProducts,
1193
1219
  canImportProductTypes: canManageProducts,
1194
1220
  canImportCustomObjects: canManageCustomObjects,
1221
+ canImportProductTailorings: canManageProducts,
1195
1222
  canImportStandalonePrices: canManageStandalonePrices
1196
1223
  };
1197
1224
  };
@@ -1338,8 +1365,8 @@ const Upload = () => {
1338
1365
  publish: checked
1339
1366
  });
1340
1367
  },
1341
- publishProductsLabel: intl.formatMessage(messages$6.publishProducts),
1342
- dataTrackingTarget: "product_import-publish_checkbox",
1368
+ publishProductsLabel: intl.formatMessage(state.resourceType === 'product-tailoring' ? messages$6.publishTailoredProducts : messages$6.publishProducts),
1369
+ dataTrackingTarget: operations.getPublishCheckboxTrackingTarget(state.resourceType),
1343
1370
  canPublishProducts: canPublishProducts
1344
1371
  })]
1345
1372
  })
@@ -2145,6 +2172,11 @@ var messages$1 = reactIntl.defineMessages({
2145
2172
  description: 'Label for the categories radio button',
2146
2173
  defaultMessage: 'Categories'
2147
2174
  },
2175
+ productTailorings: {
2176
+ id: 'ImportResourcesModal.radio.productTailorings',
2177
+ description: 'Label for the product tailorings radio button',
2178
+ defaultMessage: 'Tailored products'
2179
+ },
2148
2180
  standalonePrices: {
2149
2181
  id: 'ImportResourcesModal.radio.standalonePrices',
2150
2182
  description: 'Label for the standalone prices radio button',
@@ -2160,6 +2192,8 @@ const resourceTypeToDisplayName = resourceType => {
2160
2192
  return messages$1.inventories;
2161
2193
  case IMPORTABLE_RESOURCES.CATEGORY:
2162
2194
  return messages$1.categories;
2195
+ case IMPORTABLE_RESOURCES.PRODUCT_TAILORING:
2196
+ return messages$1.productTailorings;
2163
2197
  case IMPORTABLE_RESOURCES.STANDALONE_PRICE:
2164
2198
  return messages$1.standalonePrices;
2165
2199
  default:
@@ -77,7 +77,12 @@ function reducer(state, action) {
77
77
  uploadFileResponse: action.uploadFileResponse
78
78
  });
79
79
  if (action.type === 'setResourceType') return _objectSpread$a(_objectSpread$a({}, state), {}, {
80
- resourceType: action.resourceType
80
+ resourceType: action.resourceType,
81
+ // Reset the publish setting so it doesn't carry over between resource
82
+ // types (for example, from Products to Tailored Products).
83
+ settings: _objectSpread$a(_objectSpread$a({}, state.settings), {}, {
84
+ publish: undefined
85
+ })
81
86
  });
82
87
  if (action.type === 'setContainerKey') return _objectSpread$a(_objectSpread$a({}, state), {}, {
83
88
  containerKey: action.containerKey
@@ -442,6 +447,11 @@ var messages$6 = reactIntl.defineMessages({
442
447
  description: 'Label for the publish products checkbox',
443
448
  defaultMessage: 'Publish all products in the file'
444
449
  },
450
+ publishTailoredProducts: {
451
+ id: 'ImportResourcesModal.settings.publishTailoredProducts',
452
+ description: 'Label for the publish tailored products checkbox',
453
+ defaultMessage: 'Publish all tailored products in the file'
454
+ },
445
455
  separatorTitle: {
446
456
  id: 'ImportResourcesModal.uploadSeparator.separatorTitle',
447
457
  description: 'Title for the separator selection',
@@ -579,6 +589,7 @@ const IMPORTABLE_RESOURCES = {
579
589
  ORDER: 'order',
580
590
  PRODUCT_TYPE: 'product-type',
581
591
  BUSINESS_UNIT: 'business-unit',
592
+ PRODUCT_TAILORING: 'product-tailoring',
582
593
  STANDALONE_PRICE: 'standalone-price'
583
594
  };
584
595
 
@@ -623,6 +634,11 @@ var sharedMessages = reactIntl.defineMessages({
623
634
  description: 'Label for the product type modal title',
624
635
  defaultMessage: 'Import product types by CSV'
625
636
  },
637
+ [`modalTitle.${IMPORTABLE_RESOURCES.PRODUCT_TAILORING}`]: {
638
+ id: 'ImportResourcesModal.modalTitle.productTailoring',
639
+ description: 'Label for the product tailorings modal title',
640
+ defaultMessage: 'Import tailored products by CSV'
641
+ },
626
642
  [`modalTitle.${IMPORTABLE_RESOURCES.STANDALONE_PRICE}`]: {
627
643
  id: 'ImportResourcesModal.modalTitle.standalonePrice',
628
644
  description: 'Label for the standalone prices modal title',
@@ -829,6 +845,16 @@ var sharedMessages = reactIntl.defineMessages({
829
845
  description: 'Label for the business-units resource type',
830
846
  defaultMessage: 'Business units'
831
847
  },
848
+ 'product-tailoring': {
849
+ id: 'ImportResourcesModal.product-tailoring',
850
+ description: 'Label for the product-tailoring resource type',
851
+ defaultMessage: 'Tailored product'
852
+ },
853
+ 'product-tailorings': {
854
+ id: 'ImportResourcesModal.product-tailorings',
855
+ description: 'Label for the product-tailorings resource type',
856
+ defaultMessage: 'Tailored products'
857
+ },
832
858
  unknownResourceType: {
833
859
  id: 'ImportResourcesModal.unknown-resource-type',
834
860
  description: 'Label for the unknown resource type',
@@ -1056,7 +1082,7 @@ const useUpload = () => {
1056
1082
  const abortController = new AbortController();
1057
1083
  actions.setAbortController(abortController);
1058
1084
  actions.setCurrentStep(CurrentStep$1.Uploading);
1059
- const shouldApplyPublishSettings = state.resourceType === 'product';
1085
+ const shouldApplyPublishSettings = operations.isPublishableResourceType(state.resourceType);
1060
1086
  const uploadSettings = _objectSpread$8({
1061
1087
  format: 'CSV',
1062
1088
  decimalSeparator: state.settings?.decimalSeparator
@@ -1192,6 +1218,7 @@ const useImportPermission = () => {
1192
1218
  canImportInventories: canManageProducts,
1193
1219
  canImportProductTypes: canManageProducts,
1194
1220
  canImportCustomObjects: canManageCustomObjects,
1221
+ canImportProductTailorings: canManageProducts,
1195
1222
  canImportStandalonePrices: canManageStandalonePrices
1196
1223
  };
1197
1224
  };
@@ -1338,8 +1365,8 @@ const Upload = () => {
1338
1365
  publish: checked
1339
1366
  });
1340
1367
  },
1341
- publishProductsLabel: intl.formatMessage(messages$6.publishProducts),
1342
- dataTrackingTarget: "product_import-publish_checkbox",
1368
+ publishProductsLabel: intl.formatMessage(state.resourceType === 'product-tailoring' ? messages$6.publishTailoredProducts : messages$6.publishProducts),
1369
+ dataTrackingTarget: operations.getPublishCheckboxTrackingTarget(state.resourceType),
1343
1370
  canPublishProducts: canPublishProducts
1344
1371
  })]
1345
1372
  })
@@ -2121,6 +2148,11 @@ var messages$1 = reactIntl.defineMessages({
2121
2148
  description: 'Label for the categories radio button',
2122
2149
  defaultMessage: 'Categories'
2123
2150
  },
2151
+ productTailorings: {
2152
+ id: 'ImportResourcesModal.radio.productTailorings',
2153
+ description: 'Label for the product tailorings radio button',
2154
+ defaultMessage: 'Tailored products'
2155
+ },
2124
2156
  standalonePrices: {
2125
2157
  id: 'ImportResourcesModal.radio.standalonePrices',
2126
2158
  description: 'Label for the standalone prices radio button',
@@ -2136,6 +2168,8 @@ const resourceTypeToDisplayName = resourceType => {
2136
2168
  return messages$1.inventories;
2137
2169
  case IMPORTABLE_RESOURCES.CATEGORY:
2138
2170
  return messages$1.categories;
2171
+ case IMPORTABLE_RESOURCES.PRODUCT_TAILORING:
2172
+ return messages$1.productTailorings;
2139
2173
  case IMPORTABLE_RESOURCES.STANDALONE_PRICE:
2140
2174
  return messages$1.standalonePrices;
2141
2175
  default:
@@ -10,7 +10,7 @@ import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
10
10
  import _everyInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/every';
11
11
  import { defineMessages, useIntl, FormattedMessage, IntlProvider } from 'react-intl';
12
12
  import { useApplicationContext } from '@commercetools-frontend/application-shell-connectors';
13
- import { deleteImportContainer, FileDroppedArea, DisabledDropArea, EnabledDropArea, ActiveDragDropArea, COLUMN_DELIMITERS, useFileUpload, validateDelimiter, getRowCount, toBytes, IMPORT_MAX_FILE_SIZE_MB, IMPORT_MAX_ITEM_COUNT, isAbortError, HttpError, formatKeys, PollingTimeoutError, isError, assertResourceType, FileDropArea as FileDropArea$1, InfoBox, CT_API_DOCS_URL, UploadSeparator, UploadSettings, useFetchFileImportJobRecords, mapUploadFileErrorsResponseToUploadFileErrorRows, UnexpectedColumnError, extractErrorDescriptionFromValidationMessage, formatErrorCode, RESOURCE_TYPE_DOCUMENTATION_LINKS, mapFileUploadErrorsToUploadFileErrorRows, getValidatedColumns, processFileImportJob, processUploadedFile, UploadingModal, UnexpectedResourceTypeError as UnexpectedResourceTypeError$1, RESOURCE_TYPE_TEMPLATE_DOWNLOAD_LINKS, isResourceType } from '@commercetools-frontend-extensions/operations';
13
+ import { deleteImportContainer, FileDroppedArea, DisabledDropArea, EnabledDropArea, ActiveDragDropArea, COLUMN_DELIMITERS, useFileUpload, isPublishableResourceType, validateDelimiter, getRowCount, toBytes, IMPORT_MAX_FILE_SIZE_MB, IMPORT_MAX_ITEM_COUNT, isAbortError, HttpError, formatKeys, PollingTimeoutError, isError, assertResourceType, FileDropArea as FileDropArea$1, InfoBox, CT_API_DOCS_URL, UploadSeparator, UploadSettings, getPublishCheckboxTrackingTarget, useFetchFileImportJobRecords, mapUploadFileErrorsResponseToUploadFileErrorRows, UnexpectedColumnError, extractErrorDescriptionFromValidationMessage, formatErrorCode, RESOURCE_TYPE_DOCUMENTATION_LINKS, mapFileUploadErrorsToUploadFileErrorRows, getValidatedColumns, processFileImportJob, processUploadedFile, UploadingModal, UnexpectedResourceTypeError as UnexpectedResourceTypeError$1, RESOURCE_TYPE_TEMPLATE_DOWNLOAD_LINKS, isResourceType } from '@commercetools-frontend-extensions/operations';
14
14
  import _slicedToArray from '@babel/runtime-corejs3/helpers/esm/slicedToArray';
15
15
  import React, { useContext, useMemo, useState, useEffect } from 'react';
16
16
  import { jsx, jsxs, Fragment } from '@emotion/react/jsx-runtime';
@@ -56,7 +56,12 @@ function reducer(state, action) {
56
56
  uploadFileResponse: action.uploadFileResponse
57
57
  });
58
58
  if (action.type === 'setResourceType') return _objectSpread$a(_objectSpread$a({}, state), {}, {
59
- resourceType: action.resourceType
59
+ resourceType: action.resourceType,
60
+ // Reset the publish setting so it doesn't carry over between resource
61
+ // types (for example, from Products to Tailored Products).
62
+ settings: _objectSpread$a(_objectSpread$a({}, state.settings), {}, {
63
+ publish: undefined
64
+ })
60
65
  });
61
66
  if (action.type === 'setContainerKey') return _objectSpread$a(_objectSpread$a({}, state), {}, {
62
67
  containerKey: action.containerKey
@@ -421,6 +426,11 @@ var messages$6 = defineMessages({
421
426
  description: 'Label for the publish products checkbox',
422
427
  defaultMessage: 'Publish all products in the file'
423
428
  },
429
+ publishTailoredProducts: {
430
+ id: 'ImportResourcesModal.settings.publishTailoredProducts',
431
+ description: 'Label for the publish tailored products checkbox',
432
+ defaultMessage: 'Publish all tailored products in the file'
433
+ },
424
434
  separatorTitle: {
425
435
  id: 'ImportResourcesModal.uploadSeparator.separatorTitle',
426
436
  description: 'Title for the separator selection',
@@ -558,6 +568,7 @@ const IMPORTABLE_RESOURCES = {
558
568
  ORDER: 'order',
559
569
  PRODUCT_TYPE: 'product-type',
560
570
  BUSINESS_UNIT: 'business-unit',
571
+ PRODUCT_TAILORING: 'product-tailoring',
561
572
  STANDALONE_PRICE: 'standalone-price'
562
573
  };
563
574
 
@@ -602,6 +613,11 @@ var sharedMessages = defineMessages({
602
613
  description: 'Label for the product type modal title',
603
614
  defaultMessage: 'Import product types by CSV'
604
615
  },
616
+ [`modalTitle.${IMPORTABLE_RESOURCES.PRODUCT_TAILORING}`]: {
617
+ id: 'ImportResourcesModal.modalTitle.productTailoring',
618
+ description: 'Label for the product tailorings modal title',
619
+ defaultMessage: 'Import tailored products by CSV'
620
+ },
605
621
  [`modalTitle.${IMPORTABLE_RESOURCES.STANDALONE_PRICE}`]: {
606
622
  id: 'ImportResourcesModal.modalTitle.standalonePrice',
607
623
  description: 'Label for the standalone prices modal title',
@@ -808,6 +824,16 @@ var sharedMessages = defineMessages({
808
824
  description: 'Label for the business-units resource type',
809
825
  defaultMessage: 'Business units'
810
826
  },
827
+ 'product-tailoring': {
828
+ id: 'ImportResourcesModal.product-tailoring',
829
+ description: 'Label for the product-tailoring resource type',
830
+ defaultMessage: 'Tailored product'
831
+ },
832
+ 'product-tailorings': {
833
+ id: 'ImportResourcesModal.product-tailorings',
834
+ description: 'Label for the product-tailorings resource type',
835
+ defaultMessage: 'Tailored products'
836
+ },
811
837
  unknownResourceType: {
812
838
  id: 'ImportResourcesModal.unknown-resource-type',
813
839
  description: 'Label for the unknown resource type',
@@ -1035,7 +1061,7 @@ const useUpload = () => {
1035
1061
  const abortController = new AbortController();
1036
1062
  actions.setAbortController(abortController);
1037
1063
  actions.setCurrentStep(CurrentStep$1.Uploading);
1038
- const shouldApplyPublishSettings = state.resourceType === 'product';
1064
+ const shouldApplyPublishSettings = isPublishableResourceType(state.resourceType);
1039
1065
  const uploadSettings = _objectSpread$8({
1040
1066
  format: 'CSV',
1041
1067
  decimalSeparator: state.settings?.decimalSeparator
@@ -1171,6 +1197,7 @@ const useImportPermission = () => {
1171
1197
  canImportInventories: canManageProducts,
1172
1198
  canImportProductTypes: canManageProducts,
1173
1199
  canImportCustomObjects: canManageCustomObjects,
1200
+ canImportProductTailorings: canManageProducts,
1174
1201
  canImportStandalonePrices: canManageStandalonePrices
1175
1202
  };
1176
1203
  };
@@ -1317,8 +1344,8 @@ const Upload = () => {
1317
1344
  publish: checked
1318
1345
  });
1319
1346
  },
1320
- publishProductsLabel: intl.formatMessage(messages$6.publishProducts),
1321
- dataTrackingTarget: "product_import-publish_checkbox",
1347
+ publishProductsLabel: intl.formatMessage(state.resourceType === 'product-tailoring' ? messages$6.publishTailoredProducts : messages$6.publishProducts),
1348
+ dataTrackingTarget: getPublishCheckboxTrackingTarget(state.resourceType),
1322
1349
  canPublishProducts: canPublishProducts
1323
1350
  })]
1324
1351
  })
@@ -2124,6 +2151,11 @@ var messages$1 = defineMessages({
2124
2151
  description: 'Label for the categories radio button',
2125
2152
  defaultMessage: 'Categories'
2126
2153
  },
2154
+ productTailorings: {
2155
+ id: 'ImportResourcesModal.radio.productTailorings',
2156
+ description: 'Label for the product tailorings radio button',
2157
+ defaultMessage: 'Tailored products'
2158
+ },
2127
2159
  standalonePrices: {
2128
2160
  id: 'ImportResourcesModal.radio.standalonePrices',
2129
2161
  description: 'Label for the standalone prices radio button',
@@ -2139,6 +2171,8 @@ const resourceTypeToDisplayName = resourceType => {
2139
2171
  return messages$1.inventories;
2140
2172
  case IMPORTABLE_RESOURCES.CATEGORY:
2141
2173
  return messages$1.categories;
2174
+ case IMPORTABLE_RESOURCES.PRODUCT_TAILORING:
2175
+ return messages$1.productTailorings;
2142
2176
  case IMPORTABLE_RESOURCES.STANDALONE_PRICE:
2143
2177
  return messages$1.standalonePrices;
2144
2178
  default:
@@ -6,5 +6,6 @@ export declare const useImportPermission: () => {
6
6
  canImportInventories: boolean;
7
7
  canImportProductTypes: boolean;
8
8
  canImportCustomObjects: any;
9
+ canImportProductTailorings: boolean;
9
10
  canImportStandalonePrices: boolean;
10
11
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@commercetools-frontend-extensions/import-resources-modal",
3
3
  "description": "Shared import modal for importing resources",
4
- "version": "2.1.0",
4
+ "version": "2.3.0",
5
5
  "license": "BSD-3-Clause",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -31,7 +31,7 @@
31
31
  "pluralize": "8.0.0",
32
32
  "prop-types": "15.8.1",
33
33
  "ramda": "^0.32.0",
34
- "@commercetools-frontend-extensions/operations": "4.1.0"
34
+ "@commercetools-frontend-extensions/operations": "4.3.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@commercetools-frontend/actions-global": "27.5.1",