@commercetools-frontend-extensions/export-resources-modal 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -5
- package/dist/commercetools-frontend-extensions-export-resources-modal.cjs.dev.js +246 -385
- package/dist/commercetools-frontend-extensions-export-resources-modal.cjs.prod.js +244 -379
- package/dist/commercetools-frontend-extensions-export-resources-modal.esm.js +247 -386
- package/package.json +17 -17
|
@@ -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,179 +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
|
-
projectKey = _ref.projectKey,
|
|
665
|
-
graphQuery = _ref.graphQuery,
|
|
666
|
-
asyncDispatchFn = _ref.asyncDispatchFn;
|
|
667
|
-
const uri = "/proxy/export/".concat(projectKey, "/export-operations");
|
|
668
|
-
const response = await asyncDispatchFn(actions.post({
|
|
669
|
-
// FIXME: EXPORT is undefined
|
|
670
|
-
mcApiProxyTarget: MC_API_PROXY_TARGETS.EXPORT,
|
|
671
|
-
uri: uri,
|
|
672
|
-
headers: {
|
|
673
|
-
accept: 'application/json'
|
|
674
|
-
},
|
|
675
|
-
payload: {
|
|
676
|
-
fileName,
|
|
677
|
-
fileFormat,
|
|
678
|
-
columns,
|
|
679
|
-
query: graphQuery
|
|
680
|
-
}
|
|
681
|
-
}));
|
|
682
|
-
return response;
|
|
683
|
-
}
|
|
684
|
-
|
|
685
|
-
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; }
|
|
686
|
-
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; }
|
|
687
|
-
const getExportLogsLink = (projectKey, msg) => jsx(Link, {
|
|
688
|
-
to: "/".concat(projectKey, "/operations/export/logs"),
|
|
689
|
-
children: msg
|
|
690
|
-
});
|
|
691
|
-
function ExportConfirmationModal(props) {
|
|
692
|
-
const _useApplicationContex = useApplicationContext(applicationContext => {
|
|
693
|
-
var _applicationContext$p, _applicationContext$p2;
|
|
694
|
-
return {
|
|
695
|
-
projectName: (_applicationContext$p = applicationContext.project) === null || _applicationContext$p === void 0 ? void 0 : _applicationContext$p.name,
|
|
696
|
-
projectKey: (_applicationContext$p2 = applicationContext.project) === null || _applicationContext$p2 === void 0 ? void 0 : _applicationContext$p2.key
|
|
697
|
-
};
|
|
698
|
-
}),
|
|
699
|
-
projectName = _useApplicationContex.projectName,
|
|
700
|
-
projectKey = _useApplicationContex.projectKey;
|
|
701
|
-
const _useExportResourcesCo = useExportResourcesContext(),
|
|
702
|
-
formik = _useExportResourcesCo.formik,
|
|
703
|
-
allResourcesCount = _useExportResourcesCo.allResourcesCount,
|
|
704
|
-
matchingResourcesCount = _useExportResourcesCo.matchingResourcesCount,
|
|
705
|
-
selectedResourceIds = _useExportResourcesCo.selectedResourceIds,
|
|
706
|
-
resourceType = _useExportResourcesCo.resourceType;
|
|
707
|
-
const showNotification = useShowNotification();
|
|
708
|
-
const intl = useIntl();
|
|
709
|
-
const asyncDispatch = useAsyncDispatch();
|
|
710
|
-
const resourceTypePlural = resourceTypeToPlural({
|
|
711
|
-
resourceType: props.resourceType
|
|
712
|
-
});
|
|
713
|
-
const countInConfirmationMessage = () => {
|
|
714
|
-
switch (_valuesInstanceProperty(formik).exportSelectionType) {
|
|
715
|
-
case EXPORT_SELECTION_TYPES.ALL_RESOURCES:
|
|
716
|
-
return allResourcesCount;
|
|
717
|
-
case EXPORT_SELECTION_TYPES.ONLY_MATCHING:
|
|
718
|
-
return matchingResourcesCount;
|
|
719
|
-
case EXPORT_SELECTION_TYPES.ONLY_SELECTED:
|
|
720
|
-
return selectedResourceIds.length;
|
|
721
|
-
default:
|
|
722
|
-
throw new UnexpectedSelectionTypeError(_valuesInstanceProperty(formik).exportSelectionType);
|
|
723
|
-
}
|
|
724
|
-
};
|
|
725
|
-
return jsx(ConfirmationDialog, {
|
|
726
|
-
dataAttributesPrimaryButton: {
|
|
727
|
-
'data-testid': 'confirm-export-button'
|
|
728
|
-
},
|
|
729
|
-
title: intl.formatMessage(messages.confirmationTitle, {
|
|
730
|
-
resourceType: resourceTypePlural
|
|
731
|
-
}),
|
|
732
|
-
labelPrimary: intl.formatMessage(messages.exportConfirmationLabel, {
|
|
733
|
-
resourceType: resourceTypePlural
|
|
734
|
-
}),
|
|
735
|
-
isOpen: props.isOpen,
|
|
736
|
-
onClose: props.closeModal,
|
|
737
|
-
onCancel: props.closeModal,
|
|
738
|
-
onConfirm: async () => {
|
|
739
|
-
const graphQuery = buildGraphQuery({
|
|
740
|
-
resourceType: resourceType,
|
|
741
|
-
selectedResourceIds: selectedResourceIds,
|
|
742
|
-
fields: _valuesInstanceProperty(formik).fields,
|
|
743
|
-
exportSelectionType: _valuesInstanceProperty(formik).exportSelectionType,
|
|
744
|
-
languages: _valuesInstanceProperty(formik).languages
|
|
745
|
-
});
|
|
746
|
-
props.closeModal();
|
|
747
|
-
try {
|
|
748
|
-
var _context;
|
|
749
|
-
const response = await createExportOperation({
|
|
750
|
-
fileName: appendCsvOrJsonExtensionIfAbsent(_valuesInstanceProperty(formik).fileName, _valuesInstanceProperty(formik).outputFormat),
|
|
751
|
-
fileFormat: _valuesInstanceProperty(formik).outputFormat,
|
|
752
|
-
locales: _valuesInstanceProperty(formik).languages,
|
|
753
|
-
columns: _mapInstanceProperty(_context = flattenNestedFields(_valuesInstanceProperty(formik).fields)).call(_context, field => field.key),
|
|
754
|
-
projectKey,
|
|
755
|
-
graphQuery,
|
|
756
|
-
asyncDispatchFn: asyncDispatch
|
|
757
|
-
});
|
|
758
|
-
switch (response.state) {
|
|
759
|
-
case EXPORT_OPERATION_STATES.PROCESSING:
|
|
760
|
-
case EXPORT_OPERATION_STATES.COMPLETED:
|
|
761
|
-
showNotification({
|
|
762
|
-
kind: 'success',
|
|
763
|
-
domain: DOMAINS.SIDE,
|
|
764
|
-
text: intl.formatMessage(messages.exportOperationSuccessMessage, {
|
|
765
|
-
newline: getNewLine,
|
|
766
|
-
logsLink: msg => getExportLogsLink(projectKey, msg),
|
|
767
|
-
b: getBold
|
|
768
|
-
})
|
|
769
|
-
});
|
|
770
|
-
props.onCloseParentModal();
|
|
771
|
-
break;
|
|
772
|
-
default:
|
|
773
|
-
throw new UnexpectedExportOperationStateError(response.state);
|
|
774
|
-
}
|
|
775
|
-
} catch (errors) {
|
|
776
|
-
showApiErrorNotification({
|
|
777
|
-
errors
|
|
778
|
-
});
|
|
779
|
-
}
|
|
780
|
-
},
|
|
781
|
-
children: jsxs("div", {
|
|
782
|
-
children: [jsx(Text.Body, {
|
|
783
|
-
intlMessage: _objectSpread$7(_objectSpread$7({}, messages.confirmationBodyPlan), {}, {
|
|
784
|
-
values: {
|
|
785
|
-
resourceType: resourceTypePlural,
|
|
786
|
-
projectName: projectName,
|
|
787
|
-
count: countInConfirmationMessage(),
|
|
788
|
-
bold: getBold
|
|
789
|
-
}
|
|
790
|
-
})
|
|
791
|
-
}), jsx(Text.Body, {
|
|
792
|
-
intlMessage: messages.confirmationBodyQuestion
|
|
793
|
-
})]
|
|
794
|
-
})
|
|
795
|
-
});
|
|
796
|
-
}
|
|
797
|
-
ExportConfirmationModal.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
798
|
-
isOpen: PropTypes.bool.isRequired,
|
|
799
|
-
resourceType: PropTypes.string.isRequired,
|
|
800
|
-
closeModal: PropTypes.func.isRequired,
|
|
801
|
-
onCloseParentModal: PropTypes.func.isRequired
|
|
802
|
-
} : {};
|
|
803
|
-
|
|
804
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; }
|
|
805
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; }
|
|
806
629
|
function FieldsRenderer(_ref) {
|
|
@@ -870,6 +693,14 @@ ExportFields.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
870
693
|
})).isRequired
|
|
871
694
|
} : {};
|
|
872
695
|
|
|
696
|
+
function useExportResourcesContext() {
|
|
697
|
+
const context = useContext(ExportResourcesContext);
|
|
698
|
+
if (!context) {
|
|
699
|
+
throw new MissingExportResourceProviderError();
|
|
700
|
+
}
|
|
701
|
+
return context;
|
|
702
|
+
}
|
|
703
|
+
|
|
873
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; }
|
|
874
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; }
|
|
875
706
|
function ExportSelectionRadioButtons() {
|
|
@@ -881,7 +712,8 @@ function ExportSelectionRadioButtons() {
|
|
|
881
712
|
resourceType = _useExportResourcesCo.resourceType,
|
|
882
713
|
allResourcesCount = _useExportResourcesCo.allResourcesCount,
|
|
883
714
|
matchingResourcesCount = _useExportResourcesCo.matchingResourcesCount,
|
|
884
|
-
selectedResourceIds = _useExportResourcesCo.selectedResourceIds
|
|
715
|
+
selectedResourceIds = _useExportResourcesCo.selectedResourceIds,
|
|
716
|
+
exportSelectionType = _useExportResourcesCo.exportSelectionType;
|
|
885
717
|
const resourceTypePlural = resourceTypeToPlural({
|
|
886
718
|
resourceType: resourceType
|
|
887
719
|
});
|
|
@@ -889,7 +721,7 @@ function ExportSelectionRadioButtons() {
|
|
|
889
721
|
scale: "xl",
|
|
890
722
|
children: jsxs(RadioInput.Group, {
|
|
891
723
|
name: "exportSelectionType",
|
|
892
|
-
value:
|
|
724
|
+
value: exportSelectionType,
|
|
893
725
|
direction: "inline",
|
|
894
726
|
directionProps: {
|
|
895
727
|
scale: 'xl'
|
|
@@ -945,11 +777,11 @@ function ExportTextMessage() {
|
|
|
945
777
|
allResourcesCount = _useExportResourcesCo.allResourcesCount,
|
|
946
778
|
selectedResourceIds = _useExportResourcesCo.selectedResourceIds,
|
|
947
779
|
matchingResourcesCount = _useExportResourcesCo.matchingResourcesCount,
|
|
948
|
-
|
|
780
|
+
exportSelectionType = _useExportResourcesCo.exportSelectionType;
|
|
949
781
|
const resourceTypePlural = resourceTypeToPlural({
|
|
950
782
|
resourceType: resourceType
|
|
951
783
|
});
|
|
952
|
-
switch (
|
|
784
|
+
switch (exportSelectionType) {
|
|
953
785
|
case EXPORT_SELECTION_TYPES.ALL_RESOURCES:
|
|
954
786
|
return jsx(Text.Body, {
|
|
955
787
|
intlMessage: _objectSpread$4(_objectSpread$4({}, messages.exportAllMessage), {}, {
|
|
@@ -981,7 +813,7 @@ function ExportTextMessage() {
|
|
|
981
813
|
})
|
|
982
814
|
});
|
|
983
815
|
default:
|
|
984
|
-
throw new UnexpectedSelectionTypeError(
|
|
816
|
+
throw new UnexpectedSelectionTypeError(exportSelectionType);
|
|
985
817
|
}
|
|
986
818
|
}
|
|
987
819
|
|
|
@@ -989,7 +821,8 @@ const ExportSelection = () => {
|
|
|
989
821
|
const _useTheme = useTheme(),
|
|
990
822
|
isNewTheme = _useTheme.isNewTheme;
|
|
991
823
|
const _useExportResourcesCo = useExportResourcesContext(),
|
|
992
|
-
formik = _useExportResourcesCo.formik
|
|
824
|
+
formik = _useExportResourcesCo.formik,
|
|
825
|
+
exportSelectionType = _useExportResourcesCo.exportSelectionType;
|
|
993
826
|
const onAppliedFilterRemove = filter => {
|
|
994
827
|
var _context;
|
|
995
828
|
formik.setFieldValue('appliedFilters', _filterInstanceProperty(_context = _valuesInstanceProperty(formik).appliedFilters).call(_context, appliedFilter => appliedFilter !== filter));
|
|
@@ -1002,7 +835,7 @@ const ExportSelection = () => {
|
|
|
1002
835
|
as: "h2",
|
|
1003
836
|
intlMessage: messages.exportSelection
|
|
1004
837
|
}), jsx(ExportSelectionRadioButtons, {}), jsx(ExportTextMessage, {})]
|
|
1005
|
-
}),
|
|
838
|
+
}), exportSelectionType === EXPORT_SELECTION_TYPES.ONLY_MATCHING && jsxs(Fragment, {
|
|
1006
839
|
children: [jsx(ExportBasedOnMyViewsSelectField, {}), jsx(AppliedSearchTerms, {
|
|
1007
840
|
appliedSearchTerms: _valuesInstanceProperty(formik).appliedSearchTerms
|
|
1008
841
|
}), jsx(AppliedFilters, {
|
|
@@ -1031,7 +864,7 @@ const ExportSelection = () => {
|
|
|
1031
864
|
scale: "m",
|
|
1032
865
|
children: jsxs(Spacings.Stack, {
|
|
1033
866
|
scale: "l",
|
|
1034
|
-
children: [jsx(ExportTextMessage, {}),
|
|
867
|
+
children: [jsx(ExportTextMessage, {}), exportSelectionType === EXPORT_SELECTION_TYPES.ONLY_MATCHING && jsxs(Fragment, {
|
|
1035
868
|
children: [jsx(ExportBasedOnMyViewsSelectField, {}), jsx(AppliedSearchTerms, {
|
|
1036
869
|
appliedSearchTerms: _valuesInstanceProperty(formik).appliedSearchTerms
|
|
1037
870
|
}), jsx(AppliedFilters, {
|
|
@@ -1077,143 +910,106 @@ ExportProperties.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
1077
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; }
|
|
1078
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; }
|
|
1079
912
|
const outputFormatOptions = [{
|
|
1080
|
-
value: OUTPUT_FORMATS.JSON,
|
|
1081
|
-
label: 'JSON'
|
|
1082
|
-
}, {
|
|
1083
913
|
value: OUTPUT_FORMATS.CSV,
|
|
1084
914
|
label: 'CSV'
|
|
915
|
+
}, {
|
|
916
|
+
value: OUTPUT_FORMATS.JSON,
|
|
917
|
+
label: 'JSON'
|
|
1085
918
|
}];
|
|
1086
|
-
function
|
|
1087
|
-
return _mapInstanceProperty(
|
|
1088
|
-
value:
|
|
1089
|
-
label:
|
|
919
|
+
function mapLocalesToOptions(locales) {
|
|
920
|
+
return _mapInstanceProperty(locales).call(locales, locale => ({
|
|
921
|
+
value: locale,
|
|
922
|
+
label: locale
|
|
1090
923
|
}));
|
|
1091
924
|
}
|
|
1092
925
|
function ExportFileSettings(props) {
|
|
1093
|
-
const _useTheme = useTheme(),
|
|
1094
|
-
isNewTheme = _useTheme.isNewTheme;
|
|
1095
926
|
const intl = useIntl();
|
|
1096
927
|
const _useExportResourcesCo = useExportResourcesContext(),
|
|
1097
928
|
formik = _useExportResourcesCo.formik;
|
|
1098
929
|
const _useApplicationContex = useApplicationContext(applicationContext => {
|
|
1099
930
|
var _applicationContext$p;
|
|
1100
931
|
return {
|
|
1101
|
-
|
|
1102
|
-
|
|
932
|
+
locale: applicationContext.dataLocale,
|
|
933
|
+
locales: ((_applicationContext$p = applicationContext.project) === null || _applicationContext$p === void 0 ? void 0 : _applicationContext$p.languages) || []
|
|
1103
934
|
};
|
|
1104
935
|
}),
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
if (isNewTheme) return jsxs(Spacings.Stack, {
|
|
1108
|
-
scale: "xxxl",
|
|
1109
|
-
children: [jsx(PageContentNarrow, {
|
|
1110
|
-
children: jsxs(Spacings.Stack, {
|
|
1111
|
-
scale: "xl",
|
|
1112
|
-
children: [jsx(SelectField, _objectSpread$2(_objectSpread$2({}, formik.getFieldProps('outputFormat')), {}, {
|
|
1113
|
-
title: intl.formatMessage(messages.outputFormat),
|
|
1114
|
-
options: outputFormatOptions
|
|
1115
|
-
})), jsx(TextField, _objectSpread$2(_objectSpread$2({
|
|
1116
|
-
title: intl.formatMessage(messages.fileName)
|
|
1117
|
-
}, formik.getFieldProps('fileName')), {}, {
|
|
1118
|
-
touched: formik.touched.fileName,
|
|
1119
|
-
errors: formik.errors.fileName,
|
|
1120
|
-
renderError: renderFileNameError
|
|
1121
|
-
})), jsxs(Spacings.Stack, {
|
|
1122
|
-
scale: "xs",
|
|
1123
|
-
children: [jsx(SelectField, _objectSpread$2(_objectSpread$2({
|
|
1124
|
-
id: "languages",
|
|
1125
|
-
title: intl.formatMessage(messages.localLanguage),
|
|
1126
|
-
options: mapLanguagesToOptions(languages),
|
|
1127
|
-
isMulti: true
|
|
1128
|
-
}, formik.getFieldProps('languages')), {}, {
|
|
1129
|
-
onChange: e => {
|
|
1130
|
-
formik.handleChange(e);
|
|
1131
|
-
formik.setFieldValue('isAllLanguagesChecked', false);
|
|
1132
|
-
},
|
|
1133
|
-
touched: formik.touched.languages,
|
|
1134
|
-
errors: formik.errors.languages,
|
|
1135
|
-
renderError: renderLanguageError
|
|
1136
|
-
})), jsx(CheckboxInput, {
|
|
1137
|
-
name: "isAllLanguagesChecked",
|
|
1138
|
-
isChecked: _valuesInstanceProperty(formik).isAllLanguagesChecked,
|
|
1139
|
-
onChange: e => {
|
|
1140
|
-
if (e.target.checked) formik.setFieldValue('languages', languages);else formik.setFieldValue('languages', [language]);
|
|
1141
|
-
formik.handleChange(e);
|
|
1142
|
-
},
|
|
1143
|
-
children: intl.formatMessage(messages.all)
|
|
1144
|
-
})]
|
|
1145
|
-
})]
|
|
1146
|
-
})
|
|
1147
|
-
}), jsx(PageContentWide, {
|
|
1148
|
-
children: jsxs(Spacings.Stack, {
|
|
1149
|
-
scale: "xxxl",
|
|
1150
|
-
children: [jsx(ExportSelection, {}), jsx(ExportProperties, {
|
|
1151
|
-
renderProperties: props.renderProperties
|
|
1152
|
-
})]
|
|
1153
|
-
})
|
|
1154
|
-
})]
|
|
1155
|
-
});
|
|
936
|
+
locales = _useApplicationContex.locales,
|
|
937
|
+
locale = _useApplicationContex.locale;
|
|
1156
938
|
return jsxs(Spacings.Stack, {
|
|
1157
|
-
scale: "
|
|
1158
|
-
children: [
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
children: jsx(SelectField, _objectSpread$2(_objectSpread$2({
|
|
1174
|
-
id: "languages",
|
|
1175
|
-
title: jsxs(Spacings.Inline, {
|
|
1176
|
-
scale: "s",
|
|
1177
|
-
children: [jsx("label", {
|
|
1178
|
-
htmlFor: "languages",
|
|
1179
|
-
children: intl.formatMessage(messages.localLanguage)
|
|
1180
|
-
}), jsx(CheckboxInput, {
|
|
1181
|
-
name: "isAllLanguagesChecked",
|
|
1182
|
-
isChecked: _valuesInstanceProperty(formik).isAllLanguagesChecked,
|
|
1183
|
-
onChange: e => {
|
|
1184
|
-
if (e.target.checked) formik.setFieldValue('languages', languages);else formik.setFieldValue('languages', [language]);
|
|
1185
|
-
formik.handleChange(e);
|
|
1186
|
-
},
|
|
1187
|
-
children: jsx("div", {
|
|
1188
|
-
css: styles.notBold,
|
|
1189
|
-
children: intl.formatMessage(messages.all)
|
|
1190
|
-
})
|
|
1191
|
-
})]
|
|
1192
|
-
}),
|
|
1193
|
-
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),
|
|
1194
955
|
isMulti: true
|
|
1195
|
-
}, formik.getFieldProps('
|
|
956
|
+
}, formik.getFieldProps('locales')), {}, {
|
|
957
|
+
onChange: e => {
|
|
958
|
+
formik.handleChange(e);
|
|
959
|
+
formik.setFieldValue('isAllLocalesChecked', false);
|
|
960
|
+
},
|
|
961
|
+
touched: formik.touched.locales,
|
|
962
|
+
errors: formik.errors.locales,
|
|
963
|
+
renderError: renderLocaleError
|
|
964
|
+
})), jsx(CheckboxInput, {
|
|
965
|
+
name: "isAllLocalesChecked",
|
|
966
|
+
isChecked: _valuesInstanceProperty(formik).isAllLocalesChecked,
|
|
1196
967
|
onChange: e => {
|
|
968
|
+
if (e.target.checked) formik.setFieldValue('locales', locales);else formik.setFieldValue('locales', [locale]);
|
|
1197
969
|
formik.handleChange(e);
|
|
1198
|
-
formik.setFieldValue('isAllLanguagesChecked', false);
|
|
1199
970
|
},
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
horizontalConstraint: 7
|
|
1204
|
-
}))
|
|
1205
|
-
}), jsx(ExportSelection, {}), jsx(ExportProperties, {
|
|
971
|
+
children: intl.formatMessage(messages.selectAllLocales)
|
|
972
|
+
})]
|
|
973
|
+
}), props.showExportSelection && jsx(ExportSelection, {}), jsx(ExportProperties, {
|
|
1206
974
|
renderProperties: props.renderProperties
|
|
1207
975
|
})]
|
|
1208
976
|
});
|
|
1209
977
|
}
|
|
1210
978
|
ExportFileSettings.displayName = 'ExportFileSettings';
|
|
1211
979
|
ExportFileSettings.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
980
|
+
showExportSelection: PropTypes.bool,
|
|
1212
981
|
renderProperties: PropTypes.func
|
|
1213
982
|
} : {};
|
|
1214
983
|
|
|
1215
984
|
const ExportResourcesContext = /*#__PURE__*/createContext();
|
|
1216
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
|
+
|
|
1217
1013
|
const ExportResourcesModalShape = PropTypes.shape({
|
|
1218
1014
|
resourceType: PropTypes.string.isRequired,
|
|
1219
1015
|
outputFormat: PropTypes.string,
|
|
@@ -1221,6 +1017,7 @@ const ExportResourcesModalShape = PropTypes.shape({
|
|
|
1221
1017
|
allResourcesCount: PropTypes.number.isRequired,
|
|
1222
1018
|
matchingResourcesCount: PropTypes.number,
|
|
1223
1019
|
selectedResourceIds: PropTypes.array,
|
|
1020
|
+
showExportSelection: PropTypes.bool,
|
|
1224
1021
|
// TODO: Circular reference
|
|
1225
1022
|
fields: PropTypes.arrayOf(PropTypes.shape({
|
|
1226
1023
|
key: PropTypes.string.isRequired,
|
|
@@ -1239,34 +1036,85 @@ const ExportResourcesModalShape = PropTypes.shape({
|
|
|
1239
1036
|
}).isRequired;
|
|
1240
1037
|
|
|
1241
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; }
|
|
1242
|
-
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; }
|
|
1243
1040
|
const ExportResourcesContextProvider = props => {
|
|
1244
|
-
var
|
|
1041
|
+
var _context2;
|
|
1042
|
+
const intl = useIntl();
|
|
1245
1043
|
const todayFormatted = moment().format('DD-MM-YY_HH-mm');
|
|
1246
|
-
const
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
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
|
+
};
|
|
1250
1097
|
const formik = useFormik({
|
|
1251
1098
|
initialValues: {
|
|
1252
1099
|
outputFormat: props.outputFormat,
|
|
1253
|
-
fileName: _concatInstanceProperty(
|
|
1100
|
+
fileName: _concatInstanceProperty(_context2 = "".concat(resourceTypeToPlural({
|
|
1254
1101
|
resourceType: props.resourceType,
|
|
1255
1102
|
isUpperCase: true
|
|
1256
|
-
}), "_Export_")).call(
|
|
1257
|
-
|
|
1103
|
+
}), "_Export_")).call(_context2, todayFormatted),
|
|
1104
|
+
locales: [locale],
|
|
1258
1105
|
fields: props.fields,
|
|
1259
1106
|
appliedSearchTerms: props.appliedSearchTerms,
|
|
1260
1107
|
appliedFilters: props.appliedFilters,
|
|
1261
|
-
|
|
1262
|
-
isAllLanguagesChecked: false
|
|
1108
|
+
isAllLocalesChecked: false
|
|
1263
1109
|
},
|
|
1264
|
-
validate
|
|
1110
|
+
validate,
|
|
1111
|
+
onSubmit
|
|
1265
1112
|
});
|
|
1266
1113
|
return jsx(ExportResourcesContext.Provider, {
|
|
1267
1114
|
value: {
|
|
1268
1115
|
formik,
|
|
1269
1116
|
resourceType: props.resourceType,
|
|
1117
|
+
exportSelectionType: props.exportSelectionType,
|
|
1270
1118
|
allResourcesCount: props.allResourcesCount,
|
|
1271
1119
|
matchingResourcesCount: props.matchingResourcesCount,
|
|
1272
1120
|
selectedResourceIds: props.selectedResourceIds
|
|
@@ -1278,15 +1126,19 @@ ExportResourcesContextProvider.displayName = 'ExportResourcesContextProvider';
|
|
|
1278
1126
|
ExportResourcesContextProvider.propTypes = process.env.NODE_ENV !== "production" ? _objectSpread$1(_objectSpread$1({}, ExportResourcesModalShape), {}, {
|
|
1279
1127
|
children: PropTypes.node
|
|
1280
1128
|
}) : {};
|
|
1129
|
+
const getExportLogsLink = (projectKey, msg) => jsx(Link, {
|
|
1130
|
+
to: "/".concat(projectKey, "/operations/export/logs"),
|
|
1131
|
+
children: msg
|
|
1132
|
+
});
|
|
1281
1133
|
|
|
1282
|
-
const _excluded = ["renderProperties"];
|
|
1134
|
+
const _excluded = ["renderProperties", "showExportSelection"];
|
|
1283
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; }
|
|
1284
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; }
|
|
1285
1137
|
const ExportResourcesModal = _ref => {
|
|
1286
1138
|
let renderProperties = _ref.renderProperties,
|
|
1139
|
+
showExportSelection = _ref.showExportSelection,
|
|
1287
1140
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
1288
1141
|
const intl = useIntl();
|
|
1289
|
-
const confirmationModal = useModalState();
|
|
1290
1142
|
const resourceTypePlural = resourceTypeToPlural({
|
|
1291
1143
|
resourceType: props.resourceType
|
|
1292
1144
|
});
|
|
@@ -1294,30 +1146,38 @@ const ExportResourcesModal = _ref => {
|
|
|
1294
1146
|
children: jsx(ExportResourcesContext.Consumer, {
|
|
1295
1147
|
children: _ref2 => {
|
|
1296
1148
|
let formik = _ref2.formik;
|
|
1297
|
-
return
|
|
1149
|
+
return jsx(InfoDialog, {
|
|
1298
1150
|
isOpen: true,
|
|
1299
1151
|
title: intl.formatMessage(messages.modalTitle, {
|
|
1300
1152
|
resourceType: resourceTypePlural
|
|
1301
1153
|
}),
|
|
1302
1154
|
onClose: props.closeModal,
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
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
|
+
})
|
|
1321
1181
|
});
|
|
1322
1182
|
}
|
|
1323
1183
|
})
|
|
@@ -1331,7 +1191,8 @@ ExportResourcesModal.defaultProps = {
|
|
|
1331
1191
|
appliedFilters: [],
|
|
1332
1192
|
matchingResourcesCount: 0,
|
|
1333
1193
|
exportSelectionType: EXPORT_SELECTION_TYPES.ALL_RESOURCES,
|
|
1334
|
-
outputFormat: OUTPUT_FORMATS.CSV
|
|
1194
|
+
outputFormat: OUTPUT_FORMATS.CSV,
|
|
1195
|
+
showExportSelection: false
|
|
1335
1196
|
};
|
|
1336
1197
|
|
|
1337
1198
|
export { EXPORTABLE_RESOURCES, EXPORT_SELECTION_TYPES, ExportResourcesModal as default };
|