@commercetools-frontend-extensions/export-resources-modal 0.1.0 → 1.0.3
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.
|
@@ -2,21 +2,1222 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
6
|
+
var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
7
|
+
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
8
|
+
var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
|
|
9
|
+
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
|
|
10
|
+
var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
|
|
11
|
+
var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
|
|
12
|
+
var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
|
|
13
|
+
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
14
|
+
var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
|
|
15
|
+
var reactIntl = require('react-intl');
|
|
16
|
+
var applicationComponents = require('@commercetools-frontend/application-components');
|
|
17
|
+
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
18
|
+
var _flatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/flat');
|
|
19
|
+
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
20
|
+
var gqlQueryBuilder = require('gql-query-builder');
|
|
21
|
+
var _Reflect$construct = require('@babel/runtime-corejs3/core-js-stable/reflect/construct');
|
|
22
|
+
var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
|
|
23
|
+
var _classCallCheck = require('@babel/runtime-corejs3/helpers/classCallCheck');
|
|
24
|
+
var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
|
|
25
|
+
var _possibleConstructorReturn = require('@babel/runtime-corejs3/helpers/possibleConstructorReturn');
|
|
26
|
+
var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
|
|
27
|
+
var _wrapNativeSuper = require('@babel/runtime-corejs3/helpers/wrapNativeSuper');
|
|
28
|
+
var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
29
|
+
var PropTypes = require('prop-types');
|
|
30
|
+
var formik = require('formik');
|
|
31
|
+
var moment = require('moment');
|
|
32
|
+
var applicationShellConnectors = require('@commercetools-frontend/application-shell-connectors');
|
|
33
|
+
var react = require('react');
|
|
34
|
+
var uiKit = require('@commercetools-frontend/ui-kit');
|
|
35
|
+
var omitEmpty = require('omit-empty-es');
|
|
6
36
|
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
37
|
+
var _valuesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/values');
|
|
38
|
+
var react$1 = require('@emotion/react');
|
|
39
|
+
var designSystem = require('@commercetools-uikit/design-system');
|
|
40
|
+
var _styled = require('@emotion/styled/base');
|
|
41
|
+
var _asyncToGenerator = require('@babel/runtime-corejs3/helpers/asyncToGenerator');
|
|
42
|
+
var _regeneratorRuntime = require('@babel/runtime-corejs3/regenerator');
|
|
43
|
+
var sdk = require('@commercetools-frontend/sdk');
|
|
44
|
+
var actionsGlobal = require('@commercetools-frontend/actions-global');
|
|
45
|
+
var constants = require('@commercetools-frontend/constants');
|
|
7
46
|
|
|
8
47
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
9
48
|
|
|
10
|
-
var
|
|
49
|
+
var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
|
|
50
|
+
var _Object$getOwnPropertySymbols__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertySymbols);
|
|
51
|
+
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
52
|
+
var _Object$getOwnPropertyDescriptor__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptor);
|
|
53
|
+
var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
|
|
54
|
+
var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
|
|
55
|
+
var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
|
|
56
|
+
var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
|
|
57
|
+
var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
|
|
58
|
+
var _flatInstanceProperty__default = /*#__PURE__*/_interopDefault(_flatInstanceProperty);
|
|
59
|
+
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
60
|
+
var _Reflect$construct__default = /*#__PURE__*/_interopDefault(_Reflect$construct);
|
|
61
|
+
var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
|
|
62
|
+
var moment__default = /*#__PURE__*/_interopDefault(moment);
|
|
63
|
+
var omitEmpty__default = /*#__PURE__*/_interopDefault(omitEmpty);
|
|
64
|
+
var _valuesInstanceProperty__default = /*#__PURE__*/_interopDefault(_valuesInstanceProperty);
|
|
65
|
+
var _styled__default = /*#__PURE__*/_interopDefault(_styled);
|
|
66
|
+
var _regeneratorRuntime__default = /*#__PURE__*/_interopDefault(_regeneratorRuntime);
|
|
11
67
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
68
|
+
var EXPORTABLE_RESOURCES = {
|
|
69
|
+
CATEGORY: 'category',
|
|
70
|
+
PRODUCT: 'product'
|
|
71
|
+
};
|
|
72
|
+
var EXPORT_SELECTION_TYPES = {
|
|
73
|
+
ALL_RESOURCES: 'allResources',
|
|
74
|
+
ONLY_MATCHING: 'onlyMatching',
|
|
75
|
+
ONLY_SELECTED: 'onlySelected'
|
|
76
|
+
};
|
|
77
|
+
var OUTPUT_FORMATS = {
|
|
78
|
+
JSON: 'json',
|
|
79
|
+
CSV: 'csv'
|
|
80
|
+
};
|
|
81
|
+
var EXPORT_OPERATION_STATES = {
|
|
82
|
+
PROCESSING: 'processing',
|
|
83
|
+
COMPLETED: 'completed',
|
|
84
|
+
FAILED: 'failed'
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
function _createSuper$2(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$2(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct__default["default"](Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
88
|
+
|
|
89
|
+
function _isNativeReflectConstruct$2() { if (typeof Reflect === "undefined" || !_Reflect$construct__default["default"]) return false; if (_Reflect$construct__default["default"].sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
90
|
+
|
|
91
|
+
var UnexpectedSelectionTypeError = /*#__PURE__*/function (_Error) {
|
|
92
|
+
_inherits(UnexpectedSelectionTypeError, _Error);
|
|
93
|
+
|
|
94
|
+
var _super = _createSuper$2(UnexpectedSelectionTypeError);
|
|
95
|
+
|
|
96
|
+
function UnexpectedSelectionTypeError(exportSelectionType) {
|
|
97
|
+
var _this;
|
|
98
|
+
|
|
99
|
+
_classCallCheck(this, UnexpectedSelectionTypeError);
|
|
100
|
+
|
|
101
|
+
_this = _super.call(this, "Unexpected column: ".concat(exportSelectionType));
|
|
102
|
+
_this.name = 'UnexpectedSelectionTypeError';
|
|
103
|
+
return _this;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return _createClass(UnexpectedSelectionTypeError);
|
|
107
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
108
|
+
|
|
109
|
+
function _createSuper$1(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct__default["default"](Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
110
|
+
|
|
111
|
+
function _isNativeReflectConstruct$1() { if (typeof Reflect === "undefined" || !_Reflect$construct__default["default"]) return false; if (_Reflect$construct__default["default"].sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
112
|
+
|
|
113
|
+
var MissingExportResourceProviderError = /*#__PURE__*/function (_Error) {
|
|
114
|
+
_inherits(MissingExportResourceProviderError, _Error);
|
|
115
|
+
|
|
116
|
+
var _super = _createSuper$1(MissingExportResourceProviderError);
|
|
117
|
+
|
|
118
|
+
function MissingExportResourceProviderError() {
|
|
119
|
+
var _this;
|
|
120
|
+
|
|
121
|
+
_classCallCheck(this, MissingExportResourceProviderError);
|
|
122
|
+
|
|
123
|
+
_this = _super.call(this, 'useExportResourcesContext must be used within ExportResourcesContextProvider');
|
|
124
|
+
_this.name = 'MissingExportResourceProviderError';
|
|
125
|
+
return _this;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return _createClass(MissingExportResourceProviderError);
|
|
129
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
130
|
+
|
|
131
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct__default["default"](Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
132
|
+
|
|
133
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct__default["default"]) return false; if (_Reflect$construct__default["default"].sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
134
|
+
|
|
135
|
+
var UnexpectedExportOperationStateError = /*#__PURE__*/function (_Error) {
|
|
136
|
+
_inherits(UnexpectedExportOperationStateError, _Error);
|
|
137
|
+
|
|
138
|
+
var _super = _createSuper(UnexpectedExportOperationStateError);
|
|
139
|
+
|
|
140
|
+
function UnexpectedExportOperationStateError(state) {
|
|
141
|
+
var _this;
|
|
142
|
+
|
|
143
|
+
_classCallCheck(this, UnexpectedExportOperationStateError);
|
|
144
|
+
|
|
145
|
+
_this = _super.call(this, "Unexpected export operation state \"".concat(state, "\""));
|
|
146
|
+
_this.name = 'UnexpectedExportOperationStateError';
|
|
147
|
+
return _this;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return _createClass(UnexpectedExportOperationStateError);
|
|
151
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
152
|
+
|
|
153
|
+
function resourceTypeToPlural(_ref) {
|
|
154
|
+
var resourceType = _ref.resourceType,
|
|
155
|
+
_ref$isUpperCase = _ref.isUpperCase,
|
|
156
|
+
isUpperCase = _ref$isUpperCase === void 0 ? false : _ref$isUpperCase;
|
|
157
|
+
|
|
158
|
+
switch (resourceType) {
|
|
159
|
+
case EXPORTABLE_RESOURCES.CATEGORY:
|
|
160
|
+
return isUpperCase ? 'Categories' : 'categories';
|
|
161
|
+
|
|
162
|
+
case EXPORTABLE_RESOURCES.PRODUCT:
|
|
163
|
+
return isUpperCase ? 'Products' : 'products';
|
|
164
|
+
|
|
165
|
+
default:
|
|
166
|
+
// eslint-disable-next-line no-console
|
|
167
|
+
console.warn("Unexpected resource type: \"".concat(resourceType, "\""));
|
|
168
|
+
return resourceType;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
function replaceSpecialCharsWithUnderscore(string) {
|
|
172
|
+
return string.replace(/[^a-zA-Z0-9]/g, '_');
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function buildGraphQuery(exportSettings) {
|
|
176
|
+
var _context;
|
|
177
|
+
|
|
178
|
+
var resourceType = resourceTypeToPlural({
|
|
179
|
+
resourceType: exportSettings.resourceType
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
switch (exportSettings.exportSelectionType) {
|
|
183
|
+
case EXPORT_SELECTION_TYPES.ALL_RESOURCES:
|
|
184
|
+
return gqlQueryBuilder.query({
|
|
185
|
+
operation: resourceType,
|
|
186
|
+
fields: [{
|
|
187
|
+
results: buildColumns(exportSettings.columns, exportSettings.languages)
|
|
188
|
+
}],
|
|
189
|
+
variables: {}
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
case EXPORT_SELECTION_TYPES.ONLY_SELECTED:
|
|
193
|
+
return gqlQueryBuilder.query({
|
|
194
|
+
operation: resourceType,
|
|
195
|
+
fields: [{
|
|
196
|
+
results: buildColumns(exportSettings.columns, exportSettings.languages)
|
|
197
|
+
}],
|
|
198
|
+
variables: {
|
|
199
|
+
where: "id in (".concat(_mapInstanceProperty__default["default"](_context = exportSettings.selectedResourceIds).call(_context, function (id) {
|
|
200
|
+
return "\\\"".concat(id, "\\\"");
|
|
201
|
+
}).join(', '), ")")
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
case EXPORT_SELECTION_TYPES.ONLY_MATCHING:
|
|
206
|
+
// TODO: gql query for exporting filtered resources.
|
|
207
|
+
throw new UnexpectedSelectionTypeError(exportSettings.exportSelectionType);
|
|
208
|
+
|
|
209
|
+
default:
|
|
210
|
+
throw new UnexpectedSelectionTypeError(exportSettings.exportSelectionType);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function buildColumns(columns, languages) {
|
|
215
|
+
var _context2;
|
|
216
|
+
|
|
217
|
+
return _flatInstanceProperty__default["default"](_context2 = _mapInstanceProperty__default["default"](columns).call(columns, function (column) {
|
|
218
|
+
if (column.isLocalised) return _mapInstanceProperty__default["default"](languages).call(languages, function (language) {
|
|
219
|
+
var _context3, _context4, _context5;
|
|
220
|
+
|
|
221
|
+
var alias = replaceSpecialCharsWithUnderscore(_concatInstanceProperty__default["default"](_context3 = "".concat(column.key, "_")).call(_context3, language));
|
|
222
|
+
return _concatInstanceProperty__default["default"](_context4 = _concatInstanceProperty__default["default"](_context5 = "".concat(alias, ": ")).call(_context5, column.key, "(locale: \"")).call(_context4, language, "\")");
|
|
223
|
+
});else return column.key;
|
|
224
|
+
})).call(_context2);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
var messages = reactIntl.defineMessages({
|
|
228
|
+
modalTitle: {
|
|
229
|
+
id: 'ExportResourcesModal.modalTitle',
|
|
230
|
+
description: 'Label for the modal title',
|
|
231
|
+
defaultMessage: 'Export {resourceType}'
|
|
232
|
+
},
|
|
233
|
+
modalSubTitle: {
|
|
234
|
+
id: 'ExportResourcesModal.modalSubTitle',
|
|
235
|
+
description: 'Label for the modal subtitle',
|
|
236
|
+
defaultMessage: 'Define export settings'
|
|
237
|
+
},
|
|
238
|
+
topBarPreviousPathLabel: {
|
|
239
|
+
id: 'ExportResourcesModal.topBarPreviousPathLabel',
|
|
240
|
+
description: 'Label for the topBar previous label',
|
|
241
|
+
defaultMessage: 'To {resourceType} List'
|
|
242
|
+
},
|
|
243
|
+
exportButton: {
|
|
244
|
+
id: 'ExportResourcesModal.exportButton',
|
|
245
|
+
description: 'Export primary button',
|
|
246
|
+
defaultMessage: 'Export {resourceType}'
|
|
247
|
+
},
|
|
248
|
+
outputFormat: {
|
|
249
|
+
id: 'ExportResourcesModal.outputFormat',
|
|
250
|
+
description: 'File format like (csv, xls, ...etc)',
|
|
251
|
+
defaultMessage: 'File format'
|
|
252
|
+
},
|
|
253
|
+
fileName: {
|
|
254
|
+
id: 'ExportResourcesModal.fileName',
|
|
255
|
+
description: 'exported file name',
|
|
256
|
+
defaultMessage: 'File name'
|
|
257
|
+
},
|
|
258
|
+
localLanguage: {
|
|
259
|
+
id: 'ExportResourcesModal.localLanguage',
|
|
260
|
+
description: 'Local language',
|
|
261
|
+
defaultMessage: 'Local language'
|
|
262
|
+
},
|
|
263
|
+
exportSelection: {
|
|
264
|
+
id: 'ExportResourcesModal.exportSelection',
|
|
265
|
+
description: 'Export selection',
|
|
266
|
+
defaultMessage: 'Export selection'
|
|
267
|
+
},
|
|
268
|
+
exportAllResources: {
|
|
269
|
+
id: 'ExportResourcesModal.exportAllResources',
|
|
270
|
+
description: 'Export All selection',
|
|
271
|
+
defaultMessage: 'Export all {resourceType} ({count})'
|
|
272
|
+
},
|
|
273
|
+
exportOnlyMatchingResources: {
|
|
274
|
+
id: 'ExportResourcesModal.exportOnlyMatchingResources',
|
|
275
|
+
description: 'Export resources only matching search/filter',
|
|
276
|
+
defaultMessage: 'Export list matching search/filter ({count})'
|
|
277
|
+
},
|
|
278
|
+
exportOnlySelectedResources: {
|
|
279
|
+
id: 'ExportResourcesModal.exportOnlySelectedResources',
|
|
280
|
+
description: 'Export only selected resources',
|
|
281
|
+
defaultMessage: 'Export selected {resourceType} ({count})'
|
|
282
|
+
},
|
|
283
|
+
exportAllMessage: {
|
|
284
|
+
id: 'ExportResourcesModal.exportAllMessage',
|
|
285
|
+
description: 'All resources will be exported',
|
|
286
|
+
defaultMessage: 'All <b>{count}</b> {resourceType} will be exported.'
|
|
287
|
+
},
|
|
288
|
+
exportMatchingMessage: {
|
|
289
|
+
id: 'ExportResourcesModal.exportMatchingMessage',
|
|
290
|
+
description: 'resources will be exported',
|
|
291
|
+
defaultMessage: '<b>{count}</b> {resourceType} will be exported.'
|
|
292
|
+
},
|
|
293
|
+
exportSelectedMessage: {
|
|
294
|
+
id: 'ExportResourcesModal.exportSelectedMessage',
|
|
295
|
+
description: 'resources are selected and will be exported',
|
|
296
|
+
defaultMessage: '<b>{count}</b> {resourceType} are selected and will be exported.'
|
|
297
|
+
},
|
|
298
|
+
columnsMessage: {
|
|
299
|
+
id: 'ExportResourcesModal.columnsMessage',
|
|
300
|
+
description: 'Exported columns based on table settings',
|
|
301
|
+
defaultMessage: '<b>Exported columns based on table settings:</b> {columnsCount}'
|
|
302
|
+
},
|
|
303
|
+
appliedSearchTermsMessage: {
|
|
304
|
+
id: 'ExportResourcesModal.appliedSearchTermsMessage',
|
|
305
|
+
description: 'Applied Search Term(s)',
|
|
306
|
+
defaultMessage: '<b>Applied search term(s):</b> {searchTermsCount}'
|
|
307
|
+
},
|
|
308
|
+
appliedFiltersMessage: {
|
|
309
|
+
id: 'ExportResourcesModal.appliedFiltersMessage',
|
|
310
|
+
description: 'Applied Filter(s)',
|
|
311
|
+
defaultMessage: '<b>Applied Filter(s):</b> {filtersCount}'
|
|
312
|
+
},
|
|
313
|
+
exportBasedOnMyViewsMessage: {
|
|
314
|
+
id: 'ExportResourcesModal.exportBasedOnMyViewsMessage',
|
|
315
|
+
description: 'Select Export setttings based on my views',
|
|
316
|
+
defaultMessage: 'Select export settings based on <b>My views:</b>'
|
|
317
|
+
},
|
|
318
|
+
propertiesPanelLabel: {
|
|
319
|
+
id: 'ExportResourcesModal.propertiesPanelLabel',
|
|
320
|
+
description: 'properties panel label',
|
|
321
|
+
defaultMessage: 'Properties'
|
|
322
|
+
},
|
|
323
|
+
confirmationTitle: {
|
|
324
|
+
id: 'ExportResourcesModal.confirmationTitle',
|
|
325
|
+
description: 'Title for the confirmation dialog',
|
|
326
|
+
defaultMessage: 'Export {resourceType} data'
|
|
327
|
+
},
|
|
328
|
+
confirmationBodyPlan: {
|
|
329
|
+
id: 'ExportResourcesModal.confirmationBodyPlan',
|
|
330
|
+
description: 'Confirmation dialog action plan',
|
|
331
|
+
defaultMessage: 'You are about to export <bold>{count}</bold> {resourceType} from the project: <bold>{projectName}</bold>.'
|
|
332
|
+
},
|
|
333
|
+
confirmationBodyQuestion: {
|
|
334
|
+
id: 'ExportResourcesModal.confirmationBodyQuestion',
|
|
335
|
+
description: 'Confirmation question',
|
|
336
|
+
defaultMessage: 'Are you sure you want to continue?'
|
|
337
|
+
},
|
|
338
|
+
exportOperationSuccessMessage: {
|
|
339
|
+
id: 'ExportResourcesModal.exportOperationSuccessMessage',
|
|
340
|
+
description: 'Success message',
|
|
341
|
+
defaultMessage: 'Your export has started. Go to <logsLink>Export logs</logsLink> to view the progress of your export and download it.'
|
|
342
|
+
},
|
|
343
|
+
exportConfirmationLabel: {
|
|
344
|
+
id: 'ExportResourcesModal.exportConfirmationLabel',
|
|
345
|
+
description: 'Label for the export button in confirmation dialog',
|
|
346
|
+
defaultMessage: 'Export {resourceType}'
|
|
347
|
+
},
|
|
348
|
+
nothingApplied: {
|
|
349
|
+
id: 'ExportResourcesModal.nothingApplied',
|
|
350
|
+
description: 'Shown when there is no filter applied',
|
|
351
|
+
defaultMessage: 'nothing applied'
|
|
352
|
+
},
|
|
353
|
+
all: {
|
|
354
|
+
id: 'ExportResourcesModal.all',
|
|
355
|
+
description: 'label for "All languages" checkbox',
|
|
356
|
+
defaultMessage: 'All'
|
|
357
|
+
},
|
|
358
|
+
missingFileNameError: {
|
|
359
|
+
id: 'ExportResourcesModal.missingFileNameError',
|
|
360
|
+
description: 'Error when file name field is missing',
|
|
361
|
+
defaultMessage: 'Please enter a file name'
|
|
362
|
+
},
|
|
363
|
+
invalidFileNameError: {
|
|
364
|
+
id: 'ExportResourcesModal.invalidFileNameError',
|
|
365
|
+
description: 'Error when file name field is not valid',
|
|
366
|
+
defaultMessage: 'File name may only contain alphanumeric characters, hyphens and underscores'
|
|
367
|
+
},
|
|
368
|
+
missingLanguageError: {
|
|
369
|
+
id: 'ExportResourcesModal.missingLanguageError',
|
|
370
|
+
description: 'Error when no local language is selected',
|
|
371
|
+
defaultMessage: 'Please select at least one local language'
|
|
372
|
+
}
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
var ExportResourcesContext = /*#__PURE__*/react.createContext();
|
|
376
|
+
|
|
377
|
+
PropTypes__default["default"].shape({
|
|
378
|
+
resourceType: PropTypes__default["default"].string.isRequired,
|
|
379
|
+
outputFormat: PropTypes__default["default"].string,
|
|
380
|
+
isOpen: PropTypes__default["default"].bool.isRequired,
|
|
381
|
+
closeModal: PropTypes__default["default"].func.isRequired,
|
|
382
|
+
allResourcesCount: PropTypes__default["default"].number.isRequired,
|
|
383
|
+
matchingResourcesCount: PropTypes__default["default"].number,
|
|
384
|
+
selectedResourceIds: PropTypes__default["default"].array,
|
|
385
|
+
columns: PropTypes__default["default"].arrayOf({
|
|
386
|
+
key: PropTypes__default["default"].string.isRequired,
|
|
387
|
+
isLocalised: PropTypes__default["default"].bool
|
|
388
|
+
}).isRequired,
|
|
389
|
+
exportSelectionType: PropTypes__default["default"].string,
|
|
390
|
+
appliedSearchTerms: PropTypes__default["default"].array,
|
|
391
|
+
appliedFilters: PropTypes__default["default"].array,
|
|
392
|
+
renderProperties: PropTypes__default["default"].func
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
function validate(values) {
|
|
396
|
+
var errors = {
|
|
397
|
+
fileName: {},
|
|
398
|
+
languages: {}
|
|
399
|
+
};
|
|
400
|
+
|
|
401
|
+
if (uiKit.TextInput.isEmpty(values.fileName)) {
|
|
402
|
+
errors.fileName.missing = true;
|
|
403
|
+
} else if (!/^[a-zA-Z0-9-_]+$/.test(values.fileName)) {
|
|
404
|
+
errors.fileName.invalidInput = true;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
if (values.languages.length < 1) {
|
|
408
|
+
errors.languages.missing = true;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
return omitEmpty__default["default"](errors);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
var ExportResourcesContextProvider = function ExportResourcesContextProvider(props) {
|
|
415
|
+
var _context;
|
|
416
|
+
|
|
417
|
+
var todayFormatted = moment__default["default"]().format('DD-MM-YY_HH-mm');
|
|
418
|
+
|
|
419
|
+
var _useApplicationContex = applicationShellConnectors.useApplicationContext(function (applicationContext) {
|
|
420
|
+
return {
|
|
421
|
+
language: applicationContext.dataLocale
|
|
422
|
+
};
|
|
423
|
+
}),
|
|
424
|
+
language = _useApplicationContex.language;
|
|
425
|
+
|
|
426
|
+
var formik$1 = formik.useFormik({
|
|
427
|
+
initialValues: {
|
|
428
|
+
outputFormat: props.outputFormat,
|
|
429
|
+
fileName: _concatInstanceProperty__default["default"](_context = "".concat(resourceTypeToPlural({
|
|
430
|
+
resourceType: props.resourceType,
|
|
431
|
+
isUpperCase: true
|
|
432
|
+
}), "_Export_")).call(_context, todayFormatted),
|
|
433
|
+
languages: [language],
|
|
434
|
+
columns: props.columns,
|
|
435
|
+
appliedSearchTerms: props.appliedSearchTerms,
|
|
436
|
+
appliedFilters: props.appliedFilters,
|
|
437
|
+
exportSelectionType: props.exportSelectionType,
|
|
438
|
+
isAllLanguagesChecked: false
|
|
439
|
+
},
|
|
440
|
+
validate: validate
|
|
441
|
+
});
|
|
442
|
+
|
|
443
|
+
var _useState = react.useState(false),
|
|
444
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
445
|
+
exportOperationStarted = _useState2[0],
|
|
446
|
+
setExportOperationStarted = _useState2[1];
|
|
447
|
+
|
|
448
|
+
return jsxRuntime.jsx(ExportResourcesContext.Provider, {
|
|
449
|
+
value: {
|
|
450
|
+
formik: formik$1,
|
|
451
|
+
resourceType: props.resourceType,
|
|
452
|
+
allResourcesCount: props.allResourcesCount,
|
|
453
|
+
matchingResourcesCount: props.matchingResourcesCount,
|
|
454
|
+
selectedResourceIds: props.selectedResourceIds,
|
|
455
|
+
exportOperationStarted: exportOperationStarted,
|
|
456
|
+
setExportOperationStarted: setExportOperationStarted
|
|
457
|
+
},
|
|
458
|
+
children: props.children
|
|
459
|
+
});
|
|
460
|
+
};
|
|
461
|
+
|
|
462
|
+
ExportResourcesContextProvider.displayName = 'ExportResourcesContextProvider';
|
|
463
|
+
ExportResourcesContextProvider.propTypes = {};
|
|
464
|
+
|
|
465
|
+
function useExportResourcesContext() {
|
|
466
|
+
var context = react.useContext(ExportResourcesContext);
|
|
467
|
+
|
|
468
|
+
if (!context) {
|
|
469
|
+
throw new MissingExportResourceProviderError();
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
return context;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
var smallTopPadding = /*#__PURE__*/react$1.css("padding-top:", designSystem.customProperties.spacingXs, ";" + ("" ), "" );
|
|
476
|
+
var tagListContainer = /*#__PURE__*/react$1.css("width:100%;display:flex;flex-wrap:wrap;display:inline-flex;padding:0 ", designSystem.customProperties.spacingL, ";&>div{margin:0 ", designSystem.customProperties.spacingS, " ", designSystem.customProperties.spacingS, " 0;}" + ("" ), "" );
|
|
477
|
+
var tagListItem = /*#__PURE__*/react$1.css("margin:0 ", designSystem.customProperties.spacingXs, " ", designSystem.customProperties.spacingXs, " 0;display:flex;min-width:0;" + ("" ), "" );
|
|
478
|
+
var divider = /*#__PURE__*/react$1.css("box-sizing:border-box;width:100%;margin:0;border:0;border-top:1px solid ", designSystem.customProperties.colorNeutral60, ";" + ("" ), "" );
|
|
479
|
+
var notBold = {
|
|
480
|
+
name: "lugakg",
|
|
481
|
+
styles: "font-weight:normal"
|
|
482
|
+
} ;
|
|
483
|
+
var successMessage = /*#__PURE__*/react$1.css("margin-bottom:", designSystem.customProperties.spacingL, ";" + ("" ), "" );
|
|
484
|
+
var styles = {
|
|
485
|
+
tagListItem: tagListItem,
|
|
486
|
+
tagListContainer: tagListContainer,
|
|
487
|
+
smallTopPadding: smallTopPadding,
|
|
488
|
+
divider: divider,
|
|
489
|
+
notBold: notBold,
|
|
490
|
+
successMessage: successMessage
|
|
491
|
+
};
|
|
492
|
+
|
|
493
|
+
function ExportSelectionRadioButtons() {
|
|
494
|
+
var intl = reactIntl.useIntl();
|
|
495
|
+
|
|
496
|
+
var _useExportResourcesCo = useExportResourcesContext(),
|
|
497
|
+
formik = _useExportResourcesCo.formik,
|
|
498
|
+
resourceType = _useExportResourcesCo.resourceType,
|
|
499
|
+
allResourcesCount = _useExportResourcesCo.allResourcesCount,
|
|
500
|
+
matchingResourcesCount = _useExportResourcesCo.matchingResourcesCount,
|
|
501
|
+
selectedResourceIds = _useExportResourcesCo.selectedResourceIds;
|
|
502
|
+
|
|
503
|
+
var resourceTypePlural = resourceTypeToPlural({
|
|
504
|
+
resourceType: resourceType
|
|
505
|
+
});
|
|
506
|
+
return jsxRuntime.jsx(uiKit.Spacings.Inline, {
|
|
507
|
+
scale: "xl",
|
|
508
|
+
children: jsxRuntime.jsxs(uiKit.RadioInput.Group, {
|
|
509
|
+
name: "exportSelectionType",
|
|
510
|
+
value: _valuesInstanceProperty__default["default"](formik).exportSelectionType,
|
|
511
|
+
direction: "inline",
|
|
512
|
+
directionProps: {
|
|
513
|
+
scale: 'xl'
|
|
514
|
+
},
|
|
515
|
+
onChange: formik.handleChange,
|
|
516
|
+
children: [jsxRuntime.jsx(uiKit.RadioInput.Option, {
|
|
517
|
+
value: EXPORT_SELECTION_TYPES.ALL_RESOURCES,
|
|
518
|
+
"data-testid": 'test-all-resources',
|
|
519
|
+
children: jsxRuntime.jsx("b", {
|
|
520
|
+
children: intl.formatMessage(messages.exportAllResources, {
|
|
521
|
+
resourceType: resourceTypePlural,
|
|
522
|
+
count: allResourcesCount
|
|
523
|
+
})
|
|
524
|
+
})
|
|
525
|
+
}), jsxRuntime.jsx(uiKit.RadioInput.Option, {
|
|
526
|
+
value: EXPORT_SELECTION_TYPES.ONLY_MATCHING,
|
|
527
|
+
"data-testid": 'test-only-matching',
|
|
528
|
+
isDisabled: !Boolean(matchingResourcesCount),
|
|
529
|
+
children: jsxRuntime.jsx("b", {
|
|
530
|
+
children: intl.formatMessage(messages.exportOnlyMatchingResources, {
|
|
531
|
+
count: matchingResourcesCount || intl.formatMessage(messages.nothingApplied)
|
|
532
|
+
})
|
|
533
|
+
})
|
|
534
|
+
}), jsxRuntime.jsx(uiKit.RadioInput.Option, {
|
|
535
|
+
value: EXPORT_SELECTION_TYPES.ONLY_SELECTED,
|
|
536
|
+
"data-testid": 'test-only-selected',
|
|
537
|
+
isDisabled: !Boolean(selectedResourceIds.length),
|
|
538
|
+
children: jsxRuntime.jsx("b", {
|
|
539
|
+
children: intl.formatMessage(messages.exportOnlySelectedResources, {
|
|
540
|
+
resourceType: resourceTypePlural,
|
|
541
|
+
count: selectedResourceIds.length
|
|
542
|
+
})
|
|
543
|
+
})
|
|
544
|
+
})]
|
|
545
|
+
})
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
function getBold(msg) {
|
|
550
|
+
return jsxRuntime.jsx(uiKit.Text.Body, {
|
|
551
|
+
as: "span",
|
|
552
|
+
isBold: true,
|
|
553
|
+
children: msg
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
function ownKeys$a(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
558
|
+
|
|
559
|
+
function _objectSpread$a(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$a(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$a(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
560
|
+
function ExportTextMessage() {
|
|
561
|
+
var _useExportResourcesCo = useExportResourcesContext(),
|
|
562
|
+
resourceType = _useExportResourcesCo.resourceType,
|
|
563
|
+
allResourcesCount = _useExportResourcesCo.allResourcesCount,
|
|
564
|
+
selectedResourceIds = _useExportResourcesCo.selectedResourceIds,
|
|
565
|
+
matchingResourcesCount = _useExportResourcesCo.matchingResourcesCount,
|
|
566
|
+
formik = _useExportResourcesCo.formik;
|
|
567
|
+
|
|
568
|
+
var resourceTypePlural = resourceTypeToPlural({
|
|
569
|
+
resourceType: resourceType
|
|
570
|
+
});
|
|
571
|
+
|
|
572
|
+
switch (_valuesInstanceProperty__default["default"](formik).exportSelectionType) {
|
|
573
|
+
case EXPORT_SELECTION_TYPES.ALL_RESOURCES:
|
|
574
|
+
return jsxRuntime.jsx(uiKit.Text.Body, {
|
|
575
|
+
intlMessage: _objectSpread$a(_objectSpread$a({}, messages.exportAllMessage), {}, {
|
|
576
|
+
values: {
|
|
577
|
+
count: allResourcesCount,
|
|
578
|
+
resourceType: resourceTypePlural,
|
|
579
|
+
b: getBold
|
|
580
|
+
}
|
|
581
|
+
})
|
|
582
|
+
});
|
|
583
|
+
|
|
584
|
+
case EXPORT_SELECTION_TYPES.ONLY_MATCHING:
|
|
585
|
+
return jsxRuntime.jsx(uiKit.Text.Body, {
|
|
586
|
+
intlMessage: _objectSpread$a(_objectSpread$a({}, messages.exportMatchingMessage), {}, {
|
|
587
|
+
values: {
|
|
588
|
+
count: matchingResourcesCount,
|
|
589
|
+
resourceType: resourceTypePlural,
|
|
590
|
+
b: getBold
|
|
591
|
+
}
|
|
592
|
+
})
|
|
593
|
+
});
|
|
594
|
+
|
|
595
|
+
case EXPORT_SELECTION_TYPES.ONLY_SELECTED:
|
|
596
|
+
return jsxRuntime.jsx(uiKit.Text.Body, {
|
|
597
|
+
intlMessage: _objectSpread$a(_objectSpread$a({}, messages.exportSelectedMessage), {}, {
|
|
598
|
+
values: {
|
|
599
|
+
count: selectedResourceIds.length,
|
|
600
|
+
resourceType: resourceTypePlural,
|
|
601
|
+
b: getBold
|
|
602
|
+
}
|
|
603
|
+
})
|
|
604
|
+
});
|
|
605
|
+
|
|
606
|
+
default:
|
|
607
|
+
throw new UnexpectedSelectionTypeError(_valuesInstanceProperty__default["default"](formik).exportSelectionType);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
function TagList(props) {
|
|
612
|
+
return jsxRuntime.jsx("div", {
|
|
613
|
+
css: styles.tagListContainer,
|
|
614
|
+
"data-testid": props['data-testid'],
|
|
615
|
+
children: _mapInstanceProperty__default["default"](react.Children).call(react.Children, props.children, function (tag) {
|
|
616
|
+
return jsxRuntime.jsx("div", {
|
|
617
|
+
css: styles.tagListItem,
|
|
618
|
+
children: tag
|
|
619
|
+
});
|
|
620
|
+
})
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
TagList.displayName = 'TagList';
|
|
624
|
+
TagList.propTypes = {};
|
|
625
|
+
|
|
626
|
+
function ownKeys$9(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
627
|
+
|
|
628
|
+
function _objectSpread$9(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$9(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$9(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
629
|
+
function AppliedFilters(_ref) {
|
|
630
|
+
var filters = _ref.filters,
|
|
631
|
+
onFilterRemove = _ref.onFilterRemove;
|
|
632
|
+
return jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
633
|
+
scale: "s",
|
|
634
|
+
children: [jsxRuntime.jsxs(uiKit.Spacings.Inline, {
|
|
635
|
+
scale: "s",
|
|
636
|
+
alignItems: "flex-start",
|
|
637
|
+
children: [jsxRuntime.jsx(uiKit.AngleRightIcon, {
|
|
638
|
+
"data-testid": "test-arrowRight",
|
|
639
|
+
size: "medium",
|
|
640
|
+
color: "neutral60"
|
|
641
|
+
}), jsxRuntime.jsx(uiKit.Text.Body, {
|
|
642
|
+
intlMessage: _objectSpread$9(_objectSpread$9({}, messages.appliedFiltersMessage), {}, {
|
|
643
|
+
values: {
|
|
644
|
+
filtersCount: filters.length,
|
|
645
|
+
b: getBold
|
|
646
|
+
}
|
|
647
|
+
})
|
|
648
|
+
})]
|
|
649
|
+
}), jsxRuntime.jsx(TagList, {
|
|
650
|
+
children: _mapInstanceProperty__default["default"](filters).call(filters, function (filter) {
|
|
651
|
+
return jsxRuntime.jsx("div", {
|
|
652
|
+
"data-testid": "test-filter-".concat(filter),
|
|
653
|
+
children: jsxRuntime.jsx(uiKit.Tag, {
|
|
654
|
+
onRemove: function onRemove() {
|
|
655
|
+
onFilterRemove(filter);
|
|
656
|
+
},
|
|
657
|
+
children: filter
|
|
658
|
+
})
|
|
659
|
+
}, filter);
|
|
660
|
+
})
|
|
18
661
|
})]
|
|
19
662
|
});
|
|
20
663
|
}
|
|
664
|
+
AppliedFilters.propTypes = {};
|
|
665
|
+
|
|
666
|
+
function ownKeys$8(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
667
|
+
|
|
668
|
+
function _objectSpread$8(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$8(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$8(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
669
|
+
function ExportBasedOnMyViewsSelectField() {
|
|
670
|
+
return jsxRuntime.jsxs(uiKit.Spacings.Inline, {
|
|
671
|
+
scale: "m",
|
|
672
|
+
alignItems: "center",
|
|
673
|
+
children: [jsxRuntime.jsx(uiKit.Text.Body, {
|
|
674
|
+
intlMessage: _objectSpread$8(_objectSpread$8({}, messages.exportBasedOnMyViewsMessage), {}, {
|
|
675
|
+
values: {
|
|
676
|
+
b: getBold
|
|
677
|
+
}
|
|
678
|
+
})
|
|
679
|
+
}), jsxRuntime.jsx(uiKit.Constraints.Horizontal, {
|
|
680
|
+
max: 4,
|
|
681
|
+
children: jsxRuntime.jsx(uiKit.SelectInput, {
|
|
682
|
+
isDisabled: true,
|
|
683
|
+
placeholder: "Default"
|
|
684
|
+
})
|
|
685
|
+
})]
|
|
686
|
+
});
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
function ownKeys$7(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
690
|
+
|
|
691
|
+
function _objectSpread$7(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$7(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$7(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
692
|
+
|
|
693
|
+
var IconPlaceholder = _styled__default["default"]("div", {
|
|
694
|
+
target: "e1nl5t3e0"
|
|
695
|
+
} )("width:", uiKit.customProperties.spacingM, ";" + ("" ));
|
|
696
|
+
|
|
697
|
+
function AppliedSearchTerms(_ref) {
|
|
698
|
+
var appliedSearchTerms = _ref.appliedSearchTerms;
|
|
699
|
+
return jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
700
|
+
scale: "s",
|
|
701
|
+
children: [jsxRuntime.jsxs(uiKit.Spacings.Inline, {
|
|
702
|
+
scale: "s",
|
|
703
|
+
alignItems: "flex-start",
|
|
704
|
+
children: [jsxRuntime.jsx(uiKit.AngleRightIcon, {
|
|
705
|
+
"data-testid": "test-arrowRight",
|
|
706
|
+
size: "medium",
|
|
707
|
+
color: "neutral60"
|
|
708
|
+
}), jsxRuntime.jsx(uiKit.Text.Body, {
|
|
709
|
+
intlMessage: _objectSpread$7(_objectSpread$7({}, messages.appliedSearchTermsMessage), {}, {
|
|
710
|
+
values: {
|
|
711
|
+
searchTermsCount: appliedSearchTerms.length,
|
|
712
|
+
b: getBold
|
|
713
|
+
}
|
|
714
|
+
})
|
|
715
|
+
})]
|
|
716
|
+
}), jsxRuntime.jsxs(uiKit.Spacings.Inline, {
|
|
717
|
+
scale: "s",
|
|
718
|
+
alignItems: "flex-start",
|
|
719
|
+
children: [jsxRuntime.jsx(IconPlaceholder, {}), jsxRuntime.jsx(uiKit.Text.Body, {
|
|
720
|
+
children: appliedSearchTerms.join(', ')
|
|
721
|
+
})]
|
|
722
|
+
})]
|
|
723
|
+
});
|
|
724
|
+
}
|
|
725
|
+
AppliedSearchTerms.propTypes = {};
|
|
726
|
+
|
|
727
|
+
function ownKeys$6(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
728
|
+
|
|
729
|
+
function _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$6(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$6(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
730
|
+
function Columns(_ref) {
|
|
731
|
+
var columns = _ref.columns;
|
|
732
|
+
return jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
733
|
+
scale: "s",
|
|
734
|
+
children: [jsxRuntime.jsxs(uiKit.Spacings.Inline, {
|
|
735
|
+
scale: "s",
|
|
736
|
+
alignItems: "flex-start",
|
|
737
|
+
children: [jsxRuntime.jsx(uiKit.AngleRightIcon, {
|
|
738
|
+
"data-testid": "test-arrowRight",
|
|
739
|
+
size: "medium",
|
|
740
|
+
color: "neutral60"
|
|
741
|
+
}), jsxRuntime.jsx(uiKit.Text.Body, {
|
|
742
|
+
intlMessage: _objectSpread$6(_objectSpread$6({}, messages.columnsMessage), {}, {
|
|
743
|
+
values: {
|
|
744
|
+
columnsCount: columns.length,
|
|
745
|
+
b: getBold
|
|
746
|
+
}
|
|
747
|
+
})
|
|
748
|
+
})]
|
|
749
|
+
}), jsxRuntime.jsx(TagList, {
|
|
750
|
+
children: _mapInstanceProperty__default["default"](columns).call(columns, function (column) {
|
|
751
|
+
return jsxRuntime.jsx("div", {
|
|
752
|
+
"data-testid": "test-column-".concat(column.exportLabel),
|
|
753
|
+
children: jsxRuntime.jsx(uiKit.Tag, {
|
|
754
|
+
children: column.key
|
|
755
|
+
})
|
|
756
|
+
}, column.exportLabel);
|
|
757
|
+
})
|
|
758
|
+
})]
|
|
759
|
+
});
|
|
760
|
+
}
|
|
761
|
+
Columns.propTypes = {};
|
|
762
|
+
|
|
763
|
+
var ExportSelection = function ExportSelection() {
|
|
764
|
+
var _useExportResourcesCo = useExportResourcesContext(),
|
|
765
|
+
formik = _useExportResourcesCo.formik;
|
|
766
|
+
|
|
767
|
+
var onAppliedFilterRemove = function onAppliedFilterRemove(filter) {
|
|
768
|
+
var _context;
|
|
769
|
+
|
|
770
|
+
formik.setFieldValue('appliedFilters', _filterInstanceProperty__default["default"](_context = _valuesInstanceProperty__default["default"](formik).appliedFilters).call(_context, function (appliedFilter) {
|
|
771
|
+
return appliedFilter !== filter;
|
|
772
|
+
}));
|
|
773
|
+
};
|
|
774
|
+
|
|
775
|
+
return jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
776
|
+
scale: "s",
|
|
777
|
+
children: [jsxRuntime.jsx(uiKit.Text.Body, {
|
|
778
|
+
isBold: true,
|
|
779
|
+
intlMessage: messages.exportSelection
|
|
780
|
+
}), jsxRuntime.jsxs(uiKit.Card, {
|
|
781
|
+
theme: "dark",
|
|
782
|
+
type: "raised",
|
|
783
|
+
insetScale: "none",
|
|
784
|
+
children: [jsxRuntime.jsx(uiKit.Spacings.Inset, {
|
|
785
|
+
scale: "m",
|
|
786
|
+
children: jsxRuntime.jsx(ExportSelectionRadioButtons, {})
|
|
787
|
+
}), jsxRuntime.jsx("div", {
|
|
788
|
+
css: styles.divider
|
|
789
|
+
}), jsxRuntime.jsx(uiKit.Spacings.Inset, {
|
|
790
|
+
scale: "m",
|
|
791
|
+
children: jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
792
|
+
scale: "l",
|
|
793
|
+
children: [jsxRuntime.jsx(ExportTextMessage, {}), _valuesInstanceProperty__default["default"](formik).exportSelectionType === EXPORT_SELECTION_TYPES.ONLY_MATCHING && jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
794
|
+
children: [jsxRuntime.jsx(ExportBasedOnMyViewsSelectField, {}), jsxRuntime.jsx(AppliedSearchTerms, {
|
|
795
|
+
appliedSearchTerms: _valuesInstanceProperty__default["default"](formik).appliedSearchTerms
|
|
796
|
+
}), jsxRuntime.jsx(AppliedFilters, {
|
|
797
|
+
filters: _valuesInstanceProperty__default["default"](formik).appliedFilters,
|
|
798
|
+
onFilterRemove: onAppliedFilterRemove
|
|
799
|
+
})]
|
|
800
|
+
}), _valuesInstanceProperty__default["default"](formik).columns.length > 0 && jsxRuntime.jsx(Columns, {
|
|
801
|
+
columns: _valuesInstanceProperty__default["default"](formik).columns
|
|
802
|
+
})]
|
|
803
|
+
})
|
|
804
|
+
})]
|
|
805
|
+
})]
|
|
806
|
+
});
|
|
807
|
+
};
|
|
808
|
+
|
|
809
|
+
function ownKeys$5(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
810
|
+
|
|
811
|
+
function _objectSpread$5(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$5(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$5(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
812
|
+
var ExportPropertiesPanel = function ExportPropertiesPanel(props) {
|
|
813
|
+
if (typeof props.renderProperties !== 'function') return null;
|
|
814
|
+
return jsxRuntime.jsx(uiKit.CollapsiblePanel, {
|
|
815
|
+
header: jsxRuntime.jsx(uiKit.Text.Body, {
|
|
816
|
+
isBold: true,
|
|
817
|
+
intlMessage: _objectSpread$5({}, messages.propertiesPanelLabel)
|
|
818
|
+
}),
|
|
819
|
+
children: props.renderProperties()
|
|
820
|
+
});
|
|
821
|
+
};
|
|
822
|
+
ExportPropertiesPanel.propTypes = {};
|
|
823
|
+
|
|
824
|
+
function ownKeys$4(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
825
|
+
|
|
826
|
+
function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$4(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$4(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
827
|
+
function renderFileNameError(key) {
|
|
828
|
+
switch (key) {
|
|
829
|
+
case 'missing':
|
|
830
|
+
return jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$4({}, messages.missingFileNameError));
|
|
831
|
+
|
|
832
|
+
case 'invalidInput':
|
|
833
|
+
return jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$4({}, messages.invalidFileNameError));
|
|
834
|
+
|
|
835
|
+
default:
|
|
836
|
+
return null;
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
function renderLanguageError(key) {
|
|
840
|
+
switch (key) {
|
|
841
|
+
case 'missing':
|
|
842
|
+
return jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$4({}, messages.missingLanguageError));
|
|
843
|
+
|
|
844
|
+
default:
|
|
845
|
+
return null;
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
function ownKeys$3(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
850
|
+
|
|
851
|
+
function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$3(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$3(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
852
|
+
var outputFormatOptions = [{
|
|
853
|
+
value: OUTPUT_FORMATS.JSON,
|
|
854
|
+
label: 'JSON'
|
|
855
|
+
}, {
|
|
856
|
+
value: OUTPUT_FORMATS.CSV,
|
|
857
|
+
label: 'CSV'
|
|
858
|
+
}];
|
|
859
|
+
|
|
860
|
+
function mapLanguagesToOptions(languages) {
|
|
861
|
+
return _mapInstanceProperty__default["default"](languages).call(languages, function (language) {
|
|
862
|
+
return {
|
|
863
|
+
value: language,
|
|
864
|
+
label: language
|
|
865
|
+
};
|
|
866
|
+
});
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
function ExportFileSettings(props) {
|
|
870
|
+
var intl = reactIntl.useIntl();
|
|
871
|
+
|
|
872
|
+
var _useExportResourcesCo = useExportResourcesContext(),
|
|
873
|
+
formik = _useExportResourcesCo.formik;
|
|
874
|
+
|
|
875
|
+
var _useApplicationContex = applicationShellConnectors.useApplicationContext(function (applicationContext) {
|
|
876
|
+
var _applicationContext$p;
|
|
877
|
+
|
|
878
|
+
return {
|
|
879
|
+
language: applicationContext.dataLocale,
|
|
880
|
+
languages: ((_applicationContext$p = applicationContext.project) === null || _applicationContext$p === void 0 ? void 0 : _applicationContext$p.languages) || []
|
|
881
|
+
};
|
|
882
|
+
}),
|
|
883
|
+
languages = _useApplicationContex.languages,
|
|
884
|
+
language = _useApplicationContex.language;
|
|
885
|
+
|
|
886
|
+
return jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
887
|
+
scale: "l",
|
|
888
|
+
children: [jsxRuntime.jsxs(uiKit.Spacings.Inline, {
|
|
889
|
+
scale: "l",
|
|
890
|
+
children: [jsxRuntime.jsx(uiKit.SelectField, _objectSpread$3(_objectSpread$3({
|
|
891
|
+
isDisabled: true
|
|
892
|
+
}, formik.getFieldProps('outputFormat')), {}, {
|
|
893
|
+
title: intl.formatMessage(messages.outputFormat),
|
|
894
|
+
options: outputFormatOptions,
|
|
895
|
+
horizontalConstraint: 7
|
|
896
|
+
})), jsxRuntime.jsx(uiKit.TextField, _objectSpread$3(_objectSpread$3({
|
|
897
|
+
title: intl.formatMessage(messages.fileName)
|
|
898
|
+
}, formik.getFieldProps('fileName')), {}, {
|
|
899
|
+
touched: formik.touched.fileName,
|
|
900
|
+
errors: formik.errors.fileName,
|
|
901
|
+
renderError: renderFileNameError,
|
|
902
|
+
horizontalConstraint: 7
|
|
903
|
+
}))]
|
|
904
|
+
}), jsxRuntime.jsx(uiKit.Spacings.Inline, {
|
|
905
|
+
children: jsxRuntime.jsx(uiKit.SelectField, _objectSpread$3(_objectSpread$3({
|
|
906
|
+
id: "languages",
|
|
907
|
+
title: jsxRuntime.jsxs(uiKit.Spacings.Inline, {
|
|
908
|
+
scale: "s",
|
|
909
|
+
children: [jsxRuntime.jsx("label", {
|
|
910
|
+
htmlFor: "languages",
|
|
911
|
+
children: intl.formatMessage(messages.localLanguage)
|
|
912
|
+
}), jsxRuntime.jsx(uiKit.CheckboxInput, {
|
|
913
|
+
name: "isAllLanguagesChecked",
|
|
914
|
+
isChecked: _valuesInstanceProperty__default["default"](formik).isAllLanguagesChecked,
|
|
915
|
+
onChange: function onChange(e) {
|
|
916
|
+
if (e.target.checked) formik.setFieldValue('languages', languages);else formik.setFieldValue('languages', [language]);
|
|
917
|
+
formik.handleChange(e);
|
|
918
|
+
},
|
|
919
|
+
children: jsxRuntime.jsx("div", {
|
|
920
|
+
css: styles.notBold,
|
|
921
|
+
children: intl.formatMessage(messages.all)
|
|
922
|
+
})
|
|
923
|
+
})]
|
|
924
|
+
}),
|
|
925
|
+
options: mapLanguagesToOptions(languages),
|
|
926
|
+
isMulti: true
|
|
927
|
+
}, formik.getFieldProps('languages')), {}, {
|
|
928
|
+
onChange: function onChange(e) {
|
|
929
|
+
formik.handleChange(e);
|
|
930
|
+
formik.setFieldValue('isAllLanguagesChecked', false);
|
|
931
|
+
},
|
|
932
|
+
touched: formik.touched.languages,
|
|
933
|
+
errors: formik.errors.languages,
|
|
934
|
+
renderError: renderLanguageError,
|
|
935
|
+
horizontalConstraint: 7
|
|
936
|
+
}))
|
|
937
|
+
}), jsxRuntime.jsx(ExportSelection, {}), jsxRuntime.jsx(ExportPropertiesPanel, {
|
|
938
|
+
renderProperties: props.renderProperties
|
|
939
|
+
})]
|
|
940
|
+
});
|
|
941
|
+
}
|
|
942
|
+
ExportFileSettings.displayName = 'ExportFileSettings';
|
|
943
|
+
ExportFileSettings.propTypes = {};
|
|
944
|
+
|
|
945
|
+
function createExportOperation(_x) {
|
|
946
|
+
return _createExportOperation.apply(this, arguments);
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
function _createExportOperation() {
|
|
950
|
+
_createExportOperation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(_ref) {
|
|
951
|
+
var projectKey, graphQuery, asyncDispatchFn, uri, response;
|
|
952
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
|
|
953
|
+
while (1) {
|
|
954
|
+
switch (_context.prev = _context.next) {
|
|
955
|
+
case 0:
|
|
956
|
+
projectKey = _ref.projectKey, graphQuery = _ref.graphQuery, asyncDispatchFn = _ref.asyncDispatchFn;
|
|
957
|
+
uri = "/proxy/export/".concat(projectKey, "/export-operations");
|
|
958
|
+
_context.next = 4;
|
|
959
|
+
return asyncDispatchFn(sdk.actions.post({
|
|
960
|
+
// FIXME: EXPORT is undefined
|
|
961
|
+
mcApiProxyTarget: constants.MC_API_PROXY_TARGETS.EXPORT,
|
|
962
|
+
uri: uri,
|
|
963
|
+
headers: {
|
|
964
|
+
accept: 'application/json'
|
|
965
|
+
},
|
|
966
|
+
payload: {
|
|
967
|
+
query: graphQuery
|
|
968
|
+
}
|
|
969
|
+
}));
|
|
970
|
+
|
|
971
|
+
case 4:
|
|
972
|
+
response = _context.sent;
|
|
973
|
+
return _context.abrupt("return", response);
|
|
974
|
+
|
|
975
|
+
case 6:
|
|
976
|
+
case "end":
|
|
977
|
+
return _context.stop();
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
}, _callee);
|
|
981
|
+
}));
|
|
982
|
+
return _createExportOperation.apply(this, arguments);
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
function ownKeys$2(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
986
|
+
|
|
987
|
+
function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context2 = ownKeys$2(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context3 = ownKeys$2(Object(source))).call(_context3, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
988
|
+
function ExportConfirmationModal(props) {
|
|
989
|
+
var _useApplicationContex = applicationShellConnectors.useApplicationContext(function (applicationContext) {
|
|
990
|
+
var _applicationContext$p, _applicationContext$p2;
|
|
991
|
+
|
|
992
|
+
return {
|
|
993
|
+
projectName: (_applicationContext$p = applicationContext.project) === null || _applicationContext$p === void 0 ? void 0 : _applicationContext$p.name,
|
|
994
|
+
projectKey: (_applicationContext$p2 = applicationContext.project) === null || _applicationContext$p2 === void 0 ? void 0 : _applicationContext$p2.key
|
|
995
|
+
};
|
|
996
|
+
}),
|
|
997
|
+
projectName = _useApplicationContex.projectName,
|
|
998
|
+
projectKey = _useApplicationContex.projectKey;
|
|
999
|
+
|
|
1000
|
+
var _useExportResourcesCo = useExportResourcesContext(),
|
|
1001
|
+
formik = _useExportResourcesCo.formik,
|
|
1002
|
+
allResourcesCount = _useExportResourcesCo.allResourcesCount,
|
|
1003
|
+
matchingResourcesCount = _useExportResourcesCo.matchingResourcesCount,
|
|
1004
|
+
selectedResourceIds = _useExportResourcesCo.selectedResourceIds,
|
|
1005
|
+
resourceType = _useExportResourcesCo.resourceType,
|
|
1006
|
+
setExportOperationStarted = _useExportResourcesCo.setExportOperationStarted;
|
|
1007
|
+
|
|
1008
|
+
var intl = reactIntl.useIntl();
|
|
1009
|
+
var asyncDispatch = sdk.useAsyncDispatch();
|
|
1010
|
+
var resourceTypePlural = resourceTypeToPlural({
|
|
1011
|
+
resourceType: props.resourceType
|
|
1012
|
+
});
|
|
1013
|
+
|
|
1014
|
+
var countInConfirmationMessage = function countInConfirmationMessage() {
|
|
1015
|
+
switch (_valuesInstanceProperty__default["default"](formik).exportSelectionType) {
|
|
1016
|
+
case EXPORT_SELECTION_TYPES.ALL_RESOURCES:
|
|
1017
|
+
return allResourcesCount;
|
|
1018
|
+
|
|
1019
|
+
case EXPORT_SELECTION_TYPES.ONLY_MATCHING:
|
|
1020
|
+
return matchingResourcesCount;
|
|
1021
|
+
|
|
1022
|
+
case EXPORT_SELECTION_TYPES.ONLY_SELECTED:
|
|
1023
|
+
return selectedResourceIds.length;
|
|
1024
|
+
|
|
1025
|
+
default:
|
|
1026
|
+
throw new UnexpectedSelectionTypeError(_valuesInstanceProperty__default["default"](formik).exportSelectionType);
|
|
1027
|
+
}
|
|
1028
|
+
};
|
|
1029
|
+
|
|
1030
|
+
return jsxRuntime.jsx(applicationComponents.ConfirmationDialog, {
|
|
1031
|
+
dataAttributesPrimaryButton: {
|
|
1032
|
+
'data-testid': 'confirm-export-button'
|
|
1033
|
+
},
|
|
1034
|
+
title: intl.formatMessage(messages.confirmationTitle, {
|
|
1035
|
+
resourceType: resourceTypePlural
|
|
1036
|
+
}),
|
|
1037
|
+
labelPrimary: intl.formatMessage(messages.exportConfirmationLabel, {
|
|
1038
|
+
resourceType: resourceTypePlural
|
|
1039
|
+
}),
|
|
1040
|
+
isOpen: props.isOpen,
|
|
1041
|
+
onClose: props.closeModal,
|
|
1042
|
+
onCancel: props.closeModal,
|
|
1043
|
+
onConfirm: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee() {
|
|
1044
|
+
var graphQuery, response;
|
|
1045
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
|
|
1046
|
+
while (1) {
|
|
1047
|
+
switch (_context.prev = _context.next) {
|
|
1048
|
+
case 0:
|
|
1049
|
+
setExportOperationStarted(false);
|
|
1050
|
+
graphQuery = buildGraphQuery({
|
|
1051
|
+
resourceType: resourceType,
|
|
1052
|
+
selectedResourceIds: selectedResourceIds,
|
|
1053
|
+
columns: _valuesInstanceProperty__default["default"](formik).columns,
|
|
1054
|
+
exportSelectionType: _valuesInstanceProperty__default["default"](formik).exportSelectionType,
|
|
1055
|
+
languages: _valuesInstanceProperty__default["default"](formik).languages
|
|
1056
|
+
});
|
|
1057
|
+
props.closeModal();
|
|
1058
|
+
_context.prev = 3;
|
|
1059
|
+
_context.next = 6;
|
|
1060
|
+
return createExportOperation({
|
|
1061
|
+
projectKey: projectKey,
|
|
1062
|
+
graphQuery: graphQuery,
|
|
1063
|
+
asyncDispatchFn: asyncDispatch
|
|
1064
|
+
});
|
|
1065
|
+
|
|
1066
|
+
case 6:
|
|
1067
|
+
response = _context.sent;
|
|
1068
|
+
_context.t0 = response.state;
|
|
1069
|
+
_context.next = _context.t0 === EXPORT_OPERATION_STATES.PROCESSING ? 10 : _context.t0 === EXPORT_OPERATION_STATES.COMPLETED ? 10 : 12;
|
|
1070
|
+
break;
|
|
1071
|
+
|
|
1072
|
+
case 10:
|
|
1073
|
+
setExportOperationStarted(true);
|
|
1074
|
+
return _context.abrupt("break", 13);
|
|
1075
|
+
|
|
1076
|
+
case 12:
|
|
1077
|
+
throw new UnexpectedExportOperationStateError(response.state);
|
|
1078
|
+
|
|
1079
|
+
case 13:
|
|
1080
|
+
_context.next = 18;
|
|
1081
|
+
break;
|
|
1082
|
+
|
|
1083
|
+
case 15:
|
|
1084
|
+
_context.prev = 15;
|
|
1085
|
+
_context.t1 = _context["catch"](3);
|
|
1086
|
+
actionsGlobal.showApiErrorNotification({
|
|
1087
|
+
errors: _context.t1
|
|
1088
|
+
});
|
|
1089
|
+
|
|
1090
|
+
case 18:
|
|
1091
|
+
case "end":
|
|
1092
|
+
return _context.stop();
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
}, _callee, null, [[3, 15]]);
|
|
1096
|
+
})),
|
|
1097
|
+
children: jsxRuntime.jsxs("div", {
|
|
1098
|
+
children: [jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1099
|
+
intlMessage: _objectSpread$2(_objectSpread$2({}, messages.confirmationBodyPlan), {}, {
|
|
1100
|
+
values: {
|
|
1101
|
+
resourceType: resourceTypePlural,
|
|
1102
|
+
projectName: projectName,
|
|
1103
|
+
count: countInConfirmationMessage(),
|
|
1104
|
+
bold: getBold
|
|
1105
|
+
}
|
|
1106
|
+
})
|
|
1107
|
+
}), jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1108
|
+
intlMessage: messages.confirmationBodyQuestion
|
|
1109
|
+
})]
|
|
1110
|
+
})
|
|
1111
|
+
});
|
|
1112
|
+
}
|
|
1113
|
+
ExportConfirmationModal.propTypes = {};
|
|
1114
|
+
|
|
1115
|
+
function ownKeys$1(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
1116
|
+
|
|
1117
|
+
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$1(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$1(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
1118
|
+
|
|
1119
|
+
var getExportLogsLink = function getExportLogsLink(projectKey, msg) {
|
|
1120
|
+
return jsxRuntime.jsx(uiKit.Link, {
|
|
1121
|
+
to: "/".concat(projectKey, "/operations/export/logs"),
|
|
1122
|
+
children: msg
|
|
1123
|
+
});
|
|
1124
|
+
};
|
|
1125
|
+
|
|
1126
|
+
function ExportOperationSuccessMessage(_ref) {
|
|
1127
|
+
var isShown = _ref.isShown;
|
|
1128
|
+
|
|
1129
|
+
var _useApplicationContex = applicationShellConnectors.useApplicationContext(function (applicationContext) {
|
|
1130
|
+
var _applicationContext$p;
|
|
1131
|
+
|
|
1132
|
+
return {
|
|
1133
|
+
projectKey: (_applicationContext$p = applicationContext.project) === null || _applicationContext$p === void 0 ? void 0 : _applicationContext$p.key
|
|
1134
|
+
};
|
|
1135
|
+
}),
|
|
1136
|
+
projectKey = _useApplicationContex.projectKey;
|
|
1137
|
+
|
|
1138
|
+
if (!isShown) return null;
|
|
1139
|
+
return jsxRuntime.jsx("div", {
|
|
1140
|
+
css: styles.successMessage,
|
|
1141
|
+
"data-testid": "export-started-message",
|
|
1142
|
+
children: jsxRuntime.jsx(uiKit.Constraints.Horizontal, {
|
|
1143
|
+
max: 16,
|
|
1144
|
+
children: jsxRuntime.jsx(uiKit.ContentNotification, {
|
|
1145
|
+
type: "success",
|
|
1146
|
+
intlMessage: _objectSpread$1(_objectSpread$1({}, messages.exportOperationSuccessMessage), {}, {
|
|
1147
|
+
values: {
|
|
1148
|
+
logsLink: function logsLink(msg) {
|
|
1149
|
+
return getExportLogsLink(projectKey, msg);
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
})
|
|
1153
|
+
})
|
|
1154
|
+
})
|
|
1155
|
+
});
|
|
1156
|
+
}
|
|
1157
|
+
ExportOperationSuccessMessage.propTypes = {};
|
|
1158
|
+
|
|
1159
|
+
var _excluded = ["renderProperties"];
|
|
1160
|
+
|
|
1161
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
1162
|
+
|
|
1163
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
1164
|
+
|
|
1165
|
+
var ExportResourcesModal = function ExportResourcesModal(_ref) {
|
|
1166
|
+
var renderProperties = _ref.renderProperties,
|
|
1167
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
1168
|
+
|
|
1169
|
+
var intl = reactIntl.useIntl();
|
|
1170
|
+
var confirmationModal = applicationComponents.useModalState();
|
|
1171
|
+
var resourceTypePlural = resourceTypeToPlural({
|
|
1172
|
+
resourceType: props.resourceType
|
|
1173
|
+
});
|
|
1174
|
+
return jsxRuntime.jsx(ExportResourcesContextProvider, _objectSpread(_objectSpread({}, props), {}, {
|
|
1175
|
+
children: jsxRuntime.jsx(ExportResourcesContext.Consumer, {
|
|
1176
|
+
children: function children(_ref2) {
|
|
1177
|
+
var formik = _ref2.formik,
|
|
1178
|
+
exportOperationStarted = _ref2.exportOperationStarted;
|
|
1179
|
+
return jsxRuntime.jsxs(applicationComponents.FormModalPage, {
|
|
1180
|
+
title: intl.formatMessage(messages.modalTitle, {
|
|
1181
|
+
resourceType: resourceTypePlural
|
|
1182
|
+
}),
|
|
1183
|
+
isOpen: props.isOpen,
|
|
1184
|
+
onClose: props.closeModal,
|
|
1185
|
+
onSecondaryButtonClick: props.closeModal,
|
|
1186
|
+
isPrimaryButtonDisabled: !formik.isValid,
|
|
1187
|
+
labelPrimaryButton: intl.formatMessage(messages.exportButton, {
|
|
1188
|
+
resourceType: resourceTypePlural
|
|
1189
|
+
}),
|
|
1190
|
+
subtitle: intl.formatMessage(messages.modalSubTitle),
|
|
1191
|
+
topBarPreviousPathLabel: intl.formatMessage(messages.topBarPreviousPathLabel, {
|
|
1192
|
+
resourceType: props.resourceType
|
|
1193
|
+
}),
|
|
1194
|
+
onPrimaryButtonClick: confirmationModal.openModal,
|
|
1195
|
+
children: [jsxRuntime.jsx(ExportOperationSuccessMessage, {
|
|
1196
|
+
isShown: exportOperationStarted
|
|
1197
|
+
}), jsxRuntime.jsx(ExportFileSettings, {
|
|
1198
|
+
renderProperties: renderProperties
|
|
1199
|
+
}), jsxRuntime.jsx(ExportConfirmationModal, {
|
|
1200
|
+
resourceType: props.resourceType,
|
|
1201
|
+
isOpen: confirmationModal.isModalOpen,
|
|
1202
|
+
closeModal: confirmationModal.closeModal
|
|
1203
|
+
})]
|
|
1204
|
+
});
|
|
1205
|
+
}
|
|
1206
|
+
})
|
|
1207
|
+
}));
|
|
1208
|
+
};
|
|
1209
|
+
|
|
1210
|
+
ExportResourcesModal.displayName = 'ExportResourcesModal';
|
|
1211
|
+
ExportResourcesModal.propTypes = {};
|
|
1212
|
+
ExportResourcesModal.defaultProps = {
|
|
1213
|
+
selectedResourceIds: [],
|
|
1214
|
+
appliedSearchTerms: [],
|
|
1215
|
+
appliedFilters: [],
|
|
1216
|
+
matchingResourcesCount: 0,
|
|
1217
|
+
exportSelectionType: EXPORT_SELECTION_TYPES.ALL_RESOURCES,
|
|
1218
|
+
outputFormat: OUTPUT_FORMATS.JSON
|
|
1219
|
+
};
|
|
21
1220
|
|
|
1221
|
+
exports.EXPORTABLE_RESOURCES = EXPORTABLE_RESOURCES;
|
|
1222
|
+
exports.EXPORT_SELECTION_TYPES = EXPORT_SELECTION_TYPES;
|
|
22
1223
|
exports["default"] = ExportResourcesModal;
|