@commercetools-frontend-extensions/export-resources-modal 5.0.4 → 5.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{active-drag-drop-area-677cd139.cjs.prod.js → active-drag-drop-area-20a66ce6.cjs.prod.js} +1 -1
- package/dist/{active-drag-drop-area-ab3d5305.cjs.dev.js → active-drag-drop-area-364cae94.cjs.dev.js} +1 -1
- package/dist/{active-drag-drop-area-d0b34d8c.esm.js → active-drag-drop-area-418bdbf4.esm.js} +1 -1
- package/dist/commercetools-frontend-extensions-export-resources-modal.cjs.dev.js +1 -1
- package/dist/commercetools-frontend-extensions-export-resources-modal.cjs.prod.js +1 -1
- package/dist/commercetools-frontend-extensions-export-resources-modal.esm.js +1 -1
- package/dist/declarations/src/@constants/export-types.d.ts +4 -3
- package/dist/declarations/src/@hooks/index.d.ts +1 -1
- package/dist/declarations/src/@hooks/use-validate-export-operation.d.ts +33 -0
- package/dist/declarations/src/@types/export-api.d.ts +5 -1
- package/dist/declarations/src/@types/export-resources-modal-context.d.ts +1 -0
- package/dist/declarations/src/@types/export-resources-modal-types.d.ts +2 -1
- package/dist/declarations/src/@types/form.d.ts +5 -0
- package/dist/{enabled-drop-area-049033dc.cjs.prod.js → enabled-drop-area-93b7de32.cjs.prod.js} +1 -1
- package/dist/{enabled-drop-area-3ac1d564.esm.js → enabled-drop-area-aed3e03e.esm.js} +1 -1
- package/dist/{enabled-drop-area-76b49e4a.cjs.dev.js → enabled-drop-area-d120c17d.cjs.dev.js} +1 -1
- package/dist/{file-dropped-area-997435fa.esm.js → file-dropped-area-06a60bda.esm.js} +1 -1
- package/dist/{file-dropped-area-d2df8c70.cjs.prod.js → file-dropped-area-d6e47d57.cjs.prod.js} +1 -1
- package/dist/{file-dropped-area-44d101c3.cjs.dev.js → file-dropped-area-e45600e0.cjs.dev.js} +1 -1
- package/dist/{index-969519bd.esm.js → index-1619b654.esm.js} +361 -257
- package/dist/{index-1d25c6f7.cjs.prod.js → index-1cb3087e.cjs.prod.js} +360 -256
- package/dist/{index-e4706b61.cjs.dev.js → index-deb5c3f9.cjs.dev.js} +360 -256
- package/package.json +1 -1
- package/dist/declarations/src/@hooks/use-validate-imported-headers.d.ts +0 -15
|
@@ -15,7 +15,7 @@ import _Object$defineProperties from '@babel/runtime-corejs3/core-js-stable/obje
|
|
|
15
15
|
import _Object$defineProperty from '@babel/runtime-corejs3/core-js-stable/object/define-property';
|
|
16
16
|
import { defineMessages, FormattedMessage, useIntl, IntlProvider } from 'react-intl';
|
|
17
17
|
import { useApplicationContext } from '@commercetools-frontend/application-shell-connectors';
|
|
18
|
-
import { Text,
|
|
18
|
+
import { Text, Link, TextInput, CheckboxInput, RadioInput, TextField, AngleRightIcon, Spacings, Grid, designTokens, SelectField, FieldLabel, Constraints, Tooltip, SupportIcon, Stamp, IconButton, AngleDownIcon, CollapsibleMotion, Card, SearchTextInput, TagList, FlatButton, AngleUpIcon, CheckBoldIcon, DataTable } from '@commercetools-frontend/ui-kit';
|
|
19
19
|
import { jsx, Fragment, jsxs } from '@emotion/react/jsx-runtime';
|
|
20
20
|
import _includesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/includes';
|
|
21
21
|
import _valuesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/values';
|
|
@@ -581,6 +581,26 @@ var messages = defineMessages({
|
|
|
581
581
|
id: 'ExportResourcesModal.uploadErrorsDetected',
|
|
582
582
|
description: 'Message shown when errors are detected during file upload',
|
|
583
583
|
defaultMessage: 'There are <b>{total}</b> errors detected while uploading the file <b>{fileName}</b>. Use <templateLink>our template</templateLink> to review the right formatting and supported values, try exporting using our field selection first or visit <documentationLink>our documentation</documentationLink> for further information.'
|
|
584
|
+
},
|
|
585
|
+
queryPredicate: {
|
|
586
|
+
id: 'ExportResourcesModal.queryPredicate',
|
|
587
|
+
description: 'Label for query predicate option',
|
|
588
|
+
defaultMessage: 'Query predicate'
|
|
589
|
+
},
|
|
590
|
+
invalidQueryPredicate: {
|
|
591
|
+
id: 'ExportResourcesModal.invalidQueryPredicate',
|
|
592
|
+
description: 'Error when query predicate field is not valid',
|
|
593
|
+
defaultMessage: 'There is an error with the query predicate. Make sure the syntax is correct.'
|
|
594
|
+
},
|
|
595
|
+
missingQueryPredicateError: {
|
|
596
|
+
id: 'ExportResourcesModal.missingQueryPredicateError',
|
|
597
|
+
description: 'Error when query predicate field is missing',
|
|
598
|
+
defaultMessage: 'Please enter a query predicate'
|
|
599
|
+
},
|
|
600
|
+
noResourcesToExportForQueryPredicate: {
|
|
601
|
+
id: 'ExportResourcesModal.noResourcesToExportForQueryPredicate',
|
|
602
|
+
description: 'Error message when there are no resources to export for given query predicate',
|
|
603
|
+
defaultMessage: 'No resources match your query predicate. Please check your query predicate and try again.'
|
|
584
604
|
}
|
|
585
605
|
});
|
|
586
606
|
|
|
@@ -604,6 +624,18 @@ function renderLocaleError(key) {
|
|
|
604
624
|
return null;
|
|
605
625
|
}
|
|
606
626
|
}
|
|
627
|
+
const renderQueryPredicateError = key => {
|
|
628
|
+
switch (key) {
|
|
629
|
+
case 'missing':
|
|
630
|
+
return jsx(FormattedMessage, _objectSpread$h({}, messages.missingQueryPredicateError));
|
|
631
|
+
case 'invalidInput':
|
|
632
|
+
return jsx(FormattedMessage, _objectSpread$h({}, messages.invalidQueryPredicate));
|
|
633
|
+
case 'noResourcesToExportForQueryPredicate':
|
|
634
|
+
return jsx(FormattedMessage, _objectSpread$h({}, messages.noResourcesToExportForQueryPredicate));
|
|
635
|
+
default:
|
|
636
|
+
return null;
|
|
637
|
+
}
|
|
638
|
+
};
|
|
607
639
|
|
|
608
640
|
function _callSuper$3(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct$3() ? _Reflect$construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
609
641
|
function _isNativeReflectConstruct$3() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$3 = function () { return !!t; })(); }
|
|
@@ -748,7 +780,8 @@ const EXPORT_OPERATION_STATES = {
|
|
|
748
780
|
const EXPORT_TYPES = {
|
|
749
781
|
ALL: 'all',
|
|
750
782
|
FILTERED: 'filtered',
|
|
751
|
-
SELECTED: 'selected'
|
|
783
|
+
SELECTED: 'selected',
|
|
784
|
+
QUERY_PREDICATE: 'query-predicate'
|
|
752
785
|
};
|
|
753
786
|
|
|
754
787
|
const EXPORTABLE_RESOURCES = {
|
|
@@ -825,6 +858,140 @@ const DEFAULT_SHORT_LIVED_FLAGS = {};
|
|
|
825
858
|
const DEFAULT_LONG_LIVED_FLAGS = {};
|
|
826
859
|
_objectSpread$f(_objectSpread$f({}, DEFAULT_SHORT_LIVED_FLAGS), DEFAULT_LONG_LIVED_FLAGS);
|
|
827
860
|
|
|
861
|
+
function resourceTypeToFileName(resourceType, locale) {
|
|
862
|
+
var _context;
|
|
863
|
+
const date = new Date();
|
|
864
|
+
const dateFormatter = new Intl.DateTimeFormat(locale, {
|
|
865
|
+
year: '2-digit',
|
|
866
|
+
month: '2-digit',
|
|
867
|
+
day: '2-digit',
|
|
868
|
+
hour: '2-digit',
|
|
869
|
+
minute: '2-digit',
|
|
870
|
+
hour12: false
|
|
871
|
+
});
|
|
872
|
+
const parts = dateFormatter.formatToParts(date);
|
|
873
|
+
const dateParts = _reduceInstanceProperty(parts).call(parts, (acc, part) => {
|
|
874
|
+
if (part.type !== 'literal') {
|
|
875
|
+
acc[part.type] = part.value;
|
|
876
|
+
}
|
|
877
|
+
return acc;
|
|
878
|
+
}, {});
|
|
879
|
+
const orderedDateParts = _mapInstanceProperty(_context = _filterInstanceProperty(parts).call(parts, part => part.type === 'day' || part.type === 'month' || part.type === 'year')).call(_context, part => dateParts[part.type]).join('-');
|
|
880
|
+
const formattedDate = `${orderedDateParts}_${dateParts.hour}-${dateParts.minute}`;
|
|
881
|
+
const resourceTypeMap = {
|
|
882
|
+
[EXPORTABLE_RESOURCES.CATEGORY]: 'Categories',
|
|
883
|
+
[EXPORTABLE_RESOURCES.PRODUCT]: 'Products',
|
|
884
|
+
[EXPORTABLE_RESOURCES.PRODUCT_TYPE]: 'Product_Types',
|
|
885
|
+
[EXPORTABLE_RESOURCES.DISCOUNT_CODE]: 'Discount_Codes',
|
|
886
|
+
[EXPORTABLE_RESOURCES.INVENTORY_ENTRY]: 'Inventories',
|
|
887
|
+
[EXPORTABLE_RESOURCES.CUSTOMER]: 'Customers',
|
|
888
|
+
[EXPORTABLE_RESOURCES.ORDER]: 'Orders'
|
|
889
|
+
};
|
|
890
|
+
const displayName = resourceTypeMap[resourceType];
|
|
891
|
+
if (!displayName) {
|
|
892
|
+
throw new UnexpectedResourceTypeError(resourceType);
|
|
893
|
+
}
|
|
894
|
+
return `${displayName}_Export_${formattedDate}`;
|
|
895
|
+
}
|
|
896
|
+
function mapLocalesToOptions(locales) {
|
|
897
|
+
return _mapInstanceProperty(locales).call(locales, locale => ({
|
|
898
|
+
value: locale,
|
|
899
|
+
label: locale
|
|
900
|
+
}));
|
|
901
|
+
}
|
|
902
|
+
function isFilledArray(maybeArray) {
|
|
903
|
+
return _Array$isArray(maybeArray) && maybeArray.length > 0;
|
|
904
|
+
}
|
|
905
|
+
function appendCsvOrJsonExtensionIfAbsent(fileName, fileFormat) {
|
|
906
|
+
const extensionRegex = /\.(csv|json)$/i;
|
|
907
|
+
if (!extensionRegex.test(fileName)) return `${fileName}.${fileFormat}`;
|
|
908
|
+
return fileName;
|
|
909
|
+
}
|
|
910
|
+
function getExportLogsLink(projectKey, msg) {
|
|
911
|
+
return jsx(Link, {
|
|
912
|
+
to: `/${projectKey}/operations/export/logs`,
|
|
913
|
+
children: msg
|
|
914
|
+
}, "link");
|
|
915
|
+
}
|
|
916
|
+
const extractFieldNamesAndAdditionalFieldExtensions = fields => {
|
|
917
|
+
const result = _reduceInstanceProperty(fields).call(fields, (acc, field) => {
|
|
918
|
+
if (field.extendedFieldNames) {
|
|
919
|
+
return [...acc, field.name, ...field.extendedFieldNames];
|
|
920
|
+
}
|
|
921
|
+
return [...acc, field.name];
|
|
922
|
+
}, []);
|
|
923
|
+
return [...new _Set(result)];
|
|
924
|
+
};
|
|
925
|
+
function sortFieldsByFieldOrder(_ref) {
|
|
926
|
+
let fieldNames = _ref.fieldNames,
|
|
927
|
+
fieldOrder = _ref.fieldOrder;
|
|
928
|
+
if (isFilledArray(fieldOrder)) {
|
|
929
|
+
return _sortInstanceProperty(fieldNames).call(fieldNames, (a, b) => {
|
|
930
|
+
let orderA = _indexOfInstanceProperty(fieldOrder).call(fieldOrder, a) !== -1 ? _indexOfInstanceProperty(fieldOrder).call(fieldOrder, a) : _indexOfInstanceProperty(fieldOrder).call(fieldOrder, a.split('.')[0]);
|
|
931
|
+
let orderB = _indexOfInstanceProperty(fieldOrder).call(fieldOrder, b) !== -1 ? _indexOfInstanceProperty(fieldOrder).call(fieldOrder, b) : _indexOfInstanceProperty(fieldOrder).call(fieldOrder, b.split('.')[0]);
|
|
932
|
+
|
|
933
|
+
// If a field is not 'custom',then consider it as '*'
|
|
934
|
+
orderA = orderA === -1 ? _indexOfInstanceProperty(fieldOrder).call(fieldOrder, '*') : orderA;
|
|
935
|
+
orderB = orderB === -1 ? _indexOfInstanceProperty(fieldOrder).call(fieldOrder, '*') : orderB;
|
|
936
|
+
return orderA - orderB;
|
|
937
|
+
});
|
|
938
|
+
}
|
|
939
|
+
return fieldNames;
|
|
940
|
+
}
|
|
941
|
+
function buildSelectedExportFilters(selectedResourceIds) {
|
|
942
|
+
if (!selectedResourceIds || selectedResourceIds?.length === 0) return undefined;
|
|
943
|
+
const formattedIds = _mapInstanceProperty(selectedResourceIds).call(selectedResourceIds, id => `"${id}"`).join(', ');
|
|
944
|
+
return `id in (${formattedIds})`;
|
|
945
|
+
}
|
|
946
|
+
function isQueryFilter(filters) {
|
|
947
|
+
if (!filters) return false;
|
|
948
|
+
return 'query' in filters;
|
|
949
|
+
}
|
|
950
|
+
function isSearchFilter(filters) {
|
|
951
|
+
if (!filters) return false;
|
|
952
|
+
return 'filters' in filters || 'fullText' in filters;
|
|
953
|
+
}
|
|
954
|
+
function isPredicateFilter(filters) {
|
|
955
|
+
if (!filters) return false;
|
|
956
|
+
return 'where' in filters;
|
|
957
|
+
}
|
|
958
|
+
function validateFilters(filtersObject) {
|
|
959
|
+
if (filtersObject.where && filtersObject.filters) {
|
|
960
|
+
return false;
|
|
961
|
+
}
|
|
962
|
+
return Boolean(isQueryFilter(filtersObject.filters) || isSearchFilter(filtersObject.filters) || isPredicateFilter(filtersObject));
|
|
963
|
+
}
|
|
964
|
+
function areFiltersApplied(filtersObject) {
|
|
965
|
+
var _context2;
|
|
966
|
+
if (!filtersObject) {
|
|
967
|
+
return false;
|
|
968
|
+
}
|
|
969
|
+
if (filtersObject.where && _trimInstanceProperty(_context2 = filtersObject.where).call(_context2) !== '') {
|
|
970
|
+
return true;
|
|
971
|
+
}
|
|
972
|
+
if (isQueryFilter(filtersObject.filters)) {
|
|
973
|
+
return Boolean(filtersObject.filters.query);
|
|
974
|
+
}
|
|
975
|
+
if (isSearchFilter(filtersObject.filters)) {
|
|
976
|
+
var _context3, _context4;
|
|
977
|
+
const _filters = filtersObject.filters;
|
|
978
|
+
return Boolean(_filters.filters?.length || ((_context3 = _filters.fullText?.text) == null ? void 0 : _bindInstanceProperty(_context4 = Function.call).call(_context4, _trimInstanceProperty(_context3), _context3))?.());
|
|
979
|
+
}
|
|
980
|
+
return false;
|
|
981
|
+
}
|
|
982
|
+
function getInitialExportType(args) {
|
|
983
|
+
if (args.selectedResourceIds?.length) {
|
|
984
|
+
return EXPORT_TYPES.SELECTED;
|
|
985
|
+
}
|
|
986
|
+
if (args.filters?.total && areFiltersApplied(args.filters)) {
|
|
987
|
+
return EXPORT_TYPES.FILTERED;
|
|
988
|
+
}
|
|
989
|
+
return EXPORT_TYPES.ALL;
|
|
990
|
+
}
|
|
991
|
+
function removeEmptyGroups(groups) {
|
|
992
|
+
return _filterInstanceProperty(groups).call(groups, group => group.fields && group.fields.length > 0);
|
|
993
|
+
}
|
|
994
|
+
|
|
828
995
|
const isAnyFieldChecked = fields => {
|
|
829
996
|
return _someInstanceProperty(fields).call(fields, field => field.isChecked || field.fields && isAnyFieldChecked(field.fields));
|
|
830
997
|
};
|
|
@@ -938,6 +1105,25 @@ const getSelectedFieldLabels = group => {
|
|
|
938
1105
|
findSelectedFieldLabels(group.fields);
|
|
939
1106
|
return selectedLabels;
|
|
940
1107
|
};
|
|
1108
|
+
const extractFieldNamesFromGroups = (groups, fieldOrder) => {
|
|
1109
|
+
let checkedFields = [];
|
|
1110
|
+
const getCheckedFields = fields => {
|
|
1111
|
+
return _filterInstanceProperty(fields).call(fields, field => {
|
|
1112
|
+
if (field.fields) {
|
|
1113
|
+
return getCheckedFields(field.fields);
|
|
1114
|
+
}
|
|
1115
|
+
if (field.isChecked) checkedFields.push(field);
|
|
1116
|
+
return field.isChecked ?? false;
|
|
1117
|
+
});
|
|
1118
|
+
};
|
|
1119
|
+
_forEachInstanceProperty(groups).call(groups, group => {
|
|
1120
|
+
getCheckedFields(group.fields);
|
|
1121
|
+
});
|
|
1122
|
+
return sortFieldsByFieldOrder({
|
|
1123
|
+
fieldNames: extractFieldNamesAndAdditionalFieldExtensions(checkedFields),
|
|
1124
|
+
fieldOrder
|
|
1125
|
+
});
|
|
1126
|
+
};
|
|
941
1127
|
|
|
942
1128
|
let Step = /*#__PURE__*/function (Step) {
|
|
943
1129
|
Step["FileSettings"] = "file-settings";
|
|
@@ -958,21 +1144,27 @@ function validate(_ref) {
|
|
|
958
1144
|
let values = _valuesInstanceProperty(_ref),
|
|
959
1145
|
step = _ref.step,
|
|
960
1146
|
fieldSelectionMode = _ref.fieldSelectionMode,
|
|
961
|
-
importedHeaders = _ref.importedHeaders
|
|
1147
|
+
importedHeaders = _ref.importedHeaders,
|
|
1148
|
+
exportType = _ref.exportType;
|
|
962
1149
|
const fileName = values.fileName,
|
|
1150
|
+
queryPredicate = values.queryPredicate,
|
|
963
1151
|
locales = values.locales,
|
|
964
1152
|
groups = values.groups;
|
|
965
1153
|
const errors = {
|
|
966
1154
|
fileName: {},
|
|
967
1155
|
locales: {},
|
|
968
1156
|
fields: {},
|
|
969
|
-
importedCsvTemplateFile: {}
|
|
1157
|
+
importedCsvTemplateFile: {},
|
|
1158
|
+
queryPredicate: {}
|
|
970
1159
|
};
|
|
971
1160
|
if (TextInput.isEmpty(fileName)) {
|
|
972
1161
|
errors.fileName.missing = true;
|
|
973
1162
|
} else if (!/^[a-zA-Z0-9-_.]+$/.test(fileName)) {
|
|
974
1163
|
errors.fileName.invalidInput = true;
|
|
975
1164
|
}
|
|
1165
|
+
if (exportType === 'query-predicate' && TextInput.isEmpty(queryPredicate)) {
|
|
1166
|
+
errors.queryPredicate.missing = true;
|
|
1167
|
+
}
|
|
976
1168
|
if (step === Step.FieldsSelection) {
|
|
977
1169
|
if (fieldSelectionMode === 'selected-fields') {
|
|
978
1170
|
const allFields = _reduceInstanceProperty(groups).call(groups, (acc, group) => _concatInstanceProperty(acc).call(acc, group.fields), []);
|
|
@@ -1002,140 +1194,6 @@ function isFieldNameValid(header) {
|
|
|
1002
1194
|
return /^[a-zA-Z0-9._-]+$/.test(processedHeader);
|
|
1003
1195
|
}
|
|
1004
1196
|
|
|
1005
|
-
function resourceTypeToFileName(resourceType, locale) {
|
|
1006
|
-
var _context;
|
|
1007
|
-
const date = new Date();
|
|
1008
|
-
const dateFormatter = new Intl.DateTimeFormat(locale, {
|
|
1009
|
-
year: '2-digit',
|
|
1010
|
-
month: '2-digit',
|
|
1011
|
-
day: '2-digit',
|
|
1012
|
-
hour: '2-digit',
|
|
1013
|
-
minute: '2-digit',
|
|
1014
|
-
hour12: false
|
|
1015
|
-
});
|
|
1016
|
-
const parts = dateFormatter.formatToParts(date);
|
|
1017
|
-
const dateParts = _reduceInstanceProperty(parts).call(parts, (acc, part) => {
|
|
1018
|
-
if (part.type !== 'literal') {
|
|
1019
|
-
acc[part.type] = part.value;
|
|
1020
|
-
}
|
|
1021
|
-
return acc;
|
|
1022
|
-
}, {});
|
|
1023
|
-
const orderedDateParts = _mapInstanceProperty(_context = _filterInstanceProperty(parts).call(parts, part => part.type === 'day' || part.type === 'month' || part.type === 'year')).call(_context, part => dateParts[part.type]).join('-');
|
|
1024
|
-
const formattedDate = `${orderedDateParts}_${dateParts.hour}-${dateParts.minute}`;
|
|
1025
|
-
const resourceTypeMap = {
|
|
1026
|
-
[EXPORTABLE_RESOURCES.CATEGORY]: 'Categories',
|
|
1027
|
-
[EXPORTABLE_RESOURCES.PRODUCT]: 'Products',
|
|
1028
|
-
[EXPORTABLE_RESOURCES.PRODUCT_TYPE]: 'Product_Types',
|
|
1029
|
-
[EXPORTABLE_RESOURCES.DISCOUNT_CODE]: 'Discount_Codes',
|
|
1030
|
-
[EXPORTABLE_RESOURCES.INVENTORY_ENTRY]: 'Inventories',
|
|
1031
|
-
[EXPORTABLE_RESOURCES.CUSTOMER]: 'Customers',
|
|
1032
|
-
[EXPORTABLE_RESOURCES.ORDER]: 'Orders'
|
|
1033
|
-
};
|
|
1034
|
-
const displayName = resourceTypeMap[resourceType];
|
|
1035
|
-
if (!displayName) {
|
|
1036
|
-
throw new UnexpectedResourceTypeError(resourceType);
|
|
1037
|
-
}
|
|
1038
|
-
return `${displayName}_Export_${formattedDate}`;
|
|
1039
|
-
}
|
|
1040
|
-
function mapLocalesToOptions(locales) {
|
|
1041
|
-
return _mapInstanceProperty(locales).call(locales, locale => ({
|
|
1042
|
-
value: locale,
|
|
1043
|
-
label: locale
|
|
1044
|
-
}));
|
|
1045
|
-
}
|
|
1046
|
-
function isFilledArray(maybeArray) {
|
|
1047
|
-
return _Array$isArray(maybeArray) && maybeArray.length > 0;
|
|
1048
|
-
}
|
|
1049
|
-
function appendCsvOrJsonExtensionIfAbsent(fileName, fileFormat) {
|
|
1050
|
-
const extensionRegex = /\.(csv|json)$/i;
|
|
1051
|
-
if (!extensionRegex.test(fileName)) return `${fileName}.${fileFormat}`;
|
|
1052
|
-
return fileName;
|
|
1053
|
-
}
|
|
1054
|
-
function getExportLogsLink(projectKey, msg) {
|
|
1055
|
-
return jsx(Link, {
|
|
1056
|
-
to: `/${projectKey}/operations/export/logs`,
|
|
1057
|
-
children: msg
|
|
1058
|
-
}, "link");
|
|
1059
|
-
}
|
|
1060
|
-
const extractFieldNamesAndAdditionalFieldExtensions = fields => {
|
|
1061
|
-
const result = _reduceInstanceProperty(fields).call(fields, (acc, field) => {
|
|
1062
|
-
if (field.extendedFieldNames) {
|
|
1063
|
-
return [...acc, field.name, ...field.extendedFieldNames];
|
|
1064
|
-
}
|
|
1065
|
-
return [...acc, field.name];
|
|
1066
|
-
}, []);
|
|
1067
|
-
return [...new _Set(result)];
|
|
1068
|
-
};
|
|
1069
|
-
function sortFieldsByFieldOrder(_ref) {
|
|
1070
|
-
let fieldNames = _ref.fieldNames,
|
|
1071
|
-
fieldOrder = _ref.fieldOrder;
|
|
1072
|
-
if (isFilledArray(fieldOrder)) {
|
|
1073
|
-
return _sortInstanceProperty(fieldNames).call(fieldNames, (a, b) => {
|
|
1074
|
-
let orderA = _indexOfInstanceProperty(fieldOrder).call(fieldOrder, a) !== -1 ? _indexOfInstanceProperty(fieldOrder).call(fieldOrder, a) : _indexOfInstanceProperty(fieldOrder).call(fieldOrder, a.split('.')[0]);
|
|
1075
|
-
let orderB = _indexOfInstanceProperty(fieldOrder).call(fieldOrder, b) !== -1 ? _indexOfInstanceProperty(fieldOrder).call(fieldOrder, b) : _indexOfInstanceProperty(fieldOrder).call(fieldOrder, b.split('.')[0]);
|
|
1076
|
-
|
|
1077
|
-
// If a field is not 'custom',then consider it as '*'
|
|
1078
|
-
orderA = orderA === -1 ? _indexOfInstanceProperty(fieldOrder).call(fieldOrder, '*') : orderA;
|
|
1079
|
-
orderB = orderB === -1 ? _indexOfInstanceProperty(fieldOrder).call(fieldOrder, '*') : orderB;
|
|
1080
|
-
return orderA - orderB;
|
|
1081
|
-
});
|
|
1082
|
-
}
|
|
1083
|
-
return fieldNames;
|
|
1084
|
-
}
|
|
1085
|
-
function buildSelectedExportFilters(selectedResourceIds) {
|
|
1086
|
-
if (!selectedResourceIds || selectedResourceIds?.length === 0) return undefined;
|
|
1087
|
-
const formattedIds = _mapInstanceProperty(selectedResourceIds).call(selectedResourceIds, id => `"${id}"`).join(', ');
|
|
1088
|
-
return `id in (${formattedIds})`;
|
|
1089
|
-
}
|
|
1090
|
-
function isQueryFilter(filters) {
|
|
1091
|
-
if (!filters) return false;
|
|
1092
|
-
return 'query' in filters;
|
|
1093
|
-
}
|
|
1094
|
-
function isSearchFilter(filters) {
|
|
1095
|
-
if (!filters) return false;
|
|
1096
|
-
return 'filters' in filters || 'fullText' in filters;
|
|
1097
|
-
}
|
|
1098
|
-
function isPredicateFilter(filters) {
|
|
1099
|
-
if (!filters) return false;
|
|
1100
|
-
return 'where' in filters;
|
|
1101
|
-
}
|
|
1102
|
-
function validateFilters(filtersObject) {
|
|
1103
|
-
if (filtersObject.where && filtersObject.filters) {
|
|
1104
|
-
return false;
|
|
1105
|
-
}
|
|
1106
|
-
return Boolean(isQueryFilter(filtersObject.filters) || isSearchFilter(filtersObject.filters) || isPredicateFilter(filtersObject));
|
|
1107
|
-
}
|
|
1108
|
-
function areFiltersApplied(filtersObject) {
|
|
1109
|
-
var _context2;
|
|
1110
|
-
if (!filtersObject) {
|
|
1111
|
-
return false;
|
|
1112
|
-
}
|
|
1113
|
-
if (filtersObject.where && _trimInstanceProperty(_context2 = filtersObject.where).call(_context2) !== '') {
|
|
1114
|
-
return true;
|
|
1115
|
-
}
|
|
1116
|
-
if (isQueryFilter(filtersObject.filters)) {
|
|
1117
|
-
return Boolean(filtersObject.filters.query);
|
|
1118
|
-
}
|
|
1119
|
-
if (isSearchFilter(filtersObject.filters)) {
|
|
1120
|
-
var _context3, _context4;
|
|
1121
|
-
const _filters = filtersObject.filters;
|
|
1122
|
-
return Boolean(_filters.filters?.length || ((_context3 = _filters.fullText?.text) == null ? void 0 : _bindInstanceProperty(_context4 = Function.call).call(_context4, _trimInstanceProperty(_context3), _context3))?.());
|
|
1123
|
-
}
|
|
1124
|
-
return false;
|
|
1125
|
-
}
|
|
1126
|
-
function getInitialExportType(args) {
|
|
1127
|
-
if (args.selectedResourceIds?.length) {
|
|
1128
|
-
return EXPORT_TYPES.SELECTED;
|
|
1129
|
-
}
|
|
1130
|
-
if (args.filters?.total && areFiltersApplied(args.filters)) {
|
|
1131
|
-
return EXPORT_TYPES.FILTERED;
|
|
1132
|
-
}
|
|
1133
|
-
return EXPORT_TYPES.ALL;
|
|
1134
|
-
}
|
|
1135
|
-
function removeEmptyGroups(groups) {
|
|
1136
|
-
return _filterInstanceProperty(groups).call(groups, group => group.fields && group.fields.length > 0);
|
|
1137
|
-
}
|
|
1138
|
-
|
|
1139
1197
|
function ownKeys$e(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1140
1198
|
function _objectSpread$e(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context2 = ownKeys$e(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context3 = ownKeys$e(Object(t))).call(_context3, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1141
1199
|
const updateFieldGroupsWithIsCheckedValue = (groups, cachedSelectedGroups) => {
|
|
@@ -1360,6 +1418,13 @@ function groupFieldValidationErrors(errors, intl) {
|
|
|
1360
1418
|
});
|
|
1361
1419
|
}
|
|
1362
1420
|
|
|
1421
|
+
function isExportApiSuccessResponse(response) {
|
|
1422
|
+
return 'id' in response && 'state' in response && 'resourceType' in response && 'resourceCount' in response;
|
|
1423
|
+
}
|
|
1424
|
+
function isExportApiErrorResponse(error) {
|
|
1425
|
+
return Boolean(error && typeof error === 'object' && 'body' in error && error.body && typeof error.body === 'object' && ('validationErrors' in error.body || 'errors' in error.body) && 'message' in error.body && 'statusCode' in error.body && 'error' in error.body);
|
|
1426
|
+
}
|
|
1427
|
+
|
|
1363
1428
|
const useInitialValues = props => {
|
|
1364
1429
|
var _context;
|
|
1365
1430
|
const _useApplicationContex = useApplicationContext(applicationContext => ({
|
|
@@ -1392,6 +1457,7 @@ const useInitialValues = props => {
|
|
|
1392
1457
|
fileName: `${resourceTypeToFileName(props.resourceType, userLocale)}`,
|
|
1393
1458
|
locales: [locale],
|
|
1394
1459
|
groups: updateFieldGroupWithAdditionalFieldExtensions(groups),
|
|
1460
|
+
queryPredicate: '',
|
|
1395
1461
|
// Preferences
|
|
1396
1462
|
fillRows: false,
|
|
1397
1463
|
importedCsvTemplateFile: null
|
|
@@ -1403,37 +1469,30 @@ const _excluded$3 = ["projectKey"];
|
|
|
1403
1469
|
function ownKeys$c(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1404
1470
|
function _objectSpread$c(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys$c(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys$c(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1405
1471
|
async function makeExportRequest(params, asyncDispatchFn) {
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
throw new InvalidResponseError();
|
|
1421
|
-
}
|
|
1422
|
-
if (!('state' in response)) {
|
|
1423
|
-
throw new InvalidResponseError('Response missing state field');
|
|
1424
|
-
}
|
|
1425
|
-
return response;
|
|
1426
|
-
} catch (responseError) {
|
|
1427
|
-
if (responseError && typeof responseError === 'object' && 'body' in responseError && responseError.body && typeof responseError.body === 'object' && 'validationErrors' in responseError.body) {
|
|
1428
|
-
throw responseError.body;
|
|
1429
|
-
}
|
|
1430
|
-
throw responseError;
|
|
1472
|
+
const projectKey = params.projectKey,
|
|
1473
|
+
requestData = _objectWithoutProperties(params, _excluded$3);
|
|
1474
|
+
const uri = `/${projectKey}/export-operations`;
|
|
1475
|
+
const requestAction = actions.post({
|
|
1476
|
+
mcApiProxyTarget: MC_API_PROXY_TARGETS.EXPORT,
|
|
1477
|
+
uri,
|
|
1478
|
+
headers: {
|
|
1479
|
+
accept: 'application/json'
|
|
1480
|
+
},
|
|
1481
|
+
payload: requestData
|
|
1482
|
+
});
|
|
1483
|
+
const response = await asyncDispatchFn(requestAction);
|
|
1484
|
+
if (!response || typeof response !== 'object') {
|
|
1485
|
+
throw new InvalidResponseError();
|
|
1431
1486
|
}
|
|
1487
|
+
if (!('state' in response)) {
|
|
1488
|
+
throw new InvalidResponseError('Response missing state field');
|
|
1489
|
+
}
|
|
1490
|
+
return response;
|
|
1432
1491
|
}
|
|
1433
1492
|
function createExportOperation(params, asyncDispatchFn) {
|
|
1434
1493
|
return makeExportRequest(params, asyncDispatchFn);
|
|
1435
1494
|
}
|
|
1436
|
-
function
|
|
1495
|
+
function validateExportOperation(params, asyncDispatchFn) {
|
|
1437
1496
|
return makeExportRequest(_objectSpread$c(_objectSpread$c({}, params), {}, {
|
|
1438
1497
|
dryRun: true
|
|
1439
1498
|
}), asyncDispatchFn);
|
|
@@ -1448,25 +1507,6 @@ const useStartExportOperation = props => {
|
|
|
1448
1507
|
projectKey: applicationContext.project?.key
|
|
1449
1508
|
})),
|
|
1450
1509
|
projectKey = _useApplicationContex.projectKey;
|
|
1451
|
-
const extractFieldNamesFromGroups = groups => {
|
|
1452
|
-
let checkedFields = [];
|
|
1453
|
-
const getCheckedFields = fields => {
|
|
1454
|
-
return _filterInstanceProperty(fields).call(fields, field => {
|
|
1455
|
-
if (field.fields) {
|
|
1456
|
-
return getCheckedFields(field.fields);
|
|
1457
|
-
}
|
|
1458
|
-
if (field.isChecked) checkedFields.push(field);
|
|
1459
|
-
return field.isChecked ?? false;
|
|
1460
|
-
});
|
|
1461
|
-
};
|
|
1462
|
-
_forEachInstanceProperty(groups).call(groups, group => {
|
|
1463
|
-
getCheckedFields(group.fields);
|
|
1464
|
-
});
|
|
1465
|
-
return sortFieldsByFieldOrder({
|
|
1466
|
-
fieldNames: extractFieldNamesAndAdditionalFieldExtensions(checkedFields),
|
|
1467
|
-
fieldOrder: props.fieldOrder
|
|
1468
|
-
});
|
|
1469
|
-
};
|
|
1470
1510
|
const startExportOperation = async (values, exportType, fieldSelectionMode, localeOption, importedHeaders) => {
|
|
1471
1511
|
try {
|
|
1472
1512
|
if (!projectKey) throw new Error('Project key is missing');
|
|
@@ -1474,7 +1514,7 @@ const useStartExportOperation = props => {
|
|
|
1474
1514
|
if (fieldSelectionMode === 'imported-csv-template' && values.importedCsvTemplateFile) {
|
|
1475
1515
|
fields = importedHeaders;
|
|
1476
1516
|
} else {
|
|
1477
|
-
fields = extractFieldNamesFromGroups(values.groups);
|
|
1517
|
+
fields = extractFieldNamesFromGroups(values.groups, props.fieldOrder);
|
|
1478
1518
|
}
|
|
1479
1519
|
let where = undefined;
|
|
1480
1520
|
let filters = undefined;
|
|
@@ -1487,6 +1527,9 @@ const useStartExportOperation = props => {
|
|
|
1487
1527
|
} else if (isSearchFilter(props.filters.filters)) {
|
|
1488
1528
|
filters = props.filters.filters;
|
|
1489
1529
|
}
|
|
1530
|
+
} else if (exportType === EXPORT_TYPES.QUERY_PREDICATE) {
|
|
1531
|
+
var _context;
|
|
1532
|
+
where = _trimInstanceProperty(_context = values.queryPredicate).call(_context);
|
|
1490
1533
|
}
|
|
1491
1534
|
let locales = undefined;
|
|
1492
1535
|
if (localeOption !== 'onlyLocalesFoundInCsvFile') {
|
|
@@ -1503,29 +1546,32 @@ const useStartExportOperation = props => {
|
|
|
1503
1546
|
where,
|
|
1504
1547
|
filters
|
|
1505
1548
|
}, asyncDispatch);
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1549
|
+
if (isExportApiSuccessResponse(response)) {
|
|
1550
|
+
switch (response.state) {
|
|
1551
|
+
case EXPORT_OPERATION_STATES.QUEUED:
|
|
1552
|
+
case EXPORT_OPERATION_STATES.PROCESSING:
|
|
1553
|
+
case EXPORT_OPERATION_STATES.COMPLETED:
|
|
1554
|
+
showNotification({
|
|
1555
|
+
kind: 'info',
|
|
1556
|
+
domain: DOMAINS.SIDE,
|
|
1557
|
+
// @ts-ignore
|
|
1558
|
+
text: intl.formatMessage(messages.exportOperationSuccessMessage, {
|
|
1559
|
+
newline: getNewLine,
|
|
1560
|
+
logsLink: msg => getExportLogsLink(projectKey, msg),
|
|
1561
|
+
b: getBold
|
|
1562
|
+
})
|
|
1563
|
+
}, {
|
|
1564
|
+
dismissAfter: 5000
|
|
1565
|
+
});
|
|
1566
|
+
if (typeof props.onExportSuccess === 'function') props.onExportSuccess();
|
|
1567
|
+
break;
|
|
1568
|
+
default:
|
|
1569
|
+
throw new UnexpectedExportOperationStateError(response.state);
|
|
1570
|
+
}
|
|
1571
|
+
} else {
|
|
1572
|
+
throw new Error(response.message || 'Unknown error occurred during export operation');
|
|
1526
1573
|
}
|
|
1527
1574
|
} catch (error) {
|
|
1528
|
-
// TODO: custom error messages for each error type
|
|
1529
1575
|
showNotification({
|
|
1530
1576
|
text: intl.formatMessage(messages.unexpectedError),
|
|
1531
1577
|
kind: 'error',
|
|
@@ -1641,7 +1687,7 @@ const useConvertFieldDefinitionsForExport = () => {
|
|
|
1641
1687
|
};
|
|
1642
1688
|
};
|
|
1643
1689
|
|
|
1644
|
-
const
|
|
1690
|
+
const useValidateExportOperation = () => {
|
|
1645
1691
|
const intl = useIntl();
|
|
1646
1692
|
const asyncDispatch = useAsyncDispatch();
|
|
1647
1693
|
const showNotification = useShowNotification();
|
|
@@ -1649,9 +1695,9 @@ const useValidateImportedHeaders = () => {
|
|
|
1649
1695
|
projectKey: context.project?.key
|
|
1650
1696
|
})),
|
|
1651
1697
|
projectKey = _useApplicationContex.projectKey;
|
|
1652
|
-
const
|
|
1698
|
+
const validateExport = async params => {
|
|
1653
1699
|
try {
|
|
1654
|
-
var _context;
|
|
1700
|
+
var _context, _context2, _context3;
|
|
1655
1701
|
if (!projectKey) return;
|
|
1656
1702
|
const invalidFields = _filterInstanceProperty(_context = params.fields).call(_context, field => !isFieldNameValid(field));
|
|
1657
1703
|
if (invalidFields.length > 0) {
|
|
@@ -1663,25 +1709,46 @@ const useValidateImportedHeaders = () => {
|
|
|
1663
1709
|
}))
|
|
1664
1710
|
};
|
|
1665
1711
|
}
|
|
1666
|
-
await
|
|
1712
|
+
const response = await validateExportOperation({
|
|
1667
1713
|
projectKey,
|
|
1668
1714
|
resourceType: params.resourceType,
|
|
1669
1715
|
fileName: params.fileName,
|
|
1670
1716
|
fileFormat: params.outputFormat,
|
|
1671
1717
|
fields: params.fields,
|
|
1672
|
-
locales: params.locales
|
|
1718
|
+
locales: params.locales,
|
|
1719
|
+
where: ((_context2 = params.queryPredicate) == null ? void 0 : _bindInstanceProperty(_context3 = Function.call).call(_context3, _trimInstanceProperty(_context2), _context2))?.() || undefined
|
|
1673
1720
|
}, asyncDispatch);
|
|
1674
|
-
|
|
1675
|
-
success: true,
|
|
1676
|
-
validationErrors: []
|
|
1677
|
-
};
|
|
1678
|
-
} catch (error) {
|
|
1679
|
-
if (typeof error === 'object' && error && 'validationErrors' in error && _Array$isArray(error.validationErrors)) {
|
|
1721
|
+
if (isExportApiSuccessResponse(response) && response.resourceCount === 0) {
|
|
1680
1722
|
return {
|
|
1681
1723
|
success: false,
|
|
1682
|
-
|
|
1724
|
+
noResourcesToExportForQueryPredicate: true
|
|
1683
1725
|
};
|
|
1684
1726
|
}
|
|
1727
|
+
return {
|
|
1728
|
+
success: true
|
|
1729
|
+
};
|
|
1730
|
+
} catch (error) {
|
|
1731
|
+
if (isExportApiErrorResponse(error)) {
|
|
1732
|
+
if (error.body.errors?.length) {
|
|
1733
|
+
var _context4;
|
|
1734
|
+
const whereError = _findInstanceProperty(_context4 = error.body.errors).call(_context4, error => {
|
|
1735
|
+
var _context5;
|
|
1736
|
+
return error.message && _includesInstanceProperty(_context5 = error.message).call(_context5, 'Malformed parameter: where');
|
|
1737
|
+
});
|
|
1738
|
+
if (whereError) {
|
|
1739
|
+
return {
|
|
1740
|
+
success: false,
|
|
1741
|
+
invalidQueryPredicate: true
|
|
1742
|
+
};
|
|
1743
|
+
}
|
|
1744
|
+
}
|
|
1745
|
+
if (error.body.validationErrors?.length) {
|
|
1746
|
+
return {
|
|
1747
|
+
success: false,
|
|
1748
|
+
validationErrors: error.body.validationErrors
|
|
1749
|
+
};
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1685
1752
|
showNotification({
|
|
1686
1753
|
text: intl.formatMessage(messages.unexpectedError),
|
|
1687
1754
|
kind: 'error',
|
|
@@ -1694,7 +1761,7 @@ const useValidateImportedHeaders = () => {
|
|
|
1694
1761
|
}
|
|
1695
1762
|
};
|
|
1696
1763
|
return {
|
|
1697
|
-
|
|
1764
|
+
validateExport
|
|
1698
1765
|
};
|
|
1699
1766
|
};
|
|
1700
1767
|
|
|
@@ -1742,6 +1809,7 @@ function ownKeys$9(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySy
|
|
|
1742
1809
|
function _objectSpread$9(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys$9(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys$9(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1743
1810
|
function ExportScopeSection() {
|
|
1744
1811
|
const _useExportResourcesMo = useExportResourcesModalContext(),
|
|
1812
|
+
formik = _useExportResourcesMo.formik,
|
|
1745
1813
|
exportType = _useExportResourcesMo.exportType,
|
|
1746
1814
|
totalResourcesCount = _useExportResourcesMo.totalResourcesCount,
|
|
1747
1815
|
filters = _useExportResourcesMo.filters,
|
|
@@ -1749,10 +1817,11 @@ function ExportScopeSection() {
|
|
|
1749
1817
|
selectedResourceIds = _useExportResourcesMo.selectedResourceIds,
|
|
1750
1818
|
setExportType = _useExportResourcesMo.setExportType,
|
|
1751
1819
|
resourceType = _useExportResourcesMo.resourceType,
|
|
1752
|
-
hideExportSelectedResourcesOption = _useExportResourcesMo.hideExportSelectedResourcesOption
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1820
|
+
hideExportSelectedResourcesOption = _useExportResourcesMo.hideExportSelectedResourcesOption,
|
|
1821
|
+
showQueryPredicateOption = _useExportResourcesMo.showQueryPredicateOption;
|
|
1822
|
+
const shouldShowQueryPredicateField = exportType === EXPORT_TYPES.QUERY_PREDICATE;
|
|
1823
|
+
return jsxs(Fragment, {
|
|
1824
|
+
children: [jsxs(RadioInput.Group, {
|
|
1756
1825
|
value: exportType,
|
|
1757
1826
|
onChange: e => {
|
|
1758
1827
|
setExportType(e.target.value);
|
|
@@ -1792,8 +1861,23 @@ function ExportScopeSection() {
|
|
|
1792
1861
|
}
|
|
1793
1862
|
}) : messages.exportScopeSelectedWithoutCount
|
|
1794
1863
|
})
|
|
1864
|
+
}), showQueryPredicateOption && jsx(RadioInput.Option, {
|
|
1865
|
+
value: EXPORT_TYPES.QUERY_PREDICATE,
|
|
1866
|
+
children: jsx(Text.Body, {
|
|
1867
|
+
intlMessage: messages.queryPredicate
|
|
1868
|
+
})
|
|
1795
1869
|
})]
|
|
1796
|
-
})
|
|
1870
|
+
}), shouldShowQueryPredicateField && jsx(TextField, {
|
|
1871
|
+
name: "queryPredicate",
|
|
1872
|
+
"data-testid": "query-predicate-field",
|
|
1873
|
+
title: "",
|
|
1874
|
+
onChange: formik.handleChange,
|
|
1875
|
+
onBlur: formik.handleBlur,
|
|
1876
|
+
value: _valuesInstanceProperty(formik).queryPredicate,
|
|
1877
|
+
touched: formik.touched.queryPredicate,
|
|
1878
|
+
errors: mapFormikErrors(formik.errors.queryPredicate),
|
|
1879
|
+
renderError: renderQueryPredicateError
|
|
1880
|
+
})]
|
|
1797
1881
|
});
|
|
1798
1882
|
}
|
|
1799
1883
|
|
|
@@ -2670,47 +2754,66 @@ const ExportResourcesProvider = _ref => {
|
|
|
2670
2754
|
setValidationErrors = _React$useState12[1];
|
|
2671
2755
|
const _useStartExportOperat = useStartExportOperation(props),
|
|
2672
2756
|
startExportOperation = _useStartExportOperat.startExportOperation;
|
|
2673
|
-
const
|
|
2674
|
-
|
|
2675
|
-
const onSubmit = async values => {
|
|
2676
|
-
if (currentStep === Step.FileSettings) {
|
|
2677
|
-
setCurrentStep(Step.FieldsSelection);
|
|
2678
|
-
} else if (currentStep === Step.FieldsSelection) {
|
|
2679
|
-
if (fieldSelectionMode !== 'imported-csv-template') {
|
|
2680
|
-
setCurrentStep(Step.ConfirmExport);
|
|
2681
|
-
return;
|
|
2682
|
-
}
|
|
2683
|
-
const isUsingImportedCsvLocales = localeOption === 'onlyLocalesFoundInCsvFile';
|
|
2684
|
-
const validationResult = await validateHeaders({
|
|
2685
|
-
fileName: values.fileName,
|
|
2686
|
-
outputFormat: values.outputFormat,
|
|
2687
|
-
resourceType: props.resourceType,
|
|
2688
|
-
fields: importedHeaders,
|
|
2689
|
-
locales: isUsingImportedCsvLocales ? undefined : values.locales
|
|
2690
|
-
});
|
|
2691
|
-
if (validationResult?.success) {
|
|
2692
|
-
setCurrentStep(Step.ConfirmExport);
|
|
2693
|
-
} else {
|
|
2694
|
-
setValidationErrors(validationResult?.validationErrors);
|
|
2695
|
-
setCurrentStep(Step.ValidationErrors);
|
|
2696
|
-
}
|
|
2697
|
-
} else {
|
|
2698
|
-
startExportOperation(values, exportType, fieldSelectionMode, localeOption, importedHeaders);
|
|
2699
|
-
}
|
|
2700
|
-
};
|
|
2757
|
+
const _useValidateExportOpe = useValidateExportOperation(),
|
|
2758
|
+
validateExport = _useValidateExportOpe.validateExport;
|
|
2701
2759
|
const formik = useFormik({
|
|
2702
2760
|
initialValues,
|
|
2703
2761
|
validate: values => validate({
|
|
2704
2762
|
values,
|
|
2705
2763
|
step: currentStep,
|
|
2706
2764
|
fieldSelectionMode,
|
|
2707
|
-
importedHeaders
|
|
2765
|
+
importedHeaders,
|
|
2766
|
+
exportType
|
|
2708
2767
|
}),
|
|
2709
|
-
onSubmit
|
|
2768
|
+
onSubmit: async values => {
|
|
2769
|
+
if (currentStep === Step.FileSettings) {
|
|
2770
|
+
if (exportType === EXPORT_TYPES.QUERY_PREDICATE) {
|
|
2771
|
+
const validationResult = await validateExport({
|
|
2772
|
+
fileName: values.fileName,
|
|
2773
|
+
outputFormat: values.outputFormat,
|
|
2774
|
+
resourceType: props.resourceType,
|
|
2775
|
+
fields: extractFieldNamesFromGroups(values.groups, props.fieldOrder),
|
|
2776
|
+
locales: values.locales,
|
|
2777
|
+
queryPredicate: values.queryPredicate
|
|
2778
|
+
});
|
|
2779
|
+
if (validationResult?.invalidQueryPredicate) {
|
|
2780
|
+
formik.setFieldError('queryPredicate', 'invalidInput');
|
|
2781
|
+
return;
|
|
2782
|
+
}
|
|
2783
|
+
if (validationResult?.noResourcesToExportForQueryPredicate) {
|
|
2784
|
+
formik.setFieldError('queryPredicate', 'noResourcesToExportForQueryPredicate');
|
|
2785
|
+
return;
|
|
2786
|
+
}
|
|
2787
|
+
}
|
|
2788
|
+
setCurrentStep(Step.FieldsSelection);
|
|
2789
|
+
} else if (currentStep === Step.FieldsSelection) {
|
|
2790
|
+
if (fieldSelectionMode !== 'imported-csv-template') {
|
|
2791
|
+
setCurrentStep(Step.ConfirmExport);
|
|
2792
|
+
return;
|
|
2793
|
+
}
|
|
2794
|
+
const isUsingImportedCsvLocales = localeOption === 'onlyLocalesFoundInCsvFile';
|
|
2795
|
+
const validationResult = await validateExport({
|
|
2796
|
+
fileName: values.fileName,
|
|
2797
|
+
outputFormat: values.outputFormat,
|
|
2798
|
+
resourceType: props.resourceType,
|
|
2799
|
+
fields: importedHeaders,
|
|
2800
|
+
locales: isUsingImportedCsvLocales ? undefined : values.locales,
|
|
2801
|
+
queryPredicate: values.queryPredicate
|
|
2802
|
+
});
|
|
2803
|
+
if (validationResult?.success) {
|
|
2804
|
+
setCurrentStep(Step.ConfirmExport);
|
|
2805
|
+
} else {
|
|
2806
|
+
setValidationErrors(validationResult?.validationErrors);
|
|
2807
|
+
setCurrentStep(Step.ValidationErrors);
|
|
2808
|
+
}
|
|
2809
|
+
} else {
|
|
2810
|
+
startExportOperation(values, exportType, fieldSelectionMode, localeOption, importedHeaders);
|
|
2811
|
+
}
|
|
2812
|
+
}
|
|
2710
2813
|
});
|
|
2711
2814
|
React.useEffect(() => {
|
|
2712
2815
|
formik.validateForm();
|
|
2713
|
-
}, [currentStep, fieldSelectionMode, importedHeaders]);
|
|
2816
|
+
}, [currentStep, fieldSelectionMode, importedHeaders, exportType]);
|
|
2714
2817
|
return jsx(ExportResourcesContext.Provider, {
|
|
2715
2818
|
value: {
|
|
2716
2819
|
formik,
|
|
@@ -2722,6 +2825,7 @@ const ExportResourcesProvider = _ref => {
|
|
|
2722
2825
|
totalResourcesCount: props.totalResourcesCount,
|
|
2723
2826
|
selectedResourceIds: props.selectedResourceIds,
|
|
2724
2827
|
hideExportSelectedResourcesOption: props.hideExportSelectedResourcesOption,
|
|
2828
|
+
showQueryPredicateOption: props.showQueryPredicateOption,
|
|
2725
2829
|
filters: props.filters,
|
|
2726
2830
|
hasFilters: areFiltersApplied(props.filters),
|
|
2727
2831
|
setExportType,
|
|
@@ -3073,11 +3177,11 @@ function getDefaultDropWrapperStyles(_dropAreaState) {
|
|
|
3073
3177
|
return /*#__PURE__*/css(process.env.NODE_ENV === "production" ? "" : ";label:getDefaultDropWrapperStyles;", process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImRyb3AtYXJlYS13cmFwcGVyLnRzeCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUF5QlkiLCJmaWxlIjoiZHJvcC1hcmVhLXdyYXBwZXIudHN4Iiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgdHlwZSBEcm9wem9uZVJvb3RQcm9wcyB9IGZyb20gJ3JlYWN0LWRyb3B6b25lJ1xuaW1wb3J0IHsgY3NzIH0gZnJvbSAnQGVtb3Rpb24vcmVhY3QnXG5pbXBvcnQgc3R5bGVkIGZyb20gJ0BlbW90aW9uL3N0eWxlZCdcbmltcG9ydCB7IHN0eWxlcyB9IGZyb20gJy4vc3R5bGVzJ1xuaW1wb3J0IHsgdHlwZSBEcm9wQXJlYVN0YXRlIH0gZnJvbSAnLi4vLi4vLi4vQHR5cGVzJ1xuXG5pbnRlcmZhY2UgRHJvcFdyYXBwZXJQcm9wcyBleHRlbmRzIERyb3B6b25lUm9vdFByb3BzIHtcbiAgZHJvcEFyZWFTdGF0ZTogRHJvcEFyZWFTdGF0ZVxufVxuZXhwb3J0IGNvbnN0IERyb3BXcmFwcGVyID0gc3R5bGVkLmRpdjxEcm9wV3JhcHBlclByb3BzPmBcbiAgJHtzdHlsZXMuYmFzZX1cbiAgJHsocHJvcHMpID0+IHtcbiAgICBpZiAocHJvcHMuZHJvcEFyZWFTdGF0ZSA9PT0gJ2RlZmF1bHQnKSB7XG4gICAgICByZXR1cm4gc3R5bGVzLnJlYWR5Rm9yRHJvcFxuICAgIH1cbiAgICBpZiAocHJvcHMuZHJvcEFyZWFTdGF0ZSA9PT0gJ2FjdGl2ZS1kcmFnJykge1xuICAgICAgcmV0dXJuIHN0eWxlcy5hY3RpdmVEcmFnXG4gICAgfVxuICAgIGlmIChwcm9wcy5kcm9wQXJlYVN0YXRlID09PSAnZmlsZS1kcm9wcGVkJykge1xuICAgICAgcmV0dXJuIHN0eWxlcy5maWxlRHJvcHBlZFxuICAgIH1cbiAgICByZXR1cm4gZ2V0RGVmYXVsdERyb3BXcmFwcGVyU3R5bGVzKHByb3BzLmRyb3BBcmVhU3RhdGUpXG4gIH19XG5gXG5mdW5jdGlvbiBnZXREZWZhdWx0RHJvcFdyYXBwZXJTdHlsZXMoX2Ryb3BBcmVhU3RhdGU6IG5ldmVyKSB7XG4gIHJldHVybiBjc3NgYFxufVxuIl19 */");
|
|
3074
3178
|
}
|
|
3075
3179
|
|
|
3076
|
-
var ActiveDragDropArea = /*#__PURE__*/lazy(() => import('./active-drag-drop-area-
|
|
3180
|
+
var ActiveDragDropArea = /*#__PURE__*/lazy(() => import('./active-drag-drop-area-418bdbf4.esm.js' /* webpackChunkName: "active-drag-drop-area" */));
|
|
3077
3181
|
|
|
3078
|
-
var EnabledDropArea = /*#__PURE__*/lazy(() => import('./enabled-drop-area-
|
|
3182
|
+
var EnabledDropArea = /*#__PURE__*/lazy(() => import('./enabled-drop-area-aed3e03e.esm.js' /* webpackChunkName: "enabled-drop-area" */));
|
|
3079
3183
|
|
|
3080
|
-
var FileDropped = /*#__PURE__*/lazy(() => import('./file-dropped-area-
|
|
3184
|
+
var FileDropped = /*#__PURE__*/lazy(() => import('./file-dropped-area-06a60bda.esm.js' /* webpackChunkName: "filed-dropped-area" */));
|
|
3081
3185
|
|
|
3082
3186
|
function getDropArea(_ref) {
|
|
3083
3187
|
let dropAreaState = _ref.dropAreaState,
|