@commercetools-frontend-extensions/export-resources-modal 1.4.1 → 1.5.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/README.md +9 -5
- package/dist/commercetools-frontend-extensions-export-resources-modal.cjs.dev.js +248 -387
- package/dist/commercetools-frontend-extensions-export-resources-modal.cjs.prod.js +246 -381
- package/dist/commercetools-frontend-extensions-export-resources-modal.esm.js +249 -388
- package/package.json +20 -20
|
@@ -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,176 +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
|
-
locales = _ref.locales,
|
|
673
|
-
projectKey = _ref.projectKey,
|
|
674
|
-
graphQuery = _ref.graphQuery,
|
|
675
|
-
asyncDispatchFn = _ref.asyncDispatchFn;
|
|
676
|
-
const uri = "/proxy/export/".concat(projectKey, "/export-operations");
|
|
677
|
-
const response = await asyncDispatchFn(sdk.actions.post({
|
|
678
|
-
// FIXME: EXPORT is undefined
|
|
679
|
-
mcApiProxyTarget: constants.MC_API_PROXY_TARGETS.EXPORT,
|
|
680
|
-
uri: uri,
|
|
681
|
-
headers: {
|
|
682
|
-
accept: 'application/json'
|
|
683
|
-
},
|
|
684
|
-
payload: {
|
|
685
|
-
fileName,
|
|
686
|
-
fileFormat,
|
|
687
|
-
columns,
|
|
688
|
-
locales,
|
|
689
|
-
query: graphQuery
|
|
690
|
-
}
|
|
691
|
-
}));
|
|
692
|
-
return response;
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
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; }
|
|
696
|
-
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; }
|
|
697
|
-
const getExportLogsLink = (projectKey, msg) => jsxRuntime.jsx(uiKit.Link, {
|
|
698
|
-
to: "/".concat(projectKey, "/operations/export/logs"),
|
|
699
|
-
children: msg
|
|
700
|
-
});
|
|
701
|
-
function ExportConfirmationModal(props) {
|
|
702
|
-
const _useApplicationContex = applicationShellConnectors.useApplicationContext(applicationContext => {
|
|
703
|
-
var _applicationContext$p, _applicationContext$p2;
|
|
704
|
-
return {
|
|
705
|
-
projectName: (_applicationContext$p = applicationContext.project) === null || _applicationContext$p === void 0 ? void 0 : _applicationContext$p.name,
|
|
706
|
-
projectKey: (_applicationContext$p2 = applicationContext.project) === null || _applicationContext$p2 === void 0 ? void 0 : _applicationContext$p2.key
|
|
707
|
-
};
|
|
708
|
-
}),
|
|
709
|
-
projectName = _useApplicationContex.projectName,
|
|
710
|
-
projectKey = _useApplicationContex.projectKey;
|
|
711
|
-
const _useExportResourcesCo = useExportResourcesContext(),
|
|
712
|
-
formik = _useExportResourcesCo.formik,
|
|
713
|
-
allResourcesCount = _useExportResourcesCo.allResourcesCount,
|
|
714
|
-
matchingResourcesCount = _useExportResourcesCo.matchingResourcesCount,
|
|
715
|
-
selectedResourceIds = _useExportResourcesCo.selectedResourceIds,
|
|
716
|
-
resourceType = _useExportResourcesCo.resourceType;
|
|
717
|
-
const showNotification = actionsGlobal.useShowNotification();
|
|
718
|
-
const intl = reactIntl.useIntl();
|
|
719
|
-
const asyncDispatch = sdk.useAsyncDispatch();
|
|
720
|
-
const resourceTypePlural = resourceTypeToPlural({
|
|
721
|
-
resourceType: props.resourceType
|
|
722
|
-
});
|
|
723
|
-
const countInConfirmationMessage = () => {
|
|
724
|
-
switch (_valuesInstanceProperty__default["default"](formik).exportSelectionType) {
|
|
725
|
-
case EXPORT_SELECTION_TYPES.ALL_RESOURCES:
|
|
726
|
-
return allResourcesCount;
|
|
727
|
-
case EXPORT_SELECTION_TYPES.ONLY_MATCHING:
|
|
728
|
-
return matchingResourcesCount;
|
|
729
|
-
case EXPORT_SELECTION_TYPES.ONLY_SELECTED:
|
|
730
|
-
return selectedResourceIds.length;
|
|
731
|
-
default:
|
|
732
|
-
throw new UnexpectedSelectionTypeError(_valuesInstanceProperty__default["default"](formik).exportSelectionType);
|
|
733
|
-
}
|
|
734
|
-
};
|
|
735
|
-
return jsxRuntime.jsx(applicationComponents.ConfirmationDialog, {
|
|
736
|
-
dataAttributesPrimaryButton: {
|
|
737
|
-
'data-testid': 'confirm-export-button'
|
|
738
|
-
},
|
|
739
|
-
title: intl.formatMessage(messages.confirmationTitle, {
|
|
740
|
-
resourceType: resourceTypePlural
|
|
741
|
-
}),
|
|
742
|
-
labelPrimary: intl.formatMessage(messages.exportConfirmationLabel, {
|
|
743
|
-
resourceType: resourceTypePlural
|
|
744
|
-
}),
|
|
745
|
-
isOpen: props.isOpen,
|
|
746
|
-
onClose: props.closeModal,
|
|
747
|
-
onCancel: props.closeModal,
|
|
748
|
-
onConfirm: async () => {
|
|
749
|
-
const graphQuery = buildGraphQuery({
|
|
750
|
-
resourceType: resourceType,
|
|
751
|
-
selectedResourceIds: selectedResourceIds,
|
|
752
|
-
fields: _valuesInstanceProperty__default["default"](formik).fields,
|
|
753
|
-
exportSelectionType: _valuesInstanceProperty__default["default"](formik).exportSelectionType,
|
|
754
|
-
languages: _valuesInstanceProperty__default["default"](formik).languages
|
|
755
|
-
});
|
|
756
|
-
props.closeModal();
|
|
757
|
-
try {
|
|
758
|
-
var _context;
|
|
759
|
-
const response = await createExportOperation({
|
|
760
|
-
fileName: appendCsvOrJsonExtensionIfAbsent(_valuesInstanceProperty__default["default"](formik).fileName, _valuesInstanceProperty__default["default"](formik).outputFormat),
|
|
761
|
-
fileFormat: _valuesInstanceProperty__default["default"](formik).outputFormat,
|
|
762
|
-
locales: _valuesInstanceProperty__default["default"](formik).languages,
|
|
763
|
-
columns: _mapInstanceProperty__default["default"](_context = flattenNestedFields(_valuesInstanceProperty__default["default"](formik).fields)).call(_context, field => field.key),
|
|
764
|
-
projectKey,
|
|
765
|
-
graphQuery,
|
|
766
|
-
asyncDispatchFn: asyncDispatch
|
|
767
|
-
});
|
|
768
|
-
switch (response.state) {
|
|
769
|
-
case EXPORT_OPERATION_STATES.PROCESSING:
|
|
770
|
-
case EXPORT_OPERATION_STATES.COMPLETED:
|
|
771
|
-
showNotification({
|
|
772
|
-
kind: 'success',
|
|
773
|
-
domain: constants.DOMAINS.SIDE,
|
|
774
|
-
text: intl.formatMessage(messages.exportOperationSuccessMessage, {
|
|
775
|
-
newline: getNewLine,
|
|
776
|
-
logsLink: msg => getExportLogsLink(projectKey, msg),
|
|
777
|
-
b: getBold
|
|
778
|
-
})
|
|
779
|
-
});
|
|
780
|
-
props.onCloseParentModal();
|
|
781
|
-
break;
|
|
782
|
-
default:
|
|
783
|
-
throw new UnexpectedExportOperationStateError(response.state);
|
|
784
|
-
}
|
|
785
|
-
} catch (errors) {
|
|
786
|
-
actionsGlobal.showApiErrorNotification({
|
|
787
|
-
errors
|
|
788
|
-
});
|
|
789
|
-
}
|
|
790
|
-
},
|
|
791
|
-
children: jsxRuntime.jsxs("div", {
|
|
792
|
-
children: [jsxRuntime.jsx(uiKit.Text.Body, {
|
|
793
|
-
intlMessage: _objectSpread$6(_objectSpread$6({}, messages.confirmationBodyPlan), {}, {
|
|
794
|
-
values: {
|
|
795
|
-
resourceType: resourceTypePlural,
|
|
796
|
-
projectName: projectName,
|
|
797
|
-
count: countInConfirmationMessage(),
|
|
798
|
-
bold: getBold
|
|
799
|
-
}
|
|
800
|
-
})
|
|
801
|
-
}), jsxRuntime.jsx(uiKit.Text.Body, {
|
|
802
|
-
intlMessage: messages.confirmationBodyQuestion
|
|
803
|
-
})]
|
|
804
|
-
})
|
|
805
|
-
});
|
|
806
|
-
}
|
|
807
|
-
ExportConfirmationModal.propTypes = {};
|
|
808
|
-
|
|
809
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; }
|
|
810
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; }
|
|
811
637
|
function FieldsRenderer(_ref) {
|
|
@@ -863,6 +689,14 @@ function ExportFields(_ref2) {
|
|
|
863
689
|
}
|
|
864
690
|
ExportFields.propTypes = {};
|
|
865
691
|
|
|
692
|
+
function useExportResourcesContext() {
|
|
693
|
+
const context = react$1.useContext(ExportResourcesContext);
|
|
694
|
+
if (!context) {
|
|
695
|
+
throw new MissingExportResourceProviderError();
|
|
696
|
+
}
|
|
697
|
+
return context;
|
|
698
|
+
}
|
|
699
|
+
|
|
866
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; }
|
|
867
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; }
|
|
868
702
|
function ExportSelectionRadioButtons() {
|
|
@@ -874,7 +708,8 @@ function ExportSelectionRadioButtons() {
|
|
|
874
708
|
resourceType = _useExportResourcesCo.resourceType,
|
|
875
709
|
allResourcesCount = _useExportResourcesCo.allResourcesCount,
|
|
876
710
|
matchingResourcesCount = _useExportResourcesCo.matchingResourcesCount,
|
|
877
|
-
selectedResourceIds = _useExportResourcesCo.selectedResourceIds
|
|
711
|
+
selectedResourceIds = _useExportResourcesCo.selectedResourceIds,
|
|
712
|
+
exportSelectionType = _useExportResourcesCo.exportSelectionType;
|
|
878
713
|
const resourceTypePlural = resourceTypeToPlural({
|
|
879
714
|
resourceType: resourceType
|
|
880
715
|
});
|
|
@@ -882,7 +717,7 @@ function ExportSelectionRadioButtons() {
|
|
|
882
717
|
scale: "xl",
|
|
883
718
|
children: jsxRuntime.jsxs(uiKit.RadioInput.Group, {
|
|
884
719
|
name: "exportSelectionType",
|
|
885
|
-
value:
|
|
720
|
+
value: exportSelectionType,
|
|
886
721
|
direction: "inline",
|
|
887
722
|
directionProps: {
|
|
888
723
|
scale: 'xl'
|
|
@@ -938,11 +773,11 @@ function ExportTextMessage() {
|
|
|
938
773
|
allResourcesCount = _useExportResourcesCo.allResourcesCount,
|
|
939
774
|
selectedResourceIds = _useExportResourcesCo.selectedResourceIds,
|
|
940
775
|
matchingResourcesCount = _useExportResourcesCo.matchingResourcesCount,
|
|
941
|
-
|
|
776
|
+
exportSelectionType = _useExportResourcesCo.exportSelectionType;
|
|
942
777
|
const resourceTypePlural = resourceTypeToPlural({
|
|
943
778
|
resourceType: resourceType
|
|
944
779
|
});
|
|
945
|
-
switch (
|
|
780
|
+
switch (exportSelectionType) {
|
|
946
781
|
case EXPORT_SELECTION_TYPES.ALL_RESOURCES:
|
|
947
782
|
return jsxRuntime.jsx(uiKit.Text.Body, {
|
|
948
783
|
intlMessage: _objectSpread$3(_objectSpread$3({}, messages.exportAllMessage), {}, {
|
|
@@ -974,7 +809,7 @@ function ExportTextMessage() {
|
|
|
974
809
|
})
|
|
975
810
|
});
|
|
976
811
|
default:
|
|
977
|
-
throw new UnexpectedSelectionTypeError(
|
|
812
|
+
throw new UnexpectedSelectionTypeError(exportSelectionType);
|
|
978
813
|
}
|
|
979
814
|
}
|
|
980
815
|
|
|
@@ -982,7 +817,8 @@ const ExportSelection = () => {
|
|
|
982
817
|
const _useTheme = designSystem.useTheme(),
|
|
983
818
|
isNewTheme = _useTheme.isNewTheme;
|
|
984
819
|
const _useExportResourcesCo = useExportResourcesContext(),
|
|
985
|
-
formik = _useExportResourcesCo.formik
|
|
820
|
+
formik = _useExportResourcesCo.formik,
|
|
821
|
+
exportSelectionType = _useExportResourcesCo.exportSelectionType;
|
|
986
822
|
const onAppliedFilterRemove = filter => {
|
|
987
823
|
var _context;
|
|
988
824
|
formik.setFieldValue('appliedFilters', _filterInstanceProperty__default["default"](_context = _valuesInstanceProperty__default["default"](formik).appliedFilters).call(_context, appliedFilter => appliedFilter !== filter));
|
|
@@ -995,7 +831,7 @@ const ExportSelection = () => {
|
|
|
995
831
|
as: "h2",
|
|
996
832
|
intlMessage: messages.exportSelection
|
|
997
833
|
}), jsxRuntime.jsx(ExportSelectionRadioButtons, {}), jsxRuntime.jsx(ExportTextMessage, {})]
|
|
998
|
-
}),
|
|
834
|
+
}), exportSelectionType === EXPORT_SELECTION_TYPES.ONLY_MATCHING && jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
999
835
|
children: [jsxRuntime.jsx(ExportBasedOnMyViewsSelectField, {}), jsxRuntime.jsx(AppliedSearchTerms, {
|
|
1000
836
|
appliedSearchTerms: _valuesInstanceProperty__default["default"](formik).appliedSearchTerms
|
|
1001
837
|
}), jsxRuntime.jsx(AppliedFilters, {
|
|
@@ -1024,7 +860,7 @@ const ExportSelection = () => {
|
|
|
1024
860
|
scale: "m",
|
|
1025
861
|
children: jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
1026
862
|
scale: "l",
|
|
1027
|
-
children: [jsxRuntime.jsx(ExportTextMessage, {}),
|
|
863
|
+
children: [jsxRuntime.jsx(ExportTextMessage, {}), exportSelectionType === EXPORT_SELECTION_TYPES.ONLY_MATCHING && jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1028
864
|
children: [jsxRuntime.jsx(ExportBasedOnMyViewsSelectField, {}), jsxRuntime.jsx(AppliedSearchTerms, {
|
|
1029
865
|
appliedSearchTerms: _valuesInstanceProperty__default["default"](formik).appliedSearchTerms
|
|
1030
866
|
}), jsxRuntime.jsx(AppliedFilters, {
|
|
@@ -1068,132 +904,67 @@ ExportProperties.propTypes = {};
|
|
|
1068
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; }
|
|
1069
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; }
|
|
1070
906
|
const outputFormatOptions = [{
|
|
1071
|
-
value: OUTPUT_FORMATS.JSON,
|
|
1072
|
-
label: 'JSON'
|
|
1073
|
-
}, {
|
|
1074
907
|
value: OUTPUT_FORMATS.CSV,
|
|
1075
908
|
label: 'CSV'
|
|
909
|
+
}, {
|
|
910
|
+
value: OUTPUT_FORMATS.JSON,
|
|
911
|
+
label: 'JSON'
|
|
1076
912
|
}];
|
|
1077
|
-
function
|
|
1078
|
-
return _mapInstanceProperty__default["default"](
|
|
1079
|
-
value:
|
|
1080
|
-
label:
|
|
913
|
+
function mapLocalesToOptions(locales) {
|
|
914
|
+
return _mapInstanceProperty__default["default"](locales).call(locales, locale => ({
|
|
915
|
+
value: locale,
|
|
916
|
+
label: locale
|
|
1081
917
|
}));
|
|
1082
918
|
}
|
|
1083
919
|
function ExportFileSettings(props) {
|
|
1084
|
-
const _useTheme = designSystem.useTheme(),
|
|
1085
|
-
isNewTheme = _useTheme.isNewTheme;
|
|
1086
920
|
const intl = reactIntl.useIntl();
|
|
1087
921
|
const _useExportResourcesCo = useExportResourcesContext(),
|
|
1088
922
|
formik = _useExportResourcesCo.formik;
|
|
1089
923
|
const _useApplicationContex = applicationShellConnectors.useApplicationContext(applicationContext => {
|
|
1090
924
|
var _applicationContext$p;
|
|
1091
925
|
return {
|
|
1092
|
-
|
|
1093
|
-
|
|
926
|
+
locale: applicationContext.dataLocale,
|
|
927
|
+
locales: ((_applicationContext$p = applicationContext.project) === null || _applicationContext$p === void 0 ? void 0 : _applicationContext$p.languages) || []
|
|
1094
928
|
};
|
|
1095
929
|
}),
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
if (isNewTheme) return jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
1099
|
-
scale: "xxxl",
|
|
1100
|
-
children: [jsxRuntime.jsx(applicationComponents.PageContentNarrow, {
|
|
1101
|
-
children: jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
1102
|
-
scale: "xl",
|
|
1103
|
-
children: [jsxRuntime.jsx(uiKit.SelectField, _objectSpread$1(_objectSpread$1({}, formik.getFieldProps('outputFormat')), {}, {
|
|
1104
|
-
title: intl.formatMessage(messages.outputFormat),
|
|
1105
|
-
options: outputFormatOptions
|
|
1106
|
-
})), jsxRuntime.jsx(uiKit.TextField, _objectSpread$1(_objectSpread$1({
|
|
1107
|
-
title: intl.formatMessage(messages.fileName)
|
|
1108
|
-
}, formik.getFieldProps('fileName')), {}, {
|
|
1109
|
-
touched: formik.touched.fileName,
|
|
1110
|
-
errors: formik.errors.fileName,
|
|
1111
|
-
renderError: renderFileNameError
|
|
1112
|
-
})), jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
1113
|
-
scale: "xs",
|
|
1114
|
-
children: [jsxRuntime.jsx(uiKit.SelectField, _objectSpread$1(_objectSpread$1({
|
|
1115
|
-
id: "languages",
|
|
1116
|
-
title: intl.formatMessage(messages.localLanguage),
|
|
1117
|
-
options: mapLanguagesToOptions(languages),
|
|
1118
|
-
isMulti: true
|
|
1119
|
-
}, formik.getFieldProps('languages')), {}, {
|
|
1120
|
-
onChange: e => {
|
|
1121
|
-
formik.handleChange(e);
|
|
1122
|
-
formik.setFieldValue('isAllLanguagesChecked', false);
|
|
1123
|
-
},
|
|
1124
|
-
touched: formik.touched.languages,
|
|
1125
|
-
errors: formik.errors.languages,
|
|
1126
|
-
renderError: renderLanguageError
|
|
1127
|
-
})), jsxRuntime.jsx(uiKit.CheckboxInput, {
|
|
1128
|
-
name: "isAllLanguagesChecked",
|
|
1129
|
-
isChecked: _valuesInstanceProperty__default["default"](formik).isAllLanguagesChecked,
|
|
1130
|
-
onChange: e => {
|
|
1131
|
-
if (e.target.checked) formik.setFieldValue('languages', languages);else formik.setFieldValue('languages', [language]);
|
|
1132
|
-
formik.handleChange(e);
|
|
1133
|
-
},
|
|
1134
|
-
children: intl.formatMessage(messages.all)
|
|
1135
|
-
})]
|
|
1136
|
-
})]
|
|
1137
|
-
})
|
|
1138
|
-
}), jsxRuntime.jsx(applicationComponents.PageContentWide, {
|
|
1139
|
-
children: jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
1140
|
-
scale: "xxxl",
|
|
1141
|
-
children: [jsxRuntime.jsx(ExportSelection, {}), jsxRuntime.jsx(ExportProperties, {
|
|
1142
|
-
renderProperties: props.renderProperties
|
|
1143
|
-
})]
|
|
1144
|
-
})
|
|
1145
|
-
})]
|
|
1146
|
-
});
|
|
930
|
+
locales = _useApplicationContex.locales,
|
|
931
|
+
locale = _useApplicationContex.locale;
|
|
1147
932
|
return jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
1148
|
-
scale: "
|
|
1149
|
-
children: [jsxRuntime.
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
children: jsxRuntime.jsx(uiKit.SelectField, _objectSpread$1(_objectSpread$1({
|
|
1165
|
-
id: "languages",
|
|
1166
|
-
title: jsxRuntime.jsxs(uiKit.Spacings.Inline, {
|
|
1167
|
-
scale: "s",
|
|
1168
|
-
children: [jsxRuntime.jsx("label", {
|
|
1169
|
-
htmlFor: "languages",
|
|
1170
|
-
children: intl.formatMessage(messages.localLanguage)
|
|
1171
|
-
}), jsxRuntime.jsx(uiKit.CheckboxInput, {
|
|
1172
|
-
name: "isAllLanguagesChecked",
|
|
1173
|
-
isChecked: _valuesInstanceProperty__default["default"](formik).isAllLanguagesChecked,
|
|
1174
|
-
onChange: e => {
|
|
1175
|
-
if (e.target.checked) formik.setFieldValue('languages', languages);else formik.setFieldValue('languages', [language]);
|
|
1176
|
-
formik.handleChange(e);
|
|
1177
|
-
},
|
|
1178
|
-
children: jsxRuntime.jsx("div", {
|
|
1179
|
-
css: styles.notBold,
|
|
1180
|
-
children: intl.formatMessage(messages.all)
|
|
1181
|
-
})
|
|
1182
|
-
})]
|
|
1183
|
-
}),
|
|
1184
|
-
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),
|
|
1185
949
|
isMulti: true
|
|
1186
|
-
}, formik.getFieldProps('
|
|
950
|
+
}, formik.getFieldProps('locales')), {}, {
|
|
1187
951
|
onChange: e => {
|
|
1188
952
|
formik.handleChange(e);
|
|
1189
|
-
formik.setFieldValue('
|
|
953
|
+
formik.setFieldValue('isAllLocalesChecked', false);
|
|
1190
954
|
},
|
|
1191
|
-
touched: formik.touched.
|
|
1192
|
-
errors: formik.errors.
|
|
1193
|
-
renderError:
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
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,
|
|
961
|
+
onChange: e => {
|
|
962
|
+
if (e.target.checked) formik.setFieldValue('locales', locales);else formik.setFieldValue('locales', [locale]);
|
|
963
|
+
formik.handleChange(e);
|
|
964
|
+
},
|
|
965
|
+
children: intl.formatMessage(messages.selectAllLocales)
|
|
966
|
+
})]
|
|
967
|
+
}), props.showExportSelection && jsxRuntime.jsx(ExportSelection, {}), jsxRuntime.jsx(ExportProperties, {
|
|
1197
968
|
renderProperties: props.renderProperties
|
|
1198
969
|
})]
|
|
1199
970
|
});
|
|
@@ -1203,6 +974,33 @@ ExportFileSettings.propTypes = {};
|
|
|
1203
974
|
|
|
1204
975
|
const ExportResourcesContext = /*#__PURE__*/react$1.createContext();
|
|
1205
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
|
+
|
|
1206
1004
|
PropTypes__default["default"].shape({
|
|
1207
1005
|
resourceType: PropTypes__default["default"].string.isRequired,
|
|
1208
1006
|
outputFormat: PropTypes__default["default"].string,
|
|
@@ -1210,6 +1008,7 @@ PropTypes__default["default"].shape({
|
|
|
1210
1008
|
allResourcesCount: PropTypes__default["default"].number.isRequired,
|
|
1211
1009
|
matchingResourcesCount: PropTypes__default["default"].number,
|
|
1212
1010
|
selectedResourceIds: PropTypes__default["default"].array,
|
|
1011
|
+
showExportSelection: PropTypes__default["default"].bool,
|
|
1213
1012
|
// TODO: Circular reference
|
|
1214
1013
|
fields: PropTypes__default["default"].arrayOf(PropTypes__default["default"].shape({
|
|
1215
1014
|
key: PropTypes__default["default"].string.isRequired,
|
|
@@ -1228,32 +1027,85 @@ PropTypes__default["default"].shape({
|
|
|
1228
1027
|
}).isRequired;
|
|
1229
1028
|
|
|
1230
1029
|
const ExportResourcesContextProvider = props => {
|
|
1231
|
-
var
|
|
1030
|
+
var _context2;
|
|
1031
|
+
const intl = reactIntl.useIntl();
|
|
1232
1032
|
const todayFormatted = moment__default["default"]().format('DD-MM-YY_HH-mm');
|
|
1233
|
-
const
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
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
|
+
} finally {
|
|
1085
|
+
props.closeModal();
|
|
1086
|
+
}
|
|
1087
|
+
};
|
|
1237
1088
|
const formik$1 = formik.useFormik({
|
|
1238
1089
|
initialValues: {
|
|
1239
1090
|
outputFormat: props.outputFormat,
|
|
1240
|
-
fileName: _concatInstanceProperty__default["default"](
|
|
1091
|
+
fileName: _concatInstanceProperty__default["default"](_context2 = "".concat(resourceTypeToPlural({
|
|
1241
1092
|
resourceType: props.resourceType,
|
|
1242
1093
|
isUpperCase: true
|
|
1243
|
-
}), "_Export_")).call(
|
|
1244
|
-
|
|
1094
|
+
}), "_Export_")).call(_context2, todayFormatted),
|
|
1095
|
+
locales: [locale],
|
|
1245
1096
|
fields: props.fields,
|
|
1246
1097
|
appliedSearchTerms: props.appliedSearchTerms,
|
|
1247
1098
|
appliedFilters: props.appliedFilters,
|
|
1248
|
-
|
|
1249
|
-
isAllLanguagesChecked: false
|
|
1099
|
+
isAllLocalesChecked: false
|
|
1250
1100
|
},
|
|
1251
|
-
validate
|
|
1101
|
+
validate,
|
|
1102
|
+
onSubmit
|
|
1252
1103
|
});
|
|
1253
1104
|
return jsxRuntime.jsx(ExportResourcesContext.Provider, {
|
|
1254
1105
|
value: {
|
|
1255
1106
|
formik: formik$1,
|
|
1256
1107
|
resourceType: props.resourceType,
|
|
1108
|
+
exportSelectionType: props.exportSelectionType,
|
|
1257
1109
|
allResourcesCount: props.allResourcesCount,
|
|
1258
1110
|
matchingResourcesCount: props.matchingResourcesCount,
|
|
1259
1111
|
selectedResourceIds: props.selectedResourceIds
|
|
@@ -1263,15 +1115,19 @@ const ExportResourcesContextProvider = props => {
|
|
|
1263
1115
|
};
|
|
1264
1116
|
ExportResourcesContextProvider.displayName = 'ExportResourcesContextProvider';
|
|
1265
1117
|
ExportResourcesContextProvider.propTypes = {};
|
|
1118
|
+
const getExportLogsLink = (projectKey, msg) => jsxRuntime.jsx(uiKit.Link, {
|
|
1119
|
+
to: "/".concat(projectKey, "/operations/export/logs"),
|
|
1120
|
+
children: msg
|
|
1121
|
+
});
|
|
1266
1122
|
|
|
1267
|
-
const _excluded = ["renderProperties"];
|
|
1123
|
+
const _excluded = ["renderProperties", "showExportSelection"];
|
|
1268
1124
|
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; }
|
|
1269
1125
|
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; }
|
|
1270
1126
|
const ExportResourcesModal = _ref => {
|
|
1271
1127
|
let renderProperties = _ref.renderProperties,
|
|
1128
|
+
showExportSelection = _ref.showExportSelection,
|
|
1272
1129
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
1273
1130
|
const intl = reactIntl.useIntl();
|
|
1274
|
-
const confirmationModal = applicationComponents.useModalState();
|
|
1275
1131
|
const resourceTypePlural = resourceTypeToPlural({
|
|
1276
1132
|
resourceType: props.resourceType
|
|
1277
1133
|
});
|
|
@@ -1279,30 +1135,38 @@ const ExportResourcesModal = _ref => {
|
|
|
1279
1135
|
children: jsxRuntime.jsx(ExportResourcesContext.Consumer, {
|
|
1280
1136
|
children: _ref2 => {
|
|
1281
1137
|
let formik = _ref2.formik;
|
|
1282
|
-
return jsxRuntime.
|
|
1138
|
+
return jsxRuntime.jsx(applicationComponents.InfoDialog, {
|
|
1283
1139
|
isOpen: true,
|
|
1284
1140
|
title: intl.formatMessage(messages.modalTitle, {
|
|
1285
1141
|
resourceType: resourceTypePlural
|
|
1286
1142
|
}),
|
|
1287
1143
|
onClose: props.closeModal,
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1144
|
+
children: jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
1145
|
+
scale: "xxxl",
|
|
1146
|
+
children: [jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
1147
|
+
scale: "l",
|
|
1148
|
+
children: [jsxRuntime.jsxs(uiKit.Spacings.Inline, {
|
|
1149
|
+
alignItems: "center",
|
|
1150
|
+
children: [jsxRuntime.jsx(uiKit.ExportIcon, {
|
|
1151
|
+
size: "medium",
|
|
1152
|
+
color: "neutral60"
|
|
1153
|
+
}), jsxRuntime.jsx(ExportTextMessage, {})]
|
|
1154
|
+
}), jsxRuntime.jsx(ExportFileSettings, {
|
|
1155
|
+
renderProperties: renderProperties,
|
|
1156
|
+
showExportSelection: showExportSelection
|
|
1157
|
+
})]
|
|
1158
|
+
}), jsxRuntime.jsxs(uiKit.Spacings.Inline, {
|
|
1159
|
+
justifyContent: "flex-end",
|
|
1160
|
+
scale: "m",
|
|
1161
|
+
children: [jsxRuntime.jsx(uiKit.SecondaryButton, {
|
|
1162
|
+
label: intl.formatMessage(messages.cancel),
|
|
1163
|
+
onClick: props.closeModal
|
|
1164
|
+
}), jsxRuntime.jsx(uiKit.PrimaryButton, {
|
|
1165
|
+
label: intl.formatMessage(messages.startExport),
|
|
1166
|
+
onClick: formik.submitForm
|
|
1167
|
+
})]
|
|
1168
|
+
})]
|
|
1169
|
+
})
|
|
1306
1170
|
});
|
|
1307
1171
|
}
|
|
1308
1172
|
})
|
|
@@ -1316,7 +1180,8 @@ ExportResourcesModal.defaultProps = {
|
|
|
1316
1180
|
appliedFilters: [],
|
|
1317
1181
|
matchingResourcesCount: 0,
|
|
1318
1182
|
exportSelectionType: EXPORT_SELECTION_TYPES.ALL_RESOURCES,
|
|
1319
|
-
outputFormat: OUTPUT_FORMATS.CSV
|
|
1183
|
+
outputFormat: OUTPUT_FORMATS.CSV,
|
|
1184
|
+
showExportSelection: false
|
|
1320
1185
|
};
|
|
1321
1186
|
|
|
1322
1187
|
exports.EXPORTABLE_RESOURCES = EXPORTABLE_RESOURCES;
|