@commercetools-frontend-extensions/export-resources-modal 5.14.6 → 5.15.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.
- package/dist/commercetools-frontend-extensions-export-resources-modal.cjs.dev.js +45 -11
- package/dist/commercetools-frontend-extensions-export-resources-modal.cjs.prod.js +45 -11
- package/dist/commercetools-frontend-extensions-export-resources-modal.esm.js +46 -12
- package/dist/declarations/src/@types/export-resources-modal-context.d.ts +1 -0
- package/dist/declarations/src/@types/export-resources-modal-types.d.ts +8 -0
- package/dist/declarations/src/export-resources-modal.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1603,7 +1603,10 @@ const updateFieldDependenciesStatus = formik => {
|
|
|
1603
1603
|
_forEachInstanceProperty__default["default"](fields).call(fields, (field, index) => {
|
|
1604
1604
|
const currentPath = `${path}.fields[${index}]`;
|
|
1605
1605
|
if (hasDependentFields(field)) {
|
|
1606
|
-
|
|
1606
|
+
const nextIsChecked = isAnyDependentChecked(_valuesInstanceProperty__default["default"](formik).groups, field.dependentGroupNames, field.dependentFieldNames);
|
|
1607
|
+
if (field.isChecked !== nextIsChecked) {
|
|
1608
|
+
formik.setFieldValue(`${currentPath}.isChecked`, nextIsChecked, false);
|
|
1609
|
+
}
|
|
1607
1610
|
}
|
|
1608
1611
|
if (field.fields) {
|
|
1609
1612
|
updateFields(field.fields, currentPath);
|
|
@@ -3085,7 +3088,8 @@ const ExportFieldsSelectionStep = () => {
|
|
|
3085
3088
|
resourceType = _useExportResourcesMo.resourceType,
|
|
3086
3089
|
fieldSelectionMode = _useExportResourcesMo.fieldSelectionMode,
|
|
3087
3090
|
setFieldSelectionMode = _useExportResourcesMo.setFieldSelectionMode,
|
|
3088
|
-
setLocaleOption = _useExportResourcesMo.setLocaleOption
|
|
3091
|
+
setLocaleOption = _useExportResourcesMo.setLocaleOption,
|
|
3092
|
+
isLoading = _useExportResourcesMo.isLoading;
|
|
3089
3093
|
const shouldDisableImportedCsvTemplateOption = _valuesInstanceProperty__default["default"](formik).outputFormat === OUTPUT_FORMATS.JSON;
|
|
3090
3094
|
const isUsingImportedCsvTemplate = fieldSelectionMode === 'imported-csv-template';
|
|
3091
3095
|
const handleFieldSelectionModeChange = event => {
|
|
@@ -3106,7 +3110,7 @@ const ExportFieldsSelectionStep = () => {
|
|
|
3106
3110
|
})}: ${intl.formatMessage(messages.confirmSelection)}`,
|
|
3107
3111
|
iconLeftPrimaryButton: jsxRuntime.jsx(uiKit.AngleRightIcon, {}),
|
|
3108
3112
|
onPrimaryButtonClick: formik.submitForm,
|
|
3109
|
-
isPrimaryButtonDisabled: !formik.isValid,
|
|
3113
|
+
isPrimaryButtonDisabled: isLoading || !formik.isValid,
|
|
3110
3114
|
labelSecondary: intl.formatMessage(messages.back),
|
|
3111
3115
|
onSecondaryButtonClick: () => setCurrentStep(Step.FileSettings),
|
|
3112
3116
|
onClose: onClose,
|
|
@@ -3114,7 +3118,14 @@ const ExportFieldsSelectionStep = () => {
|
|
|
3114
3118
|
dataAttributesPrimaryButton: {
|
|
3115
3119
|
'data-tracking-target': `${resourceType}_export-start_export_button`
|
|
3116
3120
|
},
|
|
3117
|
-
children: jsxRuntime.jsx(
|
|
3121
|
+
children: isLoading ? jsxRuntime.jsx(uiKit.Spacings.Stack, {
|
|
3122
|
+
scale: "m",
|
|
3123
|
+
alignItems: "center",
|
|
3124
|
+
children: jsxRuntime.jsx(uiKit.LoadingSpinner, {
|
|
3125
|
+
scale: "l",
|
|
3126
|
+
maxDelayDuration: 0
|
|
3127
|
+
})
|
|
3128
|
+
}) : jsxRuntime.jsx(fullstory.Masking.Unmask, {
|
|
3118
3129
|
children: jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
3119
3130
|
scale: "xl",
|
|
3120
3131
|
children: [jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
@@ -3247,11 +3258,24 @@ const ExportResourcesProvider = _ref => {
|
|
|
3247
3258
|
React__default["default"].useEffect(() => {
|
|
3248
3259
|
formik$1.validateForm();
|
|
3249
3260
|
}, [currentStep, fieldSelectionMode, importedHeaders, exportType]);
|
|
3261
|
+
const mountedWhileLoadingRef = React__default["default"].useRef(Boolean(props.isLoading));
|
|
3262
|
+
const hasPopulatedFieldGroups = React__default["default"].useRef(false);
|
|
3263
|
+
React__default["default"].useLayoutEffect(() => {
|
|
3264
|
+
if (!mountedWhileLoadingRef.current || hasPopulatedFieldGroups.current) {
|
|
3265
|
+
return;
|
|
3266
|
+
}
|
|
3267
|
+
if (!props.isLoading && initialValues.groups.length > 0) {
|
|
3268
|
+
formik$1.setFieldValue('groups', initialValues.groups);
|
|
3269
|
+
hasPopulatedFieldGroups.current = true;
|
|
3270
|
+
}
|
|
3271
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3272
|
+
}, [props.isLoading, initialValues.groups]);
|
|
3250
3273
|
return jsxRuntime.jsx(ExportResourcesContext.Provider, {
|
|
3251
3274
|
value: {
|
|
3252
3275
|
formik: formik$1,
|
|
3253
3276
|
currentStep,
|
|
3254
3277
|
setCurrentStep,
|
|
3278
|
+
isLoading: props.isLoading,
|
|
3255
3279
|
onClose: props.onClose,
|
|
3256
3280
|
resourceType: props.resourceType,
|
|
3257
3281
|
exportType: exportType,
|
|
@@ -3320,7 +3344,7 @@ const FieldsPreview = _ref => {
|
|
|
3320
3344
|
};
|
|
3321
3345
|
|
|
3322
3346
|
function ownKeys$3(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; }
|
|
3323
|
-
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
3347
|
+
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context2 = ownKeys$3(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context3 = ownKeys$3(Object(t))).call(_context3, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
3324
3348
|
const ExportConfirmationStep = () => {
|
|
3325
3349
|
const intl = reactIntl.useIntl();
|
|
3326
3350
|
const _useApplicationContex = applicationShellConnectors.useApplicationContext(applicationContext => ({
|
|
@@ -3334,10 +3358,16 @@ const ExportConfirmationStep = () => {
|
|
|
3334
3358
|
localeOption = _useExportResourcesMo.localeOption,
|
|
3335
3359
|
setCurrentStep = _useExportResourcesMo.setCurrentStep,
|
|
3336
3360
|
onClose = _useExportResourcesMo.onClose;
|
|
3337
|
-
const groupsWithSelectedFields = getGroupsWithSelectedFields(_valuesInstanceProperty__default["default"](formik).groups);
|
|
3338
3361
|
const isUsingImportedCsvTemplate = fieldSelectionMode === 'imported-csv-template';
|
|
3339
3362
|
const isUsingImportedCsvLocales = localeOption === 'onlyLocalesFoundInCsvFile';
|
|
3340
|
-
const
|
|
3363
|
+
const selectedFieldsByGroup = React.useMemo(() => {
|
|
3364
|
+
var _context;
|
|
3365
|
+
return _mapInstanceProperty__default["default"](_context = getGroupsWithSelectedFields(_valuesInstanceProperty__default["default"](formik).groups)).call(_context, group => ({
|
|
3366
|
+
group,
|
|
3367
|
+
fields: getSelectedFieldLabels(group)
|
|
3368
|
+
}));
|
|
3369
|
+
}, [_valuesInstanceProperty__default["default"](formik).groups]);
|
|
3370
|
+
const allSelectedFieldCount = React.useMemo(() => isUsingImportedCsvTemplate ? importedHeaders.length : getAllSelectedFieldCount(_valuesInstanceProperty__default["default"](formik).groups), [isUsingImportedCsvTemplate, importedHeaders, _valuesInstanceProperty__default["default"](formik).groups]);
|
|
3341
3371
|
const returnToFieldsSelection = () => setCurrentStep(Step.FieldsSelection);
|
|
3342
3372
|
return jsxRuntime.jsx(applicationComponents.FormDialog, {
|
|
3343
3373
|
isOpen: true,
|
|
@@ -3384,11 +3414,12 @@ const ExportConfirmationStep = () => {
|
|
|
3384
3414
|
})]
|
|
3385
3415
|
}), isUsingImportedCsvTemplate ? jsxRuntime.jsx(FieldsPreview, {
|
|
3386
3416
|
fields: importedHeaders
|
|
3387
|
-
}) : _mapInstanceProperty__default["default"](
|
|
3388
|
-
|
|
3417
|
+
}) : _mapInstanceProperty__default["default"](selectedFieldsByGroup).call(selectedFieldsByGroup, _ref => {
|
|
3418
|
+
let group = _ref.group,
|
|
3419
|
+
fields = _ref.fields;
|
|
3389
3420
|
return jsxRuntime.jsx(FieldsPreview, {
|
|
3390
3421
|
previewGroupLabel: group.previewGroupLabel,
|
|
3391
|
-
fields:
|
|
3422
|
+
fields: fields
|
|
3392
3423
|
}, group.groupName);
|
|
3393
3424
|
})]
|
|
3394
3425
|
})
|
|
@@ -3729,7 +3760,7 @@ const useAsyncIntlMessages = (locale, loader) => {
|
|
|
3729
3760
|
return state;
|
|
3730
3761
|
};
|
|
3731
3762
|
|
|
3732
|
-
const _excluded = ["isOpen", "selectedResourceIds", "outputFormat", "fieldGroups", "fieldOrder"];
|
|
3763
|
+
const _excluded = ["isOpen", "isLoading", "selectedResourceIds", "outputFormat", "fieldGroups", "fieldOrder"];
|
|
3733
3764
|
function ownKeys(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; }
|
|
3734
3765
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
3735
3766
|
function invalidateLaunchDarklyCachedFeatureFlag(flagName) {
|
|
@@ -3752,6 +3783,8 @@ invalidateLaunchDarklyCachedFeatureFlag('enableOperationsExport');
|
|
|
3752
3783
|
const ExportResourcesModal = _ref3 => {
|
|
3753
3784
|
let _ref3$isOpen = _ref3.isOpen,
|
|
3754
3785
|
isOpen = _ref3$isOpen === void 0 ? false : _ref3$isOpen,
|
|
3786
|
+
_ref3$isLoading = _ref3.isLoading,
|
|
3787
|
+
isLoading = _ref3$isLoading === void 0 ? false : _ref3$isLoading,
|
|
3755
3788
|
_ref3$selectedResourc = _ref3.selectedResourceIds,
|
|
3756
3789
|
selectedResourceIds = _ref3$selectedResourc === void 0 ? [] : _ref3$selectedResourc,
|
|
3757
3790
|
_ref3$outputFormat = _ref3.outputFormat,
|
|
@@ -3778,6 +3811,7 @@ const ExportResourcesModal = _ref3 => {
|
|
|
3778
3811
|
fieldGroups: fieldGroups,
|
|
3779
3812
|
fieldOrder: fieldOrder,
|
|
3780
3813
|
isOpen: isOpen,
|
|
3814
|
+
isLoading: isLoading,
|
|
3781
3815
|
outputFormat: outputFormat,
|
|
3782
3816
|
selectedResourceIds: selectedResourceIds
|
|
3783
3817
|
}, props), {}, {
|
|
@@ -1603,7 +1603,10 @@ const updateFieldDependenciesStatus = formik => {
|
|
|
1603
1603
|
_forEachInstanceProperty__default["default"](fields).call(fields, (field, index) => {
|
|
1604
1604
|
const currentPath = `${path}.fields[${index}]`;
|
|
1605
1605
|
if (hasDependentFields(field)) {
|
|
1606
|
-
|
|
1606
|
+
const nextIsChecked = isAnyDependentChecked(_valuesInstanceProperty__default["default"](formik).groups, field.dependentGroupNames, field.dependentFieldNames);
|
|
1607
|
+
if (field.isChecked !== nextIsChecked) {
|
|
1608
|
+
formik.setFieldValue(`${currentPath}.isChecked`, nextIsChecked, false);
|
|
1609
|
+
}
|
|
1607
1610
|
}
|
|
1608
1611
|
if (field.fields) {
|
|
1609
1612
|
updateFields(field.fields, currentPath);
|
|
@@ -3052,7 +3055,8 @@ const ExportFieldsSelectionStep = () => {
|
|
|
3052
3055
|
resourceType = _useExportResourcesMo.resourceType,
|
|
3053
3056
|
fieldSelectionMode = _useExportResourcesMo.fieldSelectionMode,
|
|
3054
3057
|
setFieldSelectionMode = _useExportResourcesMo.setFieldSelectionMode,
|
|
3055
|
-
setLocaleOption = _useExportResourcesMo.setLocaleOption
|
|
3058
|
+
setLocaleOption = _useExportResourcesMo.setLocaleOption,
|
|
3059
|
+
isLoading = _useExportResourcesMo.isLoading;
|
|
3056
3060
|
const shouldDisableImportedCsvTemplateOption = _valuesInstanceProperty__default["default"](formik).outputFormat === OUTPUT_FORMATS.JSON;
|
|
3057
3061
|
const isUsingImportedCsvTemplate = fieldSelectionMode === 'imported-csv-template';
|
|
3058
3062
|
const handleFieldSelectionModeChange = event => {
|
|
@@ -3073,7 +3077,7 @@ const ExportFieldsSelectionStep = () => {
|
|
|
3073
3077
|
})}: ${intl.formatMessage(messages.confirmSelection)}`,
|
|
3074
3078
|
iconLeftPrimaryButton: jsxRuntime.jsx(uiKit.AngleRightIcon, {}),
|
|
3075
3079
|
onPrimaryButtonClick: formik.submitForm,
|
|
3076
|
-
isPrimaryButtonDisabled: !formik.isValid,
|
|
3080
|
+
isPrimaryButtonDisabled: isLoading || !formik.isValid,
|
|
3077
3081
|
labelSecondary: intl.formatMessage(messages.back),
|
|
3078
3082
|
onSecondaryButtonClick: () => setCurrentStep(Step.FileSettings),
|
|
3079
3083
|
onClose: onClose,
|
|
@@ -3081,7 +3085,14 @@ const ExportFieldsSelectionStep = () => {
|
|
|
3081
3085
|
dataAttributesPrimaryButton: {
|
|
3082
3086
|
'data-tracking-target': `${resourceType}_export-start_export_button`
|
|
3083
3087
|
},
|
|
3084
|
-
children: jsxRuntime.jsx(
|
|
3088
|
+
children: isLoading ? jsxRuntime.jsx(uiKit.Spacings.Stack, {
|
|
3089
|
+
scale: "m",
|
|
3090
|
+
alignItems: "center",
|
|
3091
|
+
children: jsxRuntime.jsx(uiKit.LoadingSpinner, {
|
|
3092
|
+
scale: "l",
|
|
3093
|
+
maxDelayDuration: 0
|
|
3094
|
+
})
|
|
3095
|
+
}) : jsxRuntime.jsx(fullstory.Masking.Unmask, {
|
|
3085
3096
|
children: jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
3086
3097
|
scale: "xl",
|
|
3087
3098
|
children: [jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
@@ -3214,11 +3225,24 @@ const ExportResourcesProvider = _ref => {
|
|
|
3214
3225
|
React__default["default"].useEffect(() => {
|
|
3215
3226
|
formik$1.validateForm();
|
|
3216
3227
|
}, [currentStep, fieldSelectionMode, importedHeaders, exportType]);
|
|
3228
|
+
const mountedWhileLoadingRef = React__default["default"].useRef(Boolean(props.isLoading));
|
|
3229
|
+
const hasPopulatedFieldGroups = React__default["default"].useRef(false);
|
|
3230
|
+
React__default["default"].useLayoutEffect(() => {
|
|
3231
|
+
if (!mountedWhileLoadingRef.current || hasPopulatedFieldGroups.current) {
|
|
3232
|
+
return;
|
|
3233
|
+
}
|
|
3234
|
+
if (!props.isLoading && initialValues.groups.length > 0) {
|
|
3235
|
+
formik$1.setFieldValue('groups', initialValues.groups);
|
|
3236
|
+
hasPopulatedFieldGroups.current = true;
|
|
3237
|
+
}
|
|
3238
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3239
|
+
}, [props.isLoading, initialValues.groups]);
|
|
3217
3240
|
return jsxRuntime.jsx(ExportResourcesContext.Provider, {
|
|
3218
3241
|
value: {
|
|
3219
3242
|
formik: formik$1,
|
|
3220
3243
|
currentStep,
|
|
3221
3244
|
setCurrentStep,
|
|
3245
|
+
isLoading: props.isLoading,
|
|
3222
3246
|
onClose: props.onClose,
|
|
3223
3247
|
resourceType: props.resourceType,
|
|
3224
3248
|
exportType: exportType,
|
|
@@ -3287,7 +3311,7 @@ const FieldsPreview = _ref => {
|
|
|
3287
3311
|
};
|
|
3288
3312
|
|
|
3289
3313
|
function ownKeys$3(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; }
|
|
3290
|
-
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
3314
|
+
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context2 = ownKeys$3(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context3 = ownKeys$3(Object(t))).call(_context3, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
3291
3315
|
const ExportConfirmationStep = () => {
|
|
3292
3316
|
const intl = reactIntl.useIntl();
|
|
3293
3317
|
const _useApplicationContex = applicationShellConnectors.useApplicationContext(applicationContext => ({
|
|
@@ -3301,10 +3325,16 @@ const ExportConfirmationStep = () => {
|
|
|
3301
3325
|
localeOption = _useExportResourcesMo.localeOption,
|
|
3302
3326
|
setCurrentStep = _useExportResourcesMo.setCurrentStep,
|
|
3303
3327
|
onClose = _useExportResourcesMo.onClose;
|
|
3304
|
-
const groupsWithSelectedFields = getGroupsWithSelectedFields(_valuesInstanceProperty__default["default"](formik).groups);
|
|
3305
3328
|
const isUsingImportedCsvTemplate = fieldSelectionMode === 'imported-csv-template';
|
|
3306
3329
|
const isUsingImportedCsvLocales = localeOption === 'onlyLocalesFoundInCsvFile';
|
|
3307
|
-
const
|
|
3330
|
+
const selectedFieldsByGroup = React.useMemo(() => {
|
|
3331
|
+
var _context;
|
|
3332
|
+
return _mapInstanceProperty__default["default"](_context = getGroupsWithSelectedFields(_valuesInstanceProperty__default["default"](formik).groups)).call(_context, group => ({
|
|
3333
|
+
group,
|
|
3334
|
+
fields: getSelectedFieldLabels(group)
|
|
3335
|
+
}));
|
|
3336
|
+
}, [_valuesInstanceProperty__default["default"](formik).groups]);
|
|
3337
|
+
const allSelectedFieldCount = React.useMemo(() => isUsingImportedCsvTemplate ? importedHeaders.length : getAllSelectedFieldCount(_valuesInstanceProperty__default["default"](formik).groups), [isUsingImportedCsvTemplate, importedHeaders, _valuesInstanceProperty__default["default"](formik).groups]);
|
|
3308
3338
|
const returnToFieldsSelection = () => setCurrentStep(Step.FieldsSelection);
|
|
3309
3339
|
return jsxRuntime.jsx(applicationComponents.FormDialog, {
|
|
3310
3340
|
isOpen: true,
|
|
@@ -3351,11 +3381,12 @@ const ExportConfirmationStep = () => {
|
|
|
3351
3381
|
})]
|
|
3352
3382
|
}), isUsingImportedCsvTemplate ? jsxRuntime.jsx(FieldsPreview, {
|
|
3353
3383
|
fields: importedHeaders
|
|
3354
|
-
}) : _mapInstanceProperty__default["default"](
|
|
3355
|
-
|
|
3384
|
+
}) : _mapInstanceProperty__default["default"](selectedFieldsByGroup).call(selectedFieldsByGroup, _ref => {
|
|
3385
|
+
let group = _ref.group,
|
|
3386
|
+
fields = _ref.fields;
|
|
3356
3387
|
return jsxRuntime.jsx(FieldsPreview, {
|
|
3357
3388
|
previewGroupLabel: group.previewGroupLabel,
|
|
3358
|
-
fields:
|
|
3389
|
+
fields: fields
|
|
3359
3390
|
}, group.groupName);
|
|
3360
3391
|
})]
|
|
3361
3392
|
})
|
|
@@ -3696,7 +3727,7 @@ const useAsyncIntlMessages = (locale, loader) => {
|
|
|
3696
3727
|
return state;
|
|
3697
3728
|
};
|
|
3698
3729
|
|
|
3699
|
-
const _excluded = ["isOpen", "selectedResourceIds", "outputFormat", "fieldGroups", "fieldOrder"];
|
|
3730
|
+
const _excluded = ["isOpen", "isLoading", "selectedResourceIds", "outputFormat", "fieldGroups", "fieldOrder"];
|
|
3700
3731
|
function ownKeys(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; }
|
|
3701
3732
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
3702
3733
|
function invalidateLaunchDarklyCachedFeatureFlag(flagName) {
|
|
@@ -3719,6 +3750,8 @@ invalidateLaunchDarklyCachedFeatureFlag('enableOperationsExport');
|
|
|
3719
3750
|
const ExportResourcesModal = _ref3 => {
|
|
3720
3751
|
let _ref3$isOpen = _ref3.isOpen,
|
|
3721
3752
|
isOpen = _ref3$isOpen === void 0 ? false : _ref3$isOpen,
|
|
3753
|
+
_ref3$isLoading = _ref3.isLoading,
|
|
3754
|
+
isLoading = _ref3$isLoading === void 0 ? false : _ref3$isLoading,
|
|
3722
3755
|
_ref3$selectedResourc = _ref3.selectedResourceIds,
|
|
3723
3756
|
selectedResourceIds = _ref3$selectedResourc === void 0 ? [] : _ref3$selectedResourc,
|
|
3724
3757
|
_ref3$outputFormat = _ref3.outputFormat,
|
|
@@ -3745,6 +3778,7 @@ const ExportResourcesModal = _ref3 => {
|
|
|
3745
3778
|
fieldGroups: fieldGroups,
|
|
3746
3779
|
fieldOrder: fieldOrder,
|
|
3747
3780
|
isOpen: isOpen,
|
|
3781
|
+
isLoading: isLoading,
|
|
3748
3782
|
outputFormat: outputFormat,
|
|
3749
3783
|
selectedResourceIds: selectedResourceIds
|
|
3750
3784
|
}, props), {}, {
|
|
@@ -15,7 +15,7 @@ import _Object$defineProperties from '@babel/runtime-corejs3/core-js-stable/obje
|
|
|
15
15
|
import _Object$defineProperty from '@babel/runtime-corejs3/core-js-stable/object/define-property';
|
|
16
16
|
import { defineMessages, FormattedMessage, useIntl, IntlProvider } from 'react-intl';
|
|
17
17
|
import { useApplicationContext } from '@commercetools-frontend/application-shell-connectors';
|
|
18
|
-
import { Text, TextInput, Spacings, SelectField, CheckboxInput, ContentNotification, Link, RadioInput, TextField, AngleRightIcon, Grid, designTokens, FieldLabel, Constraints, Tooltip, SupportIcon, Stamp, IconButton, AngleDownIcon, CollapsibleMotion, Card, SearchTextInput, TagList, FlatButton, AngleUpIcon, CheckBoldIcon, DataTable } from '@commercetools-frontend/ui-kit';
|
|
18
|
+
import { Text, TextInput, Spacings, SelectField, CheckboxInput, ContentNotification, Link, RadioInput, TextField, AngleRightIcon, Grid, designTokens, FieldLabel, Constraints, Tooltip, SupportIcon, Stamp, IconButton, AngleDownIcon, CollapsibleMotion, Card, SearchTextInput, LoadingSpinner, TagList, FlatButton, AngleUpIcon, CheckBoldIcon, DataTable } from '@commercetools-frontend/ui-kit';
|
|
19
19
|
import { jsx, jsxs, Fragment } from '@emotion/react/jsx-runtime';
|
|
20
20
|
import _valuesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/values';
|
|
21
21
|
import { FormDialog } from '@commercetools-frontend/application-components';
|
|
@@ -1560,7 +1560,10 @@ const updateFieldDependenciesStatus = formik => {
|
|
|
1560
1560
|
_forEachInstanceProperty(fields).call(fields, (field, index) => {
|
|
1561
1561
|
const currentPath = `${path}.fields[${index}]`;
|
|
1562
1562
|
if (hasDependentFields(field)) {
|
|
1563
|
-
|
|
1563
|
+
const nextIsChecked = isAnyDependentChecked(_valuesInstanceProperty(formik).groups, field.dependentGroupNames, field.dependentFieldNames);
|
|
1564
|
+
if (field.isChecked !== nextIsChecked) {
|
|
1565
|
+
formik.setFieldValue(`${currentPath}.isChecked`, nextIsChecked, false);
|
|
1566
|
+
}
|
|
1564
1567
|
}
|
|
1565
1568
|
if (field.fields) {
|
|
1566
1569
|
updateFields(field.fields, currentPath);
|
|
@@ -3042,7 +3045,8 @@ const ExportFieldsSelectionStep = () => {
|
|
|
3042
3045
|
resourceType = _useExportResourcesMo.resourceType,
|
|
3043
3046
|
fieldSelectionMode = _useExportResourcesMo.fieldSelectionMode,
|
|
3044
3047
|
setFieldSelectionMode = _useExportResourcesMo.setFieldSelectionMode,
|
|
3045
|
-
setLocaleOption = _useExportResourcesMo.setLocaleOption
|
|
3048
|
+
setLocaleOption = _useExportResourcesMo.setLocaleOption,
|
|
3049
|
+
isLoading = _useExportResourcesMo.isLoading;
|
|
3046
3050
|
const shouldDisableImportedCsvTemplateOption = _valuesInstanceProperty(formik).outputFormat === OUTPUT_FORMATS.JSON;
|
|
3047
3051
|
const isUsingImportedCsvTemplate = fieldSelectionMode === 'imported-csv-template';
|
|
3048
3052
|
const handleFieldSelectionModeChange = event => {
|
|
@@ -3063,7 +3067,7 @@ const ExportFieldsSelectionStep = () => {
|
|
|
3063
3067
|
})}: ${intl.formatMessage(messages.confirmSelection)}`,
|
|
3064
3068
|
iconLeftPrimaryButton: jsx(AngleRightIcon, {}),
|
|
3065
3069
|
onPrimaryButtonClick: formik.submitForm,
|
|
3066
|
-
isPrimaryButtonDisabled: !formik.isValid,
|
|
3070
|
+
isPrimaryButtonDisabled: isLoading || !formik.isValid,
|
|
3067
3071
|
labelSecondary: intl.formatMessage(messages.back),
|
|
3068
3072
|
onSecondaryButtonClick: () => setCurrentStep(Step.FileSettings),
|
|
3069
3073
|
onClose: onClose,
|
|
@@ -3071,7 +3075,14 @@ const ExportFieldsSelectionStep = () => {
|
|
|
3071
3075
|
dataAttributesPrimaryButton: {
|
|
3072
3076
|
'data-tracking-target': `${resourceType}_export-start_export_button`
|
|
3073
3077
|
},
|
|
3074
|
-
children: jsx(
|
|
3078
|
+
children: isLoading ? jsx(Spacings.Stack, {
|
|
3079
|
+
scale: "m",
|
|
3080
|
+
alignItems: "center",
|
|
3081
|
+
children: jsx(LoadingSpinner, {
|
|
3082
|
+
scale: "l",
|
|
3083
|
+
maxDelayDuration: 0
|
|
3084
|
+
})
|
|
3085
|
+
}) : jsx(Masking.Unmask, {
|
|
3075
3086
|
children: jsxs(Spacings.Stack, {
|
|
3076
3087
|
scale: "xl",
|
|
3077
3088
|
children: [jsxs(Spacings.Stack, {
|
|
@@ -3204,11 +3215,24 @@ const ExportResourcesProvider = _ref => {
|
|
|
3204
3215
|
React.useEffect(() => {
|
|
3205
3216
|
formik.validateForm();
|
|
3206
3217
|
}, [currentStep, fieldSelectionMode, importedHeaders, exportType]);
|
|
3218
|
+
const mountedWhileLoadingRef = React.useRef(Boolean(props.isLoading));
|
|
3219
|
+
const hasPopulatedFieldGroups = React.useRef(false);
|
|
3220
|
+
React.useLayoutEffect(() => {
|
|
3221
|
+
if (!mountedWhileLoadingRef.current || hasPopulatedFieldGroups.current) {
|
|
3222
|
+
return;
|
|
3223
|
+
}
|
|
3224
|
+
if (!props.isLoading && initialValues.groups.length > 0) {
|
|
3225
|
+
formik.setFieldValue('groups', initialValues.groups);
|
|
3226
|
+
hasPopulatedFieldGroups.current = true;
|
|
3227
|
+
}
|
|
3228
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3229
|
+
}, [props.isLoading, initialValues.groups]);
|
|
3207
3230
|
return jsx(ExportResourcesContext.Provider, {
|
|
3208
3231
|
value: {
|
|
3209
3232
|
formik,
|
|
3210
3233
|
currentStep,
|
|
3211
3234
|
setCurrentStep,
|
|
3235
|
+
isLoading: props.isLoading,
|
|
3212
3236
|
onClose: props.onClose,
|
|
3213
3237
|
resourceType: props.resourceType,
|
|
3214
3238
|
exportType: exportType,
|
|
@@ -3277,7 +3301,7 @@ const FieldsPreview = _ref => {
|
|
|
3277
3301
|
};
|
|
3278
3302
|
|
|
3279
3303
|
function ownKeys$3(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; }
|
|
3280
|
-
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
3304
|
+
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context2 = ownKeys$3(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context3 = ownKeys$3(Object(t))).call(_context3, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3281
3305
|
const ExportConfirmationStep = () => {
|
|
3282
3306
|
const intl = useIntl();
|
|
3283
3307
|
const _useApplicationContex = useApplicationContext(applicationContext => ({
|
|
@@ -3291,10 +3315,16 @@ const ExportConfirmationStep = () => {
|
|
|
3291
3315
|
localeOption = _useExportResourcesMo.localeOption,
|
|
3292
3316
|
setCurrentStep = _useExportResourcesMo.setCurrentStep,
|
|
3293
3317
|
onClose = _useExportResourcesMo.onClose;
|
|
3294
|
-
const groupsWithSelectedFields = getGroupsWithSelectedFields(_valuesInstanceProperty(formik).groups);
|
|
3295
3318
|
const isUsingImportedCsvTemplate = fieldSelectionMode === 'imported-csv-template';
|
|
3296
3319
|
const isUsingImportedCsvLocales = localeOption === 'onlyLocalesFoundInCsvFile';
|
|
3297
|
-
const
|
|
3320
|
+
const selectedFieldsByGroup = useMemo(() => {
|
|
3321
|
+
var _context;
|
|
3322
|
+
return _mapInstanceProperty(_context = getGroupsWithSelectedFields(_valuesInstanceProperty(formik).groups)).call(_context, group => ({
|
|
3323
|
+
group,
|
|
3324
|
+
fields: getSelectedFieldLabels(group)
|
|
3325
|
+
}));
|
|
3326
|
+
}, [_valuesInstanceProperty(formik).groups]);
|
|
3327
|
+
const allSelectedFieldCount = useMemo(() => isUsingImportedCsvTemplate ? importedHeaders.length : getAllSelectedFieldCount(_valuesInstanceProperty(formik).groups), [isUsingImportedCsvTemplate, importedHeaders, _valuesInstanceProperty(formik).groups]);
|
|
3298
3328
|
const returnToFieldsSelection = () => setCurrentStep(Step.FieldsSelection);
|
|
3299
3329
|
return jsx(FormDialog, {
|
|
3300
3330
|
isOpen: true,
|
|
@@ -3341,11 +3371,12 @@ const ExportConfirmationStep = () => {
|
|
|
3341
3371
|
})]
|
|
3342
3372
|
}), isUsingImportedCsvTemplate ? jsx(FieldsPreview, {
|
|
3343
3373
|
fields: importedHeaders
|
|
3344
|
-
}) : _mapInstanceProperty(
|
|
3345
|
-
|
|
3374
|
+
}) : _mapInstanceProperty(selectedFieldsByGroup).call(selectedFieldsByGroup, _ref => {
|
|
3375
|
+
let group = _ref.group,
|
|
3376
|
+
fields = _ref.fields;
|
|
3346
3377
|
return jsx(FieldsPreview, {
|
|
3347
3378
|
previewGroupLabel: group.previewGroupLabel,
|
|
3348
|
-
fields:
|
|
3379
|
+
fields: fields
|
|
3349
3380
|
}, group.groupName);
|
|
3350
3381
|
})]
|
|
3351
3382
|
})
|
|
@@ -3686,7 +3717,7 @@ const useAsyncIntlMessages = (locale, loader) => {
|
|
|
3686
3717
|
return state;
|
|
3687
3718
|
};
|
|
3688
3719
|
|
|
3689
|
-
const _excluded = ["isOpen", "selectedResourceIds", "outputFormat", "fieldGroups", "fieldOrder"];
|
|
3720
|
+
const _excluded = ["isOpen", "isLoading", "selectedResourceIds", "outputFormat", "fieldGroups", "fieldOrder"];
|
|
3690
3721
|
function ownKeys(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; }
|
|
3691
3722
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3692
3723
|
function invalidateLaunchDarklyCachedFeatureFlag(flagName) {
|
|
@@ -3709,6 +3740,8 @@ invalidateLaunchDarklyCachedFeatureFlag('enableOperationsExport');
|
|
|
3709
3740
|
const ExportResourcesModal = _ref3 => {
|
|
3710
3741
|
let _ref3$isOpen = _ref3.isOpen,
|
|
3711
3742
|
isOpen = _ref3$isOpen === void 0 ? false : _ref3$isOpen,
|
|
3743
|
+
_ref3$isLoading = _ref3.isLoading,
|
|
3744
|
+
isLoading = _ref3$isLoading === void 0 ? false : _ref3$isLoading,
|
|
3712
3745
|
_ref3$selectedResourc = _ref3.selectedResourceIds,
|
|
3713
3746
|
selectedResourceIds = _ref3$selectedResourc === void 0 ? [] : _ref3$selectedResourc,
|
|
3714
3747
|
_ref3$outputFormat = _ref3.outputFormat,
|
|
@@ -3735,6 +3768,7 @@ const ExportResourcesModal = _ref3 => {
|
|
|
3735
3768
|
fieldGroups: fieldGroups,
|
|
3736
3769
|
fieldOrder: fieldOrder,
|
|
3737
3770
|
isOpen: isOpen,
|
|
3771
|
+
isLoading: isLoading,
|
|
3738
3772
|
outputFormat: outputFormat,
|
|
3739
3773
|
selectedResourceIds: selectedResourceIds
|
|
3740
3774
|
}, props), {}, {
|
|
@@ -16,6 +16,7 @@ export interface ExportResourcesModalContext {
|
|
|
16
16
|
formik: FormikProps<FormValues>;
|
|
17
17
|
currentStep: Step;
|
|
18
18
|
setCurrentStep: React.Dispatch<React.SetStateAction<Step>>;
|
|
19
|
+
isLoading?: boolean;
|
|
19
20
|
onClose: () => void;
|
|
20
21
|
resourceType: ResourceType;
|
|
21
22
|
exportType: ExportType;
|
|
@@ -26,6 +26,14 @@ export interface Store {
|
|
|
26
26
|
}
|
|
27
27
|
export interface ExportResourcesModalProps {
|
|
28
28
|
isOpen?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Pass `true` while the data backing `fieldGroups` is still being fetched.
|
|
31
|
+
* The modal opens immediately to the (data-independent) file settings step,
|
|
32
|
+
* and only the field selection step shows a loading spinner until the data is
|
|
33
|
+
* ready. The fetched `fieldGroups` are then merged into the form without
|
|
34
|
+
* resetting any file settings the user already changed.
|
|
35
|
+
*/
|
|
36
|
+
isLoading?: boolean;
|
|
29
37
|
resourceType: ResourceType;
|
|
30
38
|
outputFormat?: string;
|
|
31
39
|
baseFilters?: Pick<Filters, 'where'>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ExportResourcesModalProps } from "./@types/index.js";
|
|
2
2
|
declare const ExportResourcesModal: {
|
|
3
|
-
({ isOpen, selectedResourceIds, outputFormat, fieldGroups, fieldOrder, ...props }: ExportResourcesModalProps): import("@emotion/react/jsx-runtime").JSX.Element | null;
|
|
3
|
+
({ isOpen, isLoading, selectedResourceIds, outputFormat, fieldGroups, fieldOrder, ...props }: ExportResourcesModalProps): import("@emotion/react/jsx-runtime").JSX.Element | null;
|
|
4
4
|
displayName: string;
|
|
5
5
|
};
|
|
6
6
|
export default ExportResourcesModal;
|
package/package.json
CHANGED