@commercetools-frontend-extensions/export-resources-modal 1.4.1 → 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 -387
- package/dist/commercetools-frontend-extensions-export-resources-modal.cjs.prod.js +244 -381
- package/dist/commercetools-frontend-extensions-export-resources-modal.esm.js +247 -388
- package/package.json +17 -17
|
@@ -9,7 +9,8 @@ import _Object$defineProperty from '@babel/runtime-corejs3/core-js-stable/object
|
|
|
9
9
|
import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
|
|
10
10
|
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/esm/objectWithoutProperties';
|
|
11
11
|
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
|
12
|
-
import {
|
|
12
|
+
import { InfoDialog } from '@commercetools-frontend/application-components';
|
|
13
|
+
import { TextInput, Text, CollapsiblePanel, Tag, Spacings, AngleRightIcon, customProperties as customProperties$1, Constraints, SelectInput, RadioInput, Card, SelectField, TextField, CheckboxInput, Link, ExportIcon, SecondaryButton, PrimaryButton } from '@commercetools-frontend/ui-kit';
|
|
13
14
|
import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/map';
|
|
14
15
|
import _flatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/flat';
|
|
15
16
|
import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
|
|
@@ -22,7 +23,6 @@ import _possibleConstructorReturn from '@babel/runtime-corejs3/helpers/esm/possi
|
|
|
22
23
|
import _getPrototypeOf from '@babel/runtime-corejs3/helpers/esm/getPrototypeOf';
|
|
23
24
|
import _wrapNativeSuper from '@babel/runtime-corejs3/helpers/esm/wrapNativeSuper';
|
|
24
25
|
import _Array$isArray from '@babel/runtime-corejs3/core-js-stable/array/is-array';
|
|
25
|
-
import { TextInput, Text, CollapsiblePanel, Tag, Spacings, AngleRightIcon, customProperties as customProperties$1, Constraints, SelectInput, Link, RadioInput, Card, SelectField, TextField, CheckboxInput } from '@commercetools-frontend/ui-kit';
|
|
26
26
|
import omitEmpty from 'omit-empty-es';
|
|
27
27
|
import { jsx, jsxs, Fragment } from '@emotion/react/jsx-runtime';
|
|
28
28
|
import { customProperties, useTheme } from '@commercetools-uikit/design-system';
|
|
@@ -32,11 +32,11 @@ import { css } from '@emotion/react';
|
|
|
32
32
|
import _styled from '@emotion/styled/base';
|
|
33
33
|
import _valuesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/values';
|
|
34
34
|
import { useApplicationContext } from '@commercetools-frontend/application-shell-connectors';
|
|
35
|
-
import { actions, useAsyncDispatch } from '@commercetools-frontend/sdk';
|
|
36
|
-
import { MC_API_PROXY_TARGETS, DOMAINS } from '@commercetools-frontend/constants';
|
|
37
|
-
import { useShowNotification, showApiErrorNotification } from '@commercetools-frontend/actions-global';
|
|
38
35
|
import { useFormik } from 'formik';
|
|
39
36
|
import moment from 'moment';
|
|
37
|
+
import { useShowNotification, showApiErrorNotification } from '@commercetools-frontend/actions-global';
|
|
38
|
+
import { actions, useAsyncDispatch } from '@commercetools-frontend/sdk';
|
|
39
|
+
import { MC_API_PROXY_TARGETS, DOMAINS } from '@commercetools-frontend/constants';
|
|
40
40
|
|
|
41
41
|
const EXPORT_OPERATION_STATES = {
|
|
42
42
|
PROCESSING: 'processing',
|
|
@@ -121,8 +121,8 @@ let UnexpectedResourceTypeError = /*#__PURE__*/function (_Error) {
|
|
|
121
121
|
return _createClass(UnexpectedResourceTypeError);
|
|
122
122
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
123
123
|
|
|
124
|
-
function ownKeys$
|
|
125
|
-
function _objectSpread$
|
|
124
|
+
function ownKeys$a(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
125
|
+
function _objectSpread$a(e) { for (var r = 1; r < arguments.length; r++) { var _context4, _context5; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context4 = ownKeys$a(Object(t), !0)).call(_context4, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context5 = ownKeys$a(Object(t))).call(_context5, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
126
126
|
function resourceTypeToPlural(_ref) {
|
|
127
127
|
let resourceType = _ref.resourceType,
|
|
128
128
|
_ref$isUpperCase = _ref.isUpperCase,
|
|
@@ -168,7 +168,7 @@ function flattenNestedFields(fields) {
|
|
|
168
168
|
var _context2;
|
|
169
169
|
return _mapInstanceProperty(_context2 = flattenNestedFields(field.fields)).call(_context2, nestedField => {
|
|
170
170
|
var _context3;
|
|
171
|
-
return _objectSpread$
|
|
171
|
+
return _objectSpread$a(_objectSpread$a({}, nestedField), {}, {
|
|
172
172
|
key: _concatInstanceProperty(_context3 = "".concat(field.key, ".")).call(_context3, nestedField.key)
|
|
173
173
|
});
|
|
174
174
|
});
|
|
@@ -182,8 +182,8 @@ function flattenNestedFields(fields) {
|
|
|
182
182
|
* This function is responsible for constructing the GraphQL query based on the export settings
|
|
183
183
|
*
|
|
184
184
|
* Depending on the type of export selection (all resources, only selected, or only matching/filtered) it constructs different types of queries:
|
|
185
|
-
* - For 'all resources', it generates a query that fetches all fields and
|
|
186
|
-
* - For 'only selected', it creates a query that fetches only the fields and
|
|
185
|
+
* - For 'all resources', it generates a query that fetches all fields and locales specified in the export settings.
|
|
186
|
+
* - 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.
|
|
187
187
|
* - 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.
|
|
188
188
|
*/
|
|
189
189
|
function buildGraphQuery(exportSettings) {
|
|
@@ -196,7 +196,7 @@ function buildGraphQuery(exportSettings) {
|
|
|
196
196
|
fields: [{
|
|
197
197
|
results: buildFields({
|
|
198
198
|
fields: exportSettings.fields,
|
|
199
|
-
|
|
199
|
+
locales: exportSettings.locales
|
|
200
200
|
})
|
|
201
201
|
}],
|
|
202
202
|
variables: {}
|
|
@@ -207,7 +207,7 @@ function buildGraphQuery(exportSettings) {
|
|
|
207
207
|
fields: [{
|
|
208
208
|
results: buildFields({
|
|
209
209
|
fields: exportSettings.fields,
|
|
210
|
-
|
|
210
|
+
locales: exportSettings.locales
|
|
211
211
|
})
|
|
212
212
|
}],
|
|
213
213
|
variables: {
|
|
@@ -225,13 +225,13 @@ function buildGraphQuery(exportSettings) {
|
|
|
225
225
|
/*
|
|
226
226
|
* This function builds the necessary field structure for our GraphQL queries, tt is specifically designed to handle different types of fields
|
|
227
227
|
*
|
|
228
|
-
* For fields whose values change depending on the
|
|
229
|
-
* This format combines the field and the
|
|
228
|
+
* For fields whose values change depending on the locale aka localised fields, a unique request format is used
|
|
229
|
+
* 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
|
|
230
230
|
*
|
|
231
|
-
* Fields that don't vary by
|
|
231
|
+
* Fields that don't vary by locale but contain additional subfields (known as 'nested fields') are also addressed
|
|
232
232
|
* In these cases the function is used recursively on these subfields to generate the appropriate request.
|
|
233
233
|
*
|
|
234
|
-
* Overall, this function enables us to accurately request different types of data, including those varying by
|
|
234
|
+
* Overall, this function enables us to accurately request different types of data, including those varying by locale or containing subfields.
|
|
235
235
|
*
|
|
236
236
|
* More details can be found in the related PR: https://github.com/commercetools/commercetools-exporter/pull/103
|
|
237
237
|
*/
|
|
@@ -239,18 +239,18 @@ function buildGraphQuery(exportSettings) {
|
|
|
239
239
|
function buildFields(_ref) {
|
|
240
240
|
var _context2;
|
|
241
241
|
let fields = _ref.fields,
|
|
242
|
-
|
|
242
|
+
locales = _ref.locales;
|
|
243
243
|
return _flatInstanceProperty(_context2 = _mapInstanceProperty(fields).call(fields, field => {
|
|
244
|
-
if (field.isLocalized) return _mapInstanceProperty(
|
|
244
|
+
if (field.isLocalized) return _mapInstanceProperty(locales).call(locales, locale => {
|
|
245
245
|
var _context3, _context4, _context5;
|
|
246
|
-
const alias = replaceSpecialCharsWithUnderscore(_concatInstanceProperty(_context3 = "".concat(field.key, "______")).call(_context3,
|
|
247
|
-
return _concatInstanceProperty(_context4 = _concatInstanceProperty(_context5 = "".concat(alias, ": ")).call(_context5, field.key, "(locale: \"")).call(_context4,
|
|
246
|
+
const alias = replaceSpecialCharsWithUnderscore(_concatInstanceProperty(_context3 = "".concat(field.key, "______")).call(_context3, locale));
|
|
247
|
+
return _concatInstanceProperty(_context4 = _concatInstanceProperty(_context5 = "".concat(alias, ": ")).call(_context5, field.key, "(locale: \"")).call(_context4, locale, "\")");
|
|
248
248
|
});else {
|
|
249
249
|
if (isFilledArray(field.fields)) {
|
|
250
250
|
return {
|
|
251
251
|
[field.key]: buildFields({
|
|
252
252
|
fields: field.fields,
|
|
253
|
-
|
|
253
|
+
locales
|
|
254
254
|
})
|
|
255
255
|
};
|
|
256
256
|
}
|
|
@@ -262,15 +262,15 @@ function buildFields(_ref) {
|
|
|
262
262
|
function validate(values) {
|
|
263
263
|
const errors = {
|
|
264
264
|
fileName: {},
|
|
265
|
-
|
|
265
|
+
locales: {}
|
|
266
266
|
};
|
|
267
267
|
if (TextInput.isEmpty(values.fileName)) {
|
|
268
268
|
errors.fileName.missing = true;
|
|
269
269
|
} else if (!/^[a-zA-Z0-9-_.]+$/.test(values.fileName)) {
|
|
270
270
|
errors.fileName.invalidInput = true;
|
|
271
271
|
}
|
|
272
|
-
if (values.
|
|
273
|
-
errors.
|
|
272
|
+
if (values.locales.length < 1) {
|
|
273
|
+
errors.locales.missing = true;
|
|
274
274
|
}
|
|
275
275
|
return omitEmpty(errors);
|
|
276
276
|
}
|
|
@@ -281,21 +281,6 @@ var messages = defineMessages({
|
|
|
281
281
|
description: 'Label for the modal title',
|
|
282
282
|
defaultMessage: 'Export {resourceType}'
|
|
283
283
|
},
|
|
284
|
-
modalSubTitle: {
|
|
285
|
-
id: 'ExportResourcesModal.modalSubTitle',
|
|
286
|
-
description: 'Label for the modal subtitle',
|
|
287
|
-
defaultMessage: 'Define export settings'
|
|
288
|
-
},
|
|
289
|
-
topBarPreviousPathLabel: {
|
|
290
|
-
id: 'ExportResourcesModal.topBarPreviousPathLabel',
|
|
291
|
-
description: 'Label for the topBar previous label',
|
|
292
|
-
defaultMessage: 'To {resourceType} List'
|
|
293
|
-
},
|
|
294
|
-
exportButton: {
|
|
295
|
-
id: 'ExportResourcesModal.exportButton',
|
|
296
|
-
description: 'Export primary button',
|
|
297
|
-
defaultMessage: 'Export {resourceType}'
|
|
298
|
-
},
|
|
299
284
|
outputFormat: {
|
|
300
285
|
id: 'ExportResourcesModal.outputFormat',
|
|
301
286
|
description: 'File format like (csv, xls, ...etc)',
|
|
@@ -306,10 +291,10 @@ var messages = defineMessages({
|
|
|
306
291
|
description: 'exported file name',
|
|
307
292
|
defaultMessage: 'File name'
|
|
308
293
|
},
|
|
309
|
-
|
|
310
|
-
id: 'ExportResourcesModal.
|
|
311
|
-
description: '
|
|
312
|
-
defaultMessage: '
|
|
294
|
+
locale: {
|
|
295
|
+
id: 'ExportResourcesModal.locale',
|
|
296
|
+
description: 'Locale',
|
|
297
|
+
defaultMessage: 'Locale'
|
|
313
298
|
},
|
|
314
299
|
exportSelection: {
|
|
315
300
|
id: 'ExportResourcesModal.exportSelection',
|
|
@@ -371,40 +356,20 @@ var messages = defineMessages({
|
|
|
371
356
|
description: 'properties panel label',
|
|
372
357
|
defaultMessage: 'Properties'
|
|
373
358
|
},
|
|
374
|
-
confirmationTitle: {
|
|
375
|
-
id: 'ExportResourcesModal.confirmationTitle',
|
|
376
|
-
description: 'Title for the confirmation dialog',
|
|
377
|
-
defaultMessage: 'Export {resourceType} data'
|
|
378
|
-
},
|
|
379
|
-
confirmationBodyPlan: {
|
|
380
|
-
id: 'ExportResourcesModal.confirmationBodyPlan',
|
|
381
|
-
description: 'Confirmation dialog action plan',
|
|
382
|
-
defaultMessage: 'You are about to export <bold>{count}</bold> {resourceType} from the project: <bold>{projectName}</bold>.'
|
|
383
|
-
},
|
|
384
|
-
confirmationBodyQuestion: {
|
|
385
|
-
id: 'ExportResourcesModal.confirmationBodyQuestion',
|
|
386
|
-
description: 'Confirmation question',
|
|
387
|
-
defaultMessage: 'Are you sure you want to continue?'
|
|
388
|
-
},
|
|
389
359
|
exportOperationSuccessMessage: {
|
|
390
360
|
id: 'ExportResourcesModal.exportOperationSuccessMessage',
|
|
391
361
|
description: 'Success message',
|
|
392
362
|
defaultMessage: '<b>Your export has started.</b> <newline></newline><logsLink>Go to Export logs</logsLink> to view the progress and download the file.'
|
|
393
363
|
},
|
|
394
|
-
exportConfirmationLabel: {
|
|
395
|
-
id: 'ExportResourcesModal.exportConfirmationLabel',
|
|
396
|
-
description: 'Label for the export button in confirmation dialog',
|
|
397
|
-
defaultMessage: 'Export {resourceType}'
|
|
398
|
-
},
|
|
399
364
|
nothingApplied: {
|
|
400
365
|
id: 'ExportResourcesModal.nothingApplied',
|
|
401
366
|
description: 'Shown when there is no filter applied',
|
|
402
367
|
defaultMessage: 'nothing applied'
|
|
403
368
|
},
|
|
404
|
-
|
|
405
|
-
id: 'ExportResourcesModal.
|
|
406
|
-
description: 'label for "
|
|
407
|
-
defaultMessage: '
|
|
369
|
+
selectAllLocales: {
|
|
370
|
+
id: 'ExportResourcesModal.selectAllLocales',
|
|
371
|
+
description: 'label for "Select all locales" checkbox',
|
|
372
|
+
defaultMessage: 'Select all locales'
|
|
408
373
|
},
|
|
409
374
|
missingFileNameError: {
|
|
410
375
|
id: 'ExportResourcesModal.missingFileNameError',
|
|
@@ -416,15 +381,25 @@ var messages = defineMessages({
|
|
|
416
381
|
description: 'Error when file name field is not valid',
|
|
417
382
|
defaultMessage: 'File name may only contain alphanumeric characters, hyphens and underscores'
|
|
418
383
|
},
|
|
419
|
-
|
|
420
|
-
id: 'ExportResourcesModal.
|
|
421
|
-
description: 'Error when no
|
|
422
|
-
defaultMessage: 'Please select at least one
|
|
384
|
+
missingLocaleError: {
|
|
385
|
+
id: 'ExportResourcesModal.missingLocaleError',
|
|
386
|
+
description: 'Error when no locale is selected',
|
|
387
|
+
defaultMessage: 'Please select at least one locale'
|
|
423
388
|
},
|
|
424
389
|
myViews: {
|
|
425
390
|
id: 'ExportResourcesModal.myViews',
|
|
426
391
|
description: 'Label for "My Views" Select Field',
|
|
427
392
|
defaultMessage: 'My Views'
|
|
393
|
+
},
|
|
394
|
+
cancel: {
|
|
395
|
+
id: 'ExportResourcesModal.cancel',
|
|
396
|
+
description: 'Label for "Cancel" button',
|
|
397
|
+
defaultMessage: 'Cancel'
|
|
398
|
+
},
|
|
399
|
+
startExport: {
|
|
400
|
+
id: 'ExportResourcesModal.startExport',
|
|
401
|
+
description: 'Label for "Start Export" button',
|
|
402
|
+
defaultMessage: 'Start Export'
|
|
428
403
|
}
|
|
429
404
|
});
|
|
430
405
|
|
|
@@ -487,8 +462,8 @@ TagList.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
487
462
|
'data-testid': PropTypes.string
|
|
488
463
|
} : {};
|
|
489
464
|
|
|
490
|
-
function ownKeys$
|
|
491
|
-
function _objectSpread$
|
|
465
|
+
function ownKeys$9(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
466
|
+
function _objectSpread$9(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys$9(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys$9(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
492
467
|
function AppliedFilters(_ref) {
|
|
493
468
|
let filters = _ref.filters,
|
|
494
469
|
onFilterRemove = _ref.onFilterRemove;
|
|
@@ -498,7 +473,7 @@ function AppliedFilters(_ref) {
|
|
|
498
473
|
condensed: true,
|
|
499
474
|
isDefaultClosed: !Boolean(filters.length),
|
|
500
475
|
header: jsx(Text.Body, {
|
|
501
|
-
intlMessage: _objectSpread$
|
|
476
|
+
intlMessage: _objectSpread$9(_objectSpread$9({}, messages.appliedFiltersMessage), {}, {
|
|
502
477
|
values: {
|
|
503
478
|
filtersCount: filters.length
|
|
504
479
|
}
|
|
@@ -527,7 +502,7 @@ function AppliedFilters(_ref) {
|
|
|
527
502
|
color: "neutral60"
|
|
528
503
|
}), jsx(Text.Body, {
|
|
529
504
|
isBold: true,
|
|
530
|
-
intlMessage: _objectSpread$
|
|
505
|
+
intlMessage: _objectSpread$9(_objectSpread$9({}, messages.appliedFiltersMessage), {}, {
|
|
531
506
|
values: {
|
|
532
507
|
filtersCount: filters.length
|
|
533
508
|
}
|
|
@@ -551,8 +526,8 @@ AppliedFilters.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
551
526
|
onFilterRemove: PropTypes.func.isRequired
|
|
552
527
|
} : {};
|
|
553
528
|
|
|
554
|
-
function ownKeys$
|
|
555
|
-
function _objectSpread$
|
|
529
|
+
function ownKeys$8(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
530
|
+
function _objectSpread$8(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys$8(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys$8(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
556
531
|
const IconPlaceholder = /*#__PURE__*/_styled("div", process.env.NODE_ENV === "production" ? {
|
|
557
532
|
target: "e1oion860"
|
|
558
533
|
} : {
|
|
@@ -567,7 +542,7 @@ function AppliedSearchTerms(_ref) {
|
|
|
567
542
|
condensed: true,
|
|
568
543
|
isDefaultClosed: !Boolean(appliedSearchTerms.length),
|
|
569
544
|
header: jsx(Text.Body, {
|
|
570
|
-
intlMessage: _objectSpread$
|
|
545
|
+
intlMessage: _objectSpread$8(_objectSpread$8({}, messages.appliedSearchTermsMessage), {}, {
|
|
571
546
|
values: {
|
|
572
547
|
searchTermsCount: appliedSearchTerms.length
|
|
573
548
|
}
|
|
@@ -588,7 +563,7 @@ function AppliedSearchTerms(_ref) {
|
|
|
588
563
|
color: "neutral60"
|
|
589
564
|
}), jsx(Text.Body, {
|
|
590
565
|
isBold: true,
|
|
591
|
-
intlMessage: _objectSpread$
|
|
566
|
+
intlMessage: _objectSpread$8(_objectSpread$8({}, messages.appliedSearchTermsMessage), {}, {
|
|
592
567
|
values: {
|
|
593
568
|
searchTermsCount: appliedSearchTerms.length
|
|
594
569
|
}
|
|
@@ -628,181 +603,27 @@ function ExportBasedOnMyViewsSelectField() {
|
|
|
628
603
|
});
|
|
629
604
|
}
|
|
630
605
|
|
|
631
|
-
function ownKeys$
|
|
632
|
-
function _objectSpread$
|
|
606
|
+
function ownKeys$7(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
607
|
+
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(_context = ownKeys$7(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys$7(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
633
608
|
function renderFileNameError(key) {
|
|
634
609
|
switch (key) {
|
|
635
610
|
case 'missing':
|
|
636
|
-
return jsx(FormattedMessage, _objectSpread$
|
|
611
|
+
return jsx(FormattedMessage, _objectSpread$7({}, messages.missingFileNameError));
|
|
637
612
|
case 'invalidInput':
|
|
638
|
-
return jsx(FormattedMessage, _objectSpread$
|
|
613
|
+
return jsx(FormattedMessage, _objectSpread$7({}, messages.invalidFileNameError));
|
|
639
614
|
default:
|
|
640
615
|
return null;
|
|
641
616
|
}
|
|
642
617
|
}
|
|
643
|
-
function
|
|
618
|
+
function renderLocaleError(key) {
|
|
644
619
|
switch (key) {
|
|
645
620
|
case 'missing':
|
|
646
|
-
return jsx(FormattedMessage, _objectSpread$
|
|
621
|
+
return jsx(FormattedMessage, _objectSpread$7({}, messages.missingLocaleError));
|
|
647
622
|
default:
|
|
648
623
|
return null;
|
|
649
624
|
}
|
|
650
625
|
}
|
|
651
626
|
|
|
652
|
-
function useExportResourcesContext() {
|
|
653
|
-
const context = useContext(ExportResourcesContext);
|
|
654
|
-
if (!context) {
|
|
655
|
-
throw new MissingExportResourceProviderError();
|
|
656
|
-
}
|
|
657
|
-
return context;
|
|
658
|
-
}
|
|
659
|
-
|
|
660
|
-
async function createExportOperation(_ref) {
|
|
661
|
-
let fileName = _ref.fileName,
|
|
662
|
-
fileFormat = _ref.fileFormat,
|
|
663
|
-
columns = _ref.columns,
|
|
664
|
-
locales = _ref.locales,
|
|
665
|
-
projectKey = _ref.projectKey,
|
|
666
|
-
graphQuery = _ref.graphQuery,
|
|
667
|
-
asyncDispatchFn = _ref.asyncDispatchFn;
|
|
668
|
-
const uri = "/proxy/export/".concat(projectKey, "/export-operations");
|
|
669
|
-
const response = await asyncDispatchFn(actions.post({
|
|
670
|
-
// FIXME: EXPORT is undefined
|
|
671
|
-
mcApiProxyTarget: MC_API_PROXY_TARGETS.EXPORT,
|
|
672
|
-
uri: uri,
|
|
673
|
-
headers: {
|
|
674
|
-
accept: 'application/json'
|
|
675
|
-
},
|
|
676
|
-
payload: {
|
|
677
|
-
fileName,
|
|
678
|
-
fileFormat,
|
|
679
|
-
columns,
|
|
680
|
-
locales,
|
|
681
|
-
query: graphQuery
|
|
682
|
-
}
|
|
683
|
-
}));
|
|
684
|
-
return response;
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
function ownKeys$7(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
688
|
-
function _objectSpread$7(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context2 = ownKeys$7(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context3 = ownKeys$7(Object(t))).call(_context3, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
689
|
-
const getExportLogsLink = (projectKey, msg) => jsx(Link, {
|
|
690
|
-
to: "/".concat(projectKey, "/operations/export/logs"),
|
|
691
|
-
children: msg
|
|
692
|
-
});
|
|
693
|
-
function ExportConfirmationModal(props) {
|
|
694
|
-
const _useApplicationContex = useApplicationContext(applicationContext => {
|
|
695
|
-
var _applicationContext$p, _applicationContext$p2;
|
|
696
|
-
return {
|
|
697
|
-
projectName: (_applicationContext$p = applicationContext.project) === null || _applicationContext$p === void 0 ? void 0 : _applicationContext$p.name,
|
|
698
|
-
projectKey: (_applicationContext$p2 = applicationContext.project) === null || _applicationContext$p2 === void 0 ? void 0 : _applicationContext$p2.key
|
|
699
|
-
};
|
|
700
|
-
}),
|
|
701
|
-
projectName = _useApplicationContex.projectName,
|
|
702
|
-
projectKey = _useApplicationContex.projectKey;
|
|
703
|
-
const _useExportResourcesCo = useExportResourcesContext(),
|
|
704
|
-
formik = _useExportResourcesCo.formik,
|
|
705
|
-
allResourcesCount = _useExportResourcesCo.allResourcesCount,
|
|
706
|
-
matchingResourcesCount = _useExportResourcesCo.matchingResourcesCount,
|
|
707
|
-
selectedResourceIds = _useExportResourcesCo.selectedResourceIds,
|
|
708
|
-
resourceType = _useExportResourcesCo.resourceType;
|
|
709
|
-
const showNotification = useShowNotification();
|
|
710
|
-
const intl = useIntl();
|
|
711
|
-
const asyncDispatch = useAsyncDispatch();
|
|
712
|
-
const resourceTypePlural = resourceTypeToPlural({
|
|
713
|
-
resourceType: props.resourceType
|
|
714
|
-
});
|
|
715
|
-
const countInConfirmationMessage = () => {
|
|
716
|
-
switch (_valuesInstanceProperty(formik).exportSelectionType) {
|
|
717
|
-
case EXPORT_SELECTION_TYPES.ALL_RESOURCES:
|
|
718
|
-
return allResourcesCount;
|
|
719
|
-
case EXPORT_SELECTION_TYPES.ONLY_MATCHING:
|
|
720
|
-
return matchingResourcesCount;
|
|
721
|
-
case EXPORT_SELECTION_TYPES.ONLY_SELECTED:
|
|
722
|
-
return selectedResourceIds.length;
|
|
723
|
-
default:
|
|
724
|
-
throw new UnexpectedSelectionTypeError(_valuesInstanceProperty(formik).exportSelectionType);
|
|
725
|
-
}
|
|
726
|
-
};
|
|
727
|
-
return jsx(ConfirmationDialog, {
|
|
728
|
-
dataAttributesPrimaryButton: {
|
|
729
|
-
'data-testid': 'confirm-export-button'
|
|
730
|
-
},
|
|
731
|
-
title: intl.formatMessage(messages.confirmationTitle, {
|
|
732
|
-
resourceType: resourceTypePlural
|
|
733
|
-
}),
|
|
734
|
-
labelPrimary: intl.formatMessage(messages.exportConfirmationLabel, {
|
|
735
|
-
resourceType: resourceTypePlural
|
|
736
|
-
}),
|
|
737
|
-
isOpen: props.isOpen,
|
|
738
|
-
onClose: props.closeModal,
|
|
739
|
-
onCancel: props.closeModal,
|
|
740
|
-
onConfirm: async () => {
|
|
741
|
-
const graphQuery = buildGraphQuery({
|
|
742
|
-
resourceType: resourceType,
|
|
743
|
-
selectedResourceIds: selectedResourceIds,
|
|
744
|
-
fields: _valuesInstanceProperty(formik).fields,
|
|
745
|
-
exportSelectionType: _valuesInstanceProperty(formik).exportSelectionType,
|
|
746
|
-
languages: _valuesInstanceProperty(formik).languages
|
|
747
|
-
});
|
|
748
|
-
props.closeModal();
|
|
749
|
-
try {
|
|
750
|
-
var _context;
|
|
751
|
-
const response = await createExportOperation({
|
|
752
|
-
fileName: appendCsvOrJsonExtensionIfAbsent(_valuesInstanceProperty(formik).fileName, _valuesInstanceProperty(formik).outputFormat),
|
|
753
|
-
fileFormat: _valuesInstanceProperty(formik).outputFormat,
|
|
754
|
-
locales: _valuesInstanceProperty(formik).languages,
|
|
755
|
-
columns: _mapInstanceProperty(_context = flattenNestedFields(_valuesInstanceProperty(formik).fields)).call(_context, field => field.key),
|
|
756
|
-
projectKey,
|
|
757
|
-
graphQuery,
|
|
758
|
-
asyncDispatchFn: asyncDispatch
|
|
759
|
-
});
|
|
760
|
-
switch (response.state) {
|
|
761
|
-
case EXPORT_OPERATION_STATES.PROCESSING:
|
|
762
|
-
case EXPORT_OPERATION_STATES.COMPLETED:
|
|
763
|
-
showNotification({
|
|
764
|
-
kind: 'success',
|
|
765
|
-
domain: DOMAINS.SIDE,
|
|
766
|
-
text: intl.formatMessage(messages.exportOperationSuccessMessage, {
|
|
767
|
-
newline: getNewLine,
|
|
768
|
-
logsLink: msg => getExportLogsLink(projectKey, msg),
|
|
769
|
-
b: getBold
|
|
770
|
-
})
|
|
771
|
-
});
|
|
772
|
-
props.onCloseParentModal();
|
|
773
|
-
break;
|
|
774
|
-
default:
|
|
775
|
-
throw new UnexpectedExportOperationStateError(response.state);
|
|
776
|
-
}
|
|
777
|
-
} catch (errors) {
|
|
778
|
-
showApiErrorNotification({
|
|
779
|
-
errors
|
|
780
|
-
});
|
|
781
|
-
}
|
|
782
|
-
},
|
|
783
|
-
children: jsxs("div", {
|
|
784
|
-
children: [jsx(Text.Body, {
|
|
785
|
-
intlMessage: _objectSpread$7(_objectSpread$7({}, messages.confirmationBodyPlan), {}, {
|
|
786
|
-
values: {
|
|
787
|
-
resourceType: resourceTypePlural,
|
|
788
|
-
projectName: projectName,
|
|
789
|
-
count: countInConfirmationMessage(),
|
|
790
|
-
bold: getBold
|
|
791
|
-
}
|
|
792
|
-
})
|
|
793
|
-
}), jsx(Text.Body, {
|
|
794
|
-
intlMessage: messages.confirmationBodyQuestion
|
|
795
|
-
})]
|
|
796
|
-
})
|
|
797
|
-
});
|
|
798
|
-
}
|
|
799
|
-
ExportConfirmationModal.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
800
|
-
isOpen: PropTypes.bool.isRequired,
|
|
801
|
-
resourceType: PropTypes.string.isRequired,
|
|
802
|
-
closeModal: PropTypes.func.isRequired,
|
|
803
|
-
onCloseParentModal: PropTypes.func.isRequired
|
|
804
|
-
} : {};
|
|
805
|
-
|
|
806
627
|
function ownKeys$6(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
807
628
|
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(_context = ownKeys$6(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys$6(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
808
629
|
function FieldsRenderer(_ref) {
|
|
@@ -872,6 +693,14 @@ ExportFields.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
872
693
|
})).isRequired
|
|
873
694
|
} : {};
|
|
874
695
|
|
|
696
|
+
function useExportResourcesContext() {
|
|
697
|
+
const context = useContext(ExportResourcesContext);
|
|
698
|
+
if (!context) {
|
|
699
|
+
throw new MissingExportResourceProviderError();
|
|
700
|
+
}
|
|
701
|
+
return context;
|
|
702
|
+
}
|
|
703
|
+
|
|
875
704
|
function ownKeys$5(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
876
705
|
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(_context = ownKeys$5(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys$5(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
877
706
|
function ExportSelectionRadioButtons() {
|
|
@@ -883,7 +712,8 @@ function ExportSelectionRadioButtons() {
|
|
|
883
712
|
resourceType = _useExportResourcesCo.resourceType,
|
|
884
713
|
allResourcesCount = _useExportResourcesCo.allResourcesCount,
|
|
885
714
|
matchingResourcesCount = _useExportResourcesCo.matchingResourcesCount,
|
|
886
|
-
selectedResourceIds = _useExportResourcesCo.selectedResourceIds
|
|
715
|
+
selectedResourceIds = _useExportResourcesCo.selectedResourceIds,
|
|
716
|
+
exportSelectionType = _useExportResourcesCo.exportSelectionType;
|
|
887
717
|
const resourceTypePlural = resourceTypeToPlural({
|
|
888
718
|
resourceType: resourceType
|
|
889
719
|
});
|
|
@@ -891,7 +721,7 @@ function ExportSelectionRadioButtons() {
|
|
|
891
721
|
scale: "xl",
|
|
892
722
|
children: jsxs(RadioInput.Group, {
|
|
893
723
|
name: "exportSelectionType",
|
|
894
|
-
value:
|
|
724
|
+
value: exportSelectionType,
|
|
895
725
|
direction: "inline",
|
|
896
726
|
directionProps: {
|
|
897
727
|
scale: 'xl'
|
|
@@ -947,11 +777,11 @@ function ExportTextMessage() {
|
|
|
947
777
|
allResourcesCount = _useExportResourcesCo.allResourcesCount,
|
|
948
778
|
selectedResourceIds = _useExportResourcesCo.selectedResourceIds,
|
|
949
779
|
matchingResourcesCount = _useExportResourcesCo.matchingResourcesCount,
|
|
950
|
-
|
|
780
|
+
exportSelectionType = _useExportResourcesCo.exportSelectionType;
|
|
951
781
|
const resourceTypePlural = resourceTypeToPlural({
|
|
952
782
|
resourceType: resourceType
|
|
953
783
|
});
|
|
954
|
-
switch (
|
|
784
|
+
switch (exportSelectionType) {
|
|
955
785
|
case EXPORT_SELECTION_TYPES.ALL_RESOURCES:
|
|
956
786
|
return jsx(Text.Body, {
|
|
957
787
|
intlMessage: _objectSpread$4(_objectSpread$4({}, messages.exportAllMessage), {}, {
|
|
@@ -983,7 +813,7 @@ function ExportTextMessage() {
|
|
|
983
813
|
})
|
|
984
814
|
});
|
|
985
815
|
default:
|
|
986
|
-
throw new UnexpectedSelectionTypeError(
|
|
816
|
+
throw new UnexpectedSelectionTypeError(exportSelectionType);
|
|
987
817
|
}
|
|
988
818
|
}
|
|
989
819
|
|
|
@@ -991,7 +821,8 @@ const ExportSelection = () => {
|
|
|
991
821
|
const _useTheme = useTheme(),
|
|
992
822
|
isNewTheme = _useTheme.isNewTheme;
|
|
993
823
|
const _useExportResourcesCo = useExportResourcesContext(),
|
|
994
|
-
formik = _useExportResourcesCo.formik
|
|
824
|
+
formik = _useExportResourcesCo.formik,
|
|
825
|
+
exportSelectionType = _useExportResourcesCo.exportSelectionType;
|
|
995
826
|
const onAppliedFilterRemove = filter => {
|
|
996
827
|
var _context;
|
|
997
828
|
formik.setFieldValue('appliedFilters', _filterInstanceProperty(_context = _valuesInstanceProperty(formik).appliedFilters).call(_context, appliedFilter => appliedFilter !== filter));
|
|
@@ -1004,7 +835,7 @@ const ExportSelection = () => {
|
|
|
1004
835
|
as: "h2",
|
|
1005
836
|
intlMessage: messages.exportSelection
|
|
1006
837
|
}), jsx(ExportSelectionRadioButtons, {}), jsx(ExportTextMessage, {})]
|
|
1007
|
-
}),
|
|
838
|
+
}), exportSelectionType === EXPORT_SELECTION_TYPES.ONLY_MATCHING && jsxs(Fragment, {
|
|
1008
839
|
children: [jsx(ExportBasedOnMyViewsSelectField, {}), jsx(AppliedSearchTerms, {
|
|
1009
840
|
appliedSearchTerms: _valuesInstanceProperty(formik).appliedSearchTerms
|
|
1010
841
|
}), jsx(AppliedFilters, {
|
|
@@ -1033,7 +864,7 @@ const ExportSelection = () => {
|
|
|
1033
864
|
scale: "m",
|
|
1034
865
|
children: jsxs(Spacings.Stack, {
|
|
1035
866
|
scale: "l",
|
|
1036
|
-
children: [jsx(ExportTextMessage, {}),
|
|
867
|
+
children: [jsx(ExportTextMessage, {}), exportSelectionType === EXPORT_SELECTION_TYPES.ONLY_MATCHING && jsxs(Fragment, {
|
|
1037
868
|
children: [jsx(ExportBasedOnMyViewsSelectField, {}), jsx(AppliedSearchTerms, {
|
|
1038
869
|
appliedSearchTerms: _valuesInstanceProperty(formik).appliedSearchTerms
|
|
1039
870
|
}), jsx(AppliedFilters, {
|
|
@@ -1079,143 +910,106 @@ ExportProperties.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
1079
910
|
function ownKeys$2(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1080
911
|
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys$2(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys$2(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1081
912
|
const outputFormatOptions = [{
|
|
1082
|
-
value: OUTPUT_FORMATS.JSON,
|
|
1083
|
-
label: 'JSON'
|
|
1084
|
-
}, {
|
|
1085
913
|
value: OUTPUT_FORMATS.CSV,
|
|
1086
914
|
label: 'CSV'
|
|
915
|
+
}, {
|
|
916
|
+
value: OUTPUT_FORMATS.JSON,
|
|
917
|
+
label: 'JSON'
|
|
1087
918
|
}];
|
|
1088
|
-
function
|
|
1089
|
-
return _mapInstanceProperty(
|
|
1090
|
-
value:
|
|
1091
|
-
label:
|
|
919
|
+
function mapLocalesToOptions(locales) {
|
|
920
|
+
return _mapInstanceProperty(locales).call(locales, locale => ({
|
|
921
|
+
value: locale,
|
|
922
|
+
label: locale
|
|
1092
923
|
}));
|
|
1093
924
|
}
|
|
1094
925
|
function ExportFileSettings(props) {
|
|
1095
|
-
const _useTheme = useTheme(),
|
|
1096
|
-
isNewTheme = _useTheme.isNewTheme;
|
|
1097
926
|
const intl = useIntl();
|
|
1098
927
|
const _useExportResourcesCo = useExportResourcesContext(),
|
|
1099
928
|
formik = _useExportResourcesCo.formik;
|
|
1100
929
|
const _useApplicationContex = useApplicationContext(applicationContext => {
|
|
1101
930
|
var _applicationContext$p;
|
|
1102
931
|
return {
|
|
1103
|
-
|
|
1104
|
-
|
|
932
|
+
locale: applicationContext.dataLocale,
|
|
933
|
+
locales: ((_applicationContext$p = applicationContext.project) === null || _applicationContext$p === void 0 ? void 0 : _applicationContext$p.languages) || []
|
|
1105
934
|
};
|
|
1106
935
|
}),
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
if (isNewTheme) return jsxs(Spacings.Stack, {
|
|
1110
|
-
scale: "xxxl",
|
|
1111
|
-
children: [jsx(PageContentNarrow, {
|
|
1112
|
-
children: jsxs(Spacings.Stack, {
|
|
1113
|
-
scale: "xl",
|
|
1114
|
-
children: [jsx(SelectField, _objectSpread$2(_objectSpread$2({}, formik.getFieldProps('outputFormat')), {}, {
|
|
1115
|
-
title: intl.formatMessage(messages.outputFormat),
|
|
1116
|
-
options: outputFormatOptions
|
|
1117
|
-
})), jsx(TextField, _objectSpread$2(_objectSpread$2({
|
|
1118
|
-
title: intl.formatMessage(messages.fileName)
|
|
1119
|
-
}, formik.getFieldProps('fileName')), {}, {
|
|
1120
|
-
touched: formik.touched.fileName,
|
|
1121
|
-
errors: formik.errors.fileName,
|
|
1122
|
-
renderError: renderFileNameError
|
|
1123
|
-
})), jsxs(Spacings.Stack, {
|
|
1124
|
-
scale: "xs",
|
|
1125
|
-
children: [jsx(SelectField, _objectSpread$2(_objectSpread$2({
|
|
1126
|
-
id: "languages",
|
|
1127
|
-
title: intl.formatMessage(messages.localLanguage),
|
|
1128
|
-
options: mapLanguagesToOptions(languages),
|
|
1129
|
-
isMulti: true
|
|
1130
|
-
}, formik.getFieldProps('languages')), {}, {
|
|
1131
|
-
onChange: e => {
|
|
1132
|
-
formik.handleChange(e);
|
|
1133
|
-
formik.setFieldValue('isAllLanguagesChecked', false);
|
|
1134
|
-
},
|
|
1135
|
-
touched: formik.touched.languages,
|
|
1136
|
-
errors: formik.errors.languages,
|
|
1137
|
-
renderError: renderLanguageError
|
|
1138
|
-
})), jsx(CheckboxInput, {
|
|
1139
|
-
name: "isAllLanguagesChecked",
|
|
1140
|
-
isChecked: _valuesInstanceProperty(formik).isAllLanguagesChecked,
|
|
1141
|
-
onChange: e => {
|
|
1142
|
-
if (e.target.checked) formik.setFieldValue('languages', languages);else formik.setFieldValue('languages', [language]);
|
|
1143
|
-
formik.handleChange(e);
|
|
1144
|
-
},
|
|
1145
|
-
children: intl.formatMessage(messages.all)
|
|
1146
|
-
})]
|
|
1147
|
-
})]
|
|
1148
|
-
})
|
|
1149
|
-
}), jsx(PageContentWide, {
|
|
1150
|
-
children: jsxs(Spacings.Stack, {
|
|
1151
|
-
scale: "xxxl",
|
|
1152
|
-
children: [jsx(ExportSelection, {}), jsx(ExportProperties, {
|
|
1153
|
-
renderProperties: props.renderProperties
|
|
1154
|
-
})]
|
|
1155
|
-
})
|
|
1156
|
-
})]
|
|
1157
|
-
});
|
|
936
|
+
locales = _useApplicationContex.locales,
|
|
937
|
+
locale = _useApplicationContex.locale;
|
|
1158
938
|
return jsxs(Spacings.Stack, {
|
|
1159
|
-
scale: "
|
|
1160
|
-
children: [
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
children: jsx(SelectField, _objectSpread$2(_objectSpread$2({
|
|
1176
|
-
id: "languages",
|
|
1177
|
-
title: jsxs(Spacings.Inline, {
|
|
1178
|
-
scale: "s",
|
|
1179
|
-
children: [jsx("label", {
|
|
1180
|
-
htmlFor: "languages",
|
|
1181
|
-
children: intl.formatMessage(messages.localLanguage)
|
|
1182
|
-
}), jsx(CheckboxInput, {
|
|
1183
|
-
name: "isAllLanguagesChecked",
|
|
1184
|
-
isChecked: _valuesInstanceProperty(formik).isAllLanguagesChecked,
|
|
1185
|
-
onChange: e => {
|
|
1186
|
-
if (e.target.checked) formik.setFieldValue('languages', languages);else formik.setFieldValue('languages', [language]);
|
|
1187
|
-
formik.handleChange(e);
|
|
1188
|
-
},
|
|
1189
|
-
children: jsx("div", {
|
|
1190
|
-
css: styles.notBold,
|
|
1191
|
-
children: intl.formatMessage(messages.all)
|
|
1192
|
-
})
|
|
1193
|
-
})]
|
|
1194
|
-
}),
|
|
1195
|
-
options: mapLanguagesToOptions(languages),
|
|
939
|
+
scale: "m",
|
|
940
|
+
children: [jsx(SelectField, _objectSpread$2(_objectSpread$2({}, formik.getFieldProps('outputFormat')), {}, {
|
|
941
|
+
title: intl.formatMessage(messages.outputFormat),
|
|
942
|
+
options: outputFormatOptions
|
|
943
|
+
})), jsx(TextField, _objectSpread$2(_objectSpread$2({
|
|
944
|
+
title: intl.formatMessage(messages.fileName)
|
|
945
|
+
}, formik.getFieldProps('fileName')), {}, {
|
|
946
|
+
touched: formik.touched.fileName,
|
|
947
|
+
errors: formik.errors.fileName,
|
|
948
|
+
renderError: renderFileNameError
|
|
949
|
+
})), jsxs(Spacings.Stack, {
|
|
950
|
+
scale: "xs",
|
|
951
|
+
children: [jsx(SelectField, _objectSpread$2(_objectSpread$2({
|
|
952
|
+
id: "locales",
|
|
953
|
+
title: intl.formatMessage(messages.locale),
|
|
954
|
+
options: mapLocalesToOptions(locales),
|
|
1196
955
|
isMulti: true
|
|
1197
|
-
}, formik.getFieldProps('
|
|
956
|
+
}, formik.getFieldProps('locales')), {}, {
|
|
1198
957
|
onChange: e => {
|
|
1199
958
|
formik.handleChange(e);
|
|
1200
|
-
formik.setFieldValue('
|
|
959
|
+
formik.setFieldValue('isAllLocalesChecked', false);
|
|
1201
960
|
},
|
|
1202
|
-
touched: formik.touched.
|
|
1203
|
-
errors: formik.errors.
|
|
1204
|
-
renderError:
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
961
|
+
touched: formik.touched.locales,
|
|
962
|
+
errors: formik.errors.locales,
|
|
963
|
+
renderError: renderLocaleError
|
|
964
|
+
})), jsx(CheckboxInput, {
|
|
965
|
+
name: "isAllLocalesChecked",
|
|
966
|
+
isChecked: _valuesInstanceProperty(formik).isAllLocalesChecked,
|
|
967
|
+
onChange: e => {
|
|
968
|
+
if (e.target.checked) formik.setFieldValue('locales', locales);else formik.setFieldValue('locales', [locale]);
|
|
969
|
+
formik.handleChange(e);
|
|
970
|
+
},
|
|
971
|
+
children: intl.formatMessage(messages.selectAllLocales)
|
|
972
|
+
})]
|
|
973
|
+
}), props.showExportSelection && jsx(ExportSelection, {}), jsx(ExportProperties, {
|
|
1208
974
|
renderProperties: props.renderProperties
|
|
1209
975
|
})]
|
|
1210
976
|
});
|
|
1211
977
|
}
|
|
1212
978
|
ExportFileSettings.displayName = 'ExportFileSettings';
|
|
1213
979
|
ExportFileSettings.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
980
|
+
showExportSelection: PropTypes.bool,
|
|
1214
981
|
renderProperties: PropTypes.func
|
|
1215
982
|
} : {};
|
|
1216
983
|
|
|
1217
984
|
const ExportResourcesContext = /*#__PURE__*/createContext();
|
|
1218
985
|
|
|
986
|
+
async function createExportOperation(_ref) {
|
|
987
|
+
let fileName = _ref.fileName,
|
|
988
|
+
fileFormat = _ref.fileFormat,
|
|
989
|
+
columns = _ref.columns,
|
|
990
|
+
locales = _ref.locales,
|
|
991
|
+
projectKey = _ref.projectKey,
|
|
992
|
+
graphQuery = _ref.graphQuery,
|
|
993
|
+
asyncDispatchFn = _ref.asyncDispatchFn;
|
|
994
|
+
const uri = "/proxy/export/".concat(projectKey, "/export-operations");
|
|
995
|
+
const response = await asyncDispatchFn(actions.post({
|
|
996
|
+
// FIXME: EXPORT is undefined
|
|
997
|
+
mcApiProxyTarget: MC_API_PROXY_TARGETS.EXPORT,
|
|
998
|
+
uri: uri,
|
|
999
|
+
headers: {
|
|
1000
|
+
accept: 'application/json'
|
|
1001
|
+
},
|
|
1002
|
+
payload: {
|
|
1003
|
+
fileName,
|
|
1004
|
+
fileFormat,
|
|
1005
|
+
columns,
|
|
1006
|
+
locales,
|
|
1007
|
+
query: graphQuery
|
|
1008
|
+
}
|
|
1009
|
+
}));
|
|
1010
|
+
return response;
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1219
1013
|
const ExportResourcesModalShape = PropTypes.shape({
|
|
1220
1014
|
resourceType: PropTypes.string.isRequired,
|
|
1221
1015
|
outputFormat: PropTypes.string,
|
|
@@ -1223,6 +1017,7 @@ const ExportResourcesModalShape = PropTypes.shape({
|
|
|
1223
1017
|
allResourcesCount: PropTypes.number.isRequired,
|
|
1224
1018
|
matchingResourcesCount: PropTypes.number,
|
|
1225
1019
|
selectedResourceIds: PropTypes.array,
|
|
1020
|
+
showExportSelection: PropTypes.bool,
|
|
1226
1021
|
// TODO: Circular reference
|
|
1227
1022
|
fields: PropTypes.arrayOf(PropTypes.shape({
|
|
1228
1023
|
key: PropTypes.string.isRequired,
|
|
@@ -1241,34 +1036,85 @@ const ExportResourcesModalShape = PropTypes.shape({
|
|
|
1241
1036
|
}).isRequired;
|
|
1242
1037
|
|
|
1243
1038
|
function ownKeys$1(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1244
|
-
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
1039
|
+
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context3 = ownKeys$1(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context4 = ownKeys$1(Object(t))).call(_context4, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1245
1040
|
const ExportResourcesContextProvider = props => {
|
|
1246
|
-
var
|
|
1041
|
+
var _context2;
|
|
1042
|
+
const intl = useIntl();
|
|
1247
1043
|
const todayFormatted = moment().format('DD-MM-YY_HH-mm');
|
|
1248
|
-
const
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1044
|
+
const asyncDispatch = useAsyncDispatch();
|
|
1045
|
+
const showNotification = useShowNotification();
|
|
1046
|
+
const _useApplicationContex = useApplicationContext(applicationContext => {
|
|
1047
|
+
var _applicationContext$p;
|
|
1048
|
+
return {
|
|
1049
|
+
locale: applicationContext.dataLocale,
|
|
1050
|
+
projectKey: (_applicationContext$p = applicationContext.project) === null || _applicationContext$p === void 0 ? void 0 : _applicationContext$p.key
|
|
1051
|
+
};
|
|
1052
|
+
}),
|
|
1053
|
+
projectKey = _useApplicationContex.projectKey,
|
|
1054
|
+
locale = _useApplicationContex.locale;
|
|
1055
|
+
const onSubmit = async values => {
|
|
1056
|
+
const graphQuery = buildGraphQuery({
|
|
1057
|
+
resourceType: props.resourceType,
|
|
1058
|
+
exportSelectionType: props.exportSelectionType,
|
|
1059
|
+
selectedResourceIds: props.selectedResourceIds,
|
|
1060
|
+
fields: values.fields,
|
|
1061
|
+
locales: values.locales
|
|
1062
|
+
});
|
|
1063
|
+
try {
|
|
1064
|
+
var _context;
|
|
1065
|
+
const response = await createExportOperation({
|
|
1066
|
+
fileName: appendCsvOrJsonExtensionIfAbsent(values.fileName, values.outputFormat),
|
|
1067
|
+
fileFormat: values.outputFormat,
|
|
1068
|
+
locales: values.locales,
|
|
1069
|
+
columns: _mapInstanceProperty(_context = flattenNestedFields(values.fields)).call(_context, field => field.key),
|
|
1070
|
+
projectKey,
|
|
1071
|
+
graphQuery,
|
|
1072
|
+
asyncDispatchFn: asyncDispatch
|
|
1073
|
+
});
|
|
1074
|
+
switch (response.state) {
|
|
1075
|
+
case EXPORT_OPERATION_STATES.PROCESSING:
|
|
1076
|
+
case EXPORT_OPERATION_STATES.COMPLETED:
|
|
1077
|
+
showNotification({
|
|
1078
|
+
kind: 'info',
|
|
1079
|
+
domain: DOMAINS.SIDE,
|
|
1080
|
+
text: intl.formatMessage(messages.exportOperationSuccessMessage, {
|
|
1081
|
+
newline: getNewLine,
|
|
1082
|
+
logsLink: msg => getExportLogsLink(projectKey, msg),
|
|
1083
|
+
b: getBold
|
|
1084
|
+
})
|
|
1085
|
+
});
|
|
1086
|
+
break;
|
|
1087
|
+
default:
|
|
1088
|
+
throw new UnexpectedExportOperationStateError(response.state);
|
|
1089
|
+
}
|
|
1090
|
+
} catch (errors) {
|
|
1091
|
+
// TODO: custom error messages for each error type
|
|
1092
|
+
showApiErrorNotification({
|
|
1093
|
+
errors
|
|
1094
|
+
});
|
|
1095
|
+
}
|
|
1096
|
+
};
|
|
1252
1097
|
const formik = useFormik({
|
|
1253
1098
|
initialValues: {
|
|
1254
1099
|
outputFormat: props.outputFormat,
|
|
1255
|
-
fileName: _concatInstanceProperty(
|
|
1100
|
+
fileName: _concatInstanceProperty(_context2 = "".concat(resourceTypeToPlural({
|
|
1256
1101
|
resourceType: props.resourceType,
|
|
1257
1102
|
isUpperCase: true
|
|
1258
|
-
}), "_Export_")).call(
|
|
1259
|
-
|
|
1103
|
+
}), "_Export_")).call(_context2, todayFormatted),
|
|
1104
|
+
locales: [locale],
|
|
1260
1105
|
fields: props.fields,
|
|
1261
1106
|
appliedSearchTerms: props.appliedSearchTerms,
|
|
1262
1107
|
appliedFilters: props.appliedFilters,
|
|
1263
|
-
|
|
1264
|
-
isAllLanguagesChecked: false
|
|
1108
|
+
isAllLocalesChecked: false
|
|
1265
1109
|
},
|
|
1266
|
-
validate
|
|
1110
|
+
validate,
|
|
1111
|
+
onSubmit
|
|
1267
1112
|
});
|
|
1268
1113
|
return jsx(ExportResourcesContext.Provider, {
|
|
1269
1114
|
value: {
|
|
1270
1115
|
formik,
|
|
1271
1116
|
resourceType: props.resourceType,
|
|
1117
|
+
exportSelectionType: props.exportSelectionType,
|
|
1272
1118
|
allResourcesCount: props.allResourcesCount,
|
|
1273
1119
|
matchingResourcesCount: props.matchingResourcesCount,
|
|
1274
1120
|
selectedResourceIds: props.selectedResourceIds
|
|
@@ -1280,15 +1126,19 @@ ExportResourcesContextProvider.displayName = 'ExportResourcesContextProvider';
|
|
|
1280
1126
|
ExportResourcesContextProvider.propTypes = process.env.NODE_ENV !== "production" ? _objectSpread$1(_objectSpread$1({}, ExportResourcesModalShape), {}, {
|
|
1281
1127
|
children: PropTypes.node
|
|
1282
1128
|
}) : {};
|
|
1129
|
+
const getExportLogsLink = (projectKey, msg) => jsx(Link, {
|
|
1130
|
+
to: "/".concat(projectKey, "/operations/export/logs"),
|
|
1131
|
+
children: msg
|
|
1132
|
+
});
|
|
1283
1133
|
|
|
1284
|
-
const _excluded = ["renderProperties"];
|
|
1134
|
+
const _excluded = ["renderProperties", "showExportSelection"];
|
|
1285
1135
|
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1286
1136
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1287
1137
|
const ExportResourcesModal = _ref => {
|
|
1288
1138
|
let renderProperties = _ref.renderProperties,
|
|
1139
|
+
showExportSelection = _ref.showExportSelection,
|
|
1289
1140
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
1290
1141
|
const intl = useIntl();
|
|
1291
|
-
const confirmationModal = useModalState();
|
|
1292
1142
|
const resourceTypePlural = resourceTypeToPlural({
|
|
1293
1143
|
resourceType: props.resourceType
|
|
1294
1144
|
});
|
|
@@ -1296,30 +1146,38 @@ const ExportResourcesModal = _ref => {
|
|
|
1296
1146
|
children: jsx(ExportResourcesContext.Consumer, {
|
|
1297
1147
|
children: _ref2 => {
|
|
1298
1148
|
let formik = _ref2.formik;
|
|
1299
|
-
return
|
|
1149
|
+
return jsx(InfoDialog, {
|
|
1300
1150
|
isOpen: true,
|
|
1301
1151
|
title: intl.formatMessage(messages.modalTitle, {
|
|
1302
1152
|
resourceType: resourceTypePlural
|
|
1303
1153
|
}),
|
|
1304
1154
|
onClose: props.closeModal,
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1155
|
+
children: jsxs(Spacings.Stack, {
|
|
1156
|
+
scale: "xxxl",
|
|
1157
|
+
children: [jsxs(Spacings.Stack, {
|
|
1158
|
+
scale: "l",
|
|
1159
|
+
children: [jsxs(Spacings.Inline, {
|
|
1160
|
+
alignItems: "center",
|
|
1161
|
+
children: [jsx(ExportIcon, {
|
|
1162
|
+
size: "medium",
|
|
1163
|
+
color: "neutral60"
|
|
1164
|
+
}), jsx(ExportTextMessage, {})]
|
|
1165
|
+
}), jsx(ExportFileSettings, {
|
|
1166
|
+
renderProperties: renderProperties,
|
|
1167
|
+
showExportSelection: showExportSelection
|
|
1168
|
+
})]
|
|
1169
|
+
}), jsxs(Spacings.Inline, {
|
|
1170
|
+
justifyContent: "flex-end",
|
|
1171
|
+
scale: "m",
|
|
1172
|
+
children: [jsx(SecondaryButton, {
|
|
1173
|
+
label: intl.formatMessage(messages.cancel),
|
|
1174
|
+
onClick: props.closeModal
|
|
1175
|
+
}), jsx(PrimaryButton, {
|
|
1176
|
+
label: intl.formatMessage(messages.startExport),
|
|
1177
|
+
onClick: formik.submitForm
|
|
1178
|
+
})]
|
|
1179
|
+
})]
|
|
1180
|
+
})
|
|
1323
1181
|
});
|
|
1324
1182
|
}
|
|
1325
1183
|
})
|
|
@@ -1333,7 +1191,8 @@ ExportResourcesModal.defaultProps = {
|
|
|
1333
1191
|
appliedFilters: [],
|
|
1334
1192
|
matchingResourcesCount: 0,
|
|
1335
1193
|
exportSelectionType: EXPORT_SELECTION_TYPES.ALL_RESOURCES,
|
|
1336
|
-
outputFormat: OUTPUT_FORMATS.CSV
|
|
1194
|
+
outputFormat: OUTPUT_FORMATS.CSV,
|
|
1195
|
+
showExportSelection: false
|
|
1337
1196
|
};
|
|
1338
1197
|
|
|
1339
1198
|
export { EXPORTABLE_RESOURCES, EXPORT_SELECTION_TYPES, ExportResourcesModal as default };
|