@commercetools-frontend-extensions/import-resources-modal 1.16.7 → 2.0.1
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.
|
@@ -31,7 +31,6 @@ var _possibleConstructorReturn = require('@babel/runtime-corejs3/helpers/possibl
|
|
|
31
31
|
var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
|
|
32
32
|
var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
|
|
33
33
|
var _wrapNativeSuper = require('@babel/runtime-corejs3/helpers/wrapNativeSuper');
|
|
34
|
-
var applicationShell = require('@commercetools-frontend/application-shell');
|
|
35
34
|
var sentry = require('@commercetools-frontend/sentry');
|
|
36
35
|
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
37
36
|
var _sliceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/slice');
|
|
@@ -64,26 +63,26 @@ let CurrentStep$1 = /*#__PURE__*/function (CurrentStep) {
|
|
|
64
63
|
return CurrentStep;
|
|
65
64
|
}({});
|
|
66
65
|
|
|
67
|
-
function ownKeys$
|
|
68
|
-
function _objectSpread$
|
|
66
|
+
function ownKeys$a(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; }
|
|
67
|
+
function _objectSpread$a(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$a(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$a(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
69
68
|
|
|
70
69
|
// TODO: make this resource type specific
|
|
71
70
|
|
|
72
71
|
function reducer(state, action) {
|
|
73
|
-
if (action.type === 'setCurrentStep') return _objectSpread$
|
|
72
|
+
if (action.type === 'setCurrentStep') return _objectSpread$a(_objectSpread$a({}, state), {}, {
|
|
74
73
|
currentStep: action.currentStep,
|
|
75
74
|
progress: 0
|
|
76
75
|
});
|
|
77
|
-
if (action.type === 'setUploadFileResponse') return _objectSpread$
|
|
76
|
+
if (action.type === 'setUploadFileResponse') return _objectSpread$a(_objectSpread$a({}, state), {}, {
|
|
78
77
|
uploadFileResponse: action.uploadFileResponse
|
|
79
78
|
});
|
|
80
|
-
if (action.type === 'setResourceType') return _objectSpread$
|
|
79
|
+
if (action.type === 'setResourceType') return _objectSpread$a(_objectSpread$a({}, state), {}, {
|
|
81
80
|
resourceType: action.resourceType
|
|
82
81
|
});
|
|
83
|
-
if (action.type === 'setContainerKey') return _objectSpread$
|
|
82
|
+
if (action.type === 'setContainerKey') return _objectSpread$a(_objectSpread$a({}, state), {}, {
|
|
84
83
|
containerKey: action.containerKey
|
|
85
84
|
});
|
|
86
|
-
if (action.type === 'cancelImport') return _objectSpread$
|
|
85
|
+
if (action.type === 'cancelImport') return _objectSpread$a(_objectSpread$a({}, state), {}, {
|
|
87
86
|
currentStep: CurrentStep$1.Upload,
|
|
88
87
|
containerKey: undefined,
|
|
89
88
|
jobId: undefined,
|
|
@@ -95,7 +94,7 @@ function reducer(state, action) {
|
|
|
95
94
|
validationProcessed: undefined,
|
|
96
95
|
isValidating: false
|
|
97
96
|
});
|
|
98
|
-
if (action.type === 'uploadNewFile') return _objectSpread$
|
|
97
|
+
if (action.type === 'uploadNewFile') return _objectSpread$a(_objectSpread$a({}, state), {}, {
|
|
99
98
|
currentStep: CurrentStep$1.Upload,
|
|
100
99
|
containerKey: undefined,
|
|
101
100
|
jobId: undefined,
|
|
@@ -108,37 +107,37 @@ function reducer(state, action) {
|
|
|
108
107
|
isValidating: false
|
|
109
108
|
});
|
|
110
109
|
if (action.type === 'setDroppedFile') {
|
|
111
|
-
return _objectSpread$
|
|
110
|
+
return _objectSpread$a(_objectSpread$a({}, state), {}, {
|
|
112
111
|
droppedFile: action.droppedFile
|
|
113
112
|
});
|
|
114
113
|
}
|
|
115
114
|
if (action.type === 'setFileUploadErrors') {
|
|
116
|
-
return _objectSpread$
|
|
115
|
+
return _objectSpread$a(_objectSpread$a({}, state), {}, {
|
|
117
116
|
fileUploadErrors: action.fileUploadErrors
|
|
118
117
|
});
|
|
119
118
|
}
|
|
120
119
|
if (action.type === 'setAbortController') {
|
|
121
|
-
return _objectSpread$
|
|
120
|
+
return _objectSpread$a(_objectSpread$a({}, state), {}, {
|
|
122
121
|
abortController: action.abortController
|
|
123
122
|
});
|
|
124
123
|
}
|
|
125
124
|
if (action.type === 'setProgress') {
|
|
126
|
-
return _objectSpread$
|
|
125
|
+
return _objectSpread$a(_objectSpread$a({}, state), {}, {
|
|
127
126
|
progress: action.progress
|
|
128
127
|
});
|
|
129
128
|
}
|
|
130
129
|
if (action.type === 'setUploadSettings') {
|
|
131
|
-
return _objectSpread$
|
|
132
|
-
settings: _objectSpread$
|
|
130
|
+
return _objectSpread$a(_objectSpread$a({}, state), {}, {
|
|
131
|
+
settings: _objectSpread$a(_objectSpread$a({}, state.settings), action.settings)
|
|
133
132
|
});
|
|
134
133
|
}
|
|
135
134
|
if (action.type === 'setJobId') {
|
|
136
|
-
return _objectSpread$
|
|
135
|
+
return _objectSpread$a(_objectSpread$a({}, state), {}, {
|
|
137
136
|
jobId: action.jobId
|
|
138
137
|
});
|
|
139
138
|
}
|
|
140
139
|
if (action.type === 'setValidationProgress') {
|
|
141
|
-
return _objectSpread$
|
|
140
|
+
return _objectSpread$a(_objectSpread$a({}, state), {}, {
|
|
142
141
|
validationProcessed: action.validationProcessed,
|
|
143
142
|
isValidating: action.isValidating
|
|
144
143
|
});
|
|
@@ -206,8 +205,8 @@ const initialActions = {
|
|
|
206
205
|
}
|
|
207
206
|
};
|
|
208
207
|
|
|
209
|
-
function ownKeys$
|
|
210
|
-
function _objectSpread$
|
|
208
|
+
function ownKeys$9(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; }
|
|
209
|
+
function _objectSpread$9(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$9(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$9(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
211
210
|
const ImportResourcesContext = /*#__PURE__*/React__default["default"].createContext({
|
|
212
211
|
state: initialState,
|
|
213
212
|
resourceTypes: [],
|
|
@@ -220,7 +219,7 @@ const ImportResourcesProvider = props => {
|
|
|
220
219
|
projectKey: context.project?.key
|
|
221
220
|
})),
|
|
222
221
|
projectKey = _useApplicationContex.projectKey;
|
|
223
|
-
const _React$useReducer = React__default["default"].useReducer(reducer, _objectSpread$
|
|
222
|
+
const _React$useReducer = React__default["default"].useReducer(reducer, _objectSpread$9(_objectSpread$9({}, initialState), {}, {
|
|
224
223
|
resourceType: props.resourceTypes[0]
|
|
225
224
|
})),
|
|
226
225
|
_React$useReducer2 = _slicedToArray(_React$useReducer, 2),
|
|
@@ -916,44 +915,6 @@ function resourceTypeToPluralMessage(resourceType) {
|
|
|
916
915
|
return message;
|
|
917
916
|
}
|
|
918
917
|
|
|
919
|
-
const INITIAL_COLUMN_DISPLAY_COUNT = 8;
|
|
920
|
-
|
|
921
|
-
const PERMISSIONS = {
|
|
922
|
-
// Categories
|
|
923
|
-
ManageCategories: 'ManageCategories',
|
|
924
|
-
ViewCategories: 'ViewCategories',
|
|
925
|
-
// Products
|
|
926
|
-
ManageProducts: 'ManageProducts',
|
|
927
|
-
ViewProducts: 'ViewProducts',
|
|
928
|
-
// ProductTypes
|
|
929
|
-
ManageProductTypes: 'ManageProductTypes',
|
|
930
|
-
ViewProductTypes: 'ViewProductTypes',
|
|
931
|
-
// DiscountCodes
|
|
932
|
-
ManageDiscountCodes: 'ManageDiscountCodes',
|
|
933
|
-
ViewDiscountCodes: 'ViewDiscountCodes',
|
|
934
|
-
// Customers
|
|
935
|
-
ManageCustomers: 'ManageCustomers',
|
|
936
|
-
ViewCustomers: 'ViewCustomers',
|
|
937
|
-
// Orders
|
|
938
|
-
ManageOrders: 'ManageOrders',
|
|
939
|
-
ViewOrders: 'ViewOrders',
|
|
940
|
-
// KeyValueDocuments
|
|
941
|
-
ManageKeyValueDocuments: 'ManageKeyValueDocuments',
|
|
942
|
-
ViewKeyValueDocuments: 'ViewKeyValueDocuments',
|
|
943
|
-
// BusinessUnits
|
|
944
|
-
ManageBusinessUnits: 'ManageBusinessUnits',
|
|
945
|
-
ViewBusinessUnits: 'ViewBusinessUnits'
|
|
946
|
-
};
|
|
947
|
-
|
|
948
|
-
function ownKeys$9(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; }
|
|
949
|
-
function _objectSpread$9(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$9(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$9(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
950
|
-
const FILE_IMPORT_JOB_FLOW = 'fileImportJobFlow';
|
|
951
|
-
const DEFAULT_SHORT_LIVED_FLAGS = {
|
|
952
|
-
[FILE_IMPORT_JOB_FLOW]: false
|
|
953
|
-
};
|
|
954
|
-
const DEFAULT_LONG_LIVED_FLAGS = {};
|
|
955
|
-
_objectSpread$9(_objectSpread$9({}, DEFAULT_SHORT_LIVED_FLAGS), DEFAULT_LONG_LIVED_FLAGS);
|
|
956
|
-
|
|
957
918
|
function ownKeys$8(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; }
|
|
958
919
|
function _objectSpread$8(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$8(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$8(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
959
920
|
const useUpload = () => {
|
|
@@ -966,16 +927,12 @@ const useUpload = () => {
|
|
|
966
927
|
state = _useImportResourcesCo.state,
|
|
967
928
|
actions = _useImportResourcesCo.actions;
|
|
968
929
|
const showNotification = actionsGlobal.useShowNotification();
|
|
969
|
-
const isFileImportJobFlowEnabled = applicationShell.useFeatureToggle(FILE_IMPORT_JOB_FLOW);
|
|
970
930
|
const _useFileUpload = operations.useFileUpload({
|
|
971
|
-
projectKey: projectKey
|
|
972
|
-
useJobBasedFlow: isFileImportJobFlowEnabled
|
|
931
|
+
projectKey: projectKey
|
|
973
932
|
}),
|
|
974
933
|
upload = _useFileUpload.upload;
|
|
975
934
|
const isFileValid = async file => {
|
|
976
935
|
const errors = [];
|
|
977
|
-
const maxFileSizeMB = isFileImportJobFlowEnabled ? operations.IMPORT_MAX_FILE_SIZE_MB : operations.IMPORT_LEGACY_MAX_FILE_SIZE_MB;
|
|
978
|
-
const maxItemCount = isFileImportJobFlowEnabled ? operations.IMPORT_MAX_ITEM_COUNT : operations.IMPORT_LEGACY_MAX_ROW_COUNT;
|
|
979
936
|
const isDelimiterValid = await operations.validateDelimiter(file, operations.COLUMN_DELIMITERS);
|
|
980
937
|
if (!isDelimiterValid) errors.push({
|
|
981
938
|
title: intl.formatMessage(messages$5.wrongSeparatorTitle),
|
|
@@ -988,16 +945,16 @@ const useUpload = () => {
|
|
|
988
945
|
title: intl.formatMessage(messages$5.dropAreaNotEnoughRowsTitle),
|
|
989
946
|
description: intl.formatMessage(messages$5.dropAreaNotEnoughRowsDescription)
|
|
990
947
|
});
|
|
991
|
-
if (state.resourceType && file.size > operations.toBytes(
|
|
948
|
+
if (state.resourceType && file.size > operations.toBytes(operations.IMPORT_MAX_FILE_SIZE_MB)) errors.push({
|
|
992
949
|
title: intl.formatMessage(messages$5.fileSizeExceededTitle),
|
|
993
950
|
description: intl.formatMessage(messages$5.fileSizeExceededDescription, {
|
|
994
|
-
fileSizeLimit: intl.formatNumber(
|
|
951
|
+
fileSizeLimit: intl.formatNumber(operations.IMPORT_MAX_FILE_SIZE_MB)
|
|
995
952
|
})
|
|
996
953
|
});
|
|
997
|
-
if (state.resourceType && rowCount >
|
|
954
|
+
if (state.resourceType && rowCount > operations.IMPORT_MAX_ITEM_COUNT) errors.push({
|
|
998
955
|
title: intl.formatMessage(messages$5.rowLimitExceededTitle),
|
|
999
956
|
description: intl.formatMessage(messages$5.rowLimitExceededDescription, {
|
|
1000
|
-
rowLimit: intl.formatNumber(
|
|
957
|
+
rowLimit: intl.formatNumber(operations.IMPORT_MAX_ITEM_COUNT)
|
|
1001
958
|
})
|
|
1002
959
|
});
|
|
1003
960
|
if (errors.length > 0) {
|
|
@@ -1149,6 +1106,35 @@ const useUpload = () => {
|
|
|
1149
1106
|
};
|
|
1150
1107
|
};
|
|
1151
1108
|
|
|
1109
|
+
const INITIAL_COLUMN_DISPLAY_COUNT = 8;
|
|
1110
|
+
|
|
1111
|
+
const PERMISSIONS = {
|
|
1112
|
+
// Categories
|
|
1113
|
+
ManageCategories: 'ManageCategories',
|
|
1114
|
+
ViewCategories: 'ViewCategories',
|
|
1115
|
+
// Products
|
|
1116
|
+
ManageProducts: 'ManageProducts',
|
|
1117
|
+
ViewProducts: 'ViewProducts',
|
|
1118
|
+
// ProductTypes
|
|
1119
|
+
ManageProductTypes: 'ManageProductTypes',
|
|
1120
|
+
ViewProductTypes: 'ViewProductTypes',
|
|
1121
|
+
// DiscountCodes
|
|
1122
|
+
ManageDiscountCodes: 'ManageDiscountCodes',
|
|
1123
|
+
ViewDiscountCodes: 'ViewDiscountCodes',
|
|
1124
|
+
// Customers
|
|
1125
|
+
ManageCustomers: 'ManageCustomers',
|
|
1126
|
+
ViewCustomers: 'ViewCustomers',
|
|
1127
|
+
// Orders
|
|
1128
|
+
ManageOrders: 'ManageOrders',
|
|
1129
|
+
ViewOrders: 'ViewOrders',
|
|
1130
|
+
// KeyValueDocuments
|
|
1131
|
+
ManageKeyValueDocuments: 'ManageKeyValueDocuments',
|
|
1132
|
+
ViewKeyValueDocuments: 'ViewKeyValueDocuments',
|
|
1133
|
+
// BusinessUnits
|
|
1134
|
+
ManageBusinessUnits: 'ManageBusinessUnits',
|
|
1135
|
+
ViewBusinessUnits: 'ViewBusinessUnits'
|
|
1136
|
+
};
|
|
1137
|
+
|
|
1152
1138
|
const useImportPermission = () => {
|
|
1153
1139
|
const _useApplicationContex = applicationShellConnectors.useApplicationContext(applicationContext => ({
|
|
1154
1140
|
actionRights: applicationContext.actionRights?.products
|
|
@@ -2197,16 +2183,13 @@ const Instructions = () => {
|
|
|
2197
2183
|
const intl = reactIntl.useIntl();
|
|
2198
2184
|
const _useImportResourcesCo = useImportResourcesContext(),
|
|
2199
2185
|
state = _useImportResourcesCo.state;
|
|
2200
|
-
const isFileImportJobFlowEnabled = applicationShell.useFeatureToggle(FILE_IMPORT_JOB_FLOW);
|
|
2201
2186
|
const templateLink = operations.RESOURCE_TYPE_TEMPLATE_DOWNLOAD_LINKS[state.resourceType];
|
|
2202
2187
|
const documentationLink = operations.RESOURCE_TYPE_DOCUMENTATION_LINKS[state.resourceType];
|
|
2203
|
-
const maxFileSize = isFileImportJobFlowEnabled ? operations.IMPORT_MAX_FILE_SIZE_MB : operations.IMPORT_LEGACY_MAX_FILE_SIZE_MB;
|
|
2204
|
-
const maxItemCount = isFileImportJobFlowEnabled ? operations.IMPORT_MAX_ITEM_COUNT : operations.IMPORT_LEGACY_MAX_ROW_COUNT;
|
|
2205
2188
|
return jsxRuntime.jsx(uiKit.Text.Body, {
|
|
2206
2189
|
intlMessage: _objectSpread$1(_objectSpread$1({}, messages.fileUploadInstructions), {}, {
|
|
2207
2190
|
values: {
|
|
2208
|
-
fileSize: intl.formatNumber(
|
|
2209
|
-
rowLimit: intl.formatNumber(
|
|
2191
|
+
fileSize: intl.formatNumber(operations.IMPORT_MAX_FILE_SIZE_MB),
|
|
2192
|
+
rowLimit: intl.formatNumber(operations.IMPORT_MAX_ITEM_COUNT),
|
|
2210
2193
|
csvTemplateLink: msg => jsxRuntime.jsx(uiKit.Link, {
|
|
2211
2194
|
tone: "secondary",
|
|
2212
2195
|
isExternal: true,
|
|
@@ -31,7 +31,6 @@ var _possibleConstructorReturn = require('@babel/runtime-corejs3/helpers/possibl
|
|
|
31
31
|
var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
|
|
32
32
|
var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
|
|
33
33
|
var _wrapNativeSuper = require('@babel/runtime-corejs3/helpers/wrapNativeSuper');
|
|
34
|
-
var applicationShell = require('@commercetools-frontend/application-shell');
|
|
35
34
|
var sentry = require('@commercetools-frontend/sentry');
|
|
36
35
|
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
37
36
|
var _sliceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/slice');
|
|
@@ -64,26 +63,26 @@ let CurrentStep$1 = /*#__PURE__*/function (CurrentStep) {
|
|
|
64
63
|
return CurrentStep;
|
|
65
64
|
}({});
|
|
66
65
|
|
|
67
|
-
function ownKeys$
|
|
68
|
-
function _objectSpread$
|
|
66
|
+
function ownKeys$a(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; }
|
|
67
|
+
function _objectSpread$a(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$a(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$a(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
69
68
|
|
|
70
69
|
// TODO: make this resource type specific
|
|
71
70
|
|
|
72
71
|
function reducer(state, action) {
|
|
73
|
-
if (action.type === 'setCurrentStep') return _objectSpread$
|
|
72
|
+
if (action.type === 'setCurrentStep') return _objectSpread$a(_objectSpread$a({}, state), {}, {
|
|
74
73
|
currentStep: action.currentStep,
|
|
75
74
|
progress: 0
|
|
76
75
|
});
|
|
77
|
-
if (action.type === 'setUploadFileResponse') return _objectSpread$
|
|
76
|
+
if (action.type === 'setUploadFileResponse') return _objectSpread$a(_objectSpread$a({}, state), {}, {
|
|
78
77
|
uploadFileResponse: action.uploadFileResponse
|
|
79
78
|
});
|
|
80
|
-
if (action.type === 'setResourceType') return _objectSpread$
|
|
79
|
+
if (action.type === 'setResourceType') return _objectSpread$a(_objectSpread$a({}, state), {}, {
|
|
81
80
|
resourceType: action.resourceType
|
|
82
81
|
});
|
|
83
|
-
if (action.type === 'setContainerKey') return _objectSpread$
|
|
82
|
+
if (action.type === 'setContainerKey') return _objectSpread$a(_objectSpread$a({}, state), {}, {
|
|
84
83
|
containerKey: action.containerKey
|
|
85
84
|
});
|
|
86
|
-
if (action.type === 'cancelImport') return _objectSpread$
|
|
85
|
+
if (action.type === 'cancelImport') return _objectSpread$a(_objectSpread$a({}, state), {}, {
|
|
87
86
|
currentStep: CurrentStep$1.Upload,
|
|
88
87
|
containerKey: undefined,
|
|
89
88
|
jobId: undefined,
|
|
@@ -95,7 +94,7 @@ function reducer(state, action) {
|
|
|
95
94
|
validationProcessed: undefined,
|
|
96
95
|
isValidating: false
|
|
97
96
|
});
|
|
98
|
-
if (action.type === 'uploadNewFile') return _objectSpread$
|
|
97
|
+
if (action.type === 'uploadNewFile') return _objectSpread$a(_objectSpread$a({}, state), {}, {
|
|
99
98
|
currentStep: CurrentStep$1.Upload,
|
|
100
99
|
containerKey: undefined,
|
|
101
100
|
jobId: undefined,
|
|
@@ -108,37 +107,37 @@ function reducer(state, action) {
|
|
|
108
107
|
isValidating: false
|
|
109
108
|
});
|
|
110
109
|
if (action.type === 'setDroppedFile') {
|
|
111
|
-
return _objectSpread$
|
|
110
|
+
return _objectSpread$a(_objectSpread$a({}, state), {}, {
|
|
112
111
|
droppedFile: action.droppedFile
|
|
113
112
|
});
|
|
114
113
|
}
|
|
115
114
|
if (action.type === 'setFileUploadErrors') {
|
|
116
|
-
return _objectSpread$
|
|
115
|
+
return _objectSpread$a(_objectSpread$a({}, state), {}, {
|
|
117
116
|
fileUploadErrors: action.fileUploadErrors
|
|
118
117
|
});
|
|
119
118
|
}
|
|
120
119
|
if (action.type === 'setAbortController') {
|
|
121
|
-
return _objectSpread$
|
|
120
|
+
return _objectSpread$a(_objectSpread$a({}, state), {}, {
|
|
122
121
|
abortController: action.abortController
|
|
123
122
|
});
|
|
124
123
|
}
|
|
125
124
|
if (action.type === 'setProgress') {
|
|
126
|
-
return _objectSpread$
|
|
125
|
+
return _objectSpread$a(_objectSpread$a({}, state), {}, {
|
|
127
126
|
progress: action.progress
|
|
128
127
|
});
|
|
129
128
|
}
|
|
130
129
|
if (action.type === 'setUploadSettings') {
|
|
131
|
-
return _objectSpread$
|
|
132
|
-
settings: _objectSpread$
|
|
130
|
+
return _objectSpread$a(_objectSpread$a({}, state), {}, {
|
|
131
|
+
settings: _objectSpread$a(_objectSpread$a({}, state.settings), action.settings)
|
|
133
132
|
});
|
|
134
133
|
}
|
|
135
134
|
if (action.type === 'setJobId') {
|
|
136
|
-
return _objectSpread$
|
|
135
|
+
return _objectSpread$a(_objectSpread$a({}, state), {}, {
|
|
137
136
|
jobId: action.jobId
|
|
138
137
|
});
|
|
139
138
|
}
|
|
140
139
|
if (action.type === 'setValidationProgress') {
|
|
141
|
-
return _objectSpread$
|
|
140
|
+
return _objectSpread$a(_objectSpread$a({}, state), {}, {
|
|
142
141
|
validationProcessed: action.validationProcessed,
|
|
143
142
|
isValidating: action.isValidating
|
|
144
143
|
});
|
|
@@ -206,8 +205,8 @@ const initialActions = {
|
|
|
206
205
|
}
|
|
207
206
|
};
|
|
208
207
|
|
|
209
|
-
function ownKeys$
|
|
210
|
-
function _objectSpread$
|
|
208
|
+
function ownKeys$9(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; }
|
|
209
|
+
function _objectSpread$9(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$9(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$9(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
211
210
|
const ImportResourcesContext = /*#__PURE__*/React__default["default"].createContext({
|
|
212
211
|
state: initialState,
|
|
213
212
|
resourceTypes: [],
|
|
@@ -220,7 +219,7 @@ const ImportResourcesProvider = props => {
|
|
|
220
219
|
projectKey: context.project?.key
|
|
221
220
|
})),
|
|
222
221
|
projectKey = _useApplicationContex.projectKey;
|
|
223
|
-
const _React$useReducer = React__default["default"].useReducer(reducer, _objectSpread$
|
|
222
|
+
const _React$useReducer = React__default["default"].useReducer(reducer, _objectSpread$9(_objectSpread$9({}, initialState), {}, {
|
|
224
223
|
resourceType: props.resourceTypes[0]
|
|
225
224
|
})),
|
|
226
225
|
_React$useReducer2 = _slicedToArray(_React$useReducer, 2),
|
|
@@ -916,44 +915,6 @@ function resourceTypeToPluralMessage(resourceType) {
|
|
|
916
915
|
return message;
|
|
917
916
|
}
|
|
918
917
|
|
|
919
|
-
const INITIAL_COLUMN_DISPLAY_COUNT = 8;
|
|
920
|
-
|
|
921
|
-
const PERMISSIONS = {
|
|
922
|
-
// Categories
|
|
923
|
-
ManageCategories: 'ManageCategories',
|
|
924
|
-
ViewCategories: 'ViewCategories',
|
|
925
|
-
// Products
|
|
926
|
-
ManageProducts: 'ManageProducts',
|
|
927
|
-
ViewProducts: 'ViewProducts',
|
|
928
|
-
// ProductTypes
|
|
929
|
-
ManageProductTypes: 'ManageProductTypes',
|
|
930
|
-
ViewProductTypes: 'ViewProductTypes',
|
|
931
|
-
// DiscountCodes
|
|
932
|
-
ManageDiscountCodes: 'ManageDiscountCodes',
|
|
933
|
-
ViewDiscountCodes: 'ViewDiscountCodes',
|
|
934
|
-
// Customers
|
|
935
|
-
ManageCustomers: 'ManageCustomers',
|
|
936
|
-
ViewCustomers: 'ViewCustomers',
|
|
937
|
-
// Orders
|
|
938
|
-
ManageOrders: 'ManageOrders',
|
|
939
|
-
ViewOrders: 'ViewOrders',
|
|
940
|
-
// KeyValueDocuments
|
|
941
|
-
ManageKeyValueDocuments: 'ManageKeyValueDocuments',
|
|
942
|
-
ViewKeyValueDocuments: 'ViewKeyValueDocuments',
|
|
943
|
-
// BusinessUnits
|
|
944
|
-
ManageBusinessUnits: 'ManageBusinessUnits',
|
|
945
|
-
ViewBusinessUnits: 'ViewBusinessUnits'
|
|
946
|
-
};
|
|
947
|
-
|
|
948
|
-
function ownKeys$9(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; }
|
|
949
|
-
function _objectSpread$9(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$9(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$9(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
950
|
-
const FILE_IMPORT_JOB_FLOW = 'fileImportJobFlow';
|
|
951
|
-
const DEFAULT_SHORT_LIVED_FLAGS = {
|
|
952
|
-
[FILE_IMPORT_JOB_FLOW]: false
|
|
953
|
-
};
|
|
954
|
-
const DEFAULT_LONG_LIVED_FLAGS = {};
|
|
955
|
-
_objectSpread$9(_objectSpread$9({}, DEFAULT_SHORT_LIVED_FLAGS), DEFAULT_LONG_LIVED_FLAGS);
|
|
956
|
-
|
|
957
918
|
function ownKeys$8(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; }
|
|
958
919
|
function _objectSpread$8(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$8(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$8(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
959
920
|
const useUpload = () => {
|
|
@@ -966,16 +927,12 @@ const useUpload = () => {
|
|
|
966
927
|
state = _useImportResourcesCo.state,
|
|
967
928
|
actions = _useImportResourcesCo.actions;
|
|
968
929
|
const showNotification = actionsGlobal.useShowNotification();
|
|
969
|
-
const isFileImportJobFlowEnabled = applicationShell.useFeatureToggle(FILE_IMPORT_JOB_FLOW);
|
|
970
930
|
const _useFileUpload = operations.useFileUpload({
|
|
971
|
-
projectKey: projectKey
|
|
972
|
-
useJobBasedFlow: isFileImportJobFlowEnabled
|
|
931
|
+
projectKey: projectKey
|
|
973
932
|
}),
|
|
974
933
|
upload = _useFileUpload.upload;
|
|
975
934
|
const isFileValid = async file => {
|
|
976
935
|
const errors = [];
|
|
977
|
-
const maxFileSizeMB = isFileImportJobFlowEnabled ? operations.IMPORT_MAX_FILE_SIZE_MB : operations.IMPORT_LEGACY_MAX_FILE_SIZE_MB;
|
|
978
|
-
const maxItemCount = isFileImportJobFlowEnabled ? operations.IMPORT_MAX_ITEM_COUNT : operations.IMPORT_LEGACY_MAX_ROW_COUNT;
|
|
979
936
|
const isDelimiterValid = await operations.validateDelimiter(file, operations.COLUMN_DELIMITERS);
|
|
980
937
|
if (!isDelimiterValid) errors.push({
|
|
981
938
|
title: intl.formatMessage(messages$5.wrongSeparatorTitle),
|
|
@@ -988,16 +945,16 @@ const useUpload = () => {
|
|
|
988
945
|
title: intl.formatMessage(messages$5.dropAreaNotEnoughRowsTitle),
|
|
989
946
|
description: intl.formatMessage(messages$5.dropAreaNotEnoughRowsDescription)
|
|
990
947
|
});
|
|
991
|
-
if (state.resourceType && file.size > operations.toBytes(
|
|
948
|
+
if (state.resourceType && file.size > operations.toBytes(operations.IMPORT_MAX_FILE_SIZE_MB)) errors.push({
|
|
992
949
|
title: intl.formatMessage(messages$5.fileSizeExceededTitle),
|
|
993
950
|
description: intl.formatMessage(messages$5.fileSizeExceededDescription, {
|
|
994
|
-
fileSizeLimit: intl.formatNumber(
|
|
951
|
+
fileSizeLimit: intl.formatNumber(operations.IMPORT_MAX_FILE_SIZE_MB)
|
|
995
952
|
})
|
|
996
953
|
});
|
|
997
|
-
if (state.resourceType && rowCount >
|
|
954
|
+
if (state.resourceType && rowCount > operations.IMPORT_MAX_ITEM_COUNT) errors.push({
|
|
998
955
|
title: intl.formatMessage(messages$5.rowLimitExceededTitle),
|
|
999
956
|
description: intl.formatMessage(messages$5.rowLimitExceededDescription, {
|
|
1000
|
-
rowLimit: intl.formatNumber(
|
|
957
|
+
rowLimit: intl.formatNumber(operations.IMPORT_MAX_ITEM_COUNT)
|
|
1001
958
|
})
|
|
1002
959
|
});
|
|
1003
960
|
if (errors.length > 0) {
|
|
@@ -1149,6 +1106,35 @@ const useUpload = () => {
|
|
|
1149
1106
|
};
|
|
1150
1107
|
};
|
|
1151
1108
|
|
|
1109
|
+
const INITIAL_COLUMN_DISPLAY_COUNT = 8;
|
|
1110
|
+
|
|
1111
|
+
const PERMISSIONS = {
|
|
1112
|
+
// Categories
|
|
1113
|
+
ManageCategories: 'ManageCategories',
|
|
1114
|
+
ViewCategories: 'ViewCategories',
|
|
1115
|
+
// Products
|
|
1116
|
+
ManageProducts: 'ManageProducts',
|
|
1117
|
+
ViewProducts: 'ViewProducts',
|
|
1118
|
+
// ProductTypes
|
|
1119
|
+
ManageProductTypes: 'ManageProductTypes',
|
|
1120
|
+
ViewProductTypes: 'ViewProductTypes',
|
|
1121
|
+
// DiscountCodes
|
|
1122
|
+
ManageDiscountCodes: 'ManageDiscountCodes',
|
|
1123
|
+
ViewDiscountCodes: 'ViewDiscountCodes',
|
|
1124
|
+
// Customers
|
|
1125
|
+
ManageCustomers: 'ManageCustomers',
|
|
1126
|
+
ViewCustomers: 'ViewCustomers',
|
|
1127
|
+
// Orders
|
|
1128
|
+
ManageOrders: 'ManageOrders',
|
|
1129
|
+
ViewOrders: 'ViewOrders',
|
|
1130
|
+
// KeyValueDocuments
|
|
1131
|
+
ManageKeyValueDocuments: 'ManageKeyValueDocuments',
|
|
1132
|
+
ViewKeyValueDocuments: 'ViewKeyValueDocuments',
|
|
1133
|
+
// BusinessUnits
|
|
1134
|
+
ManageBusinessUnits: 'ManageBusinessUnits',
|
|
1135
|
+
ViewBusinessUnits: 'ViewBusinessUnits'
|
|
1136
|
+
};
|
|
1137
|
+
|
|
1152
1138
|
const useImportPermission = () => {
|
|
1153
1139
|
const _useApplicationContex = applicationShellConnectors.useApplicationContext(applicationContext => ({
|
|
1154
1140
|
actionRights: applicationContext.actionRights?.products
|
|
@@ -2173,16 +2159,13 @@ const Instructions = () => {
|
|
|
2173
2159
|
const intl = reactIntl.useIntl();
|
|
2174
2160
|
const _useImportResourcesCo = useImportResourcesContext(),
|
|
2175
2161
|
state = _useImportResourcesCo.state;
|
|
2176
|
-
const isFileImportJobFlowEnabled = applicationShell.useFeatureToggle(FILE_IMPORT_JOB_FLOW);
|
|
2177
2162
|
const templateLink = operations.RESOURCE_TYPE_TEMPLATE_DOWNLOAD_LINKS[state.resourceType];
|
|
2178
2163
|
const documentationLink = operations.RESOURCE_TYPE_DOCUMENTATION_LINKS[state.resourceType];
|
|
2179
|
-
const maxFileSize = isFileImportJobFlowEnabled ? operations.IMPORT_MAX_FILE_SIZE_MB : operations.IMPORT_LEGACY_MAX_FILE_SIZE_MB;
|
|
2180
|
-
const maxItemCount = isFileImportJobFlowEnabled ? operations.IMPORT_MAX_ITEM_COUNT : operations.IMPORT_LEGACY_MAX_ROW_COUNT;
|
|
2181
2164
|
return jsxRuntime.jsx(uiKit.Text.Body, {
|
|
2182
2165
|
intlMessage: _objectSpread$1(_objectSpread$1({}, messages.fileUploadInstructions), {}, {
|
|
2183
2166
|
values: {
|
|
2184
|
-
fileSize: intl.formatNumber(
|
|
2185
|
-
rowLimit: intl.formatNumber(
|
|
2167
|
+
fileSize: intl.formatNumber(operations.IMPORT_MAX_FILE_SIZE_MB),
|
|
2168
|
+
rowLimit: intl.formatNumber(operations.IMPORT_MAX_ITEM_COUNT),
|
|
2186
2169
|
csvTemplateLink: msg => jsxRuntime.jsx(uiKit.Link, {
|
|
2187
2170
|
tone: "secondary",
|
|
2188
2171
|
isExternal: true,
|
|
@@ -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, isAbortError, HttpError, formatKeys, PollingTimeoutError, isError,
|
|
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';
|
|
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';
|
|
@@ -27,7 +27,6 @@ import _possibleConstructorReturn from '@babel/runtime-corejs3/helpers/esm/possi
|
|
|
27
27
|
import _getPrototypeOf from '@babel/runtime-corejs3/helpers/esm/getPrototypeOf';
|
|
28
28
|
import _inherits from '@babel/runtime-corejs3/helpers/esm/inherits';
|
|
29
29
|
import _wrapNativeSuper from '@babel/runtime-corejs3/helpers/esm/wrapNativeSuper';
|
|
30
|
-
import { useFeatureToggle } from '@commercetools-frontend/application-shell';
|
|
31
30
|
import { reportErrorToSentry } from '@commercetools-frontend/sentry';
|
|
32
31
|
import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/map';
|
|
33
32
|
import _sliceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/slice';
|
|
@@ -43,26 +42,26 @@ let CurrentStep$1 = /*#__PURE__*/function (CurrentStep) {
|
|
|
43
42
|
return CurrentStep;
|
|
44
43
|
}({});
|
|
45
44
|
|
|
46
|
-
function ownKeys$
|
|
47
|
-
function _objectSpread$
|
|
45
|
+
function ownKeys$a(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
46
|
+
function _objectSpread$a(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys$a(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys$a(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
48
47
|
|
|
49
48
|
// TODO: make this resource type specific
|
|
50
49
|
|
|
51
50
|
function reducer(state, action) {
|
|
52
|
-
if (action.type === 'setCurrentStep') return _objectSpread$
|
|
51
|
+
if (action.type === 'setCurrentStep') return _objectSpread$a(_objectSpread$a({}, state), {}, {
|
|
53
52
|
currentStep: action.currentStep,
|
|
54
53
|
progress: 0
|
|
55
54
|
});
|
|
56
|
-
if (action.type === 'setUploadFileResponse') return _objectSpread$
|
|
55
|
+
if (action.type === 'setUploadFileResponse') return _objectSpread$a(_objectSpread$a({}, state), {}, {
|
|
57
56
|
uploadFileResponse: action.uploadFileResponse
|
|
58
57
|
});
|
|
59
|
-
if (action.type === 'setResourceType') return _objectSpread$
|
|
58
|
+
if (action.type === 'setResourceType') return _objectSpread$a(_objectSpread$a({}, state), {}, {
|
|
60
59
|
resourceType: action.resourceType
|
|
61
60
|
});
|
|
62
|
-
if (action.type === 'setContainerKey') return _objectSpread$
|
|
61
|
+
if (action.type === 'setContainerKey') return _objectSpread$a(_objectSpread$a({}, state), {}, {
|
|
63
62
|
containerKey: action.containerKey
|
|
64
63
|
});
|
|
65
|
-
if (action.type === 'cancelImport') return _objectSpread$
|
|
64
|
+
if (action.type === 'cancelImport') return _objectSpread$a(_objectSpread$a({}, state), {}, {
|
|
66
65
|
currentStep: CurrentStep$1.Upload,
|
|
67
66
|
containerKey: undefined,
|
|
68
67
|
jobId: undefined,
|
|
@@ -74,7 +73,7 @@ function reducer(state, action) {
|
|
|
74
73
|
validationProcessed: undefined,
|
|
75
74
|
isValidating: false
|
|
76
75
|
});
|
|
77
|
-
if (action.type === 'uploadNewFile') return _objectSpread$
|
|
76
|
+
if (action.type === 'uploadNewFile') return _objectSpread$a(_objectSpread$a({}, state), {}, {
|
|
78
77
|
currentStep: CurrentStep$1.Upload,
|
|
79
78
|
containerKey: undefined,
|
|
80
79
|
jobId: undefined,
|
|
@@ -87,37 +86,37 @@ function reducer(state, action) {
|
|
|
87
86
|
isValidating: false
|
|
88
87
|
});
|
|
89
88
|
if (action.type === 'setDroppedFile') {
|
|
90
|
-
return _objectSpread$
|
|
89
|
+
return _objectSpread$a(_objectSpread$a({}, state), {}, {
|
|
91
90
|
droppedFile: action.droppedFile
|
|
92
91
|
});
|
|
93
92
|
}
|
|
94
93
|
if (action.type === 'setFileUploadErrors') {
|
|
95
|
-
return _objectSpread$
|
|
94
|
+
return _objectSpread$a(_objectSpread$a({}, state), {}, {
|
|
96
95
|
fileUploadErrors: action.fileUploadErrors
|
|
97
96
|
});
|
|
98
97
|
}
|
|
99
98
|
if (action.type === 'setAbortController') {
|
|
100
|
-
return _objectSpread$
|
|
99
|
+
return _objectSpread$a(_objectSpread$a({}, state), {}, {
|
|
101
100
|
abortController: action.abortController
|
|
102
101
|
});
|
|
103
102
|
}
|
|
104
103
|
if (action.type === 'setProgress') {
|
|
105
|
-
return _objectSpread$
|
|
104
|
+
return _objectSpread$a(_objectSpread$a({}, state), {}, {
|
|
106
105
|
progress: action.progress
|
|
107
106
|
});
|
|
108
107
|
}
|
|
109
108
|
if (action.type === 'setUploadSettings') {
|
|
110
|
-
return _objectSpread$
|
|
111
|
-
settings: _objectSpread$
|
|
109
|
+
return _objectSpread$a(_objectSpread$a({}, state), {}, {
|
|
110
|
+
settings: _objectSpread$a(_objectSpread$a({}, state.settings), action.settings)
|
|
112
111
|
});
|
|
113
112
|
}
|
|
114
113
|
if (action.type === 'setJobId') {
|
|
115
|
-
return _objectSpread$
|
|
114
|
+
return _objectSpread$a(_objectSpread$a({}, state), {}, {
|
|
116
115
|
jobId: action.jobId
|
|
117
116
|
});
|
|
118
117
|
}
|
|
119
118
|
if (action.type === 'setValidationProgress') {
|
|
120
|
-
return _objectSpread$
|
|
119
|
+
return _objectSpread$a(_objectSpread$a({}, state), {}, {
|
|
121
120
|
validationProcessed: action.validationProcessed,
|
|
122
121
|
isValidating: action.isValidating
|
|
123
122
|
});
|
|
@@ -185,8 +184,8 @@ const initialActions = {
|
|
|
185
184
|
}
|
|
186
185
|
};
|
|
187
186
|
|
|
188
|
-
function ownKeys$
|
|
189
|
-
function _objectSpread$
|
|
187
|
+
function ownKeys$9(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
188
|
+
function _objectSpread$9(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys$9(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys$9(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
190
189
|
const ImportResourcesContext = /*#__PURE__*/React.createContext({
|
|
191
190
|
state: initialState,
|
|
192
191
|
resourceTypes: [],
|
|
@@ -199,7 +198,7 @@ const ImportResourcesProvider = props => {
|
|
|
199
198
|
projectKey: context.project?.key
|
|
200
199
|
})),
|
|
201
200
|
projectKey = _useApplicationContex.projectKey;
|
|
202
|
-
const _React$useReducer = React.useReducer(reducer, _objectSpread$
|
|
201
|
+
const _React$useReducer = React.useReducer(reducer, _objectSpread$9(_objectSpread$9({}, initialState), {}, {
|
|
203
202
|
resourceType: props.resourceTypes[0]
|
|
204
203
|
})),
|
|
205
204
|
_React$useReducer2 = _slicedToArray(_React$useReducer, 2),
|
|
@@ -895,44 +894,6 @@ function resourceTypeToPluralMessage(resourceType) {
|
|
|
895
894
|
return message;
|
|
896
895
|
}
|
|
897
896
|
|
|
898
|
-
const INITIAL_COLUMN_DISPLAY_COUNT = 8;
|
|
899
|
-
|
|
900
|
-
const PERMISSIONS = {
|
|
901
|
-
// Categories
|
|
902
|
-
ManageCategories: 'ManageCategories',
|
|
903
|
-
ViewCategories: 'ViewCategories',
|
|
904
|
-
// Products
|
|
905
|
-
ManageProducts: 'ManageProducts',
|
|
906
|
-
ViewProducts: 'ViewProducts',
|
|
907
|
-
// ProductTypes
|
|
908
|
-
ManageProductTypes: 'ManageProductTypes',
|
|
909
|
-
ViewProductTypes: 'ViewProductTypes',
|
|
910
|
-
// DiscountCodes
|
|
911
|
-
ManageDiscountCodes: 'ManageDiscountCodes',
|
|
912
|
-
ViewDiscountCodes: 'ViewDiscountCodes',
|
|
913
|
-
// Customers
|
|
914
|
-
ManageCustomers: 'ManageCustomers',
|
|
915
|
-
ViewCustomers: 'ViewCustomers',
|
|
916
|
-
// Orders
|
|
917
|
-
ManageOrders: 'ManageOrders',
|
|
918
|
-
ViewOrders: 'ViewOrders',
|
|
919
|
-
// KeyValueDocuments
|
|
920
|
-
ManageKeyValueDocuments: 'ManageKeyValueDocuments',
|
|
921
|
-
ViewKeyValueDocuments: 'ViewKeyValueDocuments',
|
|
922
|
-
// BusinessUnits
|
|
923
|
-
ManageBusinessUnits: 'ManageBusinessUnits',
|
|
924
|
-
ViewBusinessUnits: 'ViewBusinessUnits'
|
|
925
|
-
};
|
|
926
|
-
|
|
927
|
-
function ownKeys$9(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
928
|
-
function _objectSpread$9(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys$9(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys$9(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
929
|
-
const FILE_IMPORT_JOB_FLOW = 'fileImportJobFlow';
|
|
930
|
-
const DEFAULT_SHORT_LIVED_FLAGS = {
|
|
931
|
-
[FILE_IMPORT_JOB_FLOW]: false
|
|
932
|
-
};
|
|
933
|
-
const DEFAULT_LONG_LIVED_FLAGS = {};
|
|
934
|
-
_objectSpread$9(_objectSpread$9({}, DEFAULT_SHORT_LIVED_FLAGS), DEFAULT_LONG_LIVED_FLAGS);
|
|
935
|
-
|
|
936
897
|
function ownKeys$8(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
937
898
|
function _objectSpread$8(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys$8(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys$8(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
938
899
|
const useUpload = () => {
|
|
@@ -945,16 +906,12 @@ const useUpload = () => {
|
|
|
945
906
|
state = _useImportResourcesCo.state,
|
|
946
907
|
actions = _useImportResourcesCo.actions;
|
|
947
908
|
const showNotification = useShowNotification();
|
|
948
|
-
const isFileImportJobFlowEnabled = useFeatureToggle(FILE_IMPORT_JOB_FLOW);
|
|
949
909
|
const _useFileUpload = useFileUpload({
|
|
950
|
-
projectKey: projectKey
|
|
951
|
-
useJobBasedFlow: isFileImportJobFlowEnabled
|
|
910
|
+
projectKey: projectKey
|
|
952
911
|
}),
|
|
953
912
|
upload = _useFileUpload.upload;
|
|
954
913
|
const isFileValid = async file => {
|
|
955
914
|
const errors = [];
|
|
956
|
-
const maxFileSizeMB = isFileImportJobFlowEnabled ? IMPORT_MAX_FILE_SIZE_MB : IMPORT_LEGACY_MAX_FILE_SIZE_MB;
|
|
957
|
-
const maxItemCount = isFileImportJobFlowEnabled ? IMPORT_MAX_ITEM_COUNT : IMPORT_LEGACY_MAX_ROW_COUNT;
|
|
958
915
|
const isDelimiterValid = await validateDelimiter(file, COLUMN_DELIMITERS);
|
|
959
916
|
if (!isDelimiterValid) errors.push({
|
|
960
917
|
title: intl.formatMessage(messages$5.wrongSeparatorTitle),
|
|
@@ -967,16 +924,16 @@ const useUpload = () => {
|
|
|
967
924
|
title: intl.formatMessage(messages$5.dropAreaNotEnoughRowsTitle),
|
|
968
925
|
description: intl.formatMessage(messages$5.dropAreaNotEnoughRowsDescription)
|
|
969
926
|
});
|
|
970
|
-
if (state.resourceType && file.size > toBytes(
|
|
927
|
+
if (state.resourceType && file.size > toBytes(IMPORT_MAX_FILE_SIZE_MB)) errors.push({
|
|
971
928
|
title: intl.formatMessage(messages$5.fileSizeExceededTitle),
|
|
972
929
|
description: intl.formatMessage(messages$5.fileSizeExceededDescription, {
|
|
973
|
-
fileSizeLimit: intl.formatNumber(
|
|
930
|
+
fileSizeLimit: intl.formatNumber(IMPORT_MAX_FILE_SIZE_MB)
|
|
974
931
|
})
|
|
975
932
|
});
|
|
976
|
-
if (state.resourceType && rowCount >
|
|
933
|
+
if (state.resourceType && rowCount > IMPORT_MAX_ITEM_COUNT) errors.push({
|
|
977
934
|
title: intl.formatMessage(messages$5.rowLimitExceededTitle),
|
|
978
935
|
description: intl.formatMessage(messages$5.rowLimitExceededDescription, {
|
|
979
|
-
rowLimit: intl.formatNumber(
|
|
936
|
+
rowLimit: intl.formatNumber(IMPORT_MAX_ITEM_COUNT)
|
|
980
937
|
})
|
|
981
938
|
});
|
|
982
939
|
if (errors.length > 0) {
|
|
@@ -1128,6 +1085,35 @@ const useUpload = () => {
|
|
|
1128
1085
|
};
|
|
1129
1086
|
};
|
|
1130
1087
|
|
|
1088
|
+
const INITIAL_COLUMN_DISPLAY_COUNT = 8;
|
|
1089
|
+
|
|
1090
|
+
const PERMISSIONS = {
|
|
1091
|
+
// Categories
|
|
1092
|
+
ManageCategories: 'ManageCategories',
|
|
1093
|
+
ViewCategories: 'ViewCategories',
|
|
1094
|
+
// Products
|
|
1095
|
+
ManageProducts: 'ManageProducts',
|
|
1096
|
+
ViewProducts: 'ViewProducts',
|
|
1097
|
+
// ProductTypes
|
|
1098
|
+
ManageProductTypes: 'ManageProductTypes',
|
|
1099
|
+
ViewProductTypes: 'ViewProductTypes',
|
|
1100
|
+
// DiscountCodes
|
|
1101
|
+
ManageDiscountCodes: 'ManageDiscountCodes',
|
|
1102
|
+
ViewDiscountCodes: 'ViewDiscountCodes',
|
|
1103
|
+
// Customers
|
|
1104
|
+
ManageCustomers: 'ManageCustomers',
|
|
1105
|
+
ViewCustomers: 'ViewCustomers',
|
|
1106
|
+
// Orders
|
|
1107
|
+
ManageOrders: 'ManageOrders',
|
|
1108
|
+
ViewOrders: 'ViewOrders',
|
|
1109
|
+
// KeyValueDocuments
|
|
1110
|
+
ManageKeyValueDocuments: 'ManageKeyValueDocuments',
|
|
1111
|
+
ViewKeyValueDocuments: 'ViewKeyValueDocuments',
|
|
1112
|
+
// BusinessUnits
|
|
1113
|
+
ManageBusinessUnits: 'ManageBusinessUnits',
|
|
1114
|
+
ViewBusinessUnits: 'ViewBusinessUnits'
|
|
1115
|
+
};
|
|
1116
|
+
|
|
1131
1117
|
const useImportPermission = () => {
|
|
1132
1118
|
const _useApplicationContex = useApplicationContext(applicationContext => ({
|
|
1133
1119
|
actionRights: applicationContext.actionRights?.products
|
|
@@ -2176,16 +2162,13 @@ const Instructions = () => {
|
|
|
2176
2162
|
const intl = useIntl();
|
|
2177
2163
|
const _useImportResourcesCo = useImportResourcesContext(),
|
|
2178
2164
|
state = _useImportResourcesCo.state;
|
|
2179
|
-
const isFileImportJobFlowEnabled = useFeatureToggle(FILE_IMPORT_JOB_FLOW);
|
|
2180
2165
|
const templateLink = RESOURCE_TYPE_TEMPLATE_DOWNLOAD_LINKS[state.resourceType];
|
|
2181
2166
|
const documentationLink = RESOURCE_TYPE_DOCUMENTATION_LINKS[state.resourceType];
|
|
2182
|
-
const maxFileSize = isFileImportJobFlowEnabled ? IMPORT_MAX_FILE_SIZE_MB : IMPORT_LEGACY_MAX_FILE_SIZE_MB;
|
|
2183
|
-
const maxItemCount = isFileImportJobFlowEnabled ? IMPORT_MAX_ITEM_COUNT : IMPORT_LEGACY_MAX_ROW_COUNT;
|
|
2184
2167
|
return jsx(Text.Body, {
|
|
2185
2168
|
intlMessage: _objectSpread$1(_objectSpread$1({}, messages.fileUploadInstructions), {}, {
|
|
2186
2169
|
values: {
|
|
2187
|
-
fileSize: intl.formatNumber(
|
|
2188
|
-
rowLimit: intl.formatNumber(
|
|
2170
|
+
fileSize: intl.formatNumber(IMPORT_MAX_FILE_SIZE_MB),
|
|
2171
|
+
rowLimit: intl.formatNumber(IMPORT_MAX_ITEM_COUNT),
|
|
2189
2172
|
csvTemplateLink: msg => jsx(Link, {
|
|
2190
2173
|
tone: "secondary",
|
|
2191
2174
|
isExternal: true,
|
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": "
|
|
4
|
+
"version": "2.0.1",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -31,25 +31,25 @@
|
|
|
31
31
|
"pluralize": "8.0.0",
|
|
32
32
|
"prop-types": "15.8.1",
|
|
33
33
|
"ramda": "^0.32.0",
|
|
34
|
-
"@commercetools-frontend-extensions/operations": "
|
|
34
|
+
"@commercetools-frontend-extensions/operations": "4.0.1"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@commercetools-frontend/actions-global": "27.
|
|
38
|
-
"@commercetools-frontend/application-components": "27.
|
|
39
|
-
"@commercetools-frontend/application-shell": "27.
|
|
40
|
-
"@commercetools-frontend/application-shell-connectors": "27.
|
|
41
|
-
"@commercetools-frontend/constants": "27.
|
|
37
|
+
"@commercetools-frontend/actions-global": "27.5.1",
|
|
38
|
+
"@commercetools-frontend/application-components": "27.5.1",
|
|
39
|
+
"@commercetools-frontend/application-shell": "27.5.1",
|
|
40
|
+
"@commercetools-frontend/application-shell-connectors": "27.5.1",
|
|
41
|
+
"@commercetools-frontend/constants": "27.5.1",
|
|
42
42
|
"@commercetools-frontend/fullstory": "4.0.3",
|
|
43
|
-
"@commercetools-frontend/i18n": "27.
|
|
44
|
-
"@commercetools-frontend/jest-preset-mc-app": "27.
|
|
45
|
-
"@commercetools-frontend/permissions": "27.
|
|
46
|
-
"@commercetools-frontend/sdk": "27.
|
|
47
|
-
"@commercetools-frontend/sentry": "27.
|
|
48
|
-
"@commercetools-frontend/ui-kit": "20.
|
|
49
|
-
"@commercetools-uikit/data-table": "20.
|
|
50
|
-
"@commercetools-uikit/design-system": "20.
|
|
51
|
-
"@commercetools-uikit/icons": "20.
|
|
52
|
-
"@commercetools-uikit/select-field": "20.
|
|
43
|
+
"@commercetools-frontend/i18n": "27.5.1",
|
|
44
|
+
"@commercetools-frontend/jest-preset-mc-app": "27.5.1",
|
|
45
|
+
"@commercetools-frontend/permissions": "27.5.1",
|
|
46
|
+
"@commercetools-frontend/sdk": "27.5.1",
|
|
47
|
+
"@commercetools-frontend/sentry": "27.5.1",
|
|
48
|
+
"@commercetools-frontend/ui-kit": "20.5.0",
|
|
49
|
+
"@commercetools-uikit/data-table": "20.5.0",
|
|
50
|
+
"@commercetools-uikit/design-system": "20.5.0",
|
|
51
|
+
"@commercetools-uikit/icons": "20.5.0",
|
|
52
|
+
"@commercetools-uikit/select-field": "20.5.0",
|
|
53
53
|
"@preconstruct/cli": "2.8.12",
|
|
54
54
|
"@types/jest": "30.0.0",
|
|
55
55
|
"@types/lodash.truncate": "^4.4.7",
|