@commercetools-frontend-extensions/export-resources-modal 1.4.0 → 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/README.md +9 -5
- package/dist/commercetools-frontend-extensions-export-resources-modal.cjs.dev.js +246 -385
- package/dist/commercetools-frontend-extensions-export-resources-modal.cjs.prod.js +244 -379
- package/dist/commercetools-frontend-extensions-export-resources-modal.esm.js +247 -386
- package/package.json +17 -17
|
@@ -14,6 +14,7 @@ var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
|
14
14
|
var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
|
|
15
15
|
var reactIntl = require('react-intl');
|
|
16
16
|
var applicationComponents = require('@commercetools-frontend/application-components');
|
|
17
|
+
var uiKit = require('@commercetools-frontend/ui-kit');
|
|
17
18
|
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
18
19
|
var _flatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/flat');
|
|
19
20
|
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
@@ -26,7 +27,6 @@ var _possibleConstructorReturn = require('@babel/runtime-corejs3/helpers/possibl
|
|
|
26
27
|
var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
|
|
27
28
|
var _wrapNativeSuper = require('@babel/runtime-corejs3/helpers/wrapNativeSuper');
|
|
28
29
|
var _Array$isArray = require('@babel/runtime-corejs3/core-js-stable/array/is-array');
|
|
29
|
-
var uiKit = require('@commercetools-frontend/ui-kit');
|
|
30
30
|
var omitEmpty = require('omit-empty-es');
|
|
31
31
|
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
32
32
|
var designSystem = require('@commercetools-uikit/design-system');
|
|
@@ -36,11 +36,11 @@ var react = require('@emotion/react');
|
|
|
36
36
|
var _styled = require('@emotion/styled/base');
|
|
37
37
|
var _valuesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/values');
|
|
38
38
|
var applicationShellConnectors = require('@commercetools-frontend/application-shell-connectors');
|
|
39
|
-
var sdk = require('@commercetools-frontend/sdk');
|
|
40
|
-
var constants = require('@commercetools-frontend/constants');
|
|
41
|
-
var actionsGlobal = require('@commercetools-frontend/actions-global');
|
|
42
39
|
var formik = require('formik');
|
|
43
40
|
var moment = require('moment');
|
|
41
|
+
var actionsGlobal = require('@commercetools-frontend/actions-global');
|
|
42
|
+
var sdk = require('@commercetools-frontend/sdk');
|
|
43
|
+
var constants = require('@commercetools-frontend/constants');
|
|
44
44
|
|
|
45
45
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
46
46
|
|
|
@@ -146,8 +146,8 @@ let UnexpectedResourceTypeError = /*#__PURE__*/function (_Error) {
|
|
|
146
146
|
return _createClass(UnexpectedResourceTypeError);
|
|
147
147
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
148
148
|
|
|
149
|
-
function ownKeys$
|
|
150
|
-
function _objectSpread$
|
|
149
|
+
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; }
|
|
150
|
+
function _objectSpread$9(e) { for (var r = 1; r < arguments.length; r++) { var _context4, _context5; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context4 = ownKeys$9(Object(t), !0)).call(_context4, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context5 = ownKeys$9(Object(t))).call(_context5, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
151
151
|
function resourceTypeToPlural(_ref) {
|
|
152
152
|
let resourceType = _ref.resourceType,
|
|
153
153
|
_ref$isUpperCase = _ref.isUpperCase,
|
|
@@ -193,7 +193,7 @@ function flattenNestedFields(fields) {
|
|
|
193
193
|
var _context2;
|
|
194
194
|
return _mapInstanceProperty__default["default"](_context2 = flattenNestedFields(field.fields)).call(_context2, nestedField => {
|
|
195
195
|
var _context3;
|
|
196
|
-
return _objectSpread$
|
|
196
|
+
return _objectSpread$9(_objectSpread$9({}, nestedField), {}, {
|
|
197
197
|
key: _concatInstanceProperty__default["default"](_context3 = "".concat(field.key, ".")).call(_context3, nestedField.key)
|
|
198
198
|
});
|
|
199
199
|
});
|
|
@@ -207,8 +207,8 @@ function flattenNestedFields(fields) {
|
|
|
207
207
|
* This function is responsible for constructing the GraphQL query based on the export settings
|
|
208
208
|
*
|
|
209
209
|
* Depending on the type of export selection (all resources, only selected, or only matching/filtered) it constructs different types of queries:
|
|
210
|
-
* - For 'all resources', it generates a query that fetches all fields and
|
|
211
|
-
* - For 'only selected', it creates a query that fetches only the fields and
|
|
210
|
+
* - For 'all resources', it generates a query that fetches all fields and locales specified in the export settings.
|
|
211
|
+
* - For 'only selected', it creates a query that fetches only the fields and locales of the selected resources. The ids of the selected resources are included in the query.
|
|
212
212
|
* - The 'only matching' case is a placeholder for future development where a query will be constructed based on certain filtering criteria using the `where` parameter.
|
|
213
213
|
*/
|
|
214
214
|
function buildGraphQuery(exportSettings) {
|
|
@@ -221,7 +221,7 @@ function buildGraphQuery(exportSettings) {
|
|
|
221
221
|
fields: [{
|
|
222
222
|
results: buildFields({
|
|
223
223
|
fields: exportSettings.fields,
|
|
224
|
-
|
|
224
|
+
locales: exportSettings.locales
|
|
225
225
|
})
|
|
226
226
|
}],
|
|
227
227
|
variables: {}
|
|
@@ -232,7 +232,7 @@ function buildGraphQuery(exportSettings) {
|
|
|
232
232
|
fields: [{
|
|
233
233
|
results: buildFields({
|
|
234
234
|
fields: exportSettings.fields,
|
|
235
|
-
|
|
235
|
+
locales: exportSettings.locales
|
|
236
236
|
})
|
|
237
237
|
}],
|
|
238
238
|
variables: {
|
|
@@ -250,13 +250,13 @@ function buildGraphQuery(exportSettings) {
|
|
|
250
250
|
/*
|
|
251
251
|
* This function builds the necessary field structure for our GraphQL queries, tt is specifically designed to handle different types of fields
|
|
252
252
|
*
|
|
253
|
-
* For fields whose values change depending on the
|
|
254
|
-
* This format combines the field and the
|
|
253
|
+
* For fields whose values change depending on the locale aka localised fields, a unique request format is used
|
|
254
|
+
* This format combines the field and the locale, separated by '______'. This approach is adopted as our system disallows the use of hyphens `-` in these situations
|
|
255
255
|
*
|
|
256
|
-
* Fields that don't vary by
|
|
256
|
+
* Fields that don't vary by locale but contain additional subfields (known as 'nested fields') are also addressed
|
|
257
257
|
* In these cases the function is used recursively on these subfields to generate the appropriate request.
|
|
258
258
|
*
|
|
259
|
-
* Overall, this function enables us to accurately request different types of data, including those varying by
|
|
259
|
+
* Overall, this function enables us to accurately request different types of data, including those varying by locale or containing subfields.
|
|
260
260
|
*
|
|
261
261
|
* More details can be found in the related PR: https://github.com/commercetools/commercetools-exporter/pull/103
|
|
262
262
|
*/
|
|
@@ -264,18 +264,18 @@ function buildGraphQuery(exportSettings) {
|
|
|
264
264
|
function buildFields(_ref) {
|
|
265
265
|
var _context2;
|
|
266
266
|
let fields = _ref.fields,
|
|
267
|
-
|
|
267
|
+
locales = _ref.locales;
|
|
268
268
|
return _flatInstanceProperty__default["default"](_context2 = _mapInstanceProperty__default["default"](fields).call(fields, field => {
|
|
269
|
-
if (field.isLocalized) return _mapInstanceProperty__default["default"](
|
|
269
|
+
if (field.isLocalized) return _mapInstanceProperty__default["default"](locales).call(locales, locale => {
|
|
270
270
|
var _context3, _context4, _context5;
|
|
271
|
-
const alias = replaceSpecialCharsWithUnderscore(_concatInstanceProperty__default["default"](_context3 = "".concat(field.key, "______")).call(_context3,
|
|
272
|
-
return _concatInstanceProperty__default["default"](_context4 = _concatInstanceProperty__default["default"](_context5 = "".concat(alias, ": ")).call(_context5, field.key, "(locale: \"")).call(_context4,
|
|
271
|
+
const alias = replaceSpecialCharsWithUnderscore(_concatInstanceProperty__default["default"](_context3 = "".concat(field.key, "______")).call(_context3, locale));
|
|
272
|
+
return _concatInstanceProperty__default["default"](_context4 = _concatInstanceProperty__default["default"](_context5 = "".concat(alias, ": ")).call(_context5, field.key, "(locale: \"")).call(_context4, locale, "\")");
|
|
273
273
|
});else {
|
|
274
274
|
if (isFilledArray(field.fields)) {
|
|
275
275
|
return {
|
|
276
276
|
[field.key]: buildFields({
|
|
277
277
|
fields: field.fields,
|
|
278
|
-
|
|
278
|
+
locales
|
|
279
279
|
})
|
|
280
280
|
};
|
|
281
281
|
}
|
|
@@ -287,15 +287,15 @@ function buildFields(_ref) {
|
|
|
287
287
|
function validate(values) {
|
|
288
288
|
const errors = {
|
|
289
289
|
fileName: {},
|
|
290
|
-
|
|
290
|
+
locales: {}
|
|
291
291
|
};
|
|
292
292
|
if (uiKit.TextInput.isEmpty(values.fileName)) {
|
|
293
293
|
errors.fileName.missing = true;
|
|
294
294
|
} else if (!/^[a-zA-Z0-9-_.]+$/.test(values.fileName)) {
|
|
295
295
|
errors.fileName.invalidInput = true;
|
|
296
296
|
}
|
|
297
|
-
if (values.
|
|
298
|
-
errors.
|
|
297
|
+
if (values.locales.length < 1) {
|
|
298
|
+
errors.locales.missing = true;
|
|
299
299
|
}
|
|
300
300
|
return omitEmpty__default["default"](errors);
|
|
301
301
|
}
|
|
@@ -306,21 +306,6 @@ var messages = reactIntl.defineMessages({
|
|
|
306
306
|
description: 'Label for the modal title',
|
|
307
307
|
defaultMessage: 'Export {resourceType}'
|
|
308
308
|
},
|
|
309
|
-
modalSubTitle: {
|
|
310
|
-
id: 'ExportResourcesModal.modalSubTitle',
|
|
311
|
-
description: 'Label for the modal subtitle',
|
|
312
|
-
defaultMessage: 'Define export settings'
|
|
313
|
-
},
|
|
314
|
-
topBarPreviousPathLabel: {
|
|
315
|
-
id: 'ExportResourcesModal.topBarPreviousPathLabel',
|
|
316
|
-
description: 'Label for the topBar previous label',
|
|
317
|
-
defaultMessage: 'To {resourceType} List'
|
|
318
|
-
},
|
|
319
|
-
exportButton: {
|
|
320
|
-
id: 'ExportResourcesModal.exportButton',
|
|
321
|
-
description: 'Export primary button',
|
|
322
|
-
defaultMessage: 'Export {resourceType}'
|
|
323
|
-
},
|
|
324
309
|
outputFormat: {
|
|
325
310
|
id: 'ExportResourcesModal.outputFormat',
|
|
326
311
|
description: 'File format like (csv, xls, ...etc)',
|
|
@@ -331,10 +316,10 @@ var messages = reactIntl.defineMessages({
|
|
|
331
316
|
description: 'exported file name',
|
|
332
317
|
defaultMessage: 'File name'
|
|
333
318
|
},
|
|
334
|
-
|
|
335
|
-
id: 'ExportResourcesModal.
|
|
336
|
-
description: '
|
|
337
|
-
defaultMessage: '
|
|
319
|
+
locale: {
|
|
320
|
+
id: 'ExportResourcesModal.locale',
|
|
321
|
+
description: 'Locale',
|
|
322
|
+
defaultMessage: 'Locale'
|
|
338
323
|
},
|
|
339
324
|
exportSelection: {
|
|
340
325
|
id: 'ExportResourcesModal.exportSelection',
|
|
@@ -396,40 +381,20 @@ var messages = reactIntl.defineMessages({
|
|
|
396
381
|
description: 'properties panel label',
|
|
397
382
|
defaultMessage: 'Properties'
|
|
398
383
|
},
|
|
399
|
-
confirmationTitle: {
|
|
400
|
-
id: 'ExportResourcesModal.confirmationTitle',
|
|
401
|
-
description: 'Title for the confirmation dialog',
|
|
402
|
-
defaultMessage: 'Export {resourceType} data'
|
|
403
|
-
},
|
|
404
|
-
confirmationBodyPlan: {
|
|
405
|
-
id: 'ExportResourcesModal.confirmationBodyPlan',
|
|
406
|
-
description: 'Confirmation dialog action plan',
|
|
407
|
-
defaultMessage: 'You are about to export <bold>{count}</bold> {resourceType} from the project: <bold>{projectName}</bold>.'
|
|
408
|
-
},
|
|
409
|
-
confirmationBodyQuestion: {
|
|
410
|
-
id: 'ExportResourcesModal.confirmationBodyQuestion',
|
|
411
|
-
description: 'Confirmation question',
|
|
412
|
-
defaultMessage: 'Are you sure you want to continue?'
|
|
413
|
-
},
|
|
414
384
|
exportOperationSuccessMessage: {
|
|
415
385
|
id: 'ExportResourcesModal.exportOperationSuccessMessage',
|
|
416
386
|
description: 'Success message',
|
|
417
387
|
defaultMessage: '<b>Your export has started.</b> <newline></newline><logsLink>Go to Export logs</logsLink> to view the progress and download the file.'
|
|
418
388
|
},
|
|
419
|
-
exportConfirmationLabel: {
|
|
420
|
-
id: 'ExportResourcesModal.exportConfirmationLabel',
|
|
421
|
-
description: 'Label for the export button in confirmation dialog',
|
|
422
|
-
defaultMessage: 'Export {resourceType}'
|
|
423
|
-
},
|
|
424
389
|
nothingApplied: {
|
|
425
390
|
id: 'ExportResourcesModal.nothingApplied',
|
|
426
391
|
description: 'Shown when there is no filter applied',
|
|
427
392
|
defaultMessage: 'nothing applied'
|
|
428
393
|
},
|
|
429
|
-
|
|
430
|
-
id: 'ExportResourcesModal.
|
|
431
|
-
description: 'label for "
|
|
432
|
-
defaultMessage: '
|
|
394
|
+
selectAllLocales: {
|
|
395
|
+
id: 'ExportResourcesModal.selectAllLocales',
|
|
396
|
+
description: 'label for "Select all locales" checkbox',
|
|
397
|
+
defaultMessage: 'Select all locales'
|
|
433
398
|
},
|
|
434
399
|
missingFileNameError: {
|
|
435
400
|
id: 'ExportResourcesModal.missingFileNameError',
|
|
@@ -441,15 +406,25 @@ var messages = reactIntl.defineMessages({
|
|
|
441
406
|
description: 'Error when file name field is not valid',
|
|
442
407
|
defaultMessage: 'File name may only contain alphanumeric characters, hyphens and underscores'
|
|
443
408
|
},
|
|
444
|
-
|
|
445
|
-
id: 'ExportResourcesModal.
|
|
446
|
-
description: 'Error when no
|
|
447
|
-
defaultMessage: 'Please select at least one
|
|
409
|
+
missingLocaleError: {
|
|
410
|
+
id: 'ExportResourcesModal.missingLocaleError',
|
|
411
|
+
description: 'Error when no locale is selected',
|
|
412
|
+
defaultMessage: 'Please select at least one locale'
|
|
448
413
|
},
|
|
449
414
|
myViews: {
|
|
450
415
|
id: 'ExportResourcesModal.myViews',
|
|
451
416
|
description: 'Label for "My Views" Select Field',
|
|
452
417
|
defaultMessage: 'My Views'
|
|
418
|
+
},
|
|
419
|
+
cancel: {
|
|
420
|
+
id: 'ExportResourcesModal.cancel',
|
|
421
|
+
description: 'Label for "Cancel" button',
|
|
422
|
+
defaultMessage: 'Cancel'
|
|
423
|
+
},
|
|
424
|
+
startExport: {
|
|
425
|
+
id: 'ExportResourcesModal.startExport',
|
|
426
|
+
description: 'Label for "Start Export" button',
|
|
427
|
+
defaultMessage: 'Start Export'
|
|
453
428
|
}
|
|
454
429
|
});
|
|
455
430
|
|
|
@@ -503,8 +478,8 @@ function TagList(props) {
|
|
|
503
478
|
TagList.displayName = 'TagList';
|
|
504
479
|
TagList.propTypes = {};
|
|
505
480
|
|
|
506
|
-
function ownKeys$
|
|
507
|
-
function _objectSpread$
|
|
481
|
+
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; }
|
|
482
|
+
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; }
|
|
508
483
|
function AppliedFilters(_ref) {
|
|
509
484
|
let filters = _ref.filters,
|
|
510
485
|
onFilterRemove = _ref.onFilterRemove;
|
|
@@ -514,7 +489,7 @@ function AppliedFilters(_ref) {
|
|
|
514
489
|
condensed: true,
|
|
515
490
|
isDefaultClosed: !Boolean(filters.length),
|
|
516
491
|
header: jsxRuntime.jsx(uiKit.Text.Body, {
|
|
517
|
-
intlMessage: _objectSpread$
|
|
492
|
+
intlMessage: _objectSpread$8(_objectSpread$8({}, messages.appliedFiltersMessage), {}, {
|
|
518
493
|
values: {
|
|
519
494
|
filtersCount: filters.length
|
|
520
495
|
}
|
|
@@ -543,7 +518,7 @@ function AppliedFilters(_ref) {
|
|
|
543
518
|
color: "neutral60"
|
|
544
519
|
}), jsxRuntime.jsx(uiKit.Text.Body, {
|
|
545
520
|
isBold: true,
|
|
546
|
-
intlMessage: _objectSpread$
|
|
521
|
+
intlMessage: _objectSpread$8(_objectSpread$8({}, messages.appliedFiltersMessage), {}, {
|
|
547
522
|
values: {
|
|
548
523
|
filtersCount: filters.length
|
|
549
524
|
}
|
|
@@ -564,8 +539,8 @@ function AppliedFilters(_ref) {
|
|
|
564
539
|
}
|
|
565
540
|
AppliedFilters.propTypes = {};
|
|
566
541
|
|
|
567
|
-
function ownKeys$
|
|
568
|
-
function _objectSpread$
|
|
542
|
+
function ownKeys$7(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; }
|
|
543
|
+
function _objectSpread$7(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$7(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$7(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
569
544
|
const IconPlaceholder = /*#__PURE__*/_styled__default["default"]("div", {
|
|
570
545
|
target: "e1oion860"
|
|
571
546
|
} )("width:", uiKit.customProperties.spacingM, ";" + ("" ));
|
|
@@ -577,7 +552,7 @@ function AppliedSearchTerms(_ref) {
|
|
|
577
552
|
condensed: true,
|
|
578
553
|
isDefaultClosed: !Boolean(appliedSearchTerms.length),
|
|
579
554
|
header: jsxRuntime.jsx(uiKit.Text.Body, {
|
|
580
|
-
intlMessage: _objectSpread$
|
|
555
|
+
intlMessage: _objectSpread$7(_objectSpread$7({}, messages.appliedSearchTermsMessage), {}, {
|
|
581
556
|
values: {
|
|
582
557
|
searchTermsCount: appliedSearchTerms.length
|
|
583
558
|
}
|
|
@@ -598,7 +573,7 @@ function AppliedSearchTerms(_ref) {
|
|
|
598
573
|
color: "neutral60"
|
|
599
574
|
}), jsxRuntime.jsx(uiKit.Text.Body, {
|
|
600
575
|
isBold: true,
|
|
601
|
-
intlMessage: _objectSpread$
|
|
576
|
+
intlMessage: _objectSpread$7(_objectSpread$7({}, messages.appliedSearchTermsMessage), {}, {
|
|
602
577
|
values: {
|
|
603
578
|
searchTermsCount: appliedSearchTerms.length
|
|
604
579
|
}
|
|
@@ -636,174 +611,27 @@ function ExportBasedOnMyViewsSelectField() {
|
|
|
636
611
|
});
|
|
637
612
|
}
|
|
638
613
|
|
|
639
|
-
function ownKeys$
|
|
640
|
-
function _objectSpread$
|
|
614
|
+
function ownKeys$6(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; }
|
|
615
|
+
function _objectSpread$6(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$6(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$6(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
641
616
|
function renderFileNameError(key) {
|
|
642
617
|
switch (key) {
|
|
643
618
|
case 'missing':
|
|
644
|
-
return jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$
|
|
619
|
+
return jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$6({}, messages.missingFileNameError));
|
|
645
620
|
case 'invalidInput':
|
|
646
|
-
return jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$
|
|
621
|
+
return jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$6({}, messages.invalidFileNameError));
|
|
647
622
|
default:
|
|
648
623
|
return null;
|
|
649
624
|
}
|
|
650
625
|
}
|
|
651
|
-
function
|
|
626
|
+
function renderLocaleError(key) {
|
|
652
627
|
switch (key) {
|
|
653
628
|
case 'missing':
|
|
654
|
-
return jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$
|
|
629
|
+
return jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$6({}, messages.missingLocaleError));
|
|
655
630
|
default:
|
|
656
631
|
return null;
|
|
657
632
|
}
|
|
658
633
|
}
|
|
659
634
|
|
|
660
|
-
function useExportResourcesContext() {
|
|
661
|
-
const context = react$1.useContext(ExportResourcesContext);
|
|
662
|
-
if (!context) {
|
|
663
|
-
throw new MissingExportResourceProviderError();
|
|
664
|
-
}
|
|
665
|
-
return context;
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
async function createExportOperation(_ref) {
|
|
669
|
-
let fileName = _ref.fileName,
|
|
670
|
-
fileFormat = _ref.fileFormat,
|
|
671
|
-
columns = _ref.columns,
|
|
672
|
-
projectKey = _ref.projectKey,
|
|
673
|
-
graphQuery = _ref.graphQuery,
|
|
674
|
-
asyncDispatchFn = _ref.asyncDispatchFn;
|
|
675
|
-
const uri = "/proxy/export/".concat(projectKey, "/export-operations");
|
|
676
|
-
const response = await asyncDispatchFn(sdk.actions.post({
|
|
677
|
-
// FIXME: EXPORT is undefined
|
|
678
|
-
mcApiProxyTarget: constants.MC_API_PROXY_TARGETS.EXPORT,
|
|
679
|
-
uri: uri,
|
|
680
|
-
headers: {
|
|
681
|
-
accept: 'application/json'
|
|
682
|
-
},
|
|
683
|
-
payload: {
|
|
684
|
-
fileName,
|
|
685
|
-
fileFormat,
|
|
686
|
-
columns,
|
|
687
|
-
query: graphQuery
|
|
688
|
-
}
|
|
689
|
-
}));
|
|
690
|
-
return response;
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
function ownKeys$6(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; }
|
|
694
|
-
function _objectSpread$6(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$6(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$6(Object(t))).call(_context3, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
695
|
-
const getExportLogsLink = (projectKey, msg) => jsxRuntime.jsx(uiKit.Link, {
|
|
696
|
-
to: "/".concat(projectKey, "/operations/export/logs"),
|
|
697
|
-
children: msg
|
|
698
|
-
});
|
|
699
|
-
function ExportConfirmationModal(props) {
|
|
700
|
-
const _useApplicationContex = applicationShellConnectors.useApplicationContext(applicationContext => {
|
|
701
|
-
var _applicationContext$p, _applicationContext$p2;
|
|
702
|
-
return {
|
|
703
|
-
projectName: (_applicationContext$p = applicationContext.project) === null || _applicationContext$p === void 0 ? void 0 : _applicationContext$p.name,
|
|
704
|
-
projectKey: (_applicationContext$p2 = applicationContext.project) === null || _applicationContext$p2 === void 0 ? void 0 : _applicationContext$p2.key
|
|
705
|
-
};
|
|
706
|
-
}),
|
|
707
|
-
projectName = _useApplicationContex.projectName,
|
|
708
|
-
projectKey = _useApplicationContex.projectKey;
|
|
709
|
-
const _useExportResourcesCo = useExportResourcesContext(),
|
|
710
|
-
formik = _useExportResourcesCo.formik,
|
|
711
|
-
allResourcesCount = _useExportResourcesCo.allResourcesCount,
|
|
712
|
-
matchingResourcesCount = _useExportResourcesCo.matchingResourcesCount,
|
|
713
|
-
selectedResourceIds = _useExportResourcesCo.selectedResourceIds,
|
|
714
|
-
resourceType = _useExportResourcesCo.resourceType;
|
|
715
|
-
const showNotification = actionsGlobal.useShowNotification();
|
|
716
|
-
const intl = reactIntl.useIntl();
|
|
717
|
-
const asyncDispatch = sdk.useAsyncDispatch();
|
|
718
|
-
const resourceTypePlural = resourceTypeToPlural({
|
|
719
|
-
resourceType: props.resourceType
|
|
720
|
-
});
|
|
721
|
-
const countInConfirmationMessage = () => {
|
|
722
|
-
switch (_valuesInstanceProperty__default["default"](formik).exportSelectionType) {
|
|
723
|
-
case EXPORT_SELECTION_TYPES.ALL_RESOURCES:
|
|
724
|
-
return allResourcesCount;
|
|
725
|
-
case EXPORT_SELECTION_TYPES.ONLY_MATCHING:
|
|
726
|
-
return matchingResourcesCount;
|
|
727
|
-
case EXPORT_SELECTION_TYPES.ONLY_SELECTED:
|
|
728
|
-
return selectedResourceIds.length;
|
|
729
|
-
default:
|
|
730
|
-
throw new UnexpectedSelectionTypeError(_valuesInstanceProperty__default["default"](formik).exportSelectionType);
|
|
731
|
-
}
|
|
732
|
-
};
|
|
733
|
-
return jsxRuntime.jsx(applicationComponents.ConfirmationDialog, {
|
|
734
|
-
dataAttributesPrimaryButton: {
|
|
735
|
-
'data-testid': 'confirm-export-button'
|
|
736
|
-
},
|
|
737
|
-
title: intl.formatMessage(messages.confirmationTitle, {
|
|
738
|
-
resourceType: resourceTypePlural
|
|
739
|
-
}),
|
|
740
|
-
labelPrimary: intl.formatMessage(messages.exportConfirmationLabel, {
|
|
741
|
-
resourceType: resourceTypePlural
|
|
742
|
-
}),
|
|
743
|
-
isOpen: props.isOpen,
|
|
744
|
-
onClose: props.closeModal,
|
|
745
|
-
onCancel: props.closeModal,
|
|
746
|
-
onConfirm: async () => {
|
|
747
|
-
const graphQuery = buildGraphQuery({
|
|
748
|
-
resourceType: resourceType,
|
|
749
|
-
selectedResourceIds: selectedResourceIds,
|
|
750
|
-
fields: _valuesInstanceProperty__default["default"](formik).fields,
|
|
751
|
-
exportSelectionType: _valuesInstanceProperty__default["default"](formik).exportSelectionType,
|
|
752
|
-
languages: _valuesInstanceProperty__default["default"](formik).languages
|
|
753
|
-
});
|
|
754
|
-
props.closeModal();
|
|
755
|
-
try {
|
|
756
|
-
var _context;
|
|
757
|
-
const response = await createExportOperation({
|
|
758
|
-
fileName: appendCsvOrJsonExtensionIfAbsent(_valuesInstanceProperty__default["default"](formik).fileName, _valuesInstanceProperty__default["default"](formik).outputFormat),
|
|
759
|
-
fileFormat: _valuesInstanceProperty__default["default"](formik).outputFormat,
|
|
760
|
-
locales: _valuesInstanceProperty__default["default"](formik).languages,
|
|
761
|
-
columns: _mapInstanceProperty__default["default"](_context = flattenNestedFields(_valuesInstanceProperty__default["default"](formik).fields)).call(_context, field => field.key),
|
|
762
|
-
projectKey,
|
|
763
|
-
graphQuery,
|
|
764
|
-
asyncDispatchFn: asyncDispatch
|
|
765
|
-
});
|
|
766
|
-
switch (response.state) {
|
|
767
|
-
case EXPORT_OPERATION_STATES.PROCESSING:
|
|
768
|
-
case EXPORT_OPERATION_STATES.COMPLETED:
|
|
769
|
-
showNotification({
|
|
770
|
-
kind: 'success',
|
|
771
|
-
domain: constants.DOMAINS.SIDE,
|
|
772
|
-
text: intl.formatMessage(messages.exportOperationSuccessMessage, {
|
|
773
|
-
newline: getNewLine,
|
|
774
|
-
logsLink: msg => getExportLogsLink(projectKey, msg),
|
|
775
|
-
b: getBold
|
|
776
|
-
})
|
|
777
|
-
});
|
|
778
|
-
props.onCloseParentModal();
|
|
779
|
-
break;
|
|
780
|
-
default:
|
|
781
|
-
throw new UnexpectedExportOperationStateError(response.state);
|
|
782
|
-
}
|
|
783
|
-
} catch (errors) {
|
|
784
|
-
actionsGlobal.showApiErrorNotification({
|
|
785
|
-
errors
|
|
786
|
-
});
|
|
787
|
-
}
|
|
788
|
-
},
|
|
789
|
-
children: jsxRuntime.jsxs("div", {
|
|
790
|
-
children: [jsxRuntime.jsx(uiKit.Text.Body, {
|
|
791
|
-
intlMessage: _objectSpread$6(_objectSpread$6({}, messages.confirmationBodyPlan), {}, {
|
|
792
|
-
values: {
|
|
793
|
-
resourceType: resourceTypePlural,
|
|
794
|
-
projectName: projectName,
|
|
795
|
-
count: countInConfirmationMessage(),
|
|
796
|
-
bold: getBold
|
|
797
|
-
}
|
|
798
|
-
})
|
|
799
|
-
}), jsxRuntime.jsx(uiKit.Text.Body, {
|
|
800
|
-
intlMessage: messages.confirmationBodyQuestion
|
|
801
|
-
})]
|
|
802
|
-
})
|
|
803
|
-
});
|
|
804
|
-
}
|
|
805
|
-
ExportConfirmationModal.propTypes = {};
|
|
806
|
-
|
|
807
635
|
function ownKeys$5(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; }
|
|
808
636
|
function _objectSpread$5(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$5(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$5(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
809
637
|
function FieldsRenderer(_ref) {
|
|
@@ -861,6 +689,14 @@ function ExportFields(_ref2) {
|
|
|
861
689
|
}
|
|
862
690
|
ExportFields.propTypes = {};
|
|
863
691
|
|
|
692
|
+
function useExportResourcesContext() {
|
|
693
|
+
const context = react$1.useContext(ExportResourcesContext);
|
|
694
|
+
if (!context) {
|
|
695
|
+
throw new MissingExportResourceProviderError();
|
|
696
|
+
}
|
|
697
|
+
return context;
|
|
698
|
+
}
|
|
699
|
+
|
|
864
700
|
function ownKeys$4(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; }
|
|
865
701
|
function _objectSpread$4(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$4(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$4(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
866
702
|
function ExportSelectionRadioButtons() {
|
|
@@ -872,7 +708,8 @@ function ExportSelectionRadioButtons() {
|
|
|
872
708
|
resourceType = _useExportResourcesCo.resourceType,
|
|
873
709
|
allResourcesCount = _useExportResourcesCo.allResourcesCount,
|
|
874
710
|
matchingResourcesCount = _useExportResourcesCo.matchingResourcesCount,
|
|
875
|
-
selectedResourceIds = _useExportResourcesCo.selectedResourceIds
|
|
711
|
+
selectedResourceIds = _useExportResourcesCo.selectedResourceIds,
|
|
712
|
+
exportSelectionType = _useExportResourcesCo.exportSelectionType;
|
|
876
713
|
const resourceTypePlural = resourceTypeToPlural({
|
|
877
714
|
resourceType: resourceType
|
|
878
715
|
});
|
|
@@ -880,7 +717,7 @@ function ExportSelectionRadioButtons() {
|
|
|
880
717
|
scale: "xl",
|
|
881
718
|
children: jsxRuntime.jsxs(uiKit.RadioInput.Group, {
|
|
882
719
|
name: "exportSelectionType",
|
|
883
|
-
value:
|
|
720
|
+
value: exportSelectionType,
|
|
884
721
|
direction: "inline",
|
|
885
722
|
directionProps: {
|
|
886
723
|
scale: 'xl'
|
|
@@ -936,11 +773,11 @@ function ExportTextMessage() {
|
|
|
936
773
|
allResourcesCount = _useExportResourcesCo.allResourcesCount,
|
|
937
774
|
selectedResourceIds = _useExportResourcesCo.selectedResourceIds,
|
|
938
775
|
matchingResourcesCount = _useExportResourcesCo.matchingResourcesCount,
|
|
939
|
-
|
|
776
|
+
exportSelectionType = _useExportResourcesCo.exportSelectionType;
|
|
940
777
|
const resourceTypePlural = resourceTypeToPlural({
|
|
941
778
|
resourceType: resourceType
|
|
942
779
|
});
|
|
943
|
-
switch (
|
|
780
|
+
switch (exportSelectionType) {
|
|
944
781
|
case EXPORT_SELECTION_TYPES.ALL_RESOURCES:
|
|
945
782
|
return jsxRuntime.jsx(uiKit.Text.Body, {
|
|
946
783
|
intlMessage: _objectSpread$3(_objectSpread$3({}, messages.exportAllMessage), {}, {
|
|
@@ -972,7 +809,7 @@ function ExportTextMessage() {
|
|
|
972
809
|
})
|
|
973
810
|
});
|
|
974
811
|
default:
|
|
975
|
-
throw new UnexpectedSelectionTypeError(
|
|
812
|
+
throw new UnexpectedSelectionTypeError(exportSelectionType);
|
|
976
813
|
}
|
|
977
814
|
}
|
|
978
815
|
|
|
@@ -980,7 +817,8 @@ const ExportSelection = () => {
|
|
|
980
817
|
const _useTheme = designSystem.useTheme(),
|
|
981
818
|
isNewTheme = _useTheme.isNewTheme;
|
|
982
819
|
const _useExportResourcesCo = useExportResourcesContext(),
|
|
983
|
-
formik = _useExportResourcesCo.formik
|
|
820
|
+
formik = _useExportResourcesCo.formik,
|
|
821
|
+
exportSelectionType = _useExportResourcesCo.exportSelectionType;
|
|
984
822
|
const onAppliedFilterRemove = filter => {
|
|
985
823
|
var _context;
|
|
986
824
|
formik.setFieldValue('appliedFilters', _filterInstanceProperty__default["default"](_context = _valuesInstanceProperty__default["default"](formik).appliedFilters).call(_context, appliedFilter => appliedFilter !== filter));
|
|
@@ -993,7 +831,7 @@ const ExportSelection = () => {
|
|
|
993
831
|
as: "h2",
|
|
994
832
|
intlMessage: messages.exportSelection
|
|
995
833
|
}), jsxRuntime.jsx(ExportSelectionRadioButtons, {}), jsxRuntime.jsx(ExportTextMessage, {})]
|
|
996
|
-
}),
|
|
834
|
+
}), exportSelectionType === EXPORT_SELECTION_TYPES.ONLY_MATCHING && jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
997
835
|
children: [jsxRuntime.jsx(ExportBasedOnMyViewsSelectField, {}), jsxRuntime.jsx(AppliedSearchTerms, {
|
|
998
836
|
appliedSearchTerms: _valuesInstanceProperty__default["default"](formik).appliedSearchTerms
|
|
999
837
|
}), jsxRuntime.jsx(AppliedFilters, {
|
|
@@ -1022,7 +860,7 @@ const ExportSelection = () => {
|
|
|
1022
860
|
scale: "m",
|
|
1023
861
|
children: jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
1024
862
|
scale: "l",
|
|
1025
|
-
children: [jsxRuntime.jsx(ExportTextMessage, {}),
|
|
863
|
+
children: [jsxRuntime.jsx(ExportTextMessage, {}), exportSelectionType === EXPORT_SELECTION_TYPES.ONLY_MATCHING && jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1026
864
|
children: [jsxRuntime.jsx(ExportBasedOnMyViewsSelectField, {}), jsxRuntime.jsx(AppliedSearchTerms, {
|
|
1027
865
|
appliedSearchTerms: _valuesInstanceProperty__default["default"](formik).appliedSearchTerms
|
|
1028
866
|
}), jsxRuntime.jsx(AppliedFilters, {
|
|
@@ -1066,132 +904,67 @@ ExportProperties.propTypes = {};
|
|
|
1066
904
|
function ownKeys$1(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; }
|
|
1067
905
|
function _objectSpread$1(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$1(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$1(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
1068
906
|
const outputFormatOptions = [{
|
|
1069
|
-
value: OUTPUT_FORMATS.JSON,
|
|
1070
|
-
label: 'JSON'
|
|
1071
|
-
}, {
|
|
1072
907
|
value: OUTPUT_FORMATS.CSV,
|
|
1073
908
|
label: 'CSV'
|
|
909
|
+
}, {
|
|
910
|
+
value: OUTPUT_FORMATS.JSON,
|
|
911
|
+
label: 'JSON'
|
|
1074
912
|
}];
|
|
1075
|
-
function
|
|
1076
|
-
return _mapInstanceProperty__default["default"](
|
|
1077
|
-
value:
|
|
1078
|
-
label:
|
|
913
|
+
function mapLocalesToOptions(locales) {
|
|
914
|
+
return _mapInstanceProperty__default["default"](locales).call(locales, locale => ({
|
|
915
|
+
value: locale,
|
|
916
|
+
label: locale
|
|
1079
917
|
}));
|
|
1080
918
|
}
|
|
1081
919
|
function ExportFileSettings(props) {
|
|
1082
|
-
const _useTheme = designSystem.useTheme(),
|
|
1083
|
-
isNewTheme = _useTheme.isNewTheme;
|
|
1084
920
|
const intl = reactIntl.useIntl();
|
|
1085
921
|
const _useExportResourcesCo = useExportResourcesContext(),
|
|
1086
922
|
formik = _useExportResourcesCo.formik;
|
|
1087
923
|
const _useApplicationContex = applicationShellConnectors.useApplicationContext(applicationContext => {
|
|
1088
924
|
var _applicationContext$p;
|
|
1089
925
|
return {
|
|
1090
|
-
|
|
1091
|
-
|
|
926
|
+
locale: applicationContext.dataLocale,
|
|
927
|
+
locales: ((_applicationContext$p = applicationContext.project) === null || _applicationContext$p === void 0 ? void 0 : _applicationContext$p.languages) || []
|
|
1092
928
|
};
|
|
1093
929
|
}),
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
if (isNewTheme) return jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
1097
|
-
scale: "xxxl",
|
|
1098
|
-
children: [jsxRuntime.jsx(applicationComponents.PageContentNarrow, {
|
|
1099
|
-
children: jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
1100
|
-
scale: "xl",
|
|
1101
|
-
children: [jsxRuntime.jsx(uiKit.SelectField, _objectSpread$1(_objectSpread$1({}, formik.getFieldProps('outputFormat')), {}, {
|
|
1102
|
-
title: intl.formatMessage(messages.outputFormat),
|
|
1103
|
-
options: outputFormatOptions
|
|
1104
|
-
})), jsxRuntime.jsx(uiKit.TextField, _objectSpread$1(_objectSpread$1({
|
|
1105
|
-
title: intl.formatMessage(messages.fileName)
|
|
1106
|
-
}, formik.getFieldProps('fileName')), {}, {
|
|
1107
|
-
touched: formik.touched.fileName,
|
|
1108
|
-
errors: formik.errors.fileName,
|
|
1109
|
-
renderError: renderFileNameError
|
|
1110
|
-
})), jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
1111
|
-
scale: "xs",
|
|
1112
|
-
children: [jsxRuntime.jsx(uiKit.SelectField, _objectSpread$1(_objectSpread$1({
|
|
1113
|
-
id: "languages",
|
|
1114
|
-
title: intl.formatMessage(messages.localLanguage),
|
|
1115
|
-
options: mapLanguagesToOptions(languages),
|
|
1116
|
-
isMulti: true
|
|
1117
|
-
}, formik.getFieldProps('languages')), {}, {
|
|
1118
|
-
onChange: e => {
|
|
1119
|
-
formik.handleChange(e);
|
|
1120
|
-
formik.setFieldValue('isAllLanguagesChecked', false);
|
|
1121
|
-
},
|
|
1122
|
-
touched: formik.touched.languages,
|
|
1123
|
-
errors: formik.errors.languages,
|
|
1124
|
-
renderError: renderLanguageError
|
|
1125
|
-
})), jsxRuntime.jsx(uiKit.CheckboxInput, {
|
|
1126
|
-
name: "isAllLanguagesChecked",
|
|
1127
|
-
isChecked: _valuesInstanceProperty__default["default"](formik).isAllLanguagesChecked,
|
|
1128
|
-
onChange: e => {
|
|
1129
|
-
if (e.target.checked) formik.setFieldValue('languages', languages);else formik.setFieldValue('languages', [language]);
|
|
1130
|
-
formik.handleChange(e);
|
|
1131
|
-
},
|
|
1132
|
-
children: intl.formatMessage(messages.all)
|
|
1133
|
-
})]
|
|
1134
|
-
})]
|
|
1135
|
-
})
|
|
1136
|
-
}), jsxRuntime.jsx(applicationComponents.PageContentWide, {
|
|
1137
|
-
children: jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
1138
|
-
scale: "xxxl",
|
|
1139
|
-
children: [jsxRuntime.jsx(ExportSelection, {}), jsxRuntime.jsx(ExportProperties, {
|
|
1140
|
-
renderProperties: props.renderProperties
|
|
1141
|
-
})]
|
|
1142
|
-
})
|
|
1143
|
-
})]
|
|
1144
|
-
});
|
|
930
|
+
locales = _useApplicationContex.locales,
|
|
931
|
+
locale = _useApplicationContex.locale;
|
|
1145
932
|
return jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
1146
|
-
scale: "
|
|
1147
|
-
children: [jsxRuntime.
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
children: jsxRuntime.jsx(uiKit.SelectField, _objectSpread$1(_objectSpread$1({
|
|
1163
|
-
id: "languages",
|
|
1164
|
-
title: jsxRuntime.jsxs(uiKit.Spacings.Inline, {
|
|
1165
|
-
scale: "s",
|
|
1166
|
-
children: [jsxRuntime.jsx("label", {
|
|
1167
|
-
htmlFor: "languages",
|
|
1168
|
-
children: intl.formatMessage(messages.localLanguage)
|
|
1169
|
-
}), jsxRuntime.jsx(uiKit.CheckboxInput, {
|
|
1170
|
-
name: "isAllLanguagesChecked",
|
|
1171
|
-
isChecked: _valuesInstanceProperty__default["default"](formik).isAllLanguagesChecked,
|
|
1172
|
-
onChange: e => {
|
|
1173
|
-
if (e.target.checked) formik.setFieldValue('languages', languages);else formik.setFieldValue('languages', [language]);
|
|
1174
|
-
formik.handleChange(e);
|
|
1175
|
-
},
|
|
1176
|
-
children: jsxRuntime.jsx("div", {
|
|
1177
|
-
css: styles.notBold,
|
|
1178
|
-
children: intl.formatMessage(messages.all)
|
|
1179
|
-
})
|
|
1180
|
-
})]
|
|
1181
|
-
}),
|
|
1182
|
-
options: mapLanguagesToOptions(languages),
|
|
933
|
+
scale: "m",
|
|
934
|
+
children: [jsxRuntime.jsx(uiKit.SelectField, _objectSpread$1(_objectSpread$1({}, formik.getFieldProps('outputFormat')), {}, {
|
|
935
|
+
title: intl.formatMessage(messages.outputFormat),
|
|
936
|
+
options: outputFormatOptions
|
|
937
|
+
})), jsxRuntime.jsx(uiKit.TextField, _objectSpread$1(_objectSpread$1({
|
|
938
|
+
title: intl.formatMessage(messages.fileName)
|
|
939
|
+
}, formik.getFieldProps('fileName')), {}, {
|
|
940
|
+
touched: formik.touched.fileName,
|
|
941
|
+
errors: formik.errors.fileName,
|
|
942
|
+
renderError: renderFileNameError
|
|
943
|
+
})), jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
944
|
+
scale: "xs",
|
|
945
|
+
children: [jsxRuntime.jsx(uiKit.SelectField, _objectSpread$1(_objectSpread$1({
|
|
946
|
+
id: "locales",
|
|
947
|
+
title: intl.formatMessage(messages.locale),
|
|
948
|
+
options: mapLocalesToOptions(locales),
|
|
1183
949
|
isMulti: true
|
|
1184
|
-
}, formik.getFieldProps('
|
|
950
|
+
}, formik.getFieldProps('locales')), {}, {
|
|
951
|
+
onChange: e => {
|
|
952
|
+
formik.handleChange(e);
|
|
953
|
+
formik.setFieldValue('isAllLocalesChecked', false);
|
|
954
|
+
},
|
|
955
|
+
touched: formik.touched.locales,
|
|
956
|
+
errors: formik.errors.locales,
|
|
957
|
+
renderError: renderLocaleError
|
|
958
|
+
})), jsxRuntime.jsx(uiKit.CheckboxInput, {
|
|
959
|
+
name: "isAllLocalesChecked",
|
|
960
|
+
isChecked: _valuesInstanceProperty__default["default"](formik).isAllLocalesChecked,
|
|
1185
961
|
onChange: e => {
|
|
962
|
+
if (e.target.checked) formik.setFieldValue('locales', locales);else formik.setFieldValue('locales', [locale]);
|
|
1186
963
|
formik.handleChange(e);
|
|
1187
|
-
formik.setFieldValue('isAllLanguagesChecked', false);
|
|
1188
964
|
},
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
horizontalConstraint: 7
|
|
1193
|
-
}))
|
|
1194
|
-
}), jsxRuntime.jsx(ExportSelection, {}), jsxRuntime.jsx(ExportProperties, {
|
|
965
|
+
children: intl.formatMessage(messages.selectAllLocales)
|
|
966
|
+
})]
|
|
967
|
+
}), props.showExportSelection && jsxRuntime.jsx(ExportSelection, {}), jsxRuntime.jsx(ExportProperties, {
|
|
1195
968
|
renderProperties: props.renderProperties
|
|
1196
969
|
})]
|
|
1197
970
|
});
|
|
@@ -1201,6 +974,33 @@ ExportFileSettings.propTypes = {};
|
|
|
1201
974
|
|
|
1202
975
|
const ExportResourcesContext = /*#__PURE__*/react$1.createContext();
|
|
1203
976
|
|
|
977
|
+
async function createExportOperation(_ref) {
|
|
978
|
+
let fileName = _ref.fileName,
|
|
979
|
+
fileFormat = _ref.fileFormat,
|
|
980
|
+
columns = _ref.columns,
|
|
981
|
+
locales = _ref.locales,
|
|
982
|
+
projectKey = _ref.projectKey,
|
|
983
|
+
graphQuery = _ref.graphQuery,
|
|
984
|
+
asyncDispatchFn = _ref.asyncDispatchFn;
|
|
985
|
+
const uri = "/proxy/export/".concat(projectKey, "/export-operations");
|
|
986
|
+
const response = await asyncDispatchFn(sdk.actions.post({
|
|
987
|
+
// FIXME: EXPORT is undefined
|
|
988
|
+
mcApiProxyTarget: constants.MC_API_PROXY_TARGETS.EXPORT,
|
|
989
|
+
uri: uri,
|
|
990
|
+
headers: {
|
|
991
|
+
accept: 'application/json'
|
|
992
|
+
},
|
|
993
|
+
payload: {
|
|
994
|
+
fileName,
|
|
995
|
+
fileFormat,
|
|
996
|
+
columns,
|
|
997
|
+
locales,
|
|
998
|
+
query: graphQuery
|
|
999
|
+
}
|
|
1000
|
+
}));
|
|
1001
|
+
return response;
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1204
1004
|
PropTypes__default["default"].shape({
|
|
1205
1005
|
resourceType: PropTypes__default["default"].string.isRequired,
|
|
1206
1006
|
outputFormat: PropTypes__default["default"].string,
|
|
@@ -1208,6 +1008,7 @@ PropTypes__default["default"].shape({
|
|
|
1208
1008
|
allResourcesCount: PropTypes__default["default"].number.isRequired,
|
|
1209
1009
|
matchingResourcesCount: PropTypes__default["default"].number,
|
|
1210
1010
|
selectedResourceIds: PropTypes__default["default"].array,
|
|
1011
|
+
showExportSelection: PropTypes__default["default"].bool,
|
|
1211
1012
|
// TODO: Circular reference
|
|
1212
1013
|
fields: PropTypes__default["default"].arrayOf(PropTypes__default["default"].shape({
|
|
1213
1014
|
key: PropTypes__default["default"].string.isRequired,
|
|
@@ -1226,32 +1027,83 @@ PropTypes__default["default"].shape({
|
|
|
1226
1027
|
}).isRequired;
|
|
1227
1028
|
|
|
1228
1029
|
const ExportResourcesContextProvider = props => {
|
|
1229
|
-
var
|
|
1030
|
+
var _context2;
|
|
1031
|
+
const intl = reactIntl.useIntl();
|
|
1230
1032
|
const todayFormatted = moment__default["default"]().format('DD-MM-YY_HH-mm');
|
|
1231
|
-
const
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1033
|
+
const asyncDispatch = sdk.useAsyncDispatch();
|
|
1034
|
+
const showNotification = actionsGlobal.useShowNotification();
|
|
1035
|
+
const _useApplicationContex = applicationShellConnectors.useApplicationContext(applicationContext => {
|
|
1036
|
+
var _applicationContext$p;
|
|
1037
|
+
return {
|
|
1038
|
+
locale: applicationContext.dataLocale,
|
|
1039
|
+
projectKey: (_applicationContext$p = applicationContext.project) === null || _applicationContext$p === void 0 ? void 0 : _applicationContext$p.key
|
|
1040
|
+
};
|
|
1041
|
+
}),
|
|
1042
|
+
projectKey = _useApplicationContex.projectKey,
|
|
1043
|
+
locale = _useApplicationContex.locale;
|
|
1044
|
+
const onSubmit = async values => {
|
|
1045
|
+
const graphQuery = buildGraphQuery({
|
|
1046
|
+
resourceType: props.resourceType,
|
|
1047
|
+
exportSelectionType: props.exportSelectionType,
|
|
1048
|
+
selectedResourceIds: props.selectedResourceIds,
|
|
1049
|
+
fields: values.fields,
|
|
1050
|
+
locales: values.locales
|
|
1051
|
+
});
|
|
1052
|
+
try {
|
|
1053
|
+
var _context;
|
|
1054
|
+
const response = await createExportOperation({
|
|
1055
|
+
fileName: appendCsvOrJsonExtensionIfAbsent(values.fileName, values.outputFormat),
|
|
1056
|
+
fileFormat: values.outputFormat,
|
|
1057
|
+
locales: values.locales,
|
|
1058
|
+
columns: _mapInstanceProperty__default["default"](_context = flattenNestedFields(values.fields)).call(_context, field => field.key),
|
|
1059
|
+
projectKey,
|
|
1060
|
+
graphQuery,
|
|
1061
|
+
asyncDispatchFn: asyncDispatch
|
|
1062
|
+
});
|
|
1063
|
+
switch (response.state) {
|
|
1064
|
+
case EXPORT_OPERATION_STATES.PROCESSING:
|
|
1065
|
+
case EXPORT_OPERATION_STATES.COMPLETED:
|
|
1066
|
+
showNotification({
|
|
1067
|
+
kind: 'info',
|
|
1068
|
+
domain: constants.DOMAINS.SIDE,
|
|
1069
|
+
text: intl.formatMessage(messages.exportOperationSuccessMessage, {
|
|
1070
|
+
newline: getNewLine,
|
|
1071
|
+
logsLink: msg => getExportLogsLink(projectKey, msg),
|
|
1072
|
+
b: getBold
|
|
1073
|
+
})
|
|
1074
|
+
});
|
|
1075
|
+
break;
|
|
1076
|
+
default:
|
|
1077
|
+
throw new UnexpectedExportOperationStateError(response.state);
|
|
1078
|
+
}
|
|
1079
|
+
} catch (errors) {
|
|
1080
|
+
// TODO: custom error messages for each error type
|
|
1081
|
+
actionsGlobal.showApiErrorNotification({
|
|
1082
|
+
errors
|
|
1083
|
+
});
|
|
1084
|
+
}
|
|
1085
|
+
};
|
|
1235
1086
|
const formik$1 = formik.useFormik({
|
|
1236
1087
|
initialValues: {
|
|
1237
1088
|
outputFormat: props.outputFormat,
|
|
1238
|
-
fileName: _concatInstanceProperty__default["default"](
|
|
1089
|
+
fileName: _concatInstanceProperty__default["default"](_context2 = "".concat(resourceTypeToPlural({
|
|
1239
1090
|
resourceType: props.resourceType,
|
|
1240
1091
|
isUpperCase: true
|
|
1241
|
-
}), "_Export_")).call(
|
|
1242
|
-
|
|
1092
|
+
}), "_Export_")).call(_context2, todayFormatted),
|
|
1093
|
+
locales: [locale],
|
|
1243
1094
|
fields: props.fields,
|
|
1244
1095
|
appliedSearchTerms: props.appliedSearchTerms,
|
|
1245
1096
|
appliedFilters: props.appliedFilters,
|
|
1246
|
-
|
|
1247
|
-
isAllLanguagesChecked: false
|
|
1097
|
+
isAllLocalesChecked: false
|
|
1248
1098
|
},
|
|
1249
|
-
validate
|
|
1099
|
+
validate,
|
|
1100
|
+
onSubmit
|
|
1250
1101
|
});
|
|
1251
1102
|
return jsxRuntime.jsx(ExportResourcesContext.Provider, {
|
|
1252
1103
|
value: {
|
|
1253
1104
|
formik: formik$1,
|
|
1254
1105
|
resourceType: props.resourceType,
|
|
1106
|
+
exportSelectionType: props.exportSelectionType,
|
|
1255
1107
|
allResourcesCount: props.allResourcesCount,
|
|
1256
1108
|
matchingResourcesCount: props.matchingResourcesCount,
|
|
1257
1109
|
selectedResourceIds: props.selectedResourceIds
|
|
@@ -1261,15 +1113,19 @@ const ExportResourcesContextProvider = props => {
|
|
|
1261
1113
|
};
|
|
1262
1114
|
ExportResourcesContextProvider.displayName = 'ExportResourcesContextProvider';
|
|
1263
1115
|
ExportResourcesContextProvider.propTypes = {};
|
|
1116
|
+
const getExportLogsLink = (projectKey, msg) => jsxRuntime.jsx(uiKit.Link, {
|
|
1117
|
+
to: "/".concat(projectKey, "/operations/export/logs"),
|
|
1118
|
+
children: msg
|
|
1119
|
+
});
|
|
1264
1120
|
|
|
1265
|
-
const _excluded = ["renderProperties"];
|
|
1121
|
+
const _excluded = ["renderProperties", "showExportSelection"];
|
|
1266
1122
|
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; }
|
|
1267
1123
|
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; }
|
|
1268
1124
|
const ExportResourcesModal = _ref => {
|
|
1269
1125
|
let renderProperties = _ref.renderProperties,
|
|
1126
|
+
showExportSelection = _ref.showExportSelection,
|
|
1270
1127
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
1271
1128
|
const intl = reactIntl.useIntl();
|
|
1272
|
-
const confirmationModal = applicationComponents.useModalState();
|
|
1273
1129
|
const resourceTypePlural = resourceTypeToPlural({
|
|
1274
1130
|
resourceType: props.resourceType
|
|
1275
1131
|
});
|
|
@@ -1277,30 +1133,38 @@ const ExportResourcesModal = _ref => {
|
|
|
1277
1133
|
children: jsxRuntime.jsx(ExportResourcesContext.Consumer, {
|
|
1278
1134
|
children: _ref2 => {
|
|
1279
1135
|
let formik = _ref2.formik;
|
|
1280
|
-
return jsxRuntime.
|
|
1136
|
+
return jsxRuntime.jsx(applicationComponents.InfoDialog, {
|
|
1281
1137
|
isOpen: true,
|
|
1282
1138
|
title: intl.formatMessage(messages.modalTitle, {
|
|
1283
1139
|
resourceType: resourceTypePlural
|
|
1284
1140
|
}),
|
|
1285
1141
|
onClose: props.closeModal,
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1142
|
+
children: jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
1143
|
+
scale: "xxxl",
|
|
1144
|
+
children: [jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
1145
|
+
scale: "l",
|
|
1146
|
+
children: [jsxRuntime.jsxs(uiKit.Spacings.Inline, {
|
|
1147
|
+
alignItems: "center",
|
|
1148
|
+
children: [jsxRuntime.jsx(uiKit.ExportIcon, {
|
|
1149
|
+
size: "medium",
|
|
1150
|
+
color: "neutral60"
|
|
1151
|
+
}), jsxRuntime.jsx(ExportTextMessage, {})]
|
|
1152
|
+
}), jsxRuntime.jsx(ExportFileSettings, {
|
|
1153
|
+
renderProperties: renderProperties,
|
|
1154
|
+
showExportSelection: showExportSelection
|
|
1155
|
+
})]
|
|
1156
|
+
}), jsxRuntime.jsxs(uiKit.Spacings.Inline, {
|
|
1157
|
+
justifyContent: "flex-end",
|
|
1158
|
+
scale: "m",
|
|
1159
|
+
children: [jsxRuntime.jsx(uiKit.SecondaryButton, {
|
|
1160
|
+
label: intl.formatMessage(messages.cancel),
|
|
1161
|
+
onClick: props.closeModal
|
|
1162
|
+
}), jsxRuntime.jsx(uiKit.PrimaryButton, {
|
|
1163
|
+
label: intl.formatMessage(messages.startExport),
|
|
1164
|
+
onClick: formik.submitForm
|
|
1165
|
+
})]
|
|
1166
|
+
})]
|
|
1167
|
+
})
|
|
1304
1168
|
});
|
|
1305
1169
|
}
|
|
1306
1170
|
})
|
|
@@ -1314,7 +1178,8 @@ ExportResourcesModal.defaultProps = {
|
|
|
1314
1178
|
appliedFilters: [],
|
|
1315
1179
|
matchingResourcesCount: 0,
|
|
1316
1180
|
exportSelectionType: EXPORT_SELECTION_TYPES.ALL_RESOURCES,
|
|
1317
|
-
outputFormat: OUTPUT_FORMATS.CSV
|
|
1181
|
+
outputFormat: OUTPUT_FORMATS.CSV,
|
|
1182
|
+
showExportSelection: false
|
|
1318
1183
|
};
|
|
1319
1184
|
|
|
1320
1185
|
exports.EXPORTABLE_RESOURCES = EXPORTABLE_RESOURCES;
|