@commercetools-frontend-extensions/export-resources-modal 0.0.0-bw-test-preview-deploy-20250115163227
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/LICENSE +29 -0
- package/README.md +386 -0
- package/dist/commercetools-frontend-extensions-export-resources-modal.cjs.d.ts +3 -0
- package/dist/commercetools-frontend-extensions-export-resources-modal.cjs.dev.js +2080 -0
- package/dist/commercetools-frontend-extensions-export-resources-modal.cjs.js +7 -0
- package/dist/commercetools-frontend-extensions-export-resources-modal.cjs.prod.js +2050 -0
- package/dist/commercetools-frontend-extensions-export-resources-modal.esm.js +2037 -0
- package/dist/de-3d4cf3d0.cjs.prod.js +237 -0
- package/dist/de-abc94d19.esm.js +235 -0
- package/dist/de-d6a38e9e.cjs.dev.js +237 -0
- package/dist/declarations/src/@constants/delimiters.d.ts +4 -0
- package/dist/declarations/src/@constants/export-operation-states.d.ts +6 -0
- package/dist/declarations/src/@constants/export-types.d.ts +5 -0
- package/dist/declarations/src/@constants/exportable-resources.d.ts +9 -0
- package/dist/declarations/src/@constants/index.d.ts +8 -0
- package/dist/declarations/src/@constants/misc.d.ts +3 -0
- package/dist/declarations/src/@constants/output-formats.d.ts +8 -0
- package/dist/declarations/src/@constants/resource-type-messages.d.ts +10 -0
- package/dist/declarations/src/@constants/urls.d.ts +2 -0
- package/dist/declarations/src/@hooks/index.d.ts +4 -0
- package/dist/declarations/src/@hooks/use-convert-field-definitions-for-export.d.ts +9 -0
- package/dist/declarations/src/@hooks/use-export-resources-modal-context.d.ts +2 -0
- package/dist/declarations/src/@hooks/use-initial-values.d.ts +2 -0
- package/dist/declarations/src/@hooks/use-start-export-operation.d.ts +4 -0
- package/dist/declarations/src/@types/export-api.d.ts +30 -0
- package/dist/declarations/src/@types/export-resources-modal-context.d.ts +22 -0
- package/dist/declarations/src/@types/export-resources-modal-types.d.ts +49 -0
- package/dist/declarations/src/@types/field-definition.d.ts +7 -0
- package/dist/declarations/src/@types/form.d.ts +37 -0
- package/dist/declarations/src/@types/index.d.ts +7 -0
- package/dist/declarations/src/@types/output-format.d.ts +1 -0
- package/dist/declarations/src/@types/resource-type.d.ts +5 -0
- package/dist/declarations/src/export-resources-modal.d.ts +6 -0
- package/dist/declarations/src/index.d.ts +5 -0
- package/dist/en-0ea9f92c.cjs.dev.js +237 -0
- package/dist/en-38313842.esm.js +235 -0
- package/dist/en-fc0085cc.cjs.prod.js +237 -0
- package/dist/es-6360d546.cjs.prod.js +237 -0
- package/dist/es-85c5a396.esm.js +235 -0
- package/dist/es-a4227b21.cjs.dev.js +237 -0
- package/dist/fr-FR-1602d5ff.cjs.dev.js +237 -0
- package/dist/fr-FR-e610590b.esm.js +235 -0
- package/dist/fr-FR-ff7ec057.cjs.prod.js +237 -0
- package/dist/ja-37632763.cjs.prod.js +6 -0
- package/dist/ja-73c088a7.esm.js +4 -0
- package/dist/ja-9bd5f452.cjs.dev.js +6 -0
- package/dist/pt-BR-7b17be9e.cjs.dev.js +237 -0
- package/dist/pt-BR-ccc18639.esm.js +235 -0
- package/dist/pt-BR-d9b0a36d.cjs.prod.js +237 -0
- package/package.json +81 -0
|
@@ -0,0 +1,2050 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
6
|
+
var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
|
|
7
|
+
var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
8
|
+
var _Object$entries = require('@babel/runtime-corejs3/core-js-stable/object/entries');
|
|
9
|
+
var _startsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/starts-with');
|
|
10
|
+
var _endsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/ends-with');
|
|
11
|
+
var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
|
|
12
|
+
var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
13
|
+
var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
14
|
+
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
15
|
+
var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
|
|
16
|
+
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
|
|
17
|
+
var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
|
|
18
|
+
var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
|
|
19
|
+
var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
|
|
20
|
+
var reactIntl = require('react-intl');
|
|
21
|
+
var applicationShellConnectors = require('@commercetools-frontend/application-shell-connectors');
|
|
22
|
+
var uiKit = require('@commercetools-frontend/ui-kit');
|
|
23
|
+
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
24
|
+
var _valuesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/values');
|
|
25
|
+
var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/includes');
|
|
26
|
+
var applicationComponents = require('@commercetools-frontend/application-components');
|
|
27
|
+
var fullstory = require('@commercetools-frontend/fullstory');
|
|
28
|
+
var React = require('react');
|
|
29
|
+
var _Reflect$construct = require('@babel/runtime-corejs3/core-js-stable/reflect/construct');
|
|
30
|
+
var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
|
|
31
|
+
var _classCallCheck = require('@babel/runtime-corejs3/helpers/classCallCheck');
|
|
32
|
+
var _possibleConstructorReturn = require('@babel/runtime-corejs3/helpers/possibleConstructorReturn');
|
|
33
|
+
var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
|
|
34
|
+
var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
|
|
35
|
+
var _wrapNativeSuper = require('@babel/runtime-corejs3/helpers/wrapNativeSuper');
|
|
36
|
+
var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
|
|
37
|
+
var experimentalComponents = require('@commercetools-frontend/experimental-components');
|
|
38
|
+
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
39
|
+
var omitEmpty = require('omit-empty-es');
|
|
40
|
+
var _someInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/some');
|
|
41
|
+
var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
|
|
42
|
+
var _everyInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/every');
|
|
43
|
+
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
44
|
+
var _Array$isArray = require('@babel/runtime-corejs3/core-js-stable/array/is-array');
|
|
45
|
+
var _Set = require('@babel/runtime-corejs3/core-js-stable/set');
|
|
46
|
+
var _sortInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/sort');
|
|
47
|
+
var _indexOfInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/index-of');
|
|
48
|
+
var _trimInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/trim');
|
|
49
|
+
var actionsGlobal = require('@commercetools-frontend/actions-global');
|
|
50
|
+
var constants = require('@commercetools-frontend/constants');
|
|
51
|
+
var sdk = require('@commercetools-frontend/sdk');
|
|
52
|
+
var l10n = require('@commercetools-frontend/l10n');
|
|
53
|
+
var sortBy = require('lodash/sortBy');
|
|
54
|
+
var _styled = require('@emotion/styled/base');
|
|
55
|
+
var throttle = require('lodash/throttle');
|
|
56
|
+
var react = require('@emotion/react');
|
|
57
|
+
var get = require('lodash/get');
|
|
58
|
+
var formik = require('formik');
|
|
59
|
+
var i18n = require('@commercetools-frontend/i18n');
|
|
60
|
+
var sentry = require('@commercetools-frontend/sentry');
|
|
61
|
+
|
|
62
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
63
|
+
|
|
64
|
+
var _Object$entries__default = /*#__PURE__*/_interopDefault(_Object$entries);
|
|
65
|
+
var _startsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_startsWithInstanceProperty);
|
|
66
|
+
var _endsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_endsWithInstanceProperty);
|
|
67
|
+
var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
|
|
68
|
+
var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
|
|
69
|
+
var _Object$getOwnPropertySymbols__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertySymbols);
|
|
70
|
+
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
71
|
+
var _Object$getOwnPropertyDescriptor__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptor);
|
|
72
|
+
var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
|
|
73
|
+
var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
|
|
74
|
+
var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
|
|
75
|
+
var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
|
|
76
|
+
var _valuesInstanceProperty__default = /*#__PURE__*/_interopDefault(_valuesInstanceProperty);
|
|
77
|
+
var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
|
|
78
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
79
|
+
var _Reflect$construct__default = /*#__PURE__*/_interopDefault(_Reflect$construct);
|
|
80
|
+
var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInstanceProperty);
|
|
81
|
+
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
82
|
+
var omitEmpty__default = /*#__PURE__*/_interopDefault(omitEmpty);
|
|
83
|
+
var _someInstanceProperty__default = /*#__PURE__*/_interopDefault(_someInstanceProperty);
|
|
84
|
+
var _findInstanceProperty__default = /*#__PURE__*/_interopDefault(_findInstanceProperty);
|
|
85
|
+
var _everyInstanceProperty__default = /*#__PURE__*/_interopDefault(_everyInstanceProperty);
|
|
86
|
+
var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
|
|
87
|
+
var _Array$isArray__default = /*#__PURE__*/_interopDefault(_Array$isArray);
|
|
88
|
+
var _Set__default = /*#__PURE__*/_interopDefault(_Set);
|
|
89
|
+
var _sortInstanceProperty__default = /*#__PURE__*/_interopDefault(_sortInstanceProperty);
|
|
90
|
+
var _indexOfInstanceProperty__default = /*#__PURE__*/_interopDefault(_indexOfInstanceProperty);
|
|
91
|
+
var _trimInstanceProperty__default = /*#__PURE__*/_interopDefault(_trimInstanceProperty);
|
|
92
|
+
var sortBy__default = /*#__PURE__*/_interopDefault(sortBy);
|
|
93
|
+
var _styled__default = /*#__PURE__*/_interopDefault(_styled);
|
|
94
|
+
var throttle__default = /*#__PURE__*/_interopDefault(throttle);
|
|
95
|
+
var get__default = /*#__PURE__*/_interopDefault(get);
|
|
96
|
+
|
|
97
|
+
function getBold(msg) {
|
|
98
|
+
return jsxRuntime.jsx(uiKit.Text.Body, {
|
|
99
|
+
as: "span",
|
|
100
|
+
isBold: true,
|
|
101
|
+
children: msg
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function getNewLine() {
|
|
106
|
+
return jsxRuntime.jsx("br", {});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
var messages = reactIntl.defineMessages({
|
|
110
|
+
'modalTitle.category': {
|
|
111
|
+
id: "ExportResourcesModal.modalTitle.category",
|
|
112
|
+
defaultMessage: "Export categories"
|
|
113
|
+
},
|
|
114
|
+
'modalTitle.product': {
|
|
115
|
+
id: "ExportResourcesModal.modalTitle.product",
|
|
116
|
+
defaultMessage: "Export products"
|
|
117
|
+
},
|
|
118
|
+
'modalTitle.inventory-entry': {
|
|
119
|
+
id: "ExportResourcesModal.modalTitle.inventoryEntry",
|
|
120
|
+
defaultMessage: "Export inventories"
|
|
121
|
+
},
|
|
122
|
+
'modalTitle.discount-code': {
|
|
123
|
+
id: "ExportResourcesModal.modalTitle.discountCode",
|
|
124
|
+
defaultMessage: "Export discount codes"
|
|
125
|
+
},
|
|
126
|
+
'modalTitle.customer': {
|
|
127
|
+
id: "ExportResourcesModal.modalTitle.customer",
|
|
128
|
+
defaultMessage: "Export customers"
|
|
129
|
+
},
|
|
130
|
+
'modalTitle.order': {
|
|
131
|
+
id: "ExportResourcesModal.modalTitle.order",
|
|
132
|
+
defaultMessage: "Export orders"
|
|
133
|
+
},
|
|
134
|
+
'modalTitle.product-type': {
|
|
135
|
+
id: "ExportResourcesModal.modalTitle.productType",
|
|
136
|
+
defaultMessage: "Export product types"
|
|
137
|
+
},
|
|
138
|
+
outputFormat: {
|
|
139
|
+
id: "ExportResourcesModal.outputFormat",
|
|
140
|
+
defaultMessage: "File format"
|
|
141
|
+
},
|
|
142
|
+
fileName: {
|
|
143
|
+
id: "ExportResourcesModal.fileName",
|
|
144
|
+
defaultMessage: "File name"
|
|
145
|
+
},
|
|
146
|
+
locale: {
|
|
147
|
+
id: "ExportResourcesModal.locale",
|
|
148
|
+
defaultMessage: "Locale"
|
|
149
|
+
},
|
|
150
|
+
exportBasedOnMyViewsMessage: {
|
|
151
|
+
id: "ExportResourcesModal.exportBasedOnMyViewsMessage",
|
|
152
|
+
defaultMessage: "Select export settings based on:"
|
|
153
|
+
},
|
|
154
|
+
propertiesPanelLabel: {
|
|
155
|
+
id: "ExportResourcesModal.propertiesPanelLabel",
|
|
156
|
+
defaultMessage: "Properties"
|
|
157
|
+
},
|
|
158
|
+
exportOperationSuccessMessage: {
|
|
159
|
+
id: "ExportResourcesModal.exportOperationSuccessMessage",
|
|
160
|
+
defaultMessage: "<b>Your export has started.</b> <newline></newline><logsLink>Go to Export logs</logsLink> to view the progress and download the file."
|
|
161
|
+
},
|
|
162
|
+
nothingApplied: {
|
|
163
|
+
id: "ExportResourcesModal.nothingApplied",
|
|
164
|
+
defaultMessage: "nothing applied"
|
|
165
|
+
},
|
|
166
|
+
includeAllLocales: {
|
|
167
|
+
id: "ExportResourcesModal.includeAllLocales",
|
|
168
|
+
defaultMessage: "Include all locales"
|
|
169
|
+
},
|
|
170
|
+
missingFileNameError: {
|
|
171
|
+
id: "ExportResourcesModal.missingFileNameError",
|
|
172
|
+
defaultMessage: "Please enter a file name"
|
|
173
|
+
},
|
|
174
|
+
invalidFileNameError: {
|
|
175
|
+
id: "ExportResourcesModal.invalidFileNameError",
|
|
176
|
+
defaultMessage: "File name may only contain alphanumeric characters, hyphens and underscores"
|
|
177
|
+
},
|
|
178
|
+
missingLocaleError: {
|
|
179
|
+
id: "ExportResourcesModal.missingLocaleError",
|
|
180
|
+
defaultMessage: "Please select at least one locale"
|
|
181
|
+
},
|
|
182
|
+
myViews: {
|
|
183
|
+
id: "ExportResourcesModal.myViews",
|
|
184
|
+
defaultMessage: "My Views"
|
|
185
|
+
},
|
|
186
|
+
selectFieldsToExport: {
|
|
187
|
+
id: "ExportResourcesModal.selectFieldsToExport",
|
|
188
|
+
defaultMessage: "Select fields to export"
|
|
189
|
+
},
|
|
190
|
+
back: {
|
|
191
|
+
id: "ExportResourcesModal.back",
|
|
192
|
+
defaultMessage: "Back"
|
|
193
|
+
},
|
|
194
|
+
startExport: {
|
|
195
|
+
id: "ExportResourcesModal.startExport",
|
|
196
|
+
defaultMessage: "Start export"
|
|
197
|
+
},
|
|
198
|
+
continue: {
|
|
199
|
+
id: "ExportResourcesModal.continue",
|
|
200
|
+
defaultMessage: "Continue"
|
|
201
|
+
},
|
|
202
|
+
fieldDefinitions: {
|
|
203
|
+
id: "ExportResourcesModal.fieldDefinitions",
|
|
204
|
+
defaultMessage: "Field definitions"
|
|
205
|
+
},
|
|
206
|
+
unexpectedError: {
|
|
207
|
+
id: "ExportResourcesModal.unexpectedError",
|
|
208
|
+
defaultMessage: "An error occurred while starting the export process. Please try again or contact support if the problem persists."
|
|
209
|
+
},
|
|
210
|
+
searchForFields: {
|
|
211
|
+
id: "ExportResourcesModal.searchForFields",
|
|
212
|
+
defaultMessage: "Search for fields"
|
|
213
|
+
},
|
|
214
|
+
thereAreNoResults: {
|
|
215
|
+
id: "ExportResourcesModal.thereAreNoResults",
|
|
216
|
+
defaultMessage: "There are no results that match your search."
|
|
217
|
+
},
|
|
218
|
+
suggestions: {
|
|
219
|
+
id: "ExportResourcesModal.suggestions",
|
|
220
|
+
defaultMessage: "Suggestions:"
|
|
221
|
+
},
|
|
222
|
+
checkTheSpelling: {
|
|
223
|
+
id: "ExportResourcesModal.checkTheSpelling",
|
|
224
|
+
defaultMessage: "Check the spelling."
|
|
225
|
+
},
|
|
226
|
+
searchByEnteringTheExactFieldName: {
|
|
227
|
+
id: "ExportResourcesModal.searchByEnteringTheExactFieldName",
|
|
228
|
+
defaultMessage: "Try searching by entering the exact field name."
|
|
229
|
+
},
|
|
230
|
+
exportScope: {
|
|
231
|
+
id: "ExportResourcesModal.exportScope",
|
|
232
|
+
defaultMessage: "Scope"
|
|
233
|
+
},
|
|
234
|
+
exportScopeAllCategories: {
|
|
235
|
+
id: "ExportResourcesModal.exportScopeAllCategories",
|
|
236
|
+
defaultMessage: "Export all: {total, plural, one {# category} other {# categories}}"
|
|
237
|
+
},
|
|
238
|
+
exportScopeSelectedCategories: {
|
|
239
|
+
id: "ExportResourcesModal.exportScopeSelectedCategories",
|
|
240
|
+
defaultMessage: "Export selected: {total, plural, one {# category} other {# categories}}"
|
|
241
|
+
},
|
|
242
|
+
exportScopeFilteredCategories: {
|
|
243
|
+
id: "ExportResourcesModal.exportScopeFilteredCategories",
|
|
244
|
+
defaultMessage: "Export filtered: {total, plural, one {# category} other {# categories}}"
|
|
245
|
+
},
|
|
246
|
+
exportScopeAllProducts: {
|
|
247
|
+
id: "ExportResourcesModal.exportScopeAllProducts",
|
|
248
|
+
defaultMessage: "Export all: {total, plural, one {# product} other {# products}}"
|
|
249
|
+
},
|
|
250
|
+
exportScopeSelectedProducts: {
|
|
251
|
+
id: "ExportResourcesModal.exportScopeSelectedProducts",
|
|
252
|
+
defaultMessage: "Export selected: {total, plural, one {# product} other {# products}}"
|
|
253
|
+
},
|
|
254
|
+
exportScopeFilteredProducts: {
|
|
255
|
+
id: "ExportResourcesModal.exportScopeFilteredProducts",
|
|
256
|
+
defaultMessage: "Export filtered: {total, plural, one {# product} other {# products}}"
|
|
257
|
+
},
|
|
258
|
+
exportScopeAllProductTypes: {
|
|
259
|
+
id: "ExportResourcesModal.exportScopeAllProductTypes",
|
|
260
|
+
defaultMessage: "Export all: {total, plural, one {# product type} other {# product types}}"
|
|
261
|
+
},
|
|
262
|
+
exportScopeSelectedProductTypes: {
|
|
263
|
+
id: "ExportResourcesModal.exportScopeSelectedProductTypes",
|
|
264
|
+
defaultMessage: "Export selected: {total, plural, one {# product type} other {# product types}}"
|
|
265
|
+
},
|
|
266
|
+
exportScopeFilteredProductTypes: {
|
|
267
|
+
id: "ExportResourcesModal.exportScopeFilteredProductTypes",
|
|
268
|
+
defaultMessage: "Export filtered: {total, plural, one {# product type} other {# product types}}"
|
|
269
|
+
},
|
|
270
|
+
exportInventoriesForAllProducts: {
|
|
271
|
+
id: "ExportResourcesModal.exportInventoriesForAllProducts",
|
|
272
|
+
defaultMessage: "Export inventories for all {total, plural, one {# product} other {# products}}"
|
|
273
|
+
},
|
|
274
|
+
exportInventoriesForSelectedProducts: {
|
|
275
|
+
id: "ExportResourcesModal.exportInventoriesForSelectedProducts",
|
|
276
|
+
defaultMessage: "Export inventories for the {total, plural, one {# selected product} other {# selected products}}"
|
|
277
|
+
},
|
|
278
|
+
exportInventoriesForFilteredProducts: {
|
|
279
|
+
id: "ExportResourcesModal.exportInventoriesForFilteredProducts",
|
|
280
|
+
defaultMessage: "Export inventories for the {total, plural, one {# filtered product} other {# filtered products}}"
|
|
281
|
+
},
|
|
282
|
+
exportScopeAllDiscountCodes: {
|
|
283
|
+
id: "ExportResourcesModal.exportScopeAllDiscountCodes",
|
|
284
|
+
defaultMessage: "Export all: {total, plural, one {# discount code} other {# discount codes}}"
|
|
285
|
+
},
|
|
286
|
+
exportScopeSelectedDiscountCodes: {
|
|
287
|
+
id: "ExportResourcesModal.exportScopeSelectedDiscountCodes",
|
|
288
|
+
defaultMessage: "Export selected: {total, plural, one {# discount code} other {# discount codes}}"
|
|
289
|
+
},
|
|
290
|
+
exportScopeFilteredDiscountCodes: {
|
|
291
|
+
id: "ExportResourcesModal.exportScopeFilteredDiscountCodes",
|
|
292
|
+
defaultMessage: "Export filtered: {total, plural, one {# discount code} other {# discount codes}}"
|
|
293
|
+
},
|
|
294
|
+
exportScopeAllOrders: {
|
|
295
|
+
id: "ExportResourcesModal.exportScopeAllOrders",
|
|
296
|
+
defaultMessage: "Export all: {total, plural, one {# order} other {# orders}}"
|
|
297
|
+
},
|
|
298
|
+
exportScopeSelectedOrders: {
|
|
299
|
+
id: "ExportResourcesModal.exportScopeSelectedOrders",
|
|
300
|
+
defaultMessage: "Export selected: {total, plural, one {# order} other {# orders}}"
|
|
301
|
+
},
|
|
302
|
+
exportScopeFilteredOrders: {
|
|
303
|
+
id: "ExportResourcesModal.exportScopeFilteredOrders",
|
|
304
|
+
defaultMessage: "Export filtered: {total, plural, one {# order} other {# orders}}"
|
|
305
|
+
},
|
|
306
|
+
exportScopeAllCustomers: {
|
|
307
|
+
id: "ExportResourcesModal.exportScopeAllCustomers",
|
|
308
|
+
defaultMessage: "Export all: {total, plural, one {# customer} other {# customers}}"
|
|
309
|
+
},
|
|
310
|
+
exportScopeSelectedCustomers: {
|
|
311
|
+
id: "ExportResourcesModal.exportScopeSelectedCustomers",
|
|
312
|
+
defaultMessage: "Export selected: {total, plural, one {# customer} other {# customers}}"
|
|
313
|
+
},
|
|
314
|
+
exportScopeFilteredCustomers: {
|
|
315
|
+
id: "ExportResourcesModal.exportScopeFilteredCustomers",
|
|
316
|
+
defaultMessage: "Export filtered: {total, plural, one {# customer} other {# customers}}"
|
|
317
|
+
},
|
|
318
|
+
exportScopeSelectedWithoutCount: {
|
|
319
|
+
id: "ExportResourcesModal.exportScopeSelectedWithoutCount",
|
|
320
|
+
defaultMessage: "Export selected"
|
|
321
|
+
},
|
|
322
|
+
exportScopeFilteredWithoutCount: {
|
|
323
|
+
id: "ExportResourcesModal.exportScopeFilteredWithoutCount",
|
|
324
|
+
defaultMessage: "Export filtered"
|
|
325
|
+
},
|
|
326
|
+
exportSettings: {
|
|
327
|
+
id: "ExportResourcesModal.exportSettings",
|
|
328
|
+
defaultMessage: "Settings"
|
|
329
|
+
},
|
|
330
|
+
selected: {
|
|
331
|
+
id: "ExportResourcesModal.selected",
|
|
332
|
+
defaultMessage: "{total} selected"
|
|
333
|
+
},
|
|
334
|
+
// Preferences
|
|
335
|
+
exportPreferences: {
|
|
336
|
+
id: "ExportResourcesModal.exportPreferences",
|
|
337
|
+
defaultMessage: "Preferences"
|
|
338
|
+
},
|
|
339
|
+
fillRowsForOrderExport: {
|
|
340
|
+
id: "ExportResourcesModal.fillRowsForOrderExport",
|
|
341
|
+
defaultMessage: "Include Order number, id, and states in every row"
|
|
342
|
+
},
|
|
343
|
+
fillRowsForProductExport: {
|
|
344
|
+
id: "ExportResourcesModal.fillRowsForProductExport",
|
|
345
|
+
defaultMessage: "Include Product- and Variant-level information in every row"
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
function ownKeys$8(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
350
|
+
function _objectSpread$8(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$8(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$8(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
351
|
+
function renderFileNameError(key) {
|
|
352
|
+
switch (key) {
|
|
353
|
+
case 'missing':
|
|
354
|
+
return jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$8({}, messages.missingFileNameError));
|
|
355
|
+
case 'invalidInput':
|
|
356
|
+
return jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$8({}, messages.invalidFileNameError));
|
|
357
|
+
default:
|
|
358
|
+
return null;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
function renderLocaleError(key) {
|
|
362
|
+
switch (key) {
|
|
363
|
+
case 'missing':
|
|
364
|
+
return jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$8({}, messages.missingLocaleError));
|
|
365
|
+
default:
|
|
366
|
+
return null;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
function _callSuper$3(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct$3() ? _Reflect$construct__default["default"](o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
371
|
+
function _isNativeReflectConstruct$3() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$3 = function () { return !!t; })(); }
|
|
372
|
+
let MissingExportResourceProviderError = /*#__PURE__*/function (_Error) {
|
|
373
|
+
function MissingExportResourceProviderError() {
|
|
374
|
+
var _this;
|
|
375
|
+
_classCallCheck(this, MissingExportResourceProviderError);
|
|
376
|
+
_this = _callSuper$3(this, MissingExportResourceProviderError, ['useExportResourcesModalContext must be used within ExportResourcesProvider']);
|
|
377
|
+
_this.name = 'MissingExportResourceProviderError';
|
|
378
|
+
return _this;
|
|
379
|
+
}
|
|
380
|
+
_inherits(MissingExportResourceProviderError, _Error);
|
|
381
|
+
return _createClass(MissingExportResourceProviderError);
|
|
382
|
+
}(/*#__PURE__*/_wrapNativeSuper(Error));
|
|
383
|
+
|
|
384
|
+
function _callSuper$2(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct$2() ? _Reflect$construct__default["default"](o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
385
|
+
function _isNativeReflectConstruct$2() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$2 = function () { return !!t; })(); }
|
|
386
|
+
let UnexpectedExportOperationStateError = /*#__PURE__*/function (_Error) {
|
|
387
|
+
function UnexpectedExportOperationStateError(state) {
|
|
388
|
+
var _this;
|
|
389
|
+
_classCallCheck(this, UnexpectedExportOperationStateError);
|
|
390
|
+
_this = _callSuper$2(this, UnexpectedExportOperationStateError, [`Unexpected export operation state "${state}"`]);
|
|
391
|
+
_this.name = 'UnexpectedExportOperationStateError';
|
|
392
|
+
return _this;
|
|
393
|
+
}
|
|
394
|
+
_inherits(UnexpectedExportOperationStateError, _Error);
|
|
395
|
+
return _createClass(UnexpectedExportOperationStateError);
|
|
396
|
+
}(/*#__PURE__*/_wrapNativeSuper(Error));
|
|
397
|
+
|
|
398
|
+
function _callSuper$1(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct$1() ? _Reflect$construct__default["default"](o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
399
|
+
function _isNativeReflectConstruct$1() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$1 = function () { return !!t; })(); }
|
|
400
|
+
let UnexpectedResourceTypeError = /*#__PURE__*/function (_Error) {
|
|
401
|
+
function UnexpectedResourceTypeError(resourceType) {
|
|
402
|
+
var _this;
|
|
403
|
+
_classCallCheck(this, UnexpectedResourceTypeError);
|
|
404
|
+
_this = _callSuper$1(this, UnexpectedResourceTypeError, [`Unexpected resource type "${resourceType}"`]);
|
|
405
|
+
_this.name = 'UnexpectedResourceTypeError';
|
|
406
|
+
return _this;
|
|
407
|
+
}
|
|
408
|
+
_inherits(UnexpectedResourceTypeError, _Error);
|
|
409
|
+
return _createClass(UnexpectedResourceTypeError);
|
|
410
|
+
}(/*#__PURE__*/_wrapNativeSuper(Error));
|
|
411
|
+
|
|
412
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? _Reflect$construct__default["default"](o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
413
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); }
|
|
414
|
+
let InvalidResponseError = /*#__PURE__*/function (_Error) {
|
|
415
|
+
function InvalidResponseError() {
|
|
416
|
+
var _this;
|
|
417
|
+
_classCallCheck(this, InvalidResponseError);
|
|
418
|
+
_this = _callSuper(this, InvalidResponseError, ['Invalid response']);
|
|
419
|
+
_this.name = 'InvalidResponseError';
|
|
420
|
+
return _this;
|
|
421
|
+
}
|
|
422
|
+
_inherits(InvalidResponseError, _Error);
|
|
423
|
+
return _createClass(InvalidResponseError);
|
|
424
|
+
}(/*#__PURE__*/_wrapNativeSuper(Error));
|
|
425
|
+
|
|
426
|
+
function useExportResourcesModalContext() {
|
|
427
|
+
const context = React.useContext(ExportResourcesContext);
|
|
428
|
+
if (!context) {
|
|
429
|
+
throw new MissingExportResourceProviderError();
|
|
430
|
+
}
|
|
431
|
+
return context;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
const Z_INDEX_DROPDOWN = 30000;
|
|
435
|
+
const OPERATIONS_EXPORT_RESOURCES_MODAL_SELECTION = 'OPERATIONS_EXPORT_RESOURCES_MODAL_SELECTION';
|
|
436
|
+
const OPERATIONS_EXPORT_RESOURCES_MODAL_EXPANDED_GROUP = 'OPERATIONS_EXPORT_RESOURCES_MODAL_EXPANDED_GROUP';
|
|
437
|
+
|
|
438
|
+
const EXPORT_OPERATION_STATES = {
|
|
439
|
+
PROCESSING: 'processing',
|
|
440
|
+
COMPLETED: 'completed',
|
|
441
|
+
FAILED: 'failed',
|
|
442
|
+
QUEUED: 'queued'
|
|
443
|
+
};
|
|
444
|
+
|
|
445
|
+
const EXPORT_TYPES = {
|
|
446
|
+
ALL: 'all',
|
|
447
|
+
FILTERED: 'filtered',
|
|
448
|
+
SELECTED: 'selected'
|
|
449
|
+
};
|
|
450
|
+
|
|
451
|
+
const EXPORTABLE_RESOURCES = {
|
|
452
|
+
CATEGORY: 'category',
|
|
453
|
+
PRODUCT: 'product',
|
|
454
|
+
PRODUCT_TYPE: 'product-type',
|
|
455
|
+
DISCOUNT_CODE: 'discount-code',
|
|
456
|
+
INVENTORY_ENTRY: 'inventory-entry',
|
|
457
|
+
ORDER: 'order',
|
|
458
|
+
CUSTOMER: 'customer'
|
|
459
|
+
};
|
|
460
|
+
|
|
461
|
+
const OUTPUT_FORMATS = {
|
|
462
|
+
JSON: 'json',
|
|
463
|
+
CSV: 'csv'
|
|
464
|
+
};
|
|
465
|
+
const OUTPUT_FORMAT_OPTIONS = [{
|
|
466
|
+
value: OUTPUT_FORMATS.CSV,
|
|
467
|
+
label: 'CSV'
|
|
468
|
+
}, {
|
|
469
|
+
value: OUTPUT_FORMATS.JSON,
|
|
470
|
+
label: 'JSON'
|
|
471
|
+
}];
|
|
472
|
+
|
|
473
|
+
const resourceTypeMessages = {
|
|
474
|
+
[EXPORTABLE_RESOURCES.CATEGORY]: {
|
|
475
|
+
exportScopeAll: messages.exportScopeAllCategories,
|
|
476
|
+
exportScopeSelected: messages.exportScopeSelectedCategories,
|
|
477
|
+
exportScopeFiltered: messages.exportScopeFilteredCategories
|
|
478
|
+
},
|
|
479
|
+
[EXPORTABLE_RESOURCES.PRODUCT]: {
|
|
480
|
+
exportScopeAll: messages.exportScopeAllProducts,
|
|
481
|
+
exportScopeSelected: messages.exportScopeSelectedProducts,
|
|
482
|
+
exportScopeFiltered: messages.exportScopeFilteredProducts
|
|
483
|
+
},
|
|
484
|
+
[EXPORTABLE_RESOURCES.PRODUCT_TYPE]: {
|
|
485
|
+
exportScopeAll: messages.exportScopeAllProductTypes,
|
|
486
|
+
exportScopeSelected: messages.exportScopeSelectedProductTypes,
|
|
487
|
+
exportScopeFiltered: messages.exportScopeFilteredProductTypes
|
|
488
|
+
},
|
|
489
|
+
[EXPORTABLE_RESOURCES.INVENTORY_ENTRY]: {
|
|
490
|
+
exportScopeAll: messages.exportInventoriesForAllProducts,
|
|
491
|
+
exportScopeSelected: messages.exportInventoriesForSelectedProducts,
|
|
492
|
+
exportScopeFiltered: messages.exportInventoriesForFilteredProducts
|
|
493
|
+
},
|
|
494
|
+
[EXPORTABLE_RESOURCES.DISCOUNT_CODE]: {
|
|
495
|
+
exportScopeAll: messages.exportScopeAllDiscountCodes,
|
|
496
|
+
exportScopeSelected: messages.exportScopeSelectedDiscountCodes,
|
|
497
|
+
exportScopeFiltered: messages.exportScopeFilteredDiscountCodes
|
|
498
|
+
},
|
|
499
|
+
[EXPORTABLE_RESOURCES.ORDER]: {
|
|
500
|
+
exportScopeAll: messages.exportScopeAllOrders,
|
|
501
|
+
exportScopeSelected: messages.exportScopeSelectedOrders,
|
|
502
|
+
exportScopeFiltered: messages.exportScopeFilteredOrders
|
|
503
|
+
},
|
|
504
|
+
[EXPORTABLE_RESOURCES.CUSTOMER]: {
|
|
505
|
+
exportScopeAll: messages.exportScopeAllCustomers,
|
|
506
|
+
exportScopeSelected: messages.exportScopeSelectedCustomers,
|
|
507
|
+
exportScopeFiltered: messages.exportScopeFilteredCustomers
|
|
508
|
+
}
|
|
509
|
+
};
|
|
510
|
+
|
|
511
|
+
const isAnyFieldChecked = fields => {
|
|
512
|
+
return _someInstanceProperty__default["default"](fields).call(fields, field => field.isChecked || field.fields && isAnyFieldChecked(field.fields));
|
|
513
|
+
};
|
|
514
|
+
const hasDependentFields = field => {
|
|
515
|
+
var _context;
|
|
516
|
+
return Boolean(field?.dependentGroupNames && field.dependentGroupNames.length > 0 || field?.dependentFieldNames && field.dependentFieldNames.length > 0 || field?.fields && _someInstanceProperty__default["default"](_context = field.fields).call(_context, nestedField => hasDependentFields(nestedField)));
|
|
517
|
+
};
|
|
518
|
+
const isFieldOrNestedFieldChecked = (field, fieldName) => {
|
|
519
|
+
if (field.name === fieldName && field.isChecked) {
|
|
520
|
+
return true;
|
|
521
|
+
}
|
|
522
|
+
if (field.fields) {
|
|
523
|
+
var _context2;
|
|
524
|
+
return _someInstanceProperty__default["default"](_context2 = field.fields).call(_context2, nestedField => {
|
|
525
|
+
return nestedField.isChecked || isFieldOrNestedFieldChecked(nestedField, fieldName);
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
return false;
|
|
529
|
+
};
|
|
530
|
+
const getIndependentFields = group => {
|
|
531
|
+
const independentFields = [];
|
|
532
|
+
const findIndependentFields = fields => {
|
|
533
|
+
_forEachInstanceProperty__default["default"](fields).call(fields, field => {
|
|
534
|
+
if (!field.dependentGroupNames?.length && !field.dependentFieldNames?.length) {
|
|
535
|
+
independentFields.push(field);
|
|
536
|
+
}
|
|
537
|
+
if (field.fields) {
|
|
538
|
+
findIndependentFields(field.fields);
|
|
539
|
+
}
|
|
540
|
+
});
|
|
541
|
+
};
|
|
542
|
+
findIndependentFields(group.fields);
|
|
543
|
+
return independentFields;
|
|
544
|
+
};
|
|
545
|
+
const checkDependentFields = (independentFields, dependentFieldNames) => {
|
|
546
|
+
return _someInstanceProperty__default["default"](dependentFieldNames).call(dependentFieldNames, fieldName => _someInstanceProperty__default["default"](independentFields).call(independentFields, field => {
|
|
547
|
+
if (field.name === fieldName) {
|
|
548
|
+
if (field.fields) {
|
|
549
|
+
var _context3;
|
|
550
|
+
return _someInstanceProperty__default["default"](_context3 = field.fields).call(_context3, nestedField => isFieldOrNestedFieldChecked(nestedField, fieldName));
|
|
551
|
+
}
|
|
552
|
+
if (isFieldOrNestedFieldChecked(field, fieldName)) {
|
|
553
|
+
return true;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
return false;
|
|
557
|
+
}));
|
|
558
|
+
};
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* Checks if any dependent fields are checked within the field groups
|
|
562
|
+
*
|
|
563
|
+
* This function iterates over the provided dependent group names and checks if any fields within those groups
|
|
564
|
+
* are checked. It considers both independent fields and their nested fields within
|
|
565
|
+
* the specified dependent field names
|
|
566
|
+
*
|
|
567
|
+
* @param groups - The array of field groups
|
|
568
|
+
* @param dependentGroupNames - The names of the groups to check for dependencies
|
|
569
|
+
* @param dependentFieldNames - The names of the fields to check within the groups
|
|
570
|
+
* @returns True if any dependent fields are checked otherwise false
|
|
571
|
+
*/
|
|
572
|
+
const isAnyDependentChecked = function (groups) {
|
|
573
|
+
let dependentGroupNames = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
574
|
+
let dependentFieldNames = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
575
|
+
return _someInstanceProperty__default["default"](dependentGroupNames).call(dependentGroupNames, groupName => {
|
|
576
|
+
const group = _findInstanceProperty__default["default"](groups).call(groups, g => g.groupName === groupName);
|
|
577
|
+
if (group) {
|
|
578
|
+
const independentFields = getIndependentFields(group);
|
|
579
|
+
const isADependentFieldChecked = isAnyFieldChecked(independentFields);
|
|
580
|
+
const isFieldDependentChecked = checkDependentFields(independentFields, dependentFieldNames);
|
|
581
|
+
if (dependentFieldNames.length > 0) {
|
|
582
|
+
return isADependentFieldChecked && isFieldDependentChecked;
|
|
583
|
+
}
|
|
584
|
+
return isADependentFieldChecked || isFieldDependentChecked;
|
|
585
|
+
}
|
|
586
|
+
return false;
|
|
587
|
+
});
|
|
588
|
+
};
|
|
589
|
+
const areAllFieldsChecked = fields => {
|
|
590
|
+
return _everyInstanceProperty__default["default"](fields).call(fields, field => field.fields ? areAllFieldsChecked(field.fields) : field.isChecked || field.isRequired || hasDependentFields(field));
|
|
591
|
+
};
|
|
592
|
+
const getTotalCheckedFields = group => {
|
|
593
|
+
const countCheckedFields = fields => {
|
|
594
|
+
return _reduceInstanceProperty__default["default"](fields).call(fields, (total, field) => {
|
|
595
|
+
if (field.fields) {
|
|
596
|
+
return total + countCheckedFields(field.fields);
|
|
597
|
+
}
|
|
598
|
+
return total + (field.isChecked ? 1 : 0);
|
|
599
|
+
}, 0);
|
|
600
|
+
};
|
|
601
|
+
return countCheckedFields(group.fields);
|
|
602
|
+
};
|
|
603
|
+
|
|
604
|
+
let Step = /*#__PURE__*/function (Step) {
|
|
605
|
+
Step["FileSettings"] = "file-settings";
|
|
606
|
+
Step["FieldsSelection"] = "fields-selection";
|
|
607
|
+
return Step;
|
|
608
|
+
}({});
|
|
609
|
+
|
|
610
|
+
function validate(_ref) {
|
|
611
|
+
let values = _valuesInstanceProperty__default["default"](_ref),
|
|
612
|
+
step = _ref.step;
|
|
613
|
+
const fileName = values.fileName,
|
|
614
|
+
locales = values.locales,
|
|
615
|
+
groups = values.groups;
|
|
616
|
+
const errors = {
|
|
617
|
+
fileName: {},
|
|
618
|
+
locales: {},
|
|
619
|
+
fields: {}
|
|
620
|
+
};
|
|
621
|
+
if (uiKit.TextInput.isEmpty(fileName)) {
|
|
622
|
+
errors.fileName.missing = true;
|
|
623
|
+
} else if (!/^[a-zA-Z0-9-_.]+$/.test(fileName)) {
|
|
624
|
+
errors.fileName.invalidInput = true;
|
|
625
|
+
}
|
|
626
|
+
if (locales.length < 1) {
|
|
627
|
+
errors.locales.missing = true;
|
|
628
|
+
}
|
|
629
|
+
if (step === Step.FieldsSelection) {
|
|
630
|
+
const allFields = _reduceInstanceProperty__default["default"](groups).call(groups, (acc, group) => _concatInstanceProperty__default["default"](acc).call(acc, group.fields), []);
|
|
631
|
+
const checkedFieldsCount = _filterInstanceProperty__default["default"](allFields).call(allFields, field => {
|
|
632
|
+
if (field.fields) return isAnyFieldChecked(field.fields);
|
|
633
|
+
return field.isChecked;
|
|
634
|
+
}).length;
|
|
635
|
+
if (checkedFieldsCount < 1) {
|
|
636
|
+
errors.fields.missing = true;
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
return omitEmpty__default["default"](errors);
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
function resourceTypeToFileName(resourceType, locale) {
|
|
643
|
+
var _context;
|
|
644
|
+
const date = new Date();
|
|
645
|
+
const dateFormatter = new Intl.DateTimeFormat(locale, {
|
|
646
|
+
year: '2-digit',
|
|
647
|
+
month: '2-digit',
|
|
648
|
+
day: '2-digit',
|
|
649
|
+
hour: '2-digit',
|
|
650
|
+
minute: '2-digit',
|
|
651
|
+
hour12: false
|
|
652
|
+
});
|
|
653
|
+
const parts = dateFormatter.formatToParts(date);
|
|
654
|
+
const dateParts = _reduceInstanceProperty__default["default"](parts).call(parts, (acc, part) => {
|
|
655
|
+
if (part.type !== 'literal') {
|
|
656
|
+
acc[part.type] = part.value;
|
|
657
|
+
}
|
|
658
|
+
return acc;
|
|
659
|
+
}, {});
|
|
660
|
+
const orderedDateParts = _mapInstanceProperty__default["default"](_context = _filterInstanceProperty__default["default"](parts).call(parts, part => part.type === 'day' || part.type === 'month' || part.type === 'year')).call(_context, part => dateParts[part.type]).join('-');
|
|
661
|
+
const formattedDate = `${orderedDateParts}_${dateParts.hour}-${dateParts.minute}`;
|
|
662
|
+
const resourceTypeMap = {
|
|
663
|
+
[EXPORTABLE_RESOURCES.CATEGORY]: 'Categories',
|
|
664
|
+
[EXPORTABLE_RESOURCES.PRODUCT]: 'Products',
|
|
665
|
+
[EXPORTABLE_RESOURCES.PRODUCT_TYPE]: 'Product_Types',
|
|
666
|
+
[EXPORTABLE_RESOURCES.DISCOUNT_CODE]: 'Discount_Codes',
|
|
667
|
+
[EXPORTABLE_RESOURCES.INVENTORY_ENTRY]: 'Inventories',
|
|
668
|
+
[EXPORTABLE_RESOURCES.CUSTOMER]: 'Customers',
|
|
669
|
+
[EXPORTABLE_RESOURCES.ORDER]: 'Orders'
|
|
670
|
+
};
|
|
671
|
+
const displayName = resourceTypeMap[resourceType];
|
|
672
|
+
if (!displayName) {
|
|
673
|
+
throw new UnexpectedResourceTypeError(resourceType);
|
|
674
|
+
}
|
|
675
|
+
return `${displayName}_Export_${formattedDate}`;
|
|
676
|
+
}
|
|
677
|
+
function mapLocalesToOptions(locales) {
|
|
678
|
+
return _mapInstanceProperty__default["default"](locales).call(locales, locale => ({
|
|
679
|
+
value: locale,
|
|
680
|
+
label: locale
|
|
681
|
+
}));
|
|
682
|
+
}
|
|
683
|
+
function isFilledArray(maybeArray) {
|
|
684
|
+
return _Array$isArray__default["default"](maybeArray) && maybeArray.length > 0;
|
|
685
|
+
}
|
|
686
|
+
function appendCsvOrJsonExtensionIfAbsent(fileName, fileFormat) {
|
|
687
|
+
const extensionRegex = /\.(csv|json)$/i;
|
|
688
|
+
if (!extensionRegex.test(fileName)) return `${fileName}.${fileFormat}`;
|
|
689
|
+
return fileName;
|
|
690
|
+
}
|
|
691
|
+
function getExportLogsLink(projectKey, msg) {
|
|
692
|
+
return jsxRuntime.jsx(uiKit.Link, {
|
|
693
|
+
to: `/${projectKey}/operations/export/logs`,
|
|
694
|
+
children: msg
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
const extractFieldNamesAndAdditionalFieldExtensions = fields => {
|
|
698
|
+
const result = _reduceInstanceProperty__default["default"](fields).call(fields, (acc, field) => {
|
|
699
|
+
if (field.extendedFieldNames) {
|
|
700
|
+
return [...acc, field.name, ...field.extendedFieldNames];
|
|
701
|
+
}
|
|
702
|
+
return [...acc, field.name];
|
|
703
|
+
}, []);
|
|
704
|
+
return [...new _Set__default["default"](result)];
|
|
705
|
+
};
|
|
706
|
+
function sortFieldsByFieldOrder(_ref) {
|
|
707
|
+
let fieldNames = _ref.fieldNames,
|
|
708
|
+
fieldOrder = _ref.fieldOrder;
|
|
709
|
+
if (isFilledArray(fieldOrder)) {
|
|
710
|
+
return _sortInstanceProperty__default["default"](fieldNames).call(fieldNames, (a, b) => {
|
|
711
|
+
let orderA = _indexOfInstanceProperty__default["default"](fieldOrder).call(fieldOrder, a) !== -1 ? _indexOfInstanceProperty__default["default"](fieldOrder).call(fieldOrder, a) : _indexOfInstanceProperty__default["default"](fieldOrder).call(fieldOrder, a.split('.')[0]);
|
|
712
|
+
let orderB = _indexOfInstanceProperty__default["default"](fieldOrder).call(fieldOrder, b) !== -1 ? _indexOfInstanceProperty__default["default"](fieldOrder).call(fieldOrder, b) : _indexOfInstanceProperty__default["default"](fieldOrder).call(fieldOrder, b.split('.')[0]);
|
|
713
|
+
|
|
714
|
+
// If a field is not 'custom',then consider it as '*'
|
|
715
|
+
orderA = orderA === -1 ? _indexOfInstanceProperty__default["default"](fieldOrder).call(fieldOrder, '*') : orderA;
|
|
716
|
+
orderB = orderB === -1 ? _indexOfInstanceProperty__default["default"](fieldOrder).call(fieldOrder, '*') : orderB;
|
|
717
|
+
return orderA - orderB;
|
|
718
|
+
});
|
|
719
|
+
}
|
|
720
|
+
return fieldNames;
|
|
721
|
+
}
|
|
722
|
+
function buildSelectedExportFilters(selectedResourceIds) {
|
|
723
|
+
if (!selectedResourceIds || selectedResourceIds?.length === 0) return undefined;
|
|
724
|
+
const formattedIds = _mapInstanceProperty__default["default"](selectedResourceIds).call(selectedResourceIds, id => `"${id}"`).join(', ');
|
|
725
|
+
return `id in (${formattedIds})`;
|
|
726
|
+
}
|
|
727
|
+
function isQueryFilter(filters) {
|
|
728
|
+
if (!filters) return false;
|
|
729
|
+
return 'query' in filters;
|
|
730
|
+
}
|
|
731
|
+
function isSearchFilter(filters) {
|
|
732
|
+
if (!filters) return false;
|
|
733
|
+
return 'filters' in filters || 'fullText' in filters;
|
|
734
|
+
}
|
|
735
|
+
function isPredicateFilter(filters) {
|
|
736
|
+
if (!filters) return false;
|
|
737
|
+
return 'where' in filters;
|
|
738
|
+
}
|
|
739
|
+
function validateFilters(filtersObject) {
|
|
740
|
+
if (filtersObject.where && filtersObject.filters) {
|
|
741
|
+
return false;
|
|
742
|
+
}
|
|
743
|
+
return Boolean(isQueryFilter(filtersObject.filters) || isSearchFilter(filtersObject.filters) || isPredicateFilter(filtersObject));
|
|
744
|
+
}
|
|
745
|
+
function areFiltersApplied(filtersObject) {
|
|
746
|
+
var _context2;
|
|
747
|
+
if (!filtersObject) {
|
|
748
|
+
return false;
|
|
749
|
+
}
|
|
750
|
+
if (filtersObject.where && _trimInstanceProperty__default["default"](_context2 = filtersObject.where).call(_context2) !== '') {
|
|
751
|
+
return true;
|
|
752
|
+
}
|
|
753
|
+
if (isQueryFilter(filtersObject.filters)) {
|
|
754
|
+
return Boolean(filtersObject.filters.query);
|
|
755
|
+
}
|
|
756
|
+
if (isSearchFilter(filtersObject.filters)) {
|
|
757
|
+
const _filters = filtersObject.filters;
|
|
758
|
+
return Boolean(_filters.filters?.length || _filters.fullText?.text?.trim());
|
|
759
|
+
}
|
|
760
|
+
return false;
|
|
761
|
+
}
|
|
762
|
+
function getInitialExportType(args) {
|
|
763
|
+
if (args.selectedResourceIds?.length) {
|
|
764
|
+
return EXPORT_TYPES.SELECTED;
|
|
765
|
+
}
|
|
766
|
+
if (args.filters?.total && areFiltersApplied(args.filters)) {
|
|
767
|
+
return EXPORT_TYPES.FILTERED;
|
|
768
|
+
}
|
|
769
|
+
return EXPORT_TYPES.ALL;
|
|
770
|
+
}
|
|
771
|
+
function removeEmptyGroups(groups) {
|
|
772
|
+
return _filterInstanceProperty__default["default"](groups).call(groups, group => group.fields && group.fields.length > 0);
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
function ownKeys$7(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
776
|
+
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__default["default"](_context2 = ownKeys$7(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context3 = ownKeys$7(Object(t))).call(_context3, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
777
|
+
const updateFieldGroupsWithIsCheckedValue = (groups, cachedSelectedGroups) => {
|
|
778
|
+
const updateFields = (fields, isParentChecked, parentFieldPath) => {
|
|
779
|
+
return _mapInstanceProperty__default["default"](fields).call(fields, field => {
|
|
780
|
+
let isChecked = false;
|
|
781
|
+
if (field.isRequired) {
|
|
782
|
+
isChecked = true;
|
|
783
|
+
} else {
|
|
784
|
+
if (cachedSelectedGroups[`${parentFieldPath}.${field.name}`] !== undefined) {
|
|
785
|
+
isChecked = cachedSelectedGroups[`${parentFieldPath}.${field.name}`];
|
|
786
|
+
} else if (!hasDependentFields(field) && field.isSelectedByDefault) {
|
|
787
|
+
isChecked = true;
|
|
788
|
+
} else if (isParentChecked) {
|
|
789
|
+
isChecked = true;
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
let updatedFields = field.fields;
|
|
793
|
+
if (field.fields) {
|
|
794
|
+
updatedFields = updateFields(field.fields, isChecked, `${parentFieldPath}.${field.name}`);
|
|
795
|
+
isChecked = false;
|
|
796
|
+
}
|
|
797
|
+
return _objectSpread$7(_objectSpread$7({}, field), {}, {
|
|
798
|
+
isChecked,
|
|
799
|
+
fields: updatedFields
|
|
800
|
+
});
|
|
801
|
+
});
|
|
802
|
+
};
|
|
803
|
+
return _mapInstanceProperty__default["default"](groups).call(groups, group => {
|
|
804
|
+
const updatedFields = updateFields(group.fields, false, group.groupName);
|
|
805
|
+
return _objectSpread$7(_objectSpread$7({}, group), {}, {
|
|
806
|
+
fields: updatedFields
|
|
807
|
+
});
|
|
808
|
+
});
|
|
809
|
+
};
|
|
810
|
+
const updateFieldGroupWithAdditionalFieldExtensions = groups => {
|
|
811
|
+
function updateAdditionalFieldExtensions(fields, extendedFieldNames) {
|
|
812
|
+
return _mapInstanceProperty__default["default"](fields).call(fields, field => {
|
|
813
|
+
const updatedAdditionalFieldExtensions = [...extendedFieldNames, ...(field.extendedFieldNames || [])];
|
|
814
|
+
if (field.fields) {
|
|
815
|
+
field.fields = updateAdditionalFieldExtensions(field.fields, updatedAdditionalFieldExtensions);
|
|
816
|
+
}
|
|
817
|
+
return _objectSpread$7(_objectSpread$7({}, field), {}, {
|
|
818
|
+
extendedFieldNames: updatedAdditionalFieldExtensions
|
|
819
|
+
});
|
|
820
|
+
});
|
|
821
|
+
}
|
|
822
|
+
function combineDependentGroupNames(fields) {
|
|
823
|
+
return _reduceInstanceProperty__default["default"](fields).call(fields, (acc, field) => {
|
|
824
|
+
if (field.dependentGroupNames) {
|
|
825
|
+
acc = [...acc, ...field.dependentGroupNames];
|
|
826
|
+
}
|
|
827
|
+
if (field.fields) {
|
|
828
|
+
acc = [...acc, ...combineDependentGroupNames(field.fields)];
|
|
829
|
+
}
|
|
830
|
+
return acc;
|
|
831
|
+
}, []);
|
|
832
|
+
}
|
|
833
|
+
return _mapInstanceProperty__default["default"](groups).call(groups, group => {
|
|
834
|
+
return _objectSpread$7(_objectSpread$7({}, group), {}, {
|
|
835
|
+
dependentGroupNames: combineDependentGroupNames(group.fields),
|
|
836
|
+
fields: updateAdditionalFieldExtensions(group.fields, [])
|
|
837
|
+
});
|
|
838
|
+
});
|
|
839
|
+
};
|
|
840
|
+
const updateFieldGroupsWithIsExpandedValue = (groups, cachedExpandedGroups) => {
|
|
841
|
+
function updateFields(fields, groupName) {
|
|
842
|
+
return _mapInstanceProperty__default["default"](fields).call(fields, field => {
|
|
843
|
+
let isExpanded = null;
|
|
844
|
+
if (field.isExpandable) {
|
|
845
|
+
isExpanded = cachedExpandedGroups[`${groupName}.${field.name}`] ?? field.isExpanded ?? false;
|
|
846
|
+
}
|
|
847
|
+
if (field.fields) {
|
|
848
|
+
field.fields = updateFields(field.fields, groupName);
|
|
849
|
+
}
|
|
850
|
+
if (isExpanded !== null) {
|
|
851
|
+
return _objectSpread$7(_objectSpread$7({}, field), {}, {
|
|
852
|
+
isExpanded
|
|
853
|
+
});
|
|
854
|
+
}
|
|
855
|
+
return field;
|
|
856
|
+
});
|
|
857
|
+
}
|
|
858
|
+
return _mapInstanceProperty__default["default"](groups).call(groups, group => {
|
|
859
|
+
const updatedFields = updateFields(group.fields, group.groupName);
|
|
860
|
+
return _objectSpread$7(_objectSpread$7({}, group), {}, {
|
|
861
|
+
isExpanded: cachedExpandedGroups[group.groupName] ?? group.isExpanded ?? false,
|
|
862
|
+
fields: updatedFields
|
|
863
|
+
});
|
|
864
|
+
});
|
|
865
|
+
};
|
|
866
|
+
const mapFormikErrors = error => {
|
|
867
|
+
if (typeof error === 'string') {
|
|
868
|
+
return {
|
|
869
|
+
[error]: true
|
|
870
|
+
};
|
|
871
|
+
}
|
|
872
|
+
if (_Array$isArray__default["default"](error)) {
|
|
873
|
+
return _reduceInstanceProperty__default["default"](error).call(error, (errorAggregator, currentError) => _objectSpread$7(_objectSpread$7({}, errorAggregator), {}, {
|
|
874
|
+
[currentError]: true
|
|
875
|
+
}), {});
|
|
876
|
+
}
|
|
877
|
+
if (!error) return {};
|
|
878
|
+
return error;
|
|
879
|
+
};
|
|
880
|
+
const updateFieldDependenciesStatus = formik => {
|
|
881
|
+
var _context;
|
|
882
|
+
const updateFields = (fields, path) => {
|
|
883
|
+
_forEachInstanceProperty__default["default"](fields).call(fields, (field, index) => {
|
|
884
|
+
const currentPath = `${path}.fields[${index}]`;
|
|
885
|
+
if (hasDependentFields(field)) {
|
|
886
|
+
formik.setFieldValue(`${currentPath}.isChecked`, isAnyDependentChecked(_valuesInstanceProperty__default["default"](formik).groups, field.dependentGroupNames, field.dependentFieldNames), false);
|
|
887
|
+
}
|
|
888
|
+
if (field.fields) {
|
|
889
|
+
updateFields(field.fields, currentPath);
|
|
890
|
+
}
|
|
891
|
+
});
|
|
892
|
+
};
|
|
893
|
+
_forEachInstanceProperty__default["default"](_context = _valuesInstanceProperty__default["default"](formik).groups).call(_context, (group, index) => {
|
|
894
|
+
updateFields(group.fields, `groups[${index}]`);
|
|
895
|
+
});
|
|
896
|
+
};
|
|
897
|
+
|
|
898
|
+
const useInitialValues = props => {
|
|
899
|
+
var _context;
|
|
900
|
+
const _useApplicationContex = applicationShellConnectors.useApplicationContext(applicationContext => ({
|
|
901
|
+
locale: applicationContext.dataLocale,
|
|
902
|
+
userLocale: applicationContext.user?.locale
|
|
903
|
+
})),
|
|
904
|
+
locale = _useApplicationContex.locale,
|
|
905
|
+
userLocale = _useApplicationContex.userLocale;
|
|
906
|
+
const _useApplicationContex2 = applicationShellConnectors.useApplicationContext(context => ({
|
|
907
|
+
projectKey: context.project?.key
|
|
908
|
+
})),
|
|
909
|
+
projectKey = _useApplicationContex2.projectKey;
|
|
910
|
+
const _useStorage = experimentalComponents.useStorage(`${projectKey}/${OPERATIONS_EXPORT_RESOURCES_MODAL_SELECTION}`, {}),
|
|
911
|
+
_useStorage2 = _slicedToArray(_useStorage, 1),
|
|
912
|
+
cachedSelectedGroups = _useStorage2[0];
|
|
913
|
+
const _useStorage3 = experimentalComponents.useStorage(`${projectKey}/${OPERATIONS_EXPORT_RESOURCES_MODAL_EXPANDED_GROUP}`, {
|
|
914
|
+
[props.resourceType]: _reduceInstanceProperty__default["default"](_context = props.fieldGroups).call(_context, (acc, group) => {
|
|
915
|
+
acc[group.groupName] = group.isExpanded;
|
|
916
|
+
return acc;
|
|
917
|
+
}, {})
|
|
918
|
+
}),
|
|
919
|
+
_useStorage4 = _slicedToArray(_useStorage3, 1),
|
|
920
|
+
cachedExpandedGroups = _useStorage4[0];
|
|
921
|
+
return React__default["default"].useMemo(() => {
|
|
922
|
+
let groups = removeEmptyGroups(props.fieldGroups);
|
|
923
|
+
groups = updateFieldGroupsWithIsCheckedValue(groups, cachedSelectedGroups[props.resourceType] || {});
|
|
924
|
+
groups = updateFieldGroupsWithIsExpandedValue(groups, cachedExpandedGroups[props.resourceType] || {});
|
|
925
|
+
return {
|
|
926
|
+
outputFormat: props.outputFormat,
|
|
927
|
+
fileName: `${resourceTypeToFileName(props.resourceType, userLocale)}`,
|
|
928
|
+
locales: [locale],
|
|
929
|
+
groups: updateFieldGroupWithAdditionalFieldExtensions(groups),
|
|
930
|
+
// Preferences
|
|
931
|
+
fillRows: false
|
|
932
|
+
};
|
|
933
|
+
}, [props.fieldGroups, props.resourceType, props.outputFormat, cachedSelectedGroups, cachedExpandedGroups, locale, userLocale]);
|
|
934
|
+
};
|
|
935
|
+
|
|
936
|
+
async function createExportOperation(_ref, asyncDispatchFn) {
|
|
937
|
+
let projectKey = _ref.projectKey,
|
|
938
|
+
resourceType = _ref.resourceType,
|
|
939
|
+
fileName = _ref.fileName,
|
|
940
|
+
fileFormat = _ref.fileFormat,
|
|
941
|
+
fields = _ref.fields,
|
|
942
|
+
locales = _ref.locales,
|
|
943
|
+
filters = _ref.filters,
|
|
944
|
+
where = _ref.where,
|
|
945
|
+
fillRows = _ref.fillRows;
|
|
946
|
+
const uri = `/${projectKey}/export-operations`;
|
|
947
|
+
const response = await asyncDispatchFn(sdk.actions.post({
|
|
948
|
+
mcApiProxyTarget: constants.MC_API_PROXY_TARGETS.EXPORT,
|
|
949
|
+
uri: uri,
|
|
950
|
+
headers: {
|
|
951
|
+
accept: 'application/json'
|
|
952
|
+
},
|
|
953
|
+
payload: {
|
|
954
|
+
resourceType,
|
|
955
|
+
fileName,
|
|
956
|
+
fileFormat,
|
|
957
|
+
fields,
|
|
958
|
+
locales,
|
|
959
|
+
fillRows,
|
|
960
|
+
// Query predicate
|
|
961
|
+
where,
|
|
962
|
+
// Search API filters or Category API filters
|
|
963
|
+
filters
|
|
964
|
+
}
|
|
965
|
+
}));
|
|
966
|
+
if (!response || typeof response !== 'object' || !('state' in response)) {
|
|
967
|
+
throw new InvalidResponseError();
|
|
968
|
+
}
|
|
969
|
+
return response;
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
const useStartExportOperation = props => {
|
|
973
|
+
const intl = reactIntl.useIntl();
|
|
974
|
+
const asyncDispatch = sdk.useAsyncDispatch();
|
|
975
|
+
const showNotification = actionsGlobal.useShowNotification();
|
|
976
|
+
const _useApplicationContex = applicationShellConnectors.useApplicationContext(applicationContext => ({
|
|
977
|
+
locale: applicationContext.dataLocale,
|
|
978
|
+
projectKey: applicationContext.project?.key
|
|
979
|
+
})),
|
|
980
|
+
projectKey = _useApplicationContex.projectKey;
|
|
981
|
+
const extractFieldNamesFromGroups = groups => {
|
|
982
|
+
let checkedFields = [];
|
|
983
|
+
const getCheckedFields = fields => {
|
|
984
|
+
return _filterInstanceProperty__default["default"](fields).call(fields, field => {
|
|
985
|
+
if (field.fields) {
|
|
986
|
+
return getCheckedFields(field.fields);
|
|
987
|
+
}
|
|
988
|
+
if (field.isChecked) checkedFields.push(field);
|
|
989
|
+
return field.isChecked ?? false;
|
|
990
|
+
});
|
|
991
|
+
};
|
|
992
|
+
_forEachInstanceProperty__default["default"](groups).call(groups, group => {
|
|
993
|
+
getCheckedFields(group.fields);
|
|
994
|
+
});
|
|
995
|
+
return sortFieldsByFieldOrder({
|
|
996
|
+
fieldNames: extractFieldNamesAndAdditionalFieldExtensions(checkedFields),
|
|
997
|
+
fieldOrder: props.fieldOrder
|
|
998
|
+
});
|
|
999
|
+
};
|
|
1000
|
+
const startExportOperation = async (values, exportType) => {
|
|
1001
|
+
try {
|
|
1002
|
+
if (!projectKey) throw new Error('Project key is missing');
|
|
1003
|
+
const fields = extractFieldNamesFromGroups(values.groups);
|
|
1004
|
+
let where = undefined;
|
|
1005
|
+
let filters = undefined;
|
|
1006
|
+
if (exportType === EXPORT_TYPES.SELECTED && props.selectedResourceIds?.length) {
|
|
1007
|
+
where = buildSelectedExportFilters(props.selectedResourceIds);
|
|
1008
|
+
} else if (exportType === EXPORT_TYPES.FILTERED && props.filters) {
|
|
1009
|
+
where = props.filters.where;
|
|
1010
|
+
if (isQueryFilter(props.filters.filters)) {
|
|
1011
|
+
filters = props.filters.filters;
|
|
1012
|
+
} else if (isSearchFilter(props.filters.filters)) {
|
|
1013
|
+
filters = props.filters.filters;
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
const response = await createExportOperation({
|
|
1017
|
+
projectKey,
|
|
1018
|
+
resourceType: props.resourceType,
|
|
1019
|
+
fileName: appendCsvOrJsonExtensionIfAbsent(values.fileName, values.outputFormat),
|
|
1020
|
+
fileFormat: values.outputFormat,
|
|
1021
|
+
locales: values.locales,
|
|
1022
|
+
fillRows: values.fillRows,
|
|
1023
|
+
fields,
|
|
1024
|
+
where,
|
|
1025
|
+
filters
|
|
1026
|
+
}, asyncDispatch);
|
|
1027
|
+
switch (response.state) {
|
|
1028
|
+
case EXPORT_OPERATION_STATES.QUEUED:
|
|
1029
|
+
case EXPORT_OPERATION_STATES.PROCESSING:
|
|
1030
|
+
case EXPORT_OPERATION_STATES.COMPLETED:
|
|
1031
|
+
showNotification({
|
|
1032
|
+
kind: 'info',
|
|
1033
|
+
domain: constants.DOMAINS.SIDE,
|
|
1034
|
+
// @ts-ignore
|
|
1035
|
+
text: intl.formatMessage(messages.exportOperationSuccessMessage, {
|
|
1036
|
+
newline: getNewLine,
|
|
1037
|
+
logsLink: msg => getExportLogsLink(projectKey, msg),
|
|
1038
|
+
b: getBold
|
|
1039
|
+
})
|
|
1040
|
+
}, {
|
|
1041
|
+
dismissAfter: 5000
|
|
1042
|
+
});
|
|
1043
|
+
if (typeof props.onExportSuccess === 'function') props.onExportSuccess();
|
|
1044
|
+
break;
|
|
1045
|
+
default:
|
|
1046
|
+
throw new UnexpectedExportOperationStateError(response.state);
|
|
1047
|
+
}
|
|
1048
|
+
} catch (error) {
|
|
1049
|
+
// TODO: custom error messages for each error type
|
|
1050
|
+
showNotification({
|
|
1051
|
+
text: intl.formatMessage(messages.unexpectedError),
|
|
1052
|
+
kind: 'error',
|
|
1053
|
+
domain: constants.DOMAINS.PAGE
|
|
1054
|
+
});
|
|
1055
|
+
} finally {
|
|
1056
|
+
if (typeof props.onClose === 'function') props.onClose();
|
|
1057
|
+
}
|
|
1058
|
+
};
|
|
1059
|
+
return {
|
|
1060
|
+
startExportOperation
|
|
1061
|
+
};
|
|
1062
|
+
};
|
|
1063
|
+
|
|
1064
|
+
const _excluded$2 = ["fields"];
|
|
1065
|
+
function ownKeys$6(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1066
|
+
function _objectSpread$6(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context2 = ownKeys$6(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context3 = ownKeys$6(Object(t))).call(_context3, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
1067
|
+
const getFieldFullName = _ref => {
|
|
1068
|
+
var _context;
|
|
1069
|
+
let fieldPrefix = _ref.fieldPrefix,
|
|
1070
|
+
fieldName = _ref.fieldName;
|
|
1071
|
+
return _filterInstanceProperty__default["default"](_context = [fieldPrefix, fieldName]).call(_context, Boolean).join('.');
|
|
1072
|
+
};
|
|
1073
|
+
const localizeTypeDefinitionLabels = function () {
|
|
1074
|
+
let fieldDefinitions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
1075
|
+
return _mapInstanceProperty__default["default"](fieldDefinitions).call(fieldDefinitions, _ref2 => {
|
|
1076
|
+
let fields = _ref2.fields,
|
|
1077
|
+
fieldsType = _objectWithoutProperties(_ref2, _excluded$2);
|
|
1078
|
+
const isFieldTypeLabelLocalized = _Array$isArray__default["default"](fieldsType.label);
|
|
1079
|
+
return {
|
|
1080
|
+
name: fieldsType.name,
|
|
1081
|
+
label: isFieldTypeLabelLocalized ? l10n.applyTransformedLocalizedFields(fieldsType, [{
|
|
1082
|
+
from: 'label',
|
|
1083
|
+
to: 'label'
|
|
1084
|
+
}]).label : fieldsType.label,
|
|
1085
|
+
fields: fields?.map(field => {
|
|
1086
|
+
const isFieldLabelLocalized = _Array$isArray__default["default"](field.label);
|
|
1087
|
+
if (!isFieldLabelLocalized) {
|
|
1088
|
+
return field;
|
|
1089
|
+
}
|
|
1090
|
+
return _objectSpread$6({}, l10n.applyTransformedLocalizedFields(field, [{
|
|
1091
|
+
from: 'label',
|
|
1092
|
+
to: 'label'
|
|
1093
|
+
}]));
|
|
1094
|
+
}) || []
|
|
1095
|
+
};
|
|
1096
|
+
});
|
|
1097
|
+
};
|
|
1098
|
+
const useConvertFieldDefinitionsForExport = () => {
|
|
1099
|
+
const _useApplicationContex = applicationShellConnectors.useApplicationContext(applicationContext => ({
|
|
1100
|
+
language: applicationContext.dataLocale,
|
|
1101
|
+
languages: applicationContext.project?.languages
|
|
1102
|
+
})),
|
|
1103
|
+
language = _useApplicationContex.language,
|
|
1104
|
+
languages = _useApplicationContex.languages;
|
|
1105
|
+
const sortByField = (fields, fieldName) => {
|
|
1106
|
+
if (!fields) return [];
|
|
1107
|
+
if (fieldName) {
|
|
1108
|
+
return sortBy__default["default"](fields, field => {
|
|
1109
|
+
return field[fieldName]?.toLowerCase();
|
|
1110
|
+
});
|
|
1111
|
+
}
|
|
1112
|
+
return fields;
|
|
1113
|
+
};
|
|
1114
|
+
const convertFieldDefinitionsForExport = _ref3 => {
|
|
1115
|
+
let fieldDefinitions = _ref3.fieldDefinitions,
|
|
1116
|
+
fieldPrefix = _ref3.fieldPrefix,
|
|
1117
|
+
_ref3$expandAll = _ref3.expandAll,
|
|
1118
|
+
expandAll = _ref3$expandAll === void 0 ? false : _ref3$expandAll,
|
|
1119
|
+
sortField = _ref3.sortField;
|
|
1120
|
+
if (!fieldDefinitions) return [];
|
|
1121
|
+
const localizedTypeDefinitions = localizeTypeDefinitionLabels(fieldDefinitions);
|
|
1122
|
+
const results = _mapInstanceProperty__default["default"](localizedTypeDefinitions).call(localizedTypeDefinitions, transformedType => {
|
|
1123
|
+
const isTypeLabelLocalized = typeof transformedType.label !== 'string';
|
|
1124
|
+
return {
|
|
1125
|
+
isExpandable: true,
|
|
1126
|
+
isExpanded: expandAll,
|
|
1127
|
+
name: transformedType.name,
|
|
1128
|
+
label: isTypeLabelLocalized ? l10n.formatLocalizedString({
|
|
1129
|
+
label: transformedType.label
|
|
1130
|
+
}, {
|
|
1131
|
+
key: 'label',
|
|
1132
|
+
locale: language,
|
|
1133
|
+
fallbackOrder: languages,
|
|
1134
|
+
fallback: transformedType.name
|
|
1135
|
+
}) : transformedType.label,
|
|
1136
|
+
fields: sortByField(transformedType.fields?.map(fieldDefinition => {
|
|
1137
|
+
const isFieldLabelLocalized = typeof fieldDefinition.label !== 'string';
|
|
1138
|
+
return {
|
|
1139
|
+
name: getFieldFullName({
|
|
1140
|
+
fieldPrefix: fieldPrefix,
|
|
1141
|
+
fieldName: fieldDefinition.name
|
|
1142
|
+
}),
|
|
1143
|
+
label: isFieldLabelLocalized ? l10n.formatLocalizedString({
|
|
1144
|
+
label: fieldDefinition.label
|
|
1145
|
+
}, {
|
|
1146
|
+
key: 'label',
|
|
1147
|
+
locale: language,
|
|
1148
|
+
fallbackOrder: languages,
|
|
1149
|
+
fallback: fieldDefinition.name
|
|
1150
|
+
}) : fieldDefinition.label,
|
|
1151
|
+
extendedFieldNames: fieldDefinition.extendedFieldNames
|
|
1152
|
+
};
|
|
1153
|
+
}), sortField)
|
|
1154
|
+
};
|
|
1155
|
+
});
|
|
1156
|
+
return sortByField(results, sortField);
|
|
1157
|
+
};
|
|
1158
|
+
return {
|
|
1159
|
+
convertFieldDefinitionsForExport
|
|
1160
|
+
};
|
|
1161
|
+
};
|
|
1162
|
+
|
|
1163
|
+
function ownKeys$5(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1164
|
+
function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$5(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$5(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
1165
|
+
const OrderPreferences = () => {
|
|
1166
|
+
const _useExportResourcesMo = useExportResourcesModalContext(),
|
|
1167
|
+
formik = _useExportResourcesMo.formik;
|
|
1168
|
+
return jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
1169
|
+
children: jsxRuntime.jsx(uiKit.CheckboxInput, {
|
|
1170
|
+
isChecked: _valuesInstanceProperty__default["default"](formik).fillRows,
|
|
1171
|
+
onChange: e => {
|
|
1172
|
+
formik.setFieldValue('fillRows', e.target.checked);
|
|
1173
|
+
},
|
|
1174
|
+
children: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$5({}, messages.fillRowsForOrderExport))
|
|
1175
|
+
})
|
|
1176
|
+
});
|
|
1177
|
+
};
|
|
1178
|
+
const ProductPreferences = () => {
|
|
1179
|
+
const _useExportResourcesMo2 = useExportResourcesModalContext(),
|
|
1180
|
+
formik = _useExportResourcesMo2.formik;
|
|
1181
|
+
return jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
1182
|
+
children: jsxRuntime.jsx(uiKit.CheckboxInput, {
|
|
1183
|
+
isChecked: _valuesInstanceProperty__default["default"](formik).fillRows,
|
|
1184
|
+
onChange: e => {
|
|
1185
|
+
formik.setFieldValue('fillRows', e.target.checked);
|
|
1186
|
+
},
|
|
1187
|
+
children: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$5({}, messages.fillRowsForProductExport))
|
|
1188
|
+
})
|
|
1189
|
+
});
|
|
1190
|
+
};
|
|
1191
|
+
const ExportPreferenceSection = () => {
|
|
1192
|
+
const _useExportResourcesMo3 = useExportResourcesModalContext(),
|
|
1193
|
+
resourceType = _useExportResourcesMo3.resourceType;
|
|
1194
|
+
if (resourceType === 'order') {
|
|
1195
|
+
return jsxRuntime.jsx(OrderPreferences, {});
|
|
1196
|
+
}
|
|
1197
|
+
if (resourceType === 'product') {
|
|
1198
|
+
return jsxRuntime.jsx(ProductPreferences, {});
|
|
1199
|
+
}
|
|
1200
|
+
return null;
|
|
1201
|
+
};
|
|
1202
|
+
|
|
1203
|
+
function ownKeys$4(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1204
|
+
function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$4(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$4(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
1205
|
+
function ExportScopeSection() {
|
|
1206
|
+
const intl = reactIntl.useIntl();
|
|
1207
|
+
const _useExportResourcesMo = useExportResourcesModalContext(),
|
|
1208
|
+
exportType = _useExportResourcesMo.exportType,
|
|
1209
|
+
totalResourcesCount = _useExportResourcesMo.totalResourcesCount,
|
|
1210
|
+
filters = _useExportResourcesMo.filters,
|
|
1211
|
+
hasFilters = _useExportResourcesMo.hasFilters,
|
|
1212
|
+
selectedResourceIds = _useExportResourcesMo.selectedResourceIds,
|
|
1213
|
+
setExportType = _useExportResourcesMo.setExportType,
|
|
1214
|
+
resourceType = _useExportResourcesMo.resourceType,
|
|
1215
|
+
hideExportSelectedResourcesOption = _useExportResourcesMo.hideExportSelectedResourcesOption;
|
|
1216
|
+
return jsxRuntime.jsx(uiKit.Spacings.Stack, {
|
|
1217
|
+
scale: "m",
|
|
1218
|
+
children: jsxRuntime.jsxs(uiKit.RadioInput.Group, {
|
|
1219
|
+
value: exportType,
|
|
1220
|
+
onChange: e => {
|
|
1221
|
+
setExportType(e.target.value);
|
|
1222
|
+
},
|
|
1223
|
+
direction: "stack",
|
|
1224
|
+
directionProps: {
|
|
1225
|
+
scale: 's'
|
|
1226
|
+
},
|
|
1227
|
+
children: [jsxRuntime.jsx(uiKit.RadioInput.Option, {
|
|
1228
|
+
value: EXPORT_TYPES.ALL,
|
|
1229
|
+
children: jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1230
|
+
intlMessage: _objectSpread$4(_objectSpread$4({}, resourceTypeMessages[resourceType].exportScopeAll), {}, {
|
|
1231
|
+
values: {
|
|
1232
|
+
total: intl.formatNumber(totalResourcesCount)
|
|
1233
|
+
}
|
|
1234
|
+
})
|
|
1235
|
+
})
|
|
1236
|
+
}), filters && jsxRuntime.jsx(uiKit.RadioInput.Option, {
|
|
1237
|
+
value: EXPORT_TYPES.FILTERED,
|
|
1238
|
+
isDisabled: !filters.total || !hasFilters,
|
|
1239
|
+
children: jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1240
|
+
tone: !filters.total || !hasFilters ? 'tertiary' : undefined,
|
|
1241
|
+
intlMessage: filters.total ? _objectSpread$4(_objectSpread$4({}, resourceTypeMessages[resourceType].exportScopeFiltered), {}, {
|
|
1242
|
+
values: {
|
|
1243
|
+
total: intl.formatNumber(filters.total)
|
|
1244
|
+
}
|
|
1245
|
+
}) : messages.exportScopeFilteredWithoutCount
|
|
1246
|
+
})
|
|
1247
|
+
}), !hideExportSelectedResourcesOption && jsxRuntime.jsx(uiKit.RadioInput.Option, {
|
|
1248
|
+
value: EXPORT_TYPES.SELECTED,
|
|
1249
|
+
isDisabled: !selectedResourceIds?.length,
|
|
1250
|
+
children: jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1251
|
+
tone: !selectedResourceIds?.length ? 'tertiary' : undefined,
|
|
1252
|
+
intlMessage: selectedResourceIds?.length ? _objectSpread$4(_objectSpread$4({}, resourceTypeMessages[resourceType].exportScopeSelected), {}, {
|
|
1253
|
+
values: {
|
|
1254
|
+
total: intl.formatNumber(selectedResourceIds.length)
|
|
1255
|
+
}
|
|
1256
|
+
}) : messages.exportScopeSelectedWithoutCount
|
|
1257
|
+
})
|
|
1258
|
+
})]
|
|
1259
|
+
})
|
|
1260
|
+
});
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1263
|
+
const ExportFileSettingsStep = () => {
|
|
1264
|
+
var _context;
|
|
1265
|
+
const intl = reactIntl.useIntl();
|
|
1266
|
+
const _useExportResourcesMo = useExportResourcesModalContext(),
|
|
1267
|
+
formik = _useExportResourcesMo.formik,
|
|
1268
|
+
resourceType = _useExportResourcesMo.resourceType,
|
|
1269
|
+
onClose = _useExportResourcesMo.onClose;
|
|
1270
|
+
const _useApplicationContex = applicationShellConnectors.useApplicationContext(applicationContext => ({
|
|
1271
|
+
locale: applicationContext.dataLocale,
|
|
1272
|
+
locales: applicationContext.project?.languages || []
|
|
1273
|
+
})),
|
|
1274
|
+
locales = _useApplicationContex.locales,
|
|
1275
|
+
locale = _useApplicationContex.locale;
|
|
1276
|
+
const areAllLocalesChecked = _valuesInstanceProperty__default["default"](formik).locales.length === locales.length;
|
|
1277
|
+
// TODO: make this dynamic based on the resource type & output format (more scalable)
|
|
1278
|
+
const shouldShowPreferences = _includesInstanceProperty__default["default"](_context = ['order', 'product']).call(_context, resourceType) && _valuesInstanceProperty__default["default"](formik).outputFormat === 'csv';
|
|
1279
|
+
return jsxRuntime.jsx(applicationComponents.FormDialog, {
|
|
1280
|
+
isOpen: true,
|
|
1281
|
+
title: intl.formatMessage(messages[`modalTitle.${resourceType}`]),
|
|
1282
|
+
labelPrimary: intl.formatMessage(messages.continue),
|
|
1283
|
+
onPrimaryButtonClick: formik.submitForm,
|
|
1284
|
+
isPrimaryButtonDisabled: !formik.isValid,
|
|
1285
|
+
onSecondaryButtonClick: onClose,
|
|
1286
|
+
onClose: onClose,
|
|
1287
|
+
size: 16,
|
|
1288
|
+
children: jsxRuntime.jsx(fullstory.Masking.Unmask, {
|
|
1289
|
+
children: jsxRuntime.jsx(uiKit.Spacings.Stack, {
|
|
1290
|
+
scale: "xxxl",
|
|
1291
|
+
children: jsxRuntime.jsx(uiKit.Spacings.Stack, {
|
|
1292
|
+
scale: "l",
|
|
1293
|
+
children: jsxRuntime.jsxs(uiKit.Grid, {
|
|
1294
|
+
gridRowGap: uiKit.designTokens.spacingL,
|
|
1295
|
+
gridTemplateColumns: `calc(${uiKit.designTokens.constraint3} + ${uiKit.designTokens.spacingL}) auto`,
|
|
1296
|
+
children: [jsxRuntime.jsx(uiKit.Grid.Item, {
|
|
1297
|
+
children: jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1298
|
+
intlMessage: messages.exportScope
|
|
1299
|
+
})
|
|
1300
|
+
}), jsxRuntime.jsx(uiKit.Grid.Item, {
|
|
1301
|
+
children: jsxRuntime.jsx(ExportScopeSection, {})
|
|
1302
|
+
}), jsxRuntime.jsx(uiKit.Grid.Item, {
|
|
1303
|
+
children: jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1304
|
+
intlMessage: messages.exportSettings
|
|
1305
|
+
})
|
|
1306
|
+
}), jsxRuntime.jsx(uiKit.Grid.Item, {
|
|
1307
|
+
children: jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
1308
|
+
scale: "m",
|
|
1309
|
+
children: [jsxRuntime.jsx(uiKit.SelectField, {
|
|
1310
|
+
name: "outputFormat",
|
|
1311
|
+
onChange: formik.handleChange,
|
|
1312
|
+
onBlur: formik.handleBlur,
|
|
1313
|
+
value: _valuesInstanceProperty__default["default"](formik).outputFormat,
|
|
1314
|
+
title: intl.formatMessage(messages.outputFormat),
|
|
1315
|
+
options: OUTPUT_FORMAT_OPTIONS
|
|
1316
|
+
}), jsxRuntime.jsx(fullstory.Masking.Mask, {
|
|
1317
|
+
children: jsxRuntime.jsx(uiKit.TextField, {
|
|
1318
|
+
name: "fileName",
|
|
1319
|
+
onChange: formik.handleChange,
|
|
1320
|
+
onBlur: formik.handleBlur,
|
|
1321
|
+
value: _valuesInstanceProperty__default["default"](formik).fileName,
|
|
1322
|
+
title: intl.formatMessage(messages.fileName),
|
|
1323
|
+
touched: formik.touched.fileName,
|
|
1324
|
+
errors: mapFormikErrors(formik.errors.fileName),
|
|
1325
|
+
renderError: renderFileNameError
|
|
1326
|
+
})
|
|
1327
|
+
}), jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
1328
|
+
scale: "xs",
|
|
1329
|
+
children: [jsxRuntime.jsx(uiKit.SelectField, {
|
|
1330
|
+
id: "locales",
|
|
1331
|
+
name: "locales",
|
|
1332
|
+
value: _valuesInstanceProperty__default["default"](formik).locales,
|
|
1333
|
+
title: intl.formatMessage(messages.locale),
|
|
1334
|
+
options: mapLocalesToOptions(locales),
|
|
1335
|
+
isMulti: true,
|
|
1336
|
+
onChange: formik.handleChange,
|
|
1337
|
+
onBlur: formik.handleBlur,
|
|
1338
|
+
touched: formik.touched.locales,
|
|
1339
|
+
errors: mapFormikErrors(formik.errors.locales),
|
|
1340
|
+
renderError: renderLocaleError,
|
|
1341
|
+
menuPortalTarget: document.body,
|
|
1342
|
+
menuPortalZIndex: Z_INDEX_DROPDOWN
|
|
1343
|
+
}), jsxRuntime.jsxs(uiKit.Spacings.Inline, {
|
|
1344
|
+
scale: "s",
|
|
1345
|
+
alignItems: "center",
|
|
1346
|
+
children: [jsxRuntime.jsx(uiKit.ToggleInput, {
|
|
1347
|
+
"data-testid": "include-all-locales-toggle-input",
|
|
1348
|
+
size: "small",
|
|
1349
|
+
isChecked: areAllLocalesChecked,
|
|
1350
|
+
onChange: e => {
|
|
1351
|
+
if (e.target.checked) formik.setFieldValue('locales', locales);else formik.setFieldValue('locales', [locale]);
|
|
1352
|
+
}
|
|
1353
|
+
}), jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1354
|
+
intlMessage: messages.includeAllLocales
|
|
1355
|
+
})]
|
|
1356
|
+
})]
|
|
1357
|
+
})]
|
|
1358
|
+
})
|
|
1359
|
+
}), shouldShowPreferences && jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1360
|
+
children: [jsxRuntime.jsx(uiKit.Grid.Item, {
|
|
1361
|
+
children: jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1362
|
+
intlMessage: messages.exportPreferences
|
|
1363
|
+
})
|
|
1364
|
+
}), jsxRuntime.jsx(uiKit.Grid.Item, {
|
|
1365
|
+
children: jsxRuntime.jsx(ExportPreferenceSection, {})
|
|
1366
|
+
})]
|
|
1367
|
+
})]
|
|
1368
|
+
})
|
|
1369
|
+
})
|
|
1370
|
+
})
|
|
1371
|
+
})
|
|
1372
|
+
});
|
|
1373
|
+
};
|
|
1374
|
+
|
|
1375
|
+
function ownKeys$3(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1376
|
+
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$3(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$3(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
1377
|
+
const exportFieldSelectionContextDefaultValues = {
|
|
1378
|
+
updateExpandedGroups: (_name, _value) => {}
|
|
1379
|
+
};
|
|
1380
|
+
const ExportFieldSelectionContext = /*#__PURE__*/React.createContext(exportFieldSelectionContextDefaultValues);
|
|
1381
|
+
const ExportFieldSelectionProvider = _ref => {
|
|
1382
|
+
let resourceType = _ref.resourceType,
|
|
1383
|
+
children = _ref.children;
|
|
1384
|
+
const _useApplicationContex = applicationShellConnectors.useApplicationContext(context => ({
|
|
1385
|
+
projectKey: context.project?.key
|
|
1386
|
+
})),
|
|
1387
|
+
projectKey = _useApplicationContex.projectKey;
|
|
1388
|
+
const _useStorage = experimentalComponents.useStorage(`${projectKey}/${OPERATIONS_EXPORT_RESOURCES_MODAL_EXPANDED_GROUP}`, {}),
|
|
1389
|
+
_useStorage2 = _slicedToArray(_useStorage, 2),
|
|
1390
|
+
cachedExpandedGroups = _useStorage2[0],
|
|
1391
|
+
setCachedExpandedGroups = _useStorage2[1];
|
|
1392
|
+
const updateExpandedGroups = React.useCallback((name, value) => {
|
|
1393
|
+
setCachedExpandedGroups({
|
|
1394
|
+
[resourceType]: _objectSpread$3(_objectSpread$3({}, cachedExpandedGroups[resourceType] || {}), {}, {
|
|
1395
|
+
[name]: value
|
|
1396
|
+
})
|
|
1397
|
+
});
|
|
1398
|
+
}, [cachedExpandedGroups, resourceType, setCachedExpandedGroups]);
|
|
1399
|
+
return jsxRuntime.jsx(ExportFieldSelectionContext.Provider, {
|
|
1400
|
+
value: {
|
|
1401
|
+
updateExpandedGroups
|
|
1402
|
+
},
|
|
1403
|
+
children: children
|
|
1404
|
+
});
|
|
1405
|
+
};
|
|
1406
|
+
const useExportFieldSelectionContext = () => {
|
|
1407
|
+
return React.useContext(ExportFieldSelectionContext);
|
|
1408
|
+
};
|
|
1409
|
+
|
|
1410
|
+
const ExportFieldSelectionStamp = _ref => {
|
|
1411
|
+
let group = _ref.group;
|
|
1412
|
+
const _useIntl = reactIntl.useIntl(),
|
|
1413
|
+
formatMessage = _useIntl.formatMessage;
|
|
1414
|
+
return jsxRuntime.jsx(uiKit.Card, {
|
|
1415
|
+
type: "flat",
|
|
1416
|
+
insetScale: "m",
|
|
1417
|
+
children: jsxRuntime.jsx(uiKit.Spacings.Inline, {
|
|
1418
|
+
justifyContent: "flex-end",
|
|
1419
|
+
children: jsxRuntime.jsx(uiKit.Stamp, {
|
|
1420
|
+
tone: "secondary",
|
|
1421
|
+
isCondensed: true,
|
|
1422
|
+
label: formatMessage(messages.selected, {
|
|
1423
|
+
total: getTotalCheckedFields(group)
|
|
1424
|
+
})
|
|
1425
|
+
})
|
|
1426
|
+
})
|
|
1427
|
+
});
|
|
1428
|
+
};
|
|
1429
|
+
|
|
1430
|
+
const FieldWrapper = /*#__PURE__*/_styled__default["default"]("div", {
|
|
1431
|
+
target: "e1judmlm0"
|
|
1432
|
+
} )({
|
|
1433
|
+
name: "9iujih",
|
|
1434
|
+
styles: "position:relative;display:flex;align-items:center"
|
|
1435
|
+
} );
|
|
1436
|
+
const CollapsibleFieldWrapper = _ref => {
|
|
1437
|
+
let isForceExpanded = _ref.isForceExpanded,
|
|
1438
|
+
field = _ref.field,
|
|
1439
|
+
children = _ref.children;
|
|
1440
|
+
if (field.isExpandable) return jsxRuntime.jsx(uiKit.CollapsibleMotion, {
|
|
1441
|
+
isDefaultClosed: isForceExpanded ? false : !field.isExpanded,
|
|
1442
|
+
children: _ref2 => {
|
|
1443
|
+
let isOpen = _ref2.isOpen,
|
|
1444
|
+
toggle = _ref2.toggle,
|
|
1445
|
+
registerContentNode = _ref2.registerContentNode;
|
|
1446
|
+
return children({
|
|
1447
|
+
isOpen,
|
|
1448
|
+
toggle,
|
|
1449
|
+
registerContentNode
|
|
1450
|
+
});
|
|
1451
|
+
}
|
|
1452
|
+
}, `${isForceExpanded}`);
|
|
1453
|
+
return children({
|
|
1454
|
+
isOpen: true,
|
|
1455
|
+
toggle: () => {},
|
|
1456
|
+
registerContentNode: () => {}
|
|
1457
|
+
});
|
|
1458
|
+
};
|
|
1459
|
+
const FieldSection = _ref3 => {
|
|
1460
|
+
let fields = _ref3.fields,
|
|
1461
|
+
parentKeys = _ref3.parentKeys,
|
|
1462
|
+
formik = _ref3.formik,
|
|
1463
|
+
isAnySiblingChecked = _ref3.isAnySiblingChecked,
|
|
1464
|
+
isForceExpanded = _ref3.isForceExpanded,
|
|
1465
|
+
groupName = _ref3.groupName;
|
|
1466
|
+
const _useExportFieldSelect = useExportFieldSelectionContext(),
|
|
1467
|
+
updateExpandedGroups = _useExportFieldSelect.updateExpandedGroups;
|
|
1468
|
+
return jsxRuntime.jsx(uiKit.Spacings.Stack, {
|
|
1469
|
+
scale: "s",
|
|
1470
|
+
children: fields?.map((field, index) => {
|
|
1471
|
+
const hasDependents = Boolean(field.dependentGroupNames?.length || field.dependentFieldNames?.length);
|
|
1472
|
+
const isAnyOfTheChildFieldsChecked = isAnyFieldChecked(field.fields || []);
|
|
1473
|
+
const allFieldsChecked = areAllFieldsChecked(field.fields || []);
|
|
1474
|
+
const getIsChecked = () => {
|
|
1475
|
+
const isParent = Boolean(field.fields && field.fields?.length > 0);
|
|
1476
|
+
if (isParent) return areAllFieldsChecked(field.fields);
|
|
1477
|
+
return field.isChecked;
|
|
1478
|
+
};
|
|
1479
|
+
if (field.isHidden) return null;
|
|
1480
|
+
return jsxRuntime.jsx(CollapsibleFieldWrapper, {
|
|
1481
|
+
isForceExpanded: isForceExpanded,
|
|
1482
|
+
field: field,
|
|
1483
|
+
children: _ref4 => {
|
|
1484
|
+
let isOpen = _ref4.isOpen,
|
|
1485
|
+
toggle = _ref4.toggle,
|
|
1486
|
+
registerContentNode = _ref4.registerContentNode;
|
|
1487
|
+
return jsxRuntime.jsxs(React.Fragment, {
|
|
1488
|
+
children: [jsxRuntime.jsxs(FieldWrapper, {
|
|
1489
|
+
children: [field.isExpandable && jsxRuntime.jsx(uiKit.IconButton, {
|
|
1490
|
+
size: "20",
|
|
1491
|
+
style: {
|
|
1492
|
+
position: 'absolute',
|
|
1493
|
+
left: `calc(-1 * ${uiKit.designTokens.spacingXl})`
|
|
1494
|
+
},
|
|
1495
|
+
onClick: () => {
|
|
1496
|
+
if (!isForceExpanded) {
|
|
1497
|
+
updateExpandedGroups(`${groupName}.${field.name}`, !isOpen);
|
|
1498
|
+
}
|
|
1499
|
+
toggle();
|
|
1500
|
+
},
|
|
1501
|
+
icon: isOpen ? jsxRuntime.jsx(uiKit.AngleDownIcon, {}) : jsxRuntime.jsx(uiKit.AngleRightIcon, {}),
|
|
1502
|
+
label: ""
|
|
1503
|
+
}), jsxRuntime.jsx(uiKit.Spacings.Inline, {
|
|
1504
|
+
scale: "s",
|
|
1505
|
+
alignItems: "center",
|
|
1506
|
+
children: jsxRuntime.jsxs(uiKit.CheckboxInput, {
|
|
1507
|
+
isIndeterminate: field.isExpandable && !allFieldsChecked && isAnyOfTheChildFieldsChecked,
|
|
1508
|
+
isChecked: getIsChecked(),
|
|
1509
|
+
isReadOnly: hasDependents || field.isRequired,
|
|
1510
|
+
onChange: e => {
|
|
1511
|
+
const path = `${parentKeys.join('.')}.fields[${index}]`;
|
|
1512
|
+
const checked = e.target.checked;
|
|
1513
|
+
// Update all child fields
|
|
1514
|
+
const updateAllChildFieldsChecked = (path, checked) => {
|
|
1515
|
+
const item = get__default["default"](_valuesInstanceProperty__default["default"](formik), path);
|
|
1516
|
+
if (item && item.fields) {
|
|
1517
|
+
var _context;
|
|
1518
|
+
_forEachInstanceProperty__default["default"](_context = item.fields).call(_context, (field, i) => {
|
|
1519
|
+
const fieldPath = `${path}.fields[${i}]`;
|
|
1520
|
+
if (!field.fields?.length) {
|
|
1521
|
+
formik.setFieldValue(`${fieldPath}.isChecked`, checked || field.isRequired,
|
|
1522
|
+
// pass `false` to avoid revalidating the form with intermediate values
|
|
1523
|
+
false);
|
|
1524
|
+
}
|
|
1525
|
+
updateAllChildFieldsChecked(fieldPath, checked);
|
|
1526
|
+
});
|
|
1527
|
+
}
|
|
1528
|
+
};
|
|
1529
|
+
if (!field.fields?.length) {
|
|
1530
|
+
formik.setFieldValue(`${path}.isChecked`, checked || field.isRequired,
|
|
1531
|
+
// pass `false` to avoid revalidating the form with intermediate values
|
|
1532
|
+
false);
|
|
1533
|
+
}
|
|
1534
|
+
updateAllChildFieldsChecked(path, checked);
|
|
1535
|
+
},
|
|
1536
|
+
children: [field.label, (hasDependents || field.isRequired) && ' *']
|
|
1537
|
+
})
|
|
1538
|
+
})]
|
|
1539
|
+
}), field.fields && field.fields?.length > 0 && jsxRuntime.jsx(StyledExpandableContent, {
|
|
1540
|
+
ref: registerContentNode,
|
|
1541
|
+
isOpen: isOpen,
|
|
1542
|
+
children: jsxRuntime.jsxs(uiKit.Spacings.Inline, {
|
|
1543
|
+
scale: "xl",
|
|
1544
|
+
children: [jsxRuntime.jsx("div", {}), jsxRuntime.jsx(FieldSection, {
|
|
1545
|
+
fields: field.fields,
|
|
1546
|
+
formik: formik,
|
|
1547
|
+
parentKeys: [...parentKeys, `fields[${index}]`],
|
|
1548
|
+
isAnySiblingChecked: isAnySiblingChecked,
|
|
1549
|
+
isForceExpanded: isForceExpanded,
|
|
1550
|
+
groupName: groupName
|
|
1551
|
+
})]
|
|
1552
|
+
})
|
|
1553
|
+
})]
|
|
1554
|
+
}, `${field.name}-${index}`);
|
|
1555
|
+
}
|
|
1556
|
+
}, `${field.name}.${isForceExpanded}`);
|
|
1557
|
+
})
|
|
1558
|
+
});
|
|
1559
|
+
};
|
|
1560
|
+
|
|
1561
|
+
function ownKeys$2(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1562
|
+
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__default["default"](_context = ownKeys$2(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$2(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
1563
|
+
const StyledGroupCard = /*#__PURE__*/_styled__default["default"](uiKit.Card, {
|
|
1564
|
+
target: "e1igkh7t2"
|
|
1565
|
+
} )("height:100%;border-radius:0;", props => props.showTopBorder && /*#__PURE__*/react.css("border-top:", uiKit.designTokens.borderWidth1, " solid ", uiKit.designTokens.colorNeutral90, ";" + ("" ), "" ), ";" + ("" ));
|
|
1566
|
+
const StyledFieldsCard = /*#__PURE__*/_styled__default["default"](uiKit.Card, {
|
|
1567
|
+
target: "e1igkh7t1"
|
|
1568
|
+
} )("border-radius:0;", props => props.showTopBorder && /*#__PURE__*/react.css("border-top:", uiKit.designTokens.borderWidth1, " solid ", uiKit.designTokens.colorNeutral90, ";" + ("" ), "" ), ";" + ("" ));
|
|
1569
|
+
var _ref$1 = {
|
|
1570
|
+
name: "2ce4ng",
|
|
1571
|
+
styles: "overflow:hidden;height:0;margin-top:0!important"
|
|
1572
|
+
} ;
|
|
1573
|
+
const StyledExpandableContent = /*#__PURE__*/_styled__default["default"]("div", {
|
|
1574
|
+
target: "e1igkh7t0"
|
|
1575
|
+
} )(props => !props.isOpen && _ref$1, " ", props => !props.isOpen && props.showTopBorder && /*#__PURE__*/react.css("border-top:", uiKit.designTokens.borderWidth1, " solid ", uiKit.designTokens.colorNeutral90, ";" + ("" ), "" ), ";" + ("" ));
|
|
1576
|
+
const FieldGroupSection = _ref2 => {
|
|
1577
|
+
let group = _ref2.group,
|
|
1578
|
+
index = _ref2.index,
|
|
1579
|
+
formik = _ref2.formik,
|
|
1580
|
+
isForceExpanded = _ref2.isForceExpanded;
|
|
1581
|
+
const allFieldsChecked = React.useMemo(() => areAllFieldsChecked(group.fields), [group.fields]);
|
|
1582
|
+
const isAnyFieldInGroupChecked = React.useMemo(() => isAnyFieldChecked(group.fields), [group.fields]);
|
|
1583
|
+
const _useExportFieldSelect = useExportFieldSelectionContext(),
|
|
1584
|
+
updateExpandedGroups = _useExportFieldSelect.updateExpandedGroups;
|
|
1585
|
+
const parentKey = `groups[${index}]`;
|
|
1586
|
+
const handleChangeAllFields = e => {
|
|
1587
|
+
const item = get__default["default"](_valuesInstanceProperty__default["default"](formik), parentKey);
|
|
1588
|
+
function updateAllFields(fields, checked) {
|
|
1589
|
+
return _mapInstanceProperty__default["default"](fields).call(fields, field => {
|
|
1590
|
+
if (field.fields) {
|
|
1591
|
+
return _objectSpread$2(_objectSpread$2({}, field), {}, {
|
|
1592
|
+
fields: updateAllFields(field.fields, checked)
|
|
1593
|
+
});
|
|
1594
|
+
}
|
|
1595
|
+
if (field.isRequired) return field;
|
|
1596
|
+
return _objectSpread$2(_objectSpread$2({}, field), {}, {
|
|
1597
|
+
isChecked: checked
|
|
1598
|
+
});
|
|
1599
|
+
});
|
|
1600
|
+
}
|
|
1601
|
+
formik.setFieldValue(parentKey, _objectSpread$2(_objectSpread$2({}, item), {}, {
|
|
1602
|
+
fields: updateAllFields(item.fields, e.target.checked)
|
|
1603
|
+
}));
|
|
1604
|
+
};
|
|
1605
|
+
if (group.isHidden) return null;
|
|
1606
|
+
return jsxRuntime.jsx(uiKit.CollapsibleMotion, {
|
|
1607
|
+
isDefaultClosed: isForceExpanded ? false : !group.isExpanded,
|
|
1608
|
+
children: _ref3 => {
|
|
1609
|
+
let isOpen = _ref3.isOpen,
|
|
1610
|
+
toggle = _ref3.toggle,
|
|
1611
|
+
registerContentNode = _ref3.registerContentNode;
|
|
1612
|
+
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1613
|
+
children: [jsxRuntime.jsx(uiKit.Grid.Item, {
|
|
1614
|
+
children: jsxRuntime.jsx(StyledGroupCard, {
|
|
1615
|
+
type: "flat",
|
|
1616
|
+
insetScale: "m",
|
|
1617
|
+
showTopBorder: index > 0,
|
|
1618
|
+
children: jsxRuntime.jsxs(uiKit.Spacings.Inline, {
|
|
1619
|
+
scale: "s",
|
|
1620
|
+
alignItems: "center",
|
|
1621
|
+
children: [jsxRuntime.jsx(uiKit.IconButton, {
|
|
1622
|
+
size: "20",
|
|
1623
|
+
onClick: () => {
|
|
1624
|
+
if (!isForceExpanded) {
|
|
1625
|
+
updateExpandedGroups(group.groupName, !isOpen);
|
|
1626
|
+
}
|
|
1627
|
+
toggle();
|
|
1628
|
+
},
|
|
1629
|
+
icon: isOpen ? jsxRuntime.jsx(uiKit.AngleDownIcon, {}) : jsxRuntime.jsx(uiKit.AngleRightIcon, {}),
|
|
1630
|
+
label: ""
|
|
1631
|
+
}), jsxRuntime.jsx(uiKit.CheckboxInput, {
|
|
1632
|
+
isIndeterminate: !allFieldsChecked && isAnyFieldInGroupChecked,
|
|
1633
|
+
isChecked: allFieldsChecked,
|
|
1634
|
+
onChange: handleChangeAllFields,
|
|
1635
|
+
children: group.groupLabel
|
|
1636
|
+
})]
|
|
1637
|
+
})
|
|
1638
|
+
})
|
|
1639
|
+
}), jsxRuntime.jsx(uiKit.Grid.Item, {
|
|
1640
|
+
children: jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1641
|
+
children: [jsxRuntime.jsx(StyledExpandableContent, {
|
|
1642
|
+
ref: registerContentNode,
|
|
1643
|
+
isOpen: isOpen,
|
|
1644
|
+
showTopBorder: index > 0,
|
|
1645
|
+
children: jsxRuntime.jsx(StyledFieldsCard, {
|
|
1646
|
+
type: "flat",
|
|
1647
|
+
insetScale: "m",
|
|
1648
|
+
showTopBorder: true,
|
|
1649
|
+
children: jsxRuntime.jsx(uiKit.Spacings.Stack, {
|
|
1650
|
+
scale: "s",
|
|
1651
|
+
children: jsxRuntime.jsx(FieldSection, {
|
|
1652
|
+
fields: group.fields,
|
|
1653
|
+
formik: formik,
|
|
1654
|
+
parentKeys: [parentKey],
|
|
1655
|
+
isAnySiblingChecked: isAnyFieldInGroupChecked,
|
|
1656
|
+
groupName: group.groupName,
|
|
1657
|
+
isForceExpanded: isForceExpanded
|
|
1658
|
+
})
|
|
1659
|
+
})
|
|
1660
|
+
})
|
|
1661
|
+
}), !isOpen && jsxRuntime.jsx(ExportFieldSelectionStamp, {
|
|
1662
|
+
group: group
|
|
1663
|
+
})]
|
|
1664
|
+
})
|
|
1665
|
+
})]
|
|
1666
|
+
});
|
|
1667
|
+
}
|
|
1668
|
+
}, `${isForceExpanded}`);
|
|
1669
|
+
};
|
|
1670
|
+
|
|
1671
|
+
var _ref = {
|
|
1672
|
+
name: "ti75j2",
|
|
1673
|
+
styles: "margin:0"
|
|
1674
|
+
} ;
|
|
1675
|
+
const NoSearchResults = () => {
|
|
1676
|
+
return jsxRuntime.jsxs(uiKit.Card, {
|
|
1677
|
+
insetScale: "xl",
|
|
1678
|
+
children: [jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
1679
|
+
scale: "s",
|
|
1680
|
+
children: [jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1681
|
+
fontWeight: "medium",
|
|
1682
|
+
intlMessage: messages.thereAreNoResults
|
|
1683
|
+
}), jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1684
|
+
intlMessage: messages.suggestions
|
|
1685
|
+
})]
|
|
1686
|
+
}), jsxRuntime.jsxs("ul", {
|
|
1687
|
+
css: _ref,
|
|
1688
|
+
children: [jsxRuntime.jsx("li", {
|
|
1689
|
+
children: jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1690
|
+
intlMessage: messages.checkTheSpelling
|
|
1691
|
+
})
|
|
1692
|
+
}), jsxRuntime.jsx("li", {
|
|
1693
|
+
children: jsxRuntime.jsx(uiKit.Text.Body, {
|
|
1694
|
+
intlMessage: messages.searchByEnteringTheExactFieldName
|
|
1695
|
+
})
|
|
1696
|
+
})]
|
|
1697
|
+
})]
|
|
1698
|
+
});
|
|
1699
|
+
};
|
|
1700
|
+
|
|
1701
|
+
function ownKeys$1(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1702
|
+
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var _context5, _context6; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context5 = ownKeys$1(Object(t), !0)).call(_context5, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context6 = ownKeys$1(Object(t))).call(_context6, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
1703
|
+
const totalSpacing = 32 * 2 + (
|
|
1704
|
+
// outer modal spacing
|
|
1705
|
+
32 + 40) +
|
|
1706
|
+
// footer (dialog buttons + margin)
|
|
1707
|
+
40 +
|
|
1708
|
+
// search input
|
|
1709
|
+
24 +
|
|
1710
|
+
// search input padding
|
|
1711
|
+
24 +
|
|
1712
|
+
// modal header
|
|
1713
|
+
16 +
|
|
1714
|
+
// modal header margin
|
|
1715
|
+
16 + (
|
|
1716
|
+
// spacing between search input and grid card
|
|
1717
|
+
16 * 2 + 8 * 2) +
|
|
1718
|
+
// modal padding
|
|
1719
|
+
56 +
|
|
1720
|
+
// MC header
|
|
1721
|
+
4; // borders
|
|
1722
|
+
|
|
1723
|
+
const StyledGridCard = /*#__PURE__*/_styled__default["default"](uiKit.Card, {
|
|
1724
|
+
target: "e5mvpn60"
|
|
1725
|
+
} )("max-height:calc(100vh - ", totalSpacing, "px);overflow:auto;" + ("" ));
|
|
1726
|
+
const ExportFieldsSelectionStep = () => {
|
|
1727
|
+
const intl = reactIntl.useIntl();
|
|
1728
|
+
const _React$useState = React__default["default"].useState(''),
|
|
1729
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
1730
|
+
fieldSearchTerm = _React$useState2[0],
|
|
1731
|
+
setFieldSearchTerm = _React$useState2[1];
|
|
1732
|
+
const _useApplicationContex = applicationShellConnectors.useApplicationContext(context => ({
|
|
1733
|
+
projectKey: context.project?.key
|
|
1734
|
+
})),
|
|
1735
|
+
projectKey = _useApplicationContex.projectKey;
|
|
1736
|
+
const _useStorage = experimentalComponents.useStorage(`${projectKey}/${OPERATIONS_EXPORT_RESOURCES_MODAL_SELECTION}`, {}),
|
|
1737
|
+
_useStorage2 = _slicedToArray(_useStorage, 2);
|
|
1738
|
+
_useStorage2[0];
|
|
1739
|
+
const setCachedSelectedGroups = _useStorage2[1];
|
|
1740
|
+
const _useExportResourcesMo = useExportResourcesModalContext(),
|
|
1741
|
+
formik = _useExportResourcesMo.formik,
|
|
1742
|
+
setCurrentStep = _useExportResourcesMo.setCurrentStep,
|
|
1743
|
+
resourceType = _useExportResourcesMo.resourceType,
|
|
1744
|
+
onClose = _useExportResourcesMo.onClose;
|
|
1745
|
+
React__default["default"].useEffect(() => {
|
|
1746
|
+
var _context2;
|
|
1747
|
+
formik.validateForm();
|
|
1748
|
+
updateFieldDependenciesStatus(formik);
|
|
1749
|
+
const checkedFields = {};
|
|
1750
|
+
function getCheckedFields(field, groupName) {
|
|
1751
|
+
const fieldName = field.name ? `${groupName}.${field.name}` : groupName;
|
|
1752
|
+
if (field.fields) {
|
|
1753
|
+
var _context;
|
|
1754
|
+
return _forEachInstanceProperty__default["default"](_context = field.fields).call(_context, f => getCheckedFields(f, fieldName));
|
|
1755
|
+
}
|
|
1756
|
+
checkedFields[fieldName] = field.isChecked;
|
|
1757
|
+
}
|
|
1758
|
+
_forEachInstanceProperty__default["default"](_context2 = _valuesInstanceProperty__default["default"](formik).groups).call(_context2, group => {
|
|
1759
|
+
var _context3;
|
|
1760
|
+
_forEachInstanceProperty__default["default"](_context3 = group.fields).call(_context3, field => {
|
|
1761
|
+
getCheckedFields(field, group.groupName);
|
|
1762
|
+
});
|
|
1763
|
+
});
|
|
1764
|
+
setCachedSelectedGroups({
|
|
1765
|
+
[resourceType]: checkedFields
|
|
1766
|
+
});
|
|
1767
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1768
|
+
}, [_valuesInstanceProperty__default["default"](formik).groups]);
|
|
1769
|
+
// adds `isHidden` property to each field based on search term
|
|
1770
|
+
const filteredGroups = React__default["default"].useMemo(() => {
|
|
1771
|
+
const updateFields = (fields, parentMatches) => {
|
|
1772
|
+
return _mapInstanceProperty__default["default"](fields).call(fields, field => {
|
|
1773
|
+
var _context4;
|
|
1774
|
+
const matches = _includesInstanceProperty__default["default"](_context4 = field.label.toLowerCase()).call(_context4, fieldSearchTerm.toLowerCase());
|
|
1775
|
+
let isHidden = !matches && !parentMatches;
|
|
1776
|
+
if (field.fields) {
|
|
1777
|
+
const updatedFields = updateFields(field.fields, matches);
|
|
1778
|
+
isHidden = isHidden && _everyInstanceProperty__default["default"](updatedFields).call(updatedFields, f => f.isHidden);
|
|
1779
|
+
field = _objectSpread$1(_objectSpread$1({}, field), {}, {
|
|
1780
|
+
fields: updatedFields
|
|
1781
|
+
});
|
|
1782
|
+
}
|
|
1783
|
+
return _objectSpread$1(_objectSpread$1({}, field), {}, {
|
|
1784
|
+
isHidden
|
|
1785
|
+
});
|
|
1786
|
+
});
|
|
1787
|
+
};
|
|
1788
|
+
if (!fieldSearchTerm?.trim()?.length) return _valuesInstanceProperty__default["default"](formik).groups;
|
|
1789
|
+
const updateGroups = groups => {
|
|
1790
|
+
return _mapInstanceProperty__default["default"](groups).call(groups, group => {
|
|
1791
|
+
const updatedFields = updateFields(group.fields, false);
|
|
1792
|
+
const isHidden = _everyInstanceProperty__default["default"](updatedFields).call(updatedFields, field => field.isHidden);
|
|
1793
|
+
return _objectSpread$1(_objectSpread$1({}, group), {}, {
|
|
1794
|
+
fields: updatedFields,
|
|
1795
|
+
isHidden
|
|
1796
|
+
});
|
|
1797
|
+
});
|
|
1798
|
+
};
|
|
1799
|
+
return updateGroups(_valuesInstanceProperty__default["default"](formik).groups);
|
|
1800
|
+
}, [_valuesInstanceProperty__default["default"](formik).groups, fieldSearchTerm]);
|
|
1801
|
+
const onSearchChange = React__default["default"].useCallback(event => {
|
|
1802
|
+
setFieldSearchTerm(event.target.value);
|
|
1803
|
+
}, [setFieldSearchTerm]);
|
|
1804
|
+
const hasResults = Boolean(_findInstanceProperty__default["default"](filteredGroups).call(filteredGroups, group => !group.isHidden));
|
|
1805
|
+
const onSearchChangeThrottled = React__default["default"].useMemo(() => throttle__default["default"](onSearchChange, 300), [onSearchChange]);
|
|
1806
|
+
const onSearchReset = () => {
|
|
1807
|
+
setFieldSearchTerm('');
|
|
1808
|
+
};
|
|
1809
|
+
return jsxRuntime.jsx(applicationComponents.FormDialog, {
|
|
1810
|
+
isOpen: true,
|
|
1811
|
+
title: intl.formatMessage(messages.selectFieldsToExport),
|
|
1812
|
+
labelPrimary: intl.formatMessage(messages.startExport),
|
|
1813
|
+
onPrimaryButtonClick: formik.submitForm,
|
|
1814
|
+
isPrimaryButtonDisabled: !formik.isValid,
|
|
1815
|
+
labelSecondary: intl.formatMessage(messages.back),
|
|
1816
|
+
onSecondaryButtonClick: () => setCurrentStep(Step.FileSettings),
|
|
1817
|
+
onClose: onClose,
|
|
1818
|
+
size: 16,
|
|
1819
|
+
dataAttributesPrimaryButton: {
|
|
1820
|
+
'data-tracking-target': `${resourceType}_export-start_export_button`
|
|
1821
|
+
},
|
|
1822
|
+
children: jsxRuntime.jsx(fullstory.Masking.Unmask, {
|
|
1823
|
+
children: jsxRuntime.jsx(ExportFieldSelectionProvider, {
|
|
1824
|
+
resourceType: resourceType,
|
|
1825
|
+
children: jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
1826
|
+
scale: "m",
|
|
1827
|
+
children: [jsxRuntime.jsx(uiKit.SearchTextInput, {
|
|
1828
|
+
placeholder: intl.formatMessage(messages.searchForFields),
|
|
1829
|
+
value: fieldSearchTerm,
|
|
1830
|
+
onChange: onSearchChangeThrottled,
|
|
1831
|
+
onReset: onSearchReset
|
|
1832
|
+
// TODO: `SearchTextInput` props to be improved. The `onSubmit` callback shouldn't be mandatory
|
|
1833
|
+
,
|
|
1834
|
+
onSubmit: () => {},
|
|
1835
|
+
id: "export-fields-search"
|
|
1836
|
+
}), hasResults ? jsxRuntime.jsx(StyledGridCard, {
|
|
1837
|
+
insetScale: "none",
|
|
1838
|
+
children: jsxRuntime.jsx(uiKit.Grid, {
|
|
1839
|
+
gridAutoFlow: "row",
|
|
1840
|
+
gridTemplateColumns: `calc(${uiKit.designTokens.spacingL} + ${uiKit.designTokens.constraint5} + ${uiKit.designTokens.spacingL}) auto`,
|
|
1841
|
+
children: _mapInstanceProperty__default["default"](filteredGroups).call(filteredGroups, (group, index) => jsxRuntime.jsx(FieldGroupSection, {
|
|
1842
|
+
group: group,
|
|
1843
|
+
index: index,
|
|
1844
|
+
formik: formik,
|
|
1845
|
+
isForceExpanded: fieldSearchTerm?.trim()?.length > 0
|
|
1846
|
+
}, group.groupName))
|
|
1847
|
+
})
|
|
1848
|
+
}) : jsxRuntime.jsx(NoSearchResults, {})]
|
|
1849
|
+
})
|
|
1850
|
+
})
|
|
1851
|
+
})
|
|
1852
|
+
});
|
|
1853
|
+
};
|
|
1854
|
+
|
|
1855
|
+
const ExportResourcesContext = /*#__PURE__*/React.createContext();
|
|
1856
|
+
|
|
1857
|
+
const _excluded$1 = ["children"];
|
|
1858
|
+
const ExportResourcesProvider = _ref => {
|
|
1859
|
+
let children = _ref.children,
|
|
1860
|
+
props = _objectWithoutProperties(_ref, _excluded$1);
|
|
1861
|
+
const initialValues = useInitialValues(props);
|
|
1862
|
+
const _React$useState = React__default["default"].useState(Step.FileSettings),
|
|
1863
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
1864
|
+
currentStep = _React$useState2[0],
|
|
1865
|
+
setCurrentStep = _React$useState2[1];
|
|
1866
|
+
const _React$useState3 = React__default["default"].useState(() => getInitialExportType({
|
|
1867
|
+
selectedResourceIds: props.selectedResourceIds,
|
|
1868
|
+
filters: props.filters
|
|
1869
|
+
})),
|
|
1870
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
1871
|
+
exportType = _React$useState4[0],
|
|
1872
|
+
setExportType = _React$useState4[1];
|
|
1873
|
+
const _useStartExportOperat = useStartExportOperation(props),
|
|
1874
|
+
startExportOperation = _useStartExportOperat.startExportOperation;
|
|
1875
|
+
const onSubmit = async values => {
|
|
1876
|
+
if (currentStep === Step.FileSettings) {
|
|
1877
|
+
setCurrentStep(Step.FieldsSelection);
|
|
1878
|
+
} else {
|
|
1879
|
+
startExportOperation(values, exportType);
|
|
1880
|
+
}
|
|
1881
|
+
};
|
|
1882
|
+
const formik$1 = formik.useFormik({
|
|
1883
|
+
initialValues,
|
|
1884
|
+
validate: values => validate({
|
|
1885
|
+
values,
|
|
1886
|
+
step: currentStep
|
|
1887
|
+
}),
|
|
1888
|
+
onSubmit
|
|
1889
|
+
});
|
|
1890
|
+
React__default["default"].useEffect(() => {
|
|
1891
|
+
formik$1.validateForm();
|
|
1892
|
+
}, [currentStep]);
|
|
1893
|
+
return jsxRuntime.jsx(ExportResourcesContext.Provider, {
|
|
1894
|
+
value: {
|
|
1895
|
+
formik: formik$1,
|
|
1896
|
+
currentStep,
|
|
1897
|
+
setCurrentStep,
|
|
1898
|
+
onClose: props.onClose,
|
|
1899
|
+
resourceType: props.resourceType,
|
|
1900
|
+
exportType: exportType,
|
|
1901
|
+
totalResourcesCount: props.totalResourcesCount,
|
|
1902
|
+
selectedResourceIds: props.selectedResourceIds,
|
|
1903
|
+
hideExportSelectedResourcesOption: props.hideExportSelectedResourcesOption,
|
|
1904
|
+
filters: props.filters,
|
|
1905
|
+
hasFilters: areFiltersApplied(props.filters),
|
|
1906
|
+
setExportType
|
|
1907
|
+
},
|
|
1908
|
+
children: children
|
|
1909
|
+
});
|
|
1910
|
+
};
|
|
1911
|
+
|
|
1912
|
+
const CurrentStep = () => {
|
|
1913
|
+
const _useExportResourcesMo = useExportResourcesModalContext(),
|
|
1914
|
+
currentStep = _useExportResourcesMo.currentStep;
|
|
1915
|
+
const steps = {
|
|
1916
|
+
'file-settings': jsxRuntime.jsx(ExportFileSettingsStep, {}),
|
|
1917
|
+
'fields-selection': jsxRuntime.jsx(ExportFieldsSelectionStep, {})
|
|
1918
|
+
};
|
|
1919
|
+
return steps[currentStep] || null;
|
|
1920
|
+
};
|
|
1921
|
+
|
|
1922
|
+
const getChunkImport = locale => {
|
|
1923
|
+
const intlLocale = i18n.mapLocaleToIntlLocale(locale);
|
|
1924
|
+
switch (intlLocale) {
|
|
1925
|
+
case 'de':
|
|
1926
|
+
return Promise.resolve().then(function () { return require(/* webpackChunkName: "export-resources-modal-i18n-de" */'./de-3d4cf3d0.cjs.prod.js'); });
|
|
1927
|
+
case 'es':
|
|
1928
|
+
return Promise.resolve().then(function () { return require(/* webpackChunkName: "export-resources-modal-i18n-es" */'./es-6360d546.cjs.prod.js'); });
|
|
1929
|
+
case 'fr-FR':
|
|
1930
|
+
return Promise.resolve().then(function () { return require(/* webpackChunkName: "export-resources-modal-i18n-fr-FR" */'./fr-FR-ff7ec057.cjs.prod.js'); });
|
|
1931
|
+
case 'ja':
|
|
1932
|
+
return Promise.resolve().then(function () { return require(/* webpackChunkName: "export-resources-modal-i18n-ja" */'./ja-37632763.cjs.prod.js'); });
|
|
1933
|
+
case 'pt-BR':
|
|
1934
|
+
return Promise.resolve().then(function () { return require(/* webpackChunkName: "change-history-i18n-pt-BR" */'./pt-BR-d9b0a36d.cjs.prod.js'); });
|
|
1935
|
+
default:
|
|
1936
|
+
return Promise.resolve().then(function () { return require(/* webpackChunkName: "export-resources-modal-i18n-en" */'./en-fc0085cc.cjs.prod.js'); });
|
|
1937
|
+
}
|
|
1938
|
+
};
|
|
1939
|
+
const loadMessages = async locale => {
|
|
1940
|
+
try {
|
|
1941
|
+
const chunkImport = await getChunkImport(locale);
|
|
1942
|
+
return i18n.parseChunkImport(chunkImport);
|
|
1943
|
+
} catch (error) {
|
|
1944
|
+
// eslint-disable-next-line no-console
|
|
1945
|
+
console.warn(`Something went wrong while loading the export-resources-modal messages for ${locale}`, error);
|
|
1946
|
+
sentry.reportErrorToSentry(new Error(`Something went wrong while loading the export-resources-modal messages for ${locale}`), {
|
|
1947
|
+
extra: error
|
|
1948
|
+
});
|
|
1949
|
+
return {};
|
|
1950
|
+
}
|
|
1951
|
+
};
|
|
1952
|
+
|
|
1953
|
+
const useAsyncIntlMessages = (locale, loader) => {
|
|
1954
|
+
const _useState = React.useState({
|
|
1955
|
+
isLoading: true,
|
|
1956
|
+
messages: undefined,
|
|
1957
|
+
error: undefined
|
|
1958
|
+
}),
|
|
1959
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1960
|
+
state = _useState2[0],
|
|
1961
|
+
setState = _useState2[1];
|
|
1962
|
+
React.useEffect(() => {
|
|
1963
|
+
let _isUnmounting = false;
|
|
1964
|
+
async function load() {
|
|
1965
|
+
try {
|
|
1966
|
+
if (!_isUnmounting) {
|
|
1967
|
+
const messages = await loader(locale);
|
|
1968
|
+
setState({
|
|
1969
|
+
isLoading: false,
|
|
1970
|
+
messages
|
|
1971
|
+
});
|
|
1972
|
+
}
|
|
1973
|
+
} catch (error) {
|
|
1974
|
+
setState({
|
|
1975
|
+
isLoading: false,
|
|
1976
|
+
error
|
|
1977
|
+
});
|
|
1978
|
+
}
|
|
1979
|
+
}
|
|
1980
|
+
if (locale) load();
|
|
1981
|
+
return () => {
|
|
1982
|
+
_isUnmounting = true;
|
|
1983
|
+
};
|
|
1984
|
+
}, [locale, loader]);
|
|
1985
|
+
return state;
|
|
1986
|
+
};
|
|
1987
|
+
|
|
1988
|
+
const _excluded = ["isOpen", "selectedResourceIds", "outputFormat", "fieldGroups", "fieldOrder"];
|
|
1989
|
+
function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1990
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
1991
|
+
function invalidateLaunchDarklyCachedFeatureFlag(flagName) {
|
|
1992
|
+
for (let _ref of _Object$entries__default["default"](localStorage)) {
|
|
1993
|
+
var _ref2 = _slicedToArray(_ref, 1);
|
|
1994
|
+
let key = _ref2[0];
|
|
1995
|
+
// This is the pattern that the LaunchDarkly adapter uses to store the flags
|
|
1996
|
+
if (_startsWithInstanceProperty__default["default"](key).call(key, '@flopflip/launchdarkly-adapter/') && _endsWithInstanceProperty__default["default"](key).call(key, '/flags')) {
|
|
1997
|
+
try {
|
|
1998
|
+
const flags = JSON.parse(localStorage.getItem(key) || '{}');
|
|
1999
|
+
if (flags[flagName] !== undefined) {
|
|
2000
|
+
delete flags[flagName];
|
|
2001
|
+
localStorage.setItem(key, _JSON$stringify__default["default"](flags));
|
|
2002
|
+
}
|
|
2003
|
+
} catch (error) {}
|
|
2004
|
+
}
|
|
2005
|
+
}
|
|
2006
|
+
}
|
|
2007
|
+
invalidateLaunchDarklyCachedFeatureFlag('enableOperationsExport');
|
|
2008
|
+
const ExportResourcesModal = _ref3 => {
|
|
2009
|
+
let _ref3$isOpen = _ref3.isOpen,
|
|
2010
|
+
isOpen = _ref3$isOpen === void 0 ? false : _ref3$isOpen,
|
|
2011
|
+
_ref3$selectedResourc = _ref3.selectedResourceIds,
|
|
2012
|
+
selectedResourceIds = _ref3$selectedResourc === void 0 ? [] : _ref3$selectedResourc,
|
|
2013
|
+
_ref3$outputFormat = _ref3.outputFormat,
|
|
2014
|
+
outputFormat = _ref3$outputFormat === void 0 ? OUTPUT_FORMATS.CSV : _ref3$outputFormat,
|
|
2015
|
+
_ref3$fieldGroups = _ref3.fieldGroups,
|
|
2016
|
+
fieldGroups = _ref3$fieldGroups === void 0 ? [] : _ref3$fieldGroups,
|
|
2017
|
+
_ref3$fieldOrder = _ref3.fieldOrder,
|
|
2018
|
+
fieldOrder = _ref3$fieldOrder === void 0 ? [] : _ref3$fieldOrder,
|
|
2019
|
+
props = _objectWithoutProperties(_ref3, _excluded);
|
|
2020
|
+
const _useApplicationContex = applicationShellConnectors.useApplicationContext(context => ({
|
|
2021
|
+
locale: context.user && context.user.locale
|
|
2022
|
+
})),
|
|
2023
|
+
locale = _useApplicationContex.locale;
|
|
2024
|
+
const messages = useAsyncIntlMessages(locale, loadMessages);
|
|
2025
|
+
if (!isOpen || messages.isLoading) return null;
|
|
2026
|
+
if (props.filters && !validateFilters(props.filters)) {
|
|
2027
|
+
console.error('Invalid filters prop:', props.filters, 'Filters must contain one of these values: `filters` or `where`');
|
|
2028
|
+
return null;
|
|
2029
|
+
}
|
|
2030
|
+
return jsxRuntime.jsx(reactIntl.IntlProvider, {
|
|
2031
|
+
locale: locale,
|
|
2032
|
+
messages: messages.messages,
|
|
2033
|
+
children: jsxRuntime.jsx(ExportResourcesProvider, _objectSpread(_objectSpread({
|
|
2034
|
+
fieldGroups: fieldGroups,
|
|
2035
|
+
fieldOrder: fieldOrder,
|
|
2036
|
+
isOpen: isOpen,
|
|
2037
|
+
outputFormat: outputFormat,
|
|
2038
|
+
selectedResourceIds: selectedResourceIds
|
|
2039
|
+
}, props), {}, {
|
|
2040
|
+
children: jsxRuntime.jsx(CurrentStep, {})
|
|
2041
|
+
}))
|
|
2042
|
+
});
|
|
2043
|
+
};
|
|
2044
|
+
ExportResourcesModal.displayName = 'ExportResourcesModal';
|
|
2045
|
+
|
|
2046
|
+
exports.EXPORTABLE_RESOURCES = EXPORTABLE_RESOURCES;
|
|
2047
|
+
exports.EXPORT_TYPES = EXPORT_TYPES;
|
|
2048
|
+
exports.Step = Step;
|
|
2049
|
+
exports["default"] = ExportResourcesModal;
|
|
2050
|
+
exports.useConvertFieldDefinitionsForExport = useConvertFieldDefinitionsForExport;
|