@commercetools-frontend-extensions/import-resources-modal 1.4.2 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{active-drag-drop-area-32d784b6.cjs.dev.js → active-drag-drop-area-41fee9e7.cjs.dev.js} +1 -1
- package/dist/{active-drag-drop-area-df263c55.esm.js → active-drag-drop-area-ba4a3de3.esm.js} +1 -1
- package/dist/{active-drag-drop-area-48b8e854.cjs.prod.js → active-drag-drop-area-f971a15f.cjs.prod.js} +1 -1
- package/dist/commercetools-frontend-extensions-import-resources-modal.cjs.dev.js +1 -1
- package/dist/commercetools-frontend-extensions-import-resources-modal.cjs.prod.js +1 -1
- package/dist/commercetools-frontend-extensions-import-resources-modal.esm.js +1 -1
- package/dist/declarations/src/@types/current-step.d.ts +6 -0
- package/dist/declarations/src/@types/index.d.ts +1 -0
- package/dist/{enabled-drop-area-d08d5874.esm.js → enabled-drop-area-8f86bce2.esm.js} +1 -1
- package/dist/{enabled-drop-area-ffc745c0.cjs.dev.js → enabled-drop-area-c92a8c96.cjs.dev.js} +1 -1
- package/dist/{enabled-drop-area-e432576d.cjs.prod.js → enabled-drop-area-f0ec971a.cjs.prod.js} +1 -1
- package/dist/{file-dropped-area-d4aa7d89.cjs.prod.js → file-dropped-area-369406e5.cjs.prod.js} +1 -1
- package/dist/{file-dropped-area-24e4301e.cjs.dev.js → file-dropped-area-3a4c29f4.cjs.dev.js} +1 -1
- package/dist/{file-dropped-area-db6c4aa8.esm.js → file-dropped-area-6b9d6fed.esm.js} +1 -1
- package/dist/{index-8bf7917d.cjs.prod.js → index-27e1b5f7.cjs.prod.js} +57 -48
- package/dist/{index-b23dddac.esm.js → index-417ba1cb.esm.js} +57 -48
- package/dist/{index-b1c07316.cjs.dev.js → index-98a32d1e.cjs.dev.js} +57 -48
- package/package.json +1 -1
package/dist/{active-drag-drop-area-32d784b6.cjs.dev.js → active-drag-drop-area-41fee9e7.cjs.dev.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var dist_commercetoolsFrontendExtensionsImportResourcesModal = require('./index-
|
|
3
|
+
var dist_commercetoolsFrontendExtensionsImportResourcesModal = require('./index-98a32d1e.cjs.dev.js');
|
|
4
4
|
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
5
5
|
require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
6
6
|
require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
package/dist/{active-drag-drop-area-df263c55.esm.js → active-drag-drop-area-ba4a3de3.esm.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as FileDropped, E as EnabledDropArea } from './index-
|
|
1
|
+
import { F as FileDropped, E as EnabledDropArea } from './index-417ba1cb.esm.js';
|
|
2
2
|
import { jsx } from '@emotion/react/jsx-runtime';
|
|
3
3
|
import '@babel/runtime-corejs3/core-js-stable/object/keys';
|
|
4
4
|
import '@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var dist_commercetoolsFrontendExtensionsImportResourcesModal = require('./index-
|
|
3
|
+
var dist_commercetoolsFrontendExtensionsImportResourcesModal = require('./index-27e1b5f7.cjs.prod.js');
|
|
4
4
|
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
5
5
|
require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
6
6
|
require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var dist_commercetoolsFrontendExtensionsImportResourcesModal = require('./index-
|
|
5
|
+
var dist_commercetoolsFrontendExtensionsImportResourcesModal = require('./index-98a32d1e.cjs.dev.js');
|
|
6
6
|
require('react');
|
|
7
7
|
require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
8
8
|
require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var dist_commercetoolsFrontendExtensionsImportResourcesModal = require('./index-
|
|
5
|
+
var dist_commercetoolsFrontendExtensionsImportResourcesModal = require('./index-27e1b5f7.cjs.prod.js');
|
|
6
6
|
require('react');
|
|
7
7
|
require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
8
8
|
require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { I as default, a as useImportPermission } from './index-
|
|
1
|
+
export { I as default, a as useImportPermission } from './index-417ba1cb.esm.js';
|
|
2
2
|
import 'react';
|
|
3
3
|
import '@babel/runtime-corejs3/core-js-stable/object/keys';
|
|
4
4
|
import '@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols';
|
|
@@ -9,7 +9,7 @@ import _Object$defineProperty from '@babel/runtime-corejs3/core-js-stable/object
|
|
|
9
9
|
import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
|
|
10
10
|
import 'react';
|
|
11
11
|
import { Spacings, Text, Link } from '@commercetools-frontend/ui-kit';
|
|
12
|
-
import { m as messages } from './index-
|
|
12
|
+
import { m as messages } from './index-417ba1cb.esm.js';
|
|
13
13
|
import { jsxs, jsx } from '@emotion/react/jsx-runtime';
|
|
14
14
|
import '@babel/runtime-corejs3/core-js-stable/instance/every';
|
|
15
15
|
import 'react-intl';
|
package/dist/{enabled-drop-area-ffc745c0.cjs.dev.js → enabled-drop-area-c92a8c96.cjs.dev.js}
RENAMED
|
@@ -11,7 +11,7 @@ var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/obje
|
|
|
11
11
|
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
12
12
|
require('react');
|
|
13
13
|
var uiKit = require('@commercetools-frontend/ui-kit');
|
|
14
|
-
var dist_commercetoolsFrontendExtensionsImportResourcesModal = require('./index-
|
|
14
|
+
var dist_commercetoolsFrontendExtensionsImportResourcesModal = require('./index-98a32d1e.cjs.dev.js');
|
|
15
15
|
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
16
16
|
require('@babel/runtime-corejs3/core-js-stable/instance/every');
|
|
17
17
|
require('react-intl');
|
package/dist/{enabled-drop-area-e432576d.cjs.prod.js → enabled-drop-area-f0ec971a.cjs.prod.js}
RENAMED
|
@@ -11,7 +11,7 @@ var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/obje
|
|
|
11
11
|
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
12
12
|
require('react');
|
|
13
13
|
var uiKit = require('@commercetools-frontend/ui-kit');
|
|
14
|
-
var dist_commercetoolsFrontendExtensionsImportResourcesModal = require('./index-
|
|
14
|
+
var dist_commercetoolsFrontendExtensionsImportResourcesModal = require('./index-27e1b5f7.cjs.prod.js');
|
|
15
15
|
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
16
16
|
require('@babel/runtime-corejs3/core-js-stable/instance/every');
|
|
17
17
|
require('react-intl');
|
package/dist/{file-dropped-area-d4aa7d89.cjs.prod.js → file-dropped-area-369406e5.cjs.prod.js}
RENAMED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var reactIntl = require('react-intl');
|
|
4
4
|
var uiKit = require('@commercetools-frontend/ui-kit');
|
|
5
|
-
var dist_commercetoolsFrontendExtensionsImportResourcesModal = require('./index-
|
|
5
|
+
var dist_commercetoolsFrontendExtensionsImportResourcesModal = require('./index-27e1b5f7.cjs.prod.js');
|
|
6
6
|
require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
7
7
|
require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
8
8
|
require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
package/dist/{file-dropped-area-24e4301e.cjs.dev.js → file-dropped-area-3a4c29f4.cjs.dev.js}
RENAMED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var reactIntl = require('react-intl');
|
|
4
4
|
var uiKit = require('@commercetools-frontend/ui-kit');
|
|
5
|
-
var dist_commercetoolsFrontendExtensionsImportResourcesModal = require('./index-
|
|
5
|
+
var dist_commercetoolsFrontendExtensionsImportResourcesModal = require('./index-98a32d1e.cjs.dev.js');
|
|
6
6
|
require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
7
7
|
require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
8
8
|
require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useIntl } from 'react-intl';
|
|
2
2
|
import { Spacings, PaperclipIcon, Constraints, Text, SecondaryButton } from '@commercetools-frontend/ui-kit';
|
|
3
|
-
import { u as useImportResourcesContext, m as messages } from './index-
|
|
3
|
+
import { u as useImportResourcesContext, m as messages } from './index-417ba1cb.esm.js';
|
|
4
4
|
import '@babel/runtime-corejs3/core-js-stable/object/keys';
|
|
5
5
|
import '@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols';
|
|
6
6
|
import '@babel/runtime-corejs3/core-js-stable/instance/filter';
|
|
@@ -79,8 +79,46 @@ var _someInstanceProperty__default = /*#__PURE__*/_interopDefault(_someInstanceP
|
|
|
79
79
|
var _styled__default = /*#__PURE__*/_interopDefault(_styled);
|
|
80
80
|
var DataTable__default = /*#__PURE__*/_interopDefault(DataTable);
|
|
81
81
|
|
|
82
|
+
const EnabledResourceType = {
|
|
83
|
+
category: true,
|
|
84
|
+
product: true,
|
|
85
|
+
inventory: true,
|
|
86
|
+
'discount-code': true,
|
|
87
|
+
customer: false,
|
|
88
|
+
order: false,
|
|
89
|
+
'product-type': false
|
|
90
|
+
};
|
|
91
|
+
function isResourceType(maybeResourceType) {
|
|
92
|
+
return typeof maybeResourceType === 'string' && maybeResourceType in EnabledResourceType;
|
|
93
|
+
}
|
|
94
|
+
function assertResourceType(maybeResourceType) {
|
|
95
|
+
if (isResourceType(maybeResourceType)) return;
|
|
96
|
+
throw new Error(`Invalid value: ${maybeResourceType}`);
|
|
97
|
+
}
|
|
98
|
+
function isError(maybeError) {
|
|
99
|
+
if (maybeError instanceof Error) return true;
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
104
|
+
function hasOwnProperty(obj, prop) {
|
|
105
|
+
return typeof obj === 'object' && obj !== null && obj.hasOwnProperty(prop);
|
|
106
|
+
}
|
|
107
|
+
function hasRequiredFields(maybeValidObject, requiredFields) {
|
|
108
|
+
return typeof maybeValidObject === 'object' && maybeValidObject !== null && _everyInstanceProperty__default["default"](requiredFields).call(requiredFields, property => hasOwnProperty(maybeValidObject, property));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
let CurrentStep$1 = /*#__PURE__*/function (CurrentStep) {
|
|
112
|
+
CurrentStep["Upload"] = "upload";
|
|
113
|
+
CurrentStep["Uploading"] = "uploading";
|
|
114
|
+
CurrentStep["UploadResult"] = "upload-result";
|
|
115
|
+
CurrentStep["ImportConfirmationModal"] = "import-confirmation-modal";
|
|
116
|
+
return CurrentStep;
|
|
117
|
+
}({});
|
|
118
|
+
|
|
82
119
|
function ownKeys$i(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; }
|
|
83
120
|
function _objectSpread$i(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$i(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$i(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
121
|
+
|
|
84
122
|
// TODO: make this resource type specific
|
|
85
123
|
|
|
86
124
|
function reducer(state, action) {
|
|
@@ -99,7 +137,7 @@ function reducer(state, action) {
|
|
|
99
137
|
containerKey: action.containerKey
|
|
100
138
|
});
|
|
101
139
|
if (action.type === 'cancelImport') return _objectSpread$i(_objectSpread$i({}, state), {}, {
|
|
102
|
-
currentStep: 1,
|
|
140
|
+
currentStep: CurrentStep$1.Upload,
|
|
103
141
|
containerKey: undefined,
|
|
104
142
|
fileUploadErrors: [],
|
|
105
143
|
uploadFileResponse: undefined,
|
|
@@ -108,7 +146,7 @@ function reducer(state, action) {
|
|
|
108
146
|
progress: 0
|
|
109
147
|
});
|
|
110
148
|
if (action.type === 'uploadNewFile') return _objectSpread$i(_objectSpread$i({}, state), {}, {
|
|
111
|
-
currentStep: 1,
|
|
149
|
+
currentStep: CurrentStep$1.Upload,
|
|
112
150
|
containerKey: undefined,
|
|
113
151
|
fileUploadErrors: [],
|
|
114
152
|
uploadFileResponse: undefined,
|
|
@@ -147,7 +185,7 @@ function getUnknownActionError(actionType) {
|
|
|
147
185
|
return `Unkown type: ${actionType}`;
|
|
148
186
|
}
|
|
149
187
|
const initialState = {
|
|
150
|
-
currentStep: 1,
|
|
188
|
+
currentStep: CurrentStep$1.Upload,
|
|
151
189
|
abortController: new AbortController(),
|
|
152
190
|
dropAreaState: 'disabled',
|
|
153
191
|
uploadFileResponse: undefined,
|
|
@@ -496,35 +534,6 @@ function getProccessFileURL(projectKey, resourceType, containerKey) {
|
|
|
496
534
|
return `/${projectKey}/${pluralize.plural(resourceType)}/import-containers/${containerKey}/process-file`;
|
|
497
535
|
}
|
|
498
536
|
|
|
499
|
-
const EnabledResourceType = {
|
|
500
|
-
category: true,
|
|
501
|
-
product: true,
|
|
502
|
-
inventory: true,
|
|
503
|
-
'discount-code': true,
|
|
504
|
-
customer: false,
|
|
505
|
-
order: false,
|
|
506
|
-
'product-type': false
|
|
507
|
-
};
|
|
508
|
-
function isResourceType(maybeResourceType) {
|
|
509
|
-
return typeof maybeResourceType === 'string' && maybeResourceType in EnabledResourceType;
|
|
510
|
-
}
|
|
511
|
-
function assertResourceType(maybeResourceType) {
|
|
512
|
-
if (isResourceType(maybeResourceType)) return;
|
|
513
|
-
throw new Error(`Invalid value: ${maybeResourceType}`);
|
|
514
|
-
}
|
|
515
|
-
function isError(maybeError) {
|
|
516
|
-
if (maybeError instanceof Error) return true;
|
|
517
|
-
return false;
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
521
|
-
function hasOwnProperty(obj, prop) {
|
|
522
|
-
return typeof obj === 'object' && obj !== null && obj.hasOwnProperty(prop);
|
|
523
|
-
}
|
|
524
|
-
function hasRequiredFields(maybeValidObject, requiredFields) {
|
|
525
|
-
return typeof maybeValidObject === 'object' && maybeValidObject !== null && _everyInstanceProperty__default["default"](requiredFields).call(requiredFields, property => hasOwnProperty(maybeValidObject, property));
|
|
526
|
-
}
|
|
527
|
-
|
|
528
537
|
function uploadFileForImport(_ref) {
|
|
529
538
|
let projectKey = _ref.projectKey,
|
|
530
539
|
containerKey = _ref.containerKey,
|
|
@@ -745,13 +754,13 @@ function getDefaultDropWrapperStyles(_dropAreaState) {
|
|
|
745
754
|
return /*#__PURE__*/react.css("" , "" );
|
|
746
755
|
}
|
|
747
756
|
|
|
748
|
-
var ActiveDragDropArea = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./active-drag-drop-area-
|
|
757
|
+
var ActiveDragDropArea = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./active-drag-drop-area-f971a15f.cjs.prod.js' /* webpackChunkName: "active-drag-drop-area" */); }));
|
|
749
758
|
|
|
750
759
|
var DisabledDropArea = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./disabled-drop-area-99c1fa0b.cjs.prod.js' /* webpackChunkName: "disabled-drop-area" */); }));
|
|
751
760
|
|
|
752
|
-
var EnabledDropArea = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./enabled-drop-area-
|
|
761
|
+
var EnabledDropArea = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./enabled-drop-area-f0ec971a.cjs.prod.js' /* webpackChunkName: "enabled-drop-area" */); }));
|
|
753
762
|
|
|
754
|
-
var FileDropped = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./file-dropped-area-
|
|
763
|
+
var FileDropped = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./file-dropped-area-369406e5.cjs.prod.js' /* webpackChunkName: "filed-dropped-area" */); }));
|
|
755
764
|
|
|
756
765
|
function getDropArea(_ref) {
|
|
757
766
|
let dropAreaState = _ref.dropAreaState,
|
|
@@ -955,7 +964,7 @@ const useUpload = () => {
|
|
|
955
964
|
});
|
|
956
965
|
if (errors.length > 0) {
|
|
957
966
|
actions.setFileUploadErrors(errors);
|
|
958
|
-
actions.setCurrentStep(
|
|
967
|
+
actions.setCurrentStep(CurrentStep$1.UploadResult);
|
|
959
968
|
return false;
|
|
960
969
|
}
|
|
961
970
|
return true;
|
|
@@ -971,7 +980,7 @@ const useUpload = () => {
|
|
|
971
980
|
title: intl.formatMessage(messages$6.missingRequiredField),
|
|
972
981
|
description: intl.formatMessage(messages$6.missingKeyError)
|
|
973
982
|
}]);
|
|
974
|
-
actions.setCurrentStep(
|
|
983
|
+
actions.setCurrentStep(CurrentStep$1.UploadResult);
|
|
975
984
|
} else if (error.errorData?.code === 'MissingCsvFieldIdentifier') {
|
|
976
985
|
const MissingCsvFieldIdentifierError = error.errorData;
|
|
977
986
|
const fieldNames = formatKeys(MissingCsvFieldIdentifierError.rowValue);
|
|
@@ -981,10 +990,10 @@ const useUpload = () => {
|
|
|
981
990
|
fieldNames
|
|
982
991
|
})
|
|
983
992
|
}]);
|
|
984
|
-
actions.setCurrentStep(
|
|
993
|
+
actions.setCurrentStep(CurrentStep$1.UploadResult);
|
|
985
994
|
} else if (error.errorData?.invalid > 0) {
|
|
986
995
|
actions.setUploadFileResponse(error.errorData);
|
|
987
|
-
actions.setCurrentStep(
|
|
996
|
+
actions.setCurrentStep(CurrentStep$1.UploadResult);
|
|
988
997
|
} else {
|
|
989
998
|
actions.cancelImport();
|
|
990
999
|
showNotification({
|
|
@@ -1015,7 +1024,7 @@ const useUpload = () => {
|
|
|
1015
1024
|
if (!projectKey || !state.droppedFile || !state.resourceType) return;
|
|
1016
1025
|
const canUpload = await isFileValid(state.droppedFile);
|
|
1017
1026
|
if (!canUpload) return;
|
|
1018
|
-
actions.setCurrentStep(
|
|
1027
|
+
actions.setCurrentStep(CurrentStep$1.Uploading);
|
|
1019
1028
|
const containerKey = encodeFileNameWithTimestampToContainerKey(state.droppedFile.name);
|
|
1020
1029
|
actions.setContainerKey(containerKey);
|
|
1021
1030
|
try {
|
|
@@ -1041,7 +1050,7 @@ const useUpload = () => {
|
|
|
1041
1050
|
file: state.droppedFile,
|
|
1042
1051
|
onSuccess: fileUploadResponse => {
|
|
1043
1052
|
actions.setUploadFileResponse(fileUploadResponse);
|
|
1044
|
-
actions.setCurrentStep(
|
|
1053
|
+
actions.setCurrentStep(CurrentStep$1.UploadResult);
|
|
1045
1054
|
},
|
|
1046
1055
|
onProgress: progress => {
|
|
1047
1056
|
actions.setProgress(progress);
|
|
@@ -1055,7 +1064,7 @@ const useUpload = () => {
|
|
|
1055
1064
|
} catch (error) {
|
|
1056
1065
|
deleteImportContainer(projectKey, containerKey, asyncDispatch);
|
|
1057
1066
|
handleUploadError(error);
|
|
1058
|
-
actions.setCurrentStep(
|
|
1067
|
+
actions.setCurrentStep(CurrentStep$1.UploadResult);
|
|
1059
1068
|
}
|
|
1060
1069
|
};
|
|
1061
1070
|
return {
|
|
@@ -1708,7 +1717,7 @@ function UploadPreviewModal() {
|
|
|
1708
1717
|
shouldDeleteImportContainer: true
|
|
1709
1718
|
}),
|
|
1710
1719
|
onPrimaryButtonClick: () => {
|
|
1711
|
-
actions.setCurrentStep(
|
|
1720
|
+
actions.setCurrentStep(CurrentStep$1.ImportConfirmationModal);
|
|
1712
1721
|
},
|
|
1713
1722
|
onClose: () => onClose({
|
|
1714
1723
|
shouldDeleteImportContainer: true
|
|
@@ -2017,7 +2026,7 @@ const Uploading = () => {
|
|
|
2017
2026
|
size: "medium",
|
|
2018
2027
|
label: intl.formatMessage(sharedMessages.cancel),
|
|
2019
2028
|
onClick: () => {
|
|
2020
|
-
actions.setCurrentStep(1);
|
|
2029
|
+
actions.setCurrentStep(CurrentStep$1.Upload);
|
|
2021
2030
|
state.abortController.abort();
|
|
2022
2031
|
}
|
|
2023
2032
|
})]
|
|
@@ -2035,10 +2044,10 @@ const CurrentStep = () => {
|
|
|
2035
2044
|
const _useImportResourcesCo = useImportResourcesContext(),
|
|
2036
2045
|
state = _useImportResourcesCo.state;
|
|
2037
2046
|
const steps = {
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2047
|
+
upload: jsxRuntime.jsx(Upload, {}),
|
|
2048
|
+
uploading: jsxRuntime.jsx(Uploading, {}),
|
|
2049
|
+
'upload-result': jsxRuntime.jsx(UploadResult, {}),
|
|
2050
|
+
'import-confirmation-modal': jsxRuntime.jsx(ImportConfirmationModal, {})
|
|
2042
2051
|
};
|
|
2043
2052
|
return steps[state.currentStep] || null;
|
|
2044
2053
|
};
|
|
@@ -50,8 +50,46 @@ import { useIsAuthorized } from '@commercetools-frontend/permissions';
|
|
|
50
50
|
import DataTable from '@commercetools-uikit/data-table';
|
|
51
51
|
import { parseChunkImport, mapLocaleToIntlLocale } from '@commercetools-frontend/i18n';
|
|
52
52
|
|
|
53
|
+
const EnabledResourceType = {
|
|
54
|
+
category: true,
|
|
55
|
+
product: true,
|
|
56
|
+
inventory: true,
|
|
57
|
+
'discount-code': true,
|
|
58
|
+
customer: false,
|
|
59
|
+
order: false,
|
|
60
|
+
'product-type': false
|
|
61
|
+
};
|
|
62
|
+
function isResourceType(maybeResourceType) {
|
|
63
|
+
return typeof maybeResourceType === 'string' && maybeResourceType in EnabledResourceType;
|
|
64
|
+
}
|
|
65
|
+
function assertResourceType(maybeResourceType) {
|
|
66
|
+
if (isResourceType(maybeResourceType)) return;
|
|
67
|
+
throw new Error(`Invalid value: ${maybeResourceType}`);
|
|
68
|
+
}
|
|
69
|
+
function isError(maybeError) {
|
|
70
|
+
if (maybeError instanceof Error) return true;
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
75
|
+
function hasOwnProperty(obj, prop) {
|
|
76
|
+
return typeof obj === 'object' && obj !== null && obj.hasOwnProperty(prop);
|
|
77
|
+
}
|
|
78
|
+
function hasRequiredFields(maybeValidObject, requiredFields) {
|
|
79
|
+
return typeof maybeValidObject === 'object' && maybeValidObject !== null && _everyInstanceProperty(requiredFields).call(requiredFields, property => hasOwnProperty(maybeValidObject, property));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
let CurrentStep$1 = /*#__PURE__*/function (CurrentStep) {
|
|
83
|
+
CurrentStep["Upload"] = "upload";
|
|
84
|
+
CurrentStep["Uploading"] = "uploading";
|
|
85
|
+
CurrentStep["UploadResult"] = "upload-result";
|
|
86
|
+
CurrentStep["ImportConfirmationModal"] = "import-confirmation-modal";
|
|
87
|
+
return CurrentStep;
|
|
88
|
+
}({});
|
|
89
|
+
|
|
53
90
|
function ownKeys$i(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; }
|
|
54
91
|
function _objectSpread$i(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys$i(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys$i(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
92
|
+
|
|
55
93
|
// TODO: make this resource type specific
|
|
56
94
|
|
|
57
95
|
function reducer(state, action) {
|
|
@@ -70,7 +108,7 @@ function reducer(state, action) {
|
|
|
70
108
|
containerKey: action.containerKey
|
|
71
109
|
});
|
|
72
110
|
if (action.type === 'cancelImport') return _objectSpread$i(_objectSpread$i({}, state), {}, {
|
|
73
|
-
currentStep: 1,
|
|
111
|
+
currentStep: CurrentStep$1.Upload,
|
|
74
112
|
containerKey: undefined,
|
|
75
113
|
fileUploadErrors: [],
|
|
76
114
|
uploadFileResponse: undefined,
|
|
@@ -79,7 +117,7 @@ function reducer(state, action) {
|
|
|
79
117
|
progress: 0
|
|
80
118
|
});
|
|
81
119
|
if (action.type === 'uploadNewFile') return _objectSpread$i(_objectSpread$i({}, state), {}, {
|
|
82
|
-
currentStep: 1,
|
|
120
|
+
currentStep: CurrentStep$1.Upload,
|
|
83
121
|
containerKey: undefined,
|
|
84
122
|
fileUploadErrors: [],
|
|
85
123
|
uploadFileResponse: undefined,
|
|
@@ -118,7 +156,7 @@ function getUnknownActionError(actionType) {
|
|
|
118
156
|
return `Unkown type: ${actionType}`;
|
|
119
157
|
}
|
|
120
158
|
const initialState = {
|
|
121
|
-
currentStep: 1,
|
|
159
|
+
currentStep: CurrentStep$1.Upload,
|
|
122
160
|
abortController: new AbortController(),
|
|
123
161
|
dropAreaState: 'disabled',
|
|
124
162
|
uploadFileResponse: undefined,
|
|
@@ -467,35 +505,6 @@ function getProccessFileURL(projectKey, resourceType, containerKey) {
|
|
|
467
505
|
return `/${projectKey}/${plural(resourceType)}/import-containers/${containerKey}/process-file`;
|
|
468
506
|
}
|
|
469
507
|
|
|
470
|
-
const EnabledResourceType = {
|
|
471
|
-
category: true,
|
|
472
|
-
product: true,
|
|
473
|
-
inventory: true,
|
|
474
|
-
'discount-code': true,
|
|
475
|
-
customer: false,
|
|
476
|
-
order: false,
|
|
477
|
-
'product-type': false
|
|
478
|
-
};
|
|
479
|
-
function isResourceType(maybeResourceType) {
|
|
480
|
-
return typeof maybeResourceType === 'string' && maybeResourceType in EnabledResourceType;
|
|
481
|
-
}
|
|
482
|
-
function assertResourceType(maybeResourceType) {
|
|
483
|
-
if (isResourceType(maybeResourceType)) return;
|
|
484
|
-
throw new Error(`Invalid value: ${maybeResourceType}`);
|
|
485
|
-
}
|
|
486
|
-
function isError(maybeError) {
|
|
487
|
-
if (maybeError instanceof Error) return true;
|
|
488
|
-
return false;
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
492
|
-
function hasOwnProperty(obj, prop) {
|
|
493
|
-
return typeof obj === 'object' && obj !== null && obj.hasOwnProperty(prop);
|
|
494
|
-
}
|
|
495
|
-
function hasRequiredFields(maybeValidObject, requiredFields) {
|
|
496
|
-
return typeof maybeValidObject === 'object' && maybeValidObject !== null && _everyInstanceProperty(requiredFields).call(requiredFields, property => hasOwnProperty(maybeValidObject, property));
|
|
497
|
-
}
|
|
498
|
-
|
|
499
508
|
function uploadFileForImport(_ref) {
|
|
500
509
|
let projectKey = _ref.projectKey,
|
|
501
510
|
containerKey = _ref.containerKey,
|
|
@@ -719,13 +728,13 @@ function getDefaultDropWrapperStyles(_dropAreaState) {
|
|
|
719
728
|
return /*#__PURE__*/css(process.env.NODE_ENV === "production" ? "" : ";label:getDefaultDropWrapperStyles;", process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImRyb3AtYXJlYS13cmFwcGVyLnRzeCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUE0QlkiLCJmaWxlIjoiZHJvcC1hcmVhLXdyYXBwZXIudHN4Iiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgdHlwZSBEcm9wem9uZVJvb3RQcm9wcyB9IGZyb20gJ3JlYWN0LWRyb3B6b25lJ1xuaW1wb3J0IHsgY3NzIH0gZnJvbSAnQGVtb3Rpb24vcmVhY3QnXG5pbXBvcnQgc3R5bGVkIGZyb20gJ0BlbW90aW9uL3N0eWxlZCdcbmltcG9ydCB7IHN0eWxlcyB9IGZyb20gJy4vc3R5bGVzJ1xuaW1wb3J0IHsgdHlwZSBEcm9wQXJlYVN0YXRlIH0gZnJvbSAnLi4vLi4vLi4vQHR5cGVzJ1xuXG5pbnRlcmZhY2UgRHJvcFdyYXBwZXJQcm9wcyBleHRlbmRzIERyb3B6b25lUm9vdFByb3BzIHtcbiAgZHJvcEFyZWFTdGF0ZTogRHJvcEFyZWFTdGF0ZVxufVxuZXhwb3J0IGNvbnN0IERyb3BXcmFwcGVyID0gc3R5bGVkLmRpdjxEcm9wV3JhcHBlclByb3BzPmBcbiAgJHtzdHlsZXMuYmFzZX1cbiAgJHsocHJvcHMpID0+IHtcbiAgICBpZiAocHJvcHMuZHJvcEFyZWFTdGF0ZSA9PT0gJ2Rpc2FibGVkJykge1xuICAgICAgcmV0dXJuIHN0eWxlcy5kaXNhYmxlZFxuICAgIH1cbiAgICBpZiAocHJvcHMuZHJvcEFyZWFTdGF0ZSA9PT0gJ3JlYWR5LWZvci1kcm9wJykge1xuICAgICAgcmV0dXJuIHN0eWxlcy5yZWFkeUZvckRyb3BcbiAgICB9XG4gICAgaWYgKHByb3BzLmRyb3BBcmVhU3RhdGUgPT09ICdhY3RpdmUtZHJhZycpIHtcbiAgICAgIHJldHVybiBzdHlsZXMuYWN0aXZlRHJhZ1xuICAgIH1cbiAgICBpZiAocHJvcHMuZHJvcEFyZWFTdGF0ZSA9PT0gJ2ZpbGUtZHJvcHBlZCcpIHtcbiAgICAgIHJldHVybiBzdHlsZXMuZmlsZURyb3BwZWRcbiAgICB9XG4gICAgcmV0dXJuIGdldERlZmF1bHREcm9wV3JhcHBlclN0eWxlcyhwcm9wcy5kcm9wQXJlYVN0YXRlKVxuICB9fVxuYFxuZnVuY3Rpb24gZ2V0RGVmYXVsdERyb3BXcmFwcGVyU3R5bGVzKF9kcm9wQXJlYVN0YXRlOiBuZXZlcikge1xuICByZXR1cm4gY3NzYGBcbn1cbiJdfQ== */");
|
|
720
729
|
}
|
|
721
730
|
|
|
722
|
-
var ActiveDragDropArea = /*#__PURE__*/lazy(() => import('./active-drag-drop-area-
|
|
731
|
+
var ActiveDragDropArea = /*#__PURE__*/lazy(() => import('./active-drag-drop-area-ba4a3de3.esm.js' /* webpackChunkName: "active-drag-drop-area" */));
|
|
723
732
|
|
|
724
733
|
var DisabledDropArea = /*#__PURE__*/lazy(() => import('./disabled-drop-area-2c088477.esm.js' /* webpackChunkName: "disabled-drop-area" */));
|
|
725
734
|
|
|
726
|
-
var EnabledDropArea = /*#__PURE__*/lazy(() => import('./enabled-drop-area-
|
|
735
|
+
var EnabledDropArea = /*#__PURE__*/lazy(() => import('./enabled-drop-area-8f86bce2.esm.js' /* webpackChunkName: "enabled-drop-area" */));
|
|
727
736
|
|
|
728
|
-
var FileDropped = /*#__PURE__*/lazy(() => import('./file-dropped-area-
|
|
737
|
+
var FileDropped = /*#__PURE__*/lazy(() => import('./file-dropped-area-6b9d6fed.esm.js' /* webpackChunkName: "filed-dropped-area" */));
|
|
729
738
|
|
|
730
739
|
function getDropArea(_ref) {
|
|
731
740
|
let dropAreaState = _ref.dropAreaState,
|
|
@@ -929,7 +938,7 @@ const useUpload = () => {
|
|
|
929
938
|
});
|
|
930
939
|
if (errors.length > 0) {
|
|
931
940
|
actions.setFileUploadErrors(errors);
|
|
932
|
-
actions.setCurrentStep(
|
|
941
|
+
actions.setCurrentStep(CurrentStep$1.UploadResult);
|
|
933
942
|
return false;
|
|
934
943
|
}
|
|
935
944
|
return true;
|
|
@@ -945,7 +954,7 @@ const useUpload = () => {
|
|
|
945
954
|
title: intl.formatMessage(messages$6.missingRequiredField),
|
|
946
955
|
description: intl.formatMessage(messages$6.missingKeyError)
|
|
947
956
|
}]);
|
|
948
|
-
actions.setCurrentStep(
|
|
957
|
+
actions.setCurrentStep(CurrentStep$1.UploadResult);
|
|
949
958
|
} else if (error.errorData?.code === 'MissingCsvFieldIdentifier') {
|
|
950
959
|
const MissingCsvFieldIdentifierError = error.errorData;
|
|
951
960
|
const fieldNames = formatKeys(MissingCsvFieldIdentifierError.rowValue);
|
|
@@ -955,10 +964,10 @@ const useUpload = () => {
|
|
|
955
964
|
fieldNames
|
|
956
965
|
})
|
|
957
966
|
}]);
|
|
958
|
-
actions.setCurrentStep(
|
|
967
|
+
actions.setCurrentStep(CurrentStep$1.UploadResult);
|
|
959
968
|
} else if (error.errorData?.invalid > 0) {
|
|
960
969
|
actions.setUploadFileResponse(error.errorData);
|
|
961
|
-
actions.setCurrentStep(
|
|
970
|
+
actions.setCurrentStep(CurrentStep$1.UploadResult);
|
|
962
971
|
} else {
|
|
963
972
|
actions.cancelImport();
|
|
964
973
|
showNotification({
|
|
@@ -989,7 +998,7 @@ const useUpload = () => {
|
|
|
989
998
|
if (!projectKey || !state.droppedFile || !state.resourceType) return;
|
|
990
999
|
const canUpload = await isFileValid(state.droppedFile);
|
|
991
1000
|
if (!canUpload) return;
|
|
992
|
-
actions.setCurrentStep(
|
|
1001
|
+
actions.setCurrentStep(CurrentStep$1.Uploading);
|
|
993
1002
|
const containerKey = encodeFileNameWithTimestampToContainerKey(state.droppedFile.name);
|
|
994
1003
|
actions.setContainerKey(containerKey);
|
|
995
1004
|
try {
|
|
@@ -1015,7 +1024,7 @@ const useUpload = () => {
|
|
|
1015
1024
|
file: state.droppedFile,
|
|
1016
1025
|
onSuccess: fileUploadResponse => {
|
|
1017
1026
|
actions.setUploadFileResponse(fileUploadResponse);
|
|
1018
|
-
actions.setCurrentStep(
|
|
1027
|
+
actions.setCurrentStep(CurrentStep$1.UploadResult);
|
|
1019
1028
|
},
|
|
1020
1029
|
onProgress: progress => {
|
|
1021
1030
|
actions.setProgress(progress);
|
|
@@ -1029,7 +1038,7 @@ const useUpload = () => {
|
|
|
1029
1038
|
} catch (error) {
|
|
1030
1039
|
deleteImportContainer(projectKey, containerKey, asyncDispatch);
|
|
1031
1040
|
handleUploadError(error);
|
|
1032
|
-
actions.setCurrentStep(
|
|
1041
|
+
actions.setCurrentStep(CurrentStep$1.UploadResult);
|
|
1033
1042
|
}
|
|
1034
1043
|
};
|
|
1035
1044
|
return {
|
|
@@ -1699,7 +1708,7 @@ function UploadPreviewModal() {
|
|
|
1699
1708
|
shouldDeleteImportContainer: true
|
|
1700
1709
|
}),
|
|
1701
1710
|
onPrimaryButtonClick: () => {
|
|
1702
|
-
actions.setCurrentStep(
|
|
1711
|
+
actions.setCurrentStep(CurrentStep$1.ImportConfirmationModal);
|
|
1703
1712
|
},
|
|
1704
1713
|
onClose: () => onClose({
|
|
1705
1714
|
shouldDeleteImportContainer: true
|
|
@@ -2019,7 +2028,7 @@ const Uploading = () => {
|
|
|
2019
2028
|
size: "medium",
|
|
2020
2029
|
label: intl.formatMessage(sharedMessages.cancel),
|
|
2021
2030
|
onClick: () => {
|
|
2022
|
-
actions.setCurrentStep(1);
|
|
2031
|
+
actions.setCurrentStep(CurrentStep$1.Upload);
|
|
2023
2032
|
state.abortController.abort();
|
|
2024
2033
|
}
|
|
2025
2034
|
})]
|
|
@@ -2037,10 +2046,10 @@ const CurrentStep = () => {
|
|
|
2037
2046
|
const _useImportResourcesCo = useImportResourcesContext(),
|
|
2038
2047
|
state = _useImportResourcesCo.state;
|
|
2039
2048
|
const steps = {
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2049
|
+
upload: jsx(Upload, {}),
|
|
2050
|
+
uploading: jsx(Uploading, {}),
|
|
2051
|
+
'upload-result': jsx(UploadResult, {}),
|
|
2052
|
+
'import-confirmation-modal': jsx(ImportConfirmationModal, {})
|
|
2044
2053
|
};
|
|
2045
2054
|
return steps[state.currentStep] || null;
|
|
2046
2055
|
};
|
|
@@ -79,8 +79,46 @@ var _someInstanceProperty__default = /*#__PURE__*/_interopDefault(_someInstanceP
|
|
|
79
79
|
var _styled__default = /*#__PURE__*/_interopDefault(_styled);
|
|
80
80
|
var DataTable__default = /*#__PURE__*/_interopDefault(DataTable);
|
|
81
81
|
|
|
82
|
+
const EnabledResourceType = {
|
|
83
|
+
category: true,
|
|
84
|
+
product: true,
|
|
85
|
+
inventory: true,
|
|
86
|
+
'discount-code': true,
|
|
87
|
+
customer: false,
|
|
88
|
+
order: false,
|
|
89
|
+
'product-type': false
|
|
90
|
+
};
|
|
91
|
+
function isResourceType(maybeResourceType) {
|
|
92
|
+
return typeof maybeResourceType === 'string' && maybeResourceType in EnabledResourceType;
|
|
93
|
+
}
|
|
94
|
+
function assertResourceType(maybeResourceType) {
|
|
95
|
+
if (isResourceType(maybeResourceType)) return;
|
|
96
|
+
throw new Error(`Invalid value: ${maybeResourceType}`);
|
|
97
|
+
}
|
|
98
|
+
function isError(maybeError) {
|
|
99
|
+
if (maybeError instanceof Error) return true;
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
104
|
+
function hasOwnProperty(obj, prop) {
|
|
105
|
+
return typeof obj === 'object' && obj !== null && obj.hasOwnProperty(prop);
|
|
106
|
+
}
|
|
107
|
+
function hasRequiredFields(maybeValidObject, requiredFields) {
|
|
108
|
+
return typeof maybeValidObject === 'object' && maybeValidObject !== null && _everyInstanceProperty__default["default"](requiredFields).call(requiredFields, property => hasOwnProperty(maybeValidObject, property));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
let CurrentStep$1 = /*#__PURE__*/function (CurrentStep) {
|
|
112
|
+
CurrentStep["Upload"] = "upload";
|
|
113
|
+
CurrentStep["Uploading"] = "uploading";
|
|
114
|
+
CurrentStep["UploadResult"] = "upload-result";
|
|
115
|
+
CurrentStep["ImportConfirmationModal"] = "import-confirmation-modal";
|
|
116
|
+
return CurrentStep;
|
|
117
|
+
}({});
|
|
118
|
+
|
|
82
119
|
function ownKeys$i(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; }
|
|
83
120
|
function _objectSpread$i(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$i(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$i(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
121
|
+
|
|
84
122
|
// TODO: make this resource type specific
|
|
85
123
|
|
|
86
124
|
function reducer(state, action) {
|
|
@@ -99,7 +137,7 @@ function reducer(state, action) {
|
|
|
99
137
|
containerKey: action.containerKey
|
|
100
138
|
});
|
|
101
139
|
if (action.type === 'cancelImport') return _objectSpread$i(_objectSpread$i({}, state), {}, {
|
|
102
|
-
currentStep: 1,
|
|
140
|
+
currentStep: CurrentStep$1.Upload,
|
|
103
141
|
containerKey: undefined,
|
|
104
142
|
fileUploadErrors: [],
|
|
105
143
|
uploadFileResponse: undefined,
|
|
@@ -108,7 +146,7 @@ function reducer(state, action) {
|
|
|
108
146
|
progress: 0
|
|
109
147
|
});
|
|
110
148
|
if (action.type === 'uploadNewFile') return _objectSpread$i(_objectSpread$i({}, state), {}, {
|
|
111
|
-
currentStep: 1,
|
|
149
|
+
currentStep: CurrentStep$1.Upload,
|
|
112
150
|
containerKey: undefined,
|
|
113
151
|
fileUploadErrors: [],
|
|
114
152
|
uploadFileResponse: undefined,
|
|
@@ -147,7 +185,7 @@ function getUnknownActionError(actionType) {
|
|
|
147
185
|
return `Unkown type: ${actionType}`;
|
|
148
186
|
}
|
|
149
187
|
const initialState = {
|
|
150
|
-
currentStep: 1,
|
|
188
|
+
currentStep: CurrentStep$1.Upload,
|
|
151
189
|
abortController: new AbortController(),
|
|
152
190
|
dropAreaState: 'disabled',
|
|
153
191
|
uploadFileResponse: undefined,
|
|
@@ -496,35 +534,6 @@ function getProccessFileURL(projectKey, resourceType, containerKey) {
|
|
|
496
534
|
return `/${projectKey}/${pluralize.plural(resourceType)}/import-containers/${containerKey}/process-file`;
|
|
497
535
|
}
|
|
498
536
|
|
|
499
|
-
const EnabledResourceType = {
|
|
500
|
-
category: true,
|
|
501
|
-
product: true,
|
|
502
|
-
inventory: true,
|
|
503
|
-
'discount-code': true,
|
|
504
|
-
customer: false,
|
|
505
|
-
order: false,
|
|
506
|
-
'product-type': false
|
|
507
|
-
};
|
|
508
|
-
function isResourceType(maybeResourceType) {
|
|
509
|
-
return typeof maybeResourceType === 'string' && maybeResourceType in EnabledResourceType;
|
|
510
|
-
}
|
|
511
|
-
function assertResourceType(maybeResourceType) {
|
|
512
|
-
if (isResourceType(maybeResourceType)) return;
|
|
513
|
-
throw new Error(`Invalid value: ${maybeResourceType}`);
|
|
514
|
-
}
|
|
515
|
-
function isError(maybeError) {
|
|
516
|
-
if (maybeError instanceof Error) return true;
|
|
517
|
-
return false;
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
521
|
-
function hasOwnProperty(obj, prop) {
|
|
522
|
-
return typeof obj === 'object' && obj !== null && obj.hasOwnProperty(prop);
|
|
523
|
-
}
|
|
524
|
-
function hasRequiredFields(maybeValidObject, requiredFields) {
|
|
525
|
-
return typeof maybeValidObject === 'object' && maybeValidObject !== null && _everyInstanceProperty__default["default"](requiredFields).call(requiredFields, property => hasOwnProperty(maybeValidObject, property));
|
|
526
|
-
}
|
|
527
|
-
|
|
528
537
|
function uploadFileForImport(_ref) {
|
|
529
538
|
let projectKey = _ref.projectKey,
|
|
530
539
|
containerKey = _ref.containerKey,
|
|
@@ -748,13 +757,13 @@ function getDefaultDropWrapperStyles(_dropAreaState) {
|
|
|
748
757
|
return /*#__PURE__*/react.css(process.env.NODE_ENV === "production" ? "" : ";label:getDefaultDropWrapperStyles;", process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImRyb3AtYXJlYS13cmFwcGVyLnRzeCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUE0QlkiLCJmaWxlIjoiZHJvcC1hcmVhLXdyYXBwZXIudHN4Iiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgdHlwZSBEcm9wem9uZVJvb3RQcm9wcyB9IGZyb20gJ3JlYWN0LWRyb3B6b25lJ1xuaW1wb3J0IHsgY3NzIH0gZnJvbSAnQGVtb3Rpb24vcmVhY3QnXG5pbXBvcnQgc3R5bGVkIGZyb20gJ0BlbW90aW9uL3N0eWxlZCdcbmltcG9ydCB7IHN0eWxlcyB9IGZyb20gJy4vc3R5bGVzJ1xuaW1wb3J0IHsgdHlwZSBEcm9wQXJlYVN0YXRlIH0gZnJvbSAnLi4vLi4vLi4vQHR5cGVzJ1xuXG5pbnRlcmZhY2UgRHJvcFdyYXBwZXJQcm9wcyBleHRlbmRzIERyb3B6b25lUm9vdFByb3BzIHtcbiAgZHJvcEFyZWFTdGF0ZTogRHJvcEFyZWFTdGF0ZVxufVxuZXhwb3J0IGNvbnN0IERyb3BXcmFwcGVyID0gc3R5bGVkLmRpdjxEcm9wV3JhcHBlclByb3BzPmBcbiAgJHtzdHlsZXMuYmFzZX1cbiAgJHsocHJvcHMpID0+IHtcbiAgICBpZiAocHJvcHMuZHJvcEFyZWFTdGF0ZSA9PT0gJ2Rpc2FibGVkJykge1xuICAgICAgcmV0dXJuIHN0eWxlcy5kaXNhYmxlZFxuICAgIH1cbiAgICBpZiAocHJvcHMuZHJvcEFyZWFTdGF0ZSA9PT0gJ3JlYWR5LWZvci1kcm9wJykge1xuICAgICAgcmV0dXJuIHN0eWxlcy5yZWFkeUZvckRyb3BcbiAgICB9XG4gICAgaWYgKHByb3BzLmRyb3BBcmVhU3RhdGUgPT09ICdhY3RpdmUtZHJhZycpIHtcbiAgICAgIHJldHVybiBzdHlsZXMuYWN0aXZlRHJhZ1xuICAgIH1cbiAgICBpZiAocHJvcHMuZHJvcEFyZWFTdGF0ZSA9PT0gJ2ZpbGUtZHJvcHBlZCcpIHtcbiAgICAgIHJldHVybiBzdHlsZXMuZmlsZURyb3BwZWRcbiAgICB9XG4gICAgcmV0dXJuIGdldERlZmF1bHREcm9wV3JhcHBlclN0eWxlcyhwcm9wcy5kcm9wQXJlYVN0YXRlKVxuICB9fVxuYFxuZnVuY3Rpb24gZ2V0RGVmYXVsdERyb3BXcmFwcGVyU3R5bGVzKF9kcm9wQXJlYVN0YXRlOiBuZXZlcikge1xuICByZXR1cm4gY3NzYGBcbn1cbiJdfQ== */");
|
|
749
758
|
}
|
|
750
759
|
|
|
751
|
-
var ActiveDragDropArea = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./active-drag-drop-area-
|
|
760
|
+
var ActiveDragDropArea = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./active-drag-drop-area-41fee9e7.cjs.dev.js' /* webpackChunkName: "active-drag-drop-area" */); }));
|
|
752
761
|
|
|
753
762
|
var DisabledDropArea = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./disabled-drop-area-aa78075b.cjs.dev.js' /* webpackChunkName: "disabled-drop-area" */); }));
|
|
754
763
|
|
|
755
|
-
var EnabledDropArea = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./enabled-drop-area-
|
|
764
|
+
var EnabledDropArea = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./enabled-drop-area-c92a8c96.cjs.dev.js' /* webpackChunkName: "enabled-drop-area" */); }));
|
|
756
765
|
|
|
757
|
-
var FileDropped = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./file-dropped-area-
|
|
766
|
+
var FileDropped = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./file-dropped-area-3a4c29f4.cjs.dev.js' /* webpackChunkName: "filed-dropped-area" */); }));
|
|
758
767
|
|
|
759
768
|
function getDropArea(_ref) {
|
|
760
769
|
let dropAreaState = _ref.dropAreaState,
|
|
@@ -958,7 +967,7 @@ const useUpload = () => {
|
|
|
958
967
|
});
|
|
959
968
|
if (errors.length > 0) {
|
|
960
969
|
actions.setFileUploadErrors(errors);
|
|
961
|
-
actions.setCurrentStep(
|
|
970
|
+
actions.setCurrentStep(CurrentStep$1.UploadResult);
|
|
962
971
|
return false;
|
|
963
972
|
}
|
|
964
973
|
return true;
|
|
@@ -974,7 +983,7 @@ const useUpload = () => {
|
|
|
974
983
|
title: intl.formatMessage(messages$6.missingRequiredField),
|
|
975
984
|
description: intl.formatMessage(messages$6.missingKeyError)
|
|
976
985
|
}]);
|
|
977
|
-
actions.setCurrentStep(
|
|
986
|
+
actions.setCurrentStep(CurrentStep$1.UploadResult);
|
|
978
987
|
} else if (error.errorData?.code === 'MissingCsvFieldIdentifier') {
|
|
979
988
|
const MissingCsvFieldIdentifierError = error.errorData;
|
|
980
989
|
const fieldNames = formatKeys(MissingCsvFieldIdentifierError.rowValue);
|
|
@@ -984,10 +993,10 @@ const useUpload = () => {
|
|
|
984
993
|
fieldNames
|
|
985
994
|
})
|
|
986
995
|
}]);
|
|
987
|
-
actions.setCurrentStep(
|
|
996
|
+
actions.setCurrentStep(CurrentStep$1.UploadResult);
|
|
988
997
|
} else if (error.errorData?.invalid > 0) {
|
|
989
998
|
actions.setUploadFileResponse(error.errorData);
|
|
990
|
-
actions.setCurrentStep(
|
|
999
|
+
actions.setCurrentStep(CurrentStep$1.UploadResult);
|
|
991
1000
|
} else {
|
|
992
1001
|
actions.cancelImport();
|
|
993
1002
|
showNotification({
|
|
@@ -1018,7 +1027,7 @@ const useUpload = () => {
|
|
|
1018
1027
|
if (!projectKey || !state.droppedFile || !state.resourceType) return;
|
|
1019
1028
|
const canUpload = await isFileValid(state.droppedFile);
|
|
1020
1029
|
if (!canUpload) return;
|
|
1021
|
-
actions.setCurrentStep(
|
|
1030
|
+
actions.setCurrentStep(CurrentStep$1.Uploading);
|
|
1022
1031
|
const containerKey = encodeFileNameWithTimestampToContainerKey(state.droppedFile.name);
|
|
1023
1032
|
actions.setContainerKey(containerKey);
|
|
1024
1033
|
try {
|
|
@@ -1044,7 +1053,7 @@ const useUpload = () => {
|
|
|
1044
1053
|
file: state.droppedFile,
|
|
1045
1054
|
onSuccess: fileUploadResponse => {
|
|
1046
1055
|
actions.setUploadFileResponse(fileUploadResponse);
|
|
1047
|
-
actions.setCurrentStep(
|
|
1056
|
+
actions.setCurrentStep(CurrentStep$1.UploadResult);
|
|
1048
1057
|
},
|
|
1049
1058
|
onProgress: progress => {
|
|
1050
1059
|
actions.setProgress(progress);
|
|
@@ -1058,7 +1067,7 @@ const useUpload = () => {
|
|
|
1058
1067
|
} catch (error) {
|
|
1059
1068
|
deleteImportContainer(projectKey, containerKey, asyncDispatch);
|
|
1060
1069
|
handleUploadError(error);
|
|
1061
|
-
actions.setCurrentStep(
|
|
1070
|
+
actions.setCurrentStep(CurrentStep$1.UploadResult);
|
|
1062
1071
|
}
|
|
1063
1072
|
};
|
|
1064
1073
|
return {
|
|
@@ -1728,7 +1737,7 @@ function UploadPreviewModal() {
|
|
|
1728
1737
|
shouldDeleteImportContainer: true
|
|
1729
1738
|
}),
|
|
1730
1739
|
onPrimaryButtonClick: () => {
|
|
1731
|
-
actions.setCurrentStep(
|
|
1740
|
+
actions.setCurrentStep(CurrentStep$1.ImportConfirmationModal);
|
|
1732
1741
|
},
|
|
1733
1742
|
onClose: () => onClose({
|
|
1734
1743
|
shouldDeleteImportContainer: true
|
|
@@ -2048,7 +2057,7 @@ const Uploading = () => {
|
|
|
2048
2057
|
size: "medium",
|
|
2049
2058
|
label: intl.formatMessage(sharedMessages.cancel),
|
|
2050
2059
|
onClick: () => {
|
|
2051
|
-
actions.setCurrentStep(1);
|
|
2060
|
+
actions.setCurrentStep(CurrentStep$1.Upload);
|
|
2052
2061
|
state.abortController.abort();
|
|
2053
2062
|
}
|
|
2054
2063
|
})]
|
|
@@ -2066,10 +2075,10 @@ const CurrentStep = () => {
|
|
|
2066
2075
|
const _useImportResourcesCo = useImportResourcesContext(),
|
|
2067
2076
|
state = _useImportResourcesCo.state;
|
|
2068
2077
|
const steps = {
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2078
|
+
upload: jsxRuntime.jsx(Upload, {}),
|
|
2079
|
+
uploading: jsxRuntime.jsx(Uploading, {}),
|
|
2080
|
+
'upload-result': jsxRuntime.jsx(UploadResult, {}),
|
|
2081
|
+
'import-confirmation-modal': jsxRuntime.jsx(ImportConfirmationModal, {})
|
|
2073
2082
|
};
|
|
2074
2083
|
return steps[state.currentStep] || null;
|
|
2075
2084
|
};
|
package/package.json
CHANGED