@commercetools-frontend-extensions/export-resources-modal 5.0.4 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{active-drag-drop-area-ab3d5305.cjs.dev.js → active-drag-drop-area-56db6919.cjs.dev.js} +1 -1
- package/dist/{active-drag-drop-area-d0b34d8c.esm.js → active-drag-drop-area-69b691d5.esm.js} +1 -1
- package/dist/{active-drag-drop-area-677cd139.cjs.prod.js → active-drag-drop-area-7fd53916.cjs.prod.js} +1 -1
- package/dist/commercetools-frontend-extensions-export-resources-modal.cjs.dev.js +3 -3
- package/dist/commercetools-frontend-extensions-export-resources-modal.cjs.prod.js +3 -3
- package/dist/commercetools-frontend-extensions-export-resources-modal.esm.js +3 -3
- 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-3ac1d564.esm.js → enabled-drop-area-48a953a6.esm.js} +1 -1
- package/dist/{enabled-drop-area-049033dc.cjs.prod.js → enabled-drop-area-4c8d613f.cjs.prod.js} +1 -1
- package/dist/{enabled-drop-area-76b49e4a.cjs.dev.js → enabled-drop-area-a5fe741d.cjs.dev.js} +1 -1
- package/dist/{file-dropped-area-44d101c3.cjs.dev.js → file-dropped-area-5979698c.cjs.dev.js} +1 -1
- package/dist/{file-dropped-area-d2df8c70.cjs.prod.js → file-dropped-area-b685a683.cjs.prod.js} +1 -1
- package/dist/{file-dropped-area-997435fa.esm.js → file-dropped-area-c8a5f539.esm.js} +1 -1
- package/dist/{index-e4706b61.cjs.dev.js → index-32b358db.cjs.dev.js} +364 -256
- package/dist/{index-1d25c6f7.cjs.prod.js → index-bcefd2cf.cjs.prod.js} +364 -256
- package/dist/{index-969519bd.esm.js → index-f7e098bb.esm.js} +365 -257
- 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
|
+
noResourcesToExport: {
|
|
601
|
+
id: 'ExportResourcesModal.noResourcesToExport',
|
|
602
|
+
description: 'Error message when there are no resources to export',
|
|
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,16 @@ 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
|
+
default:
|
|
634
|
+
return null;
|
|
635
|
+
}
|
|
636
|
+
};
|
|
607
637
|
|
|
608
638
|
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
639
|
function _isNativeReflectConstruct$3() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$3 = function () { return !!t; })(); }
|
|
@@ -748,7 +778,8 @@ const EXPORT_OPERATION_STATES = {
|
|
|
748
778
|
const EXPORT_TYPES = {
|
|
749
779
|
ALL: 'all',
|
|
750
780
|
FILTERED: 'filtered',
|
|
751
|
-
SELECTED: 'selected'
|
|
781
|
+
SELECTED: 'selected',
|
|
782
|
+
QUERY_PREDICATE: 'query-predicate'
|
|
752
783
|
};
|
|
753
784
|
|
|
754
785
|
const EXPORTABLE_RESOURCES = {
|
|
@@ -825,6 +856,140 @@ const DEFAULT_SHORT_LIVED_FLAGS = {};
|
|
|
825
856
|
const DEFAULT_LONG_LIVED_FLAGS = {};
|
|
826
857
|
_objectSpread$f(_objectSpread$f({}, DEFAULT_SHORT_LIVED_FLAGS), DEFAULT_LONG_LIVED_FLAGS);
|
|
827
858
|
|
|
859
|
+
function resourceTypeToFileName(resourceType, locale) {
|
|
860
|
+
var _context;
|
|
861
|
+
const date = new Date();
|
|
862
|
+
const dateFormatter = new Intl.DateTimeFormat(locale, {
|
|
863
|
+
year: '2-digit',
|
|
864
|
+
month: '2-digit',
|
|
865
|
+
day: '2-digit',
|
|
866
|
+
hour: '2-digit',
|
|
867
|
+
minute: '2-digit',
|
|
868
|
+
hour12: false
|
|
869
|
+
});
|
|
870
|
+
const parts = dateFormatter.formatToParts(date);
|
|
871
|
+
const dateParts = _reduceInstanceProperty(parts).call(parts, (acc, part) => {
|
|
872
|
+
if (part.type !== 'literal') {
|
|
873
|
+
acc[part.type] = part.value;
|
|
874
|
+
}
|
|
875
|
+
return acc;
|
|
876
|
+
}, {});
|
|
877
|
+
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('-');
|
|
878
|
+
const formattedDate = `${orderedDateParts}_${dateParts.hour}-${dateParts.minute}`;
|
|
879
|
+
const resourceTypeMap = {
|
|
880
|
+
[EXPORTABLE_RESOURCES.CATEGORY]: 'Categories',
|
|
881
|
+
[EXPORTABLE_RESOURCES.PRODUCT]: 'Products',
|
|
882
|
+
[EXPORTABLE_RESOURCES.PRODUCT_TYPE]: 'Product_Types',
|
|
883
|
+
[EXPORTABLE_RESOURCES.DISCOUNT_CODE]: 'Discount_Codes',
|
|
884
|
+
[EXPORTABLE_RESOURCES.INVENTORY_ENTRY]: 'Inventories',
|
|
885
|
+
[EXPORTABLE_RESOURCES.CUSTOMER]: 'Customers',
|
|
886
|
+
[EXPORTABLE_RESOURCES.ORDER]: 'Orders'
|
|
887
|
+
};
|
|
888
|
+
const displayName = resourceTypeMap[resourceType];
|
|
889
|
+
if (!displayName) {
|
|
890
|
+
throw new UnexpectedResourceTypeError(resourceType);
|
|
891
|
+
}
|
|
892
|
+
return `${displayName}_Export_${formattedDate}`;
|
|
893
|
+
}
|
|
894
|
+
function mapLocalesToOptions(locales) {
|
|
895
|
+
return _mapInstanceProperty(locales).call(locales, locale => ({
|
|
896
|
+
value: locale,
|
|
897
|
+
label: locale
|
|
898
|
+
}));
|
|
899
|
+
}
|
|
900
|
+
function isFilledArray(maybeArray) {
|
|
901
|
+
return _Array$isArray(maybeArray) && maybeArray.length > 0;
|
|
902
|
+
}
|
|
903
|
+
function appendCsvOrJsonExtensionIfAbsent(fileName, fileFormat) {
|
|
904
|
+
const extensionRegex = /\.(csv|json)$/i;
|
|
905
|
+
if (!extensionRegex.test(fileName)) return `${fileName}.${fileFormat}`;
|
|
906
|
+
return fileName;
|
|
907
|
+
}
|
|
908
|
+
function getExportLogsLink(projectKey, msg) {
|
|
909
|
+
return jsx(Link, {
|
|
910
|
+
to: `/${projectKey}/operations/export/logs`,
|
|
911
|
+
children: msg
|
|
912
|
+
}, "link");
|
|
913
|
+
}
|
|
914
|
+
const extractFieldNamesAndAdditionalFieldExtensions = fields => {
|
|
915
|
+
const result = _reduceInstanceProperty(fields).call(fields, (acc, field) => {
|
|
916
|
+
if (field.extendedFieldNames) {
|
|
917
|
+
return [...acc, field.name, ...field.extendedFieldNames];
|
|
918
|
+
}
|
|
919
|
+
return [...acc, field.name];
|
|
920
|
+
}, []);
|
|
921
|
+
return [...new _Set(result)];
|
|
922
|
+
};
|
|
923
|
+
function sortFieldsByFieldOrder(_ref) {
|
|
924
|
+
let fieldNames = _ref.fieldNames,
|
|
925
|
+
fieldOrder = _ref.fieldOrder;
|
|
926
|
+
if (isFilledArray(fieldOrder)) {
|
|
927
|
+
return _sortInstanceProperty(fieldNames).call(fieldNames, (a, b) => {
|
|
928
|
+
let orderA = _indexOfInstanceProperty(fieldOrder).call(fieldOrder, a) !== -1 ? _indexOfInstanceProperty(fieldOrder).call(fieldOrder, a) : _indexOfInstanceProperty(fieldOrder).call(fieldOrder, a.split('.')[0]);
|
|
929
|
+
let orderB = _indexOfInstanceProperty(fieldOrder).call(fieldOrder, b) !== -1 ? _indexOfInstanceProperty(fieldOrder).call(fieldOrder, b) : _indexOfInstanceProperty(fieldOrder).call(fieldOrder, b.split('.')[0]);
|
|
930
|
+
|
|
931
|
+
// If a field is not 'custom',then consider it as '*'
|
|
932
|
+
orderA = orderA === -1 ? _indexOfInstanceProperty(fieldOrder).call(fieldOrder, '*') : orderA;
|
|
933
|
+
orderB = orderB === -1 ? _indexOfInstanceProperty(fieldOrder).call(fieldOrder, '*') : orderB;
|
|
934
|
+
return orderA - orderB;
|
|
935
|
+
});
|
|
936
|
+
}
|
|
937
|
+
return fieldNames;
|
|
938
|
+
}
|
|
939
|
+
function buildSelectedExportFilters(selectedResourceIds) {
|
|
940
|
+
if (!selectedResourceIds || selectedResourceIds?.length === 0) return undefined;
|
|
941
|
+
const formattedIds = _mapInstanceProperty(selectedResourceIds).call(selectedResourceIds, id => `"${id}"`).join(', ');
|
|
942
|
+
return `id in (${formattedIds})`;
|
|
943
|
+
}
|
|
944
|
+
function isQueryFilter(filters) {
|
|
945
|
+
if (!filters) return false;
|
|
946
|
+
return 'query' in filters;
|
|
947
|
+
}
|
|
948
|
+
function isSearchFilter(filters) {
|
|
949
|
+
if (!filters) return false;
|
|
950
|
+
return 'filters' in filters || 'fullText' in filters;
|
|
951
|
+
}
|
|
952
|
+
function isPredicateFilter(filters) {
|
|
953
|
+
if (!filters) return false;
|
|
954
|
+
return 'where' in filters;
|
|
955
|
+
}
|
|
956
|
+
function validateFilters(filtersObject) {
|
|
957
|
+
if (filtersObject.where && filtersObject.filters) {
|
|
958
|
+
return false;
|
|
959
|
+
}
|
|
960
|
+
return Boolean(isQueryFilter(filtersObject.filters) || isSearchFilter(filtersObject.filters) || isPredicateFilter(filtersObject));
|
|
961
|
+
}
|
|
962
|
+
function areFiltersApplied(filtersObject) {
|
|
963
|
+
var _context2;
|
|
964
|
+
if (!filtersObject) {
|
|
965
|
+
return false;
|
|
966
|
+
}
|
|
967
|
+
if (filtersObject.where && _trimInstanceProperty(_context2 = filtersObject.where).call(_context2) !== '') {
|
|
968
|
+
return true;
|
|
969
|
+
}
|
|
970
|
+
if (isQueryFilter(filtersObject.filters)) {
|
|
971
|
+
return Boolean(filtersObject.filters.query);
|
|
972
|
+
}
|
|
973
|
+
if (isSearchFilter(filtersObject.filters)) {
|
|
974
|
+
var _context3, _context4;
|
|
975
|
+
const _filters = filtersObject.filters;
|
|
976
|
+
return Boolean(_filters.filters?.length || ((_context3 = _filters.fullText?.text) == null ? void 0 : _bindInstanceProperty(_context4 = Function.call).call(_context4, _trimInstanceProperty(_context3), _context3))?.());
|
|
977
|
+
}
|
|
978
|
+
return false;
|
|
979
|
+
}
|
|
980
|
+
function getInitialExportType(args) {
|
|
981
|
+
if (args.selectedResourceIds?.length) {
|
|
982
|
+
return EXPORT_TYPES.SELECTED;
|
|
983
|
+
}
|
|
984
|
+
if (args.filters?.total && areFiltersApplied(args.filters)) {
|
|
985
|
+
return EXPORT_TYPES.FILTERED;
|
|
986
|
+
}
|
|
987
|
+
return EXPORT_TYPES.ALL;
|
|
988
|
+
}
|
|
989
|
+
function removeEmptyGroups(groups) {
|
|
990
|
+
return _filterInstanceProperty(groups).call(groups, group => group.fields && group.fields.length > 0);
|
|
991
|
+
}
|
|
992
|
+
|
|
828
993
|
const isAnyFieldChecked = fields => {
|
|
829
994
|
return _someInstanceProperty(fields).call(fields, field => field.isChecked || field.fields && isAnyFieldChecked(field.fields));
|
|
830
995
|
};
|
|
@@ -938,6 +1103,25 @@ const getSelectedFieldLabels = group => {
|
|
|
938
1103
|
findSelectedFieldLabels(group.fields);
|
|
939
1104
|
return selectedLabels;
|
|
940
1105
|
};
|
|
1106
|
+
const extractFieldNamesFromGroups = (groups, fieldOrder) => {
|
|
1107
|
+
let checkedFields = [];
|
|
1108
|
+
const getCheckedFields = fields => {
|
|
1109
|
+
return _filterInstanceProperty(fields).call(fields, field => {
|
|
1110
|
+
if (field.fields) {
|
|
1111
|
+
return getCheckedFields(field.fields);
|
|
1112
|
+
}
|
|
1113
|
+
if (field.isChecked) checkedFields.push(field);
|
|
1114
|
+
return field.isChecked ?? false;
|
|
1115
|
+
});
|
|
1116
|
+
};
|
|
1117
|
+
_forEachInstanceProperty(groups).call(groups, group => {
|
|
1118
|
+
getCheckedFields(group.fields);
|
|
1119
|
+
});
|
|
1120
|
+
return sortFieldsByFieldOrder({
|
|
1121
|
+
fieldNames: extractFieldNamesAndAdditionalFieldExtensions(checkedFields),
|
|
1122
|
+
fieldOrder
|
|
1123
|
+
});
|
|
1124
|
+
};
|
|
941
1125
|
|
|
942
1126
|
let Step = /*#__PURE__*/function (Step) {
|
|
943
1127
|
Step["FileSettings"] = "file-settings";
|
|
@@ -958,21 +1142,27 @@ function validate(_ref) {
|
|
|
958
1142
|
let values = _valuesInstanceProperty(_ref),
|
|
959
1143
|
step = _ref.step,
|
|
960
1144
|
fieldSelectionMode = _ref.fieldSelectionMode,
|
|
961
|
-
importedHeaders = _ref.importedHeaders
|
|
1145
|
+
importedHeaders = _ref.importedHeaders,
|
|
1146
|
+
exportType = _ref.exportType;
|
|
962
1147
|
const fileName = values.fileName,
|
|
1148
|
+
queryPredicate = values.queryPredicate,
|
|
963
1149
|
locales = values.locales,
|
|
964
1150
|
groups = values.groups;
|
|
965
1151
|
const errors = {
|
|
966
1152
|
fileName: {},
|
|
967
1153
|
locales: {},
|
|
968
1154
|
fields: {},
|
|
969
|
-
importedCsvTemplateFile: {}
|
|
1155
|
+
importedCsvTemplateFile: {},
|
|
1156
|
+
queryPredicate: {}
|
|
970
1157
|
};
|
|
971
1158
|
if (TextInput.isEmpty(fileName)) {
|
|
972
1159
|
errors.fileName.missing = true;
|
|
973
1160
|
} else if (!/^[a-zA-Z0-9-_.]+$/.test(fileName)) {
|
|
974
1161
|
errors.fileName.invalidInput = true;
|
|
975
1162
|
}
|
|
1163
|
+
if (exportType === 'query-predicate' && TextInput.isEmpty(queryPredicate)) {
|
|
1164
|
+
errors.queryPredicate.missing = true;
|
|
1165
|
+
}
|
|
976
1166
|
if (step === Step.FieldsSelection) {
|
|
977
1167
|
if (fieldSelectionMode === 'selected-fields') {
|
|
978
1168
|
const allFields = _reduceInstanceProperty(groups).call(groups, (acc, group) => _concatInstanceProperty(acc).call(acc, group.fields), []);
|
|
@@ -1002,140 +1192,6 @@ function isFieldNameValid(header) {
|
|
|
1002
1192
|
return /^[a-zA-Z0-9._-]+$/.test(processedHeader);
|
|
1003
1193
|
}
|
|
1004
1194
|
|
|
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
1195
|
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
1196
|
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
1197
|
const updateFieldGroupsWithIsCheckedValue = (groups, cachedSelectedGroups) => {
|
|
@@ -1360,6 +1416,13 @@ function groupFieldValidationErrors(errors, intl) {
|
|
|
1360
1416
|
});
|
|
1361
1417
|
}
|
|
1362
1418
|
|
|
1419
|
+
function isExportApiSuccessResponse(response) {
|
|
1420
|
+
return 'id' in response && 'state' in response && 'resourceType' in response && 'resourceCount' in response;
|
|
1421
|
+
}
|
|
1422
|
+
function isExportApiErrorResponse(error) {
|
|
1423
|
+
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);
|
|
1424
|
+
}
|
|
1425
|
+
|
|
1363
1426
|
const useInitialValues = props => {
|
|
1364
1427
|
var _context;
|
|
1365
1428
|
const _useApplicationContex = useApplicationContext(applicationContext => ({
|
|
@@ -1392,6 +1455,7 @@ const useInitialValues = props => {
|
|
|
1392
1455
|
fileName: `${resourceTypeToFileName(props.resourceType, userLocale)}`,
|
|
1393
1456
|
locales: [locale],
|
|
1394
1457
|
groups: updateFieldGroupWithAdditionalFieldExtensions(groups),
|
|
1458
|
+
queryPredicate: '',
|
|
1395
1459
|
// Preferences
|
|
1396
1460
|
fillRows: false,
|
|
1397
1461
|
importedCsvTemplateFile: null
|
|
@@ -1403,37 +1467,30 @@ const _excluded$3 = ["projectKey"];
|
|
|
1403
1467
|
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
1468
|
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
1469
|
async function makeExportRequest(params, asyncDispatchFn) {
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
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;
|
|
1470
|
+
const projectKey = params.projectKey,
|
|
1471
|
+
requestData = _objectWithoutProperties(params, _excluded$3);
|
|
1472
|
+
const uri = `/${projectKey}/export-operations`;
|
|
1473
|
+
const requestAction = actions.post({
|
|
1474
|
+
mcApiProxyTarget: MC_API_PROXY_TARGETS.EXPORT,
|
|
1475
|
+
uri,
|
|
1476
|
+
headers: {
|
|
1477
|
+
accept: 'application/json'
|
|
1478
|
+
},
|
|
1479
|
+
payload: requestData
|
|
1480
|
+
});
|
|
1481
|
+
const response = await asyncDispatchFn(requestAction);
|
|
1482
|
+
if (!response || typeof response !== 'object') {
|
|
1483
|
+
throw new InvalidResponseError();
|
|
1484
|
+
}
|
|
1485
|
+
if (!('state' in response)) {
|
|
1486
|
+
throw new InvalidResponseError('Response missing state field');
|
|
1431
1487
|
}
|
|
1488
|
+
return response;
|
|
1432
1489
|
}
|
|
1433
1490
|
function createExportOperation(params, asyncDispatchFn) {
|
|
1434
1491
|
return makeExportRequest(params, asyncDispatchFn);
|
|
1435
1492
|
}
|
|
1436
|
-
function
|
|
1493
|
+
function validateExportOperation(params, asyncDispatchFn) {
|
|
1437
1494
|
return makeExportRequest(_objectSpread$c(_objectSpread$c({}, params), {}, {
|
|
1438
1495
|
dryRun: true
|
|
1439
1496
|
}), asyncDispatchFn);
|
|
@@ -1448,25 +1505,6 @@ const useStartExportOperation = props => {
|
|
|
1448
1505
|
projectKey: applicationContext.project?.key
|
|
1449
1506
|
})),
|
|
1450
1507
|
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
1508
|
const startExportOperation = async (values, exportType, fieldSelectionMode, localeOption, importedHeaders) => {
|
|
1471
1509
|
try {
|
|
1472
1510
|
if (!projectKey) throw new Error('Project key is missing');
|
|
@@ -1474,7 +1512,7 @@ const useStartExportOperation = props => {
|
|
|
1474
1512
|
if (fieldSelectionMode === 'imported-csv-template' && values.importedCsvTemplateFile) {
|
|
1475
1513
|
fields = importedHeaders;
|
|
1476
1514
|
} else {
|
|
1477
|
-
fields = extractFieldNamesFromGroups(values.groups);
|
|
1515
|
+
fields = extractFieldNamesFromGroups(values.groups, props.fieldOrder);
|
|
1478
1516
|
}
|
|
1479
1517
|
let where = undefined;
|
|
1480
1518
|
let filters = undefined;
|
|
@@ -1487,6 +1525,9 @@ const useStartExportOperation = props => {
|
|
|
1487
1525
|
} else if (isSearchFilter(props.filters.filters)) {
|
|
1488
1526
|
filters = props.filters.filters;
|
|
1489
1527
|
}
|
|
1528
|
+
} else if (exportType === EXPORT_TYPES.QUERY_PREDICATE) {
|
|
1529
|
+
var _context;
|
|
1530
|
+
where = _trimInstanceProperty(_context = values.queryPredicate).call(_context);
|
|
1490
1531
|
}
|
|
1491
1532
|
let locales = undefined;
|
|
1492
1533
|
if (localeOption !== 'onlyLocalesFoundInCsvFile') {
|
|
@@ -1503,29 +1544,32 @@ const useStartExportOperation = props => {
|
|
|
1503
1544
|
where,
|
|
1504
1545
|
filters
|
|
1505
1546
|
}, asyncDispatch);
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1547
|
+
if (isExportApiSuccessResponse(response)) {
|
|
1548
|
+
switch (response.state) {
|
|
1549
|
+
case EXPORT_OPERATION_STATES.QUEUED:
|
|
1550
|
+
case EXPORT_OPERATION_STATES.PROCESSING:
|
|
1551
|
+
case EXPORT_OPERATION_STATES.COMPLETED:
|
|
1552
|
+
showNotification({
|
|
1553
|
+
kind: 'info',
|
|
1554
|
+
domain: DOMAINS.SIDE,
|
|
1555
|
+
// @ts-ignore
|
|
1556
|
+
text: intl.formatMessage(messages.exportOperationSuccessMessage, {
|
|
1557
|
+
newline: getNewLine,
|
|
1558
|
+
logsLink: msg => getExportLogsLink(projectKey, msg),
|
|
1559
|
+
b: getBold
|
|
1560
|
+
})
|
|
1561
|
+
}, {
|
|
1562
|
+
dismissAfter: 5000
|
|
1563
|
+
});
|
|
1564
|
+
if (typeof props.onExportSuccess === 'function') props.onExportSuccess();
|
|
1565
|
+
break;
|
|
1566
|
+
default:
|
|
1567
|
+
throw new UnexpectedExportOperationStateError(response.state);
|
|
1568
|
+
}
|
|
1569
|
+
} else {
|
|
1570
|
+
throw new Error(response.message || 'Unknown error occurred during export operation');
|
|
1526
1571
|
}
|
|
1527
1572
|
} catch (error) {
|
|
1528
|
-
// TODO: custom error messages for each error type
|
|
1529
1573
|
showNotification({
|
|
1530
1574
|
text: intl.formatMessage(messages.unexpectedError),
|
|
1531
1575
|
kind: 'error',
|
|
@@ -1641,7 +1685,7 @@ const useConvertFieldDefinitionsForExport = () => {
|
|
|
1641
1685
|
};
|
|
1642
1686
|
};
|
|
1643
1687
|
|
|
1644
|
-
const
|
|
1688
|
+
const useValidateExportOperation = () => {
|
|
1645
1689
|
const intl = useIntl();
|
|
1646
1690
|
const asyncDispatch = useAsyncDispatch();
|
|
1647
1691
|
const showNotification = useShowNotification();
|
|
@@ -1649,9 +1693,9 @@ const useValidateImportedHeaders = () => {
|
|
|
1649
1693
|
projectKey: context.project?.key
|
|
1650
1694
|
})),
|
|
1651
1695
|
projectKey = _useApplicationContex.projectKey;
|
|
1652
|
-
const
|
|
1696
|
+
const validateExport = async params => {
|
|
1653
1697
|
try {
|
|
1654
|
-
var _context;
|
|
1698
|
+
var _context, _context2, _context3;
|
|
1655
1699
|
if (!projectKey) return;
|
|
1656
1700
|
const invalidFields = _filterInstanceProperty(_context = params.fields).call(_context, field => !isFieldNameValid(field));
|
|
1657
1701
|
if (invalidFields.length > 0) {
|
|
@@ -1663,25 +1707,46 @@ const useValidateImportedHeaders = () => {
|
|
|
1663
1707
|
}))
|
|
1664
1708
|
};
|
|
1665
1709
|
}
|
|
1666
|
-
await
|
|
1710
|
+
const response = await validateExportOperation({
|
|
1667
1711
|
projectKey,
|
|
1668
1712
|
resourceType: params.resourceType,
|
|
1669
1713
|
fileName: params.fileName,
|
|
1670
1714
|
fileFormat: params.outputFormat,
|
|
1671
1715
|
fields: params.fields,
|
|
1672
|
-
locales: params.locales
|
|
1716
|
+
locales: params.locales,
|
|
1717
|
+
where: ((_context2 = params.queryPredicate) == null ? void 0 : _bindInstanceProperty(_context3 = Function.call).call(_context3, _trimInstanceProperty(_context2), _context2))?.() || undefined
|
|
1673
1718
|
}, asyncDispatch);
|
|
1674
|
-
|
|
1675
|
-
success: true,
|
|
1676
|
-
validationErrors: []
|
|
1677
|
-
};
|
|
1678
|
-
} catch (error) {
|
|
1679
|
-
if (typeof error === 'object' && error && 'validationErrors' in error && _Array$isArray(error.validationErrors)) {
|
|
1719
|
+
if (isExportApiSuccessResponse(response) && response.resourceCount === 0) {
|
|
1680
1720
|
return {
|
|
1681
1721
|
success: false,
|
|
1682
|
-
|
|
1722
|
+
noResourcesToExport: true
|
|
1683
1723
|
};
|
|
1684
1724
|
}
|
|
1725
|
+
return {
|
|
1726
|
+
success: true
|
|
1727
|
+
};
|
|
1728
|
+
} catch (error) {
|
|
1729
|
+
if (isExportApiErrorResponse(error)) {
|
|
1730
|
+
if (error.body.errors?.length) {
|
|
1731
|
+
var _context4;
|
|
1732
|
+
const whereError = _findInstanceProperty(_context4 = error.body.errors).call(_context4, error => {
|
|
1733
|
+
var _context5;
|
|
1734
|
+
return error.message && _includesInstanceProperty(_context5 = error.message).call(_context5, 'Malformed parameter: where');
|
|
1735
|
+
});
|
|
1736
|
+
if (whereError) {
|
|
1737
|
+
return {
|
|
1738
|
+
success: false,
|
|
1739
|
+
invalidQueryPredicate: true
|
|
1740
|
+
};
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1743
|
+
if (error.body.validationErrors?.length) {
|
|
1744
|
+
return {
|
|
1745
|
+
success: false,
|
|
1746
|
+
validationErrors: error.body.validationErrors
|
|
1747
|
+
};
|
|
1748
|
+
}
|
|
1749
|
+
}
|
|
1685
1750
|
showNotification({
|
|
1686
1751
|
text: intl.formatMessage(messages.unexpectedError),
|
|
1687
1752
|
kind: 'error',
|
|
@@ -1694,7 +1759,7 @@ const useValidateImportedHeaders = () => {
|
|
|
1694
1759
|
}
|
|
1695
1760
|
};
|
|
1696
1761
|
return {
|
|
1697
|
-
|
|
1762
|
+
validateExport
|
|
1698
1763
|
};
|
|
1699
1764
|
};
|
|
1700
1765
|
|
|
@@ -1742,6 +1807,7 @@ function ownKeys$9(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySy
|
|
|
1742
1807
|
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
1808
|
function ExportScopeSection() {
|
|
1744
1809
|
const _useExportResourcesMo = useExportResourcesModalContext(),
|
|
1810
|
+
formik = _useExportResourcesMo.formik,
|
|
1745
1811
|
exportType = _useExportResourcesMo.exportType,
|
|
1746
1812
|
totalResourcesCount = _useExportResourcesMo.totalResourcesCount,
|
|
1747
1813
|
filters = _useExportResourcesMo.filters,
|
|
@@ -1749,10 +1815,11 @@ function ExportScopeSection() {
|
|
|
1749
1815
|
selectedResourceIds = _useExportResourcesMo.selectedResourceIds,
|
|
1750
1816
|
setExportType = _useExportResourcesMo.setExportType,
|
|
1751
1817
|
resourceType = _useExportResourcesMo.resourceType,
|
|
1752
|
-
hideExportSelectedResourcesOption = _useExportResourcesMo.hideExportSelectedResourcesOption
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1818
|
+
hideExportSelectedResourcesOption = _useExportResourcesMo.hideExportSelectedResourcesOption,
|
|
1819
|
+
showQueryPredicateOption = _useExportResourcesMo.showQueryPredicateOption;
|
|
1820
|
+
const shouldShowQueryPredicateField = exportType === EXPORT_TYPES.QUERY_PREDICATE;
|
|
1821
|
+
return jsxs(Fragment, {
|
|
1822
|
+
children: [jsxs(RadioInput.Group, {
|
|
1756
1823
|
value: exportType,
|
|
1757
1824
|
onChange: e => {
|
|
1758
1825
|
setExportType(e.target.value);
|
|
@@ -1792,8 +1859,23 @@ function ExportScopeSection() {
|
|
|
1792
1859
|
}
|
|
1793
1860
|
}) : messages.exportScopeSelectedWithoutCount
|
|
1794
1861
|
})
|
|
1862
|
+
}), showQueryPredicateOption && jsx(RadioInput.Option, {
|
|
1863
|
+
value: EXPORT_TYPES.QUERY_PREDICATE,
|
|
1864
|
+
children: jsx(Text.Body, {
|
|
1865
|
+
intlMessage: messages.queryPredicate
|
|
1866
|
+
})
|
|
1795
1867
|
})]
|
|
1796
|
-
})
|
|
1868
|
+
}), shouldShowQueryPredicateField && jsx(TextField, {
|
|
1869
|
+
name: "queryPredicate",
|
|
1870
|
+
"data-testid": "query-predicate-field",
|
|
1871
|
+
title: "",
|
|
1872
|
+
onChange: formik.handleChange,
|
|
1873
|
+
onBlur: formik.handleBlur,
|
|
1874
|
+
value: _valuesInstanceProperty(formik).queryPredicate,
|
|
1875
|
+
touched: formik.touched.queryPredicate,
|
|
1876
|
+
errors: mapFormikErrors(formik.errors.queryPredicate),
|
|
1877
|
+
renderError: renderQueryPredicateError
|
|
1878
|
+
})]
|
|
1797
1879
|
});
|
|
1798
1880
|
}
|
|
1799
1881
|
|
|
@@ -2640,6 +2722,8 @@ const _excluded$1 = ["children"];
|
|
|
2640
2722
|
const ExportResourcesProvider = _ref => {
|
|
2641
2723
|
let children = _ref.children,
|
|
2642
2724
|
props = _objectWithoutProperties(_ref, _excluded$1);
|
|
2725
|
+
const intl = useIntl();
|
|
2726
|
+
const showNotification = useShowNotification();
|
|
2643
2727
|
const initialValues = useInitialValues(props);
|
|
2644
2728
|
const _React$useState = React.useState(Step.FileSettings),
|
|
2645
2729
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
@@ -2670,47 +2754,70 @@ 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?.noResourcesToExport) {
|
|
2784
|
+
showNotification({
|
|
2785
|
+
text: intl.formatMessage(messages.noResourcesToExport),
|
|
2786
|
+
kind: 'error',
|
|
2787
|
+
domain: DOMAINS.PAGE
|
|
2788
|
+
});
|
|
2789
|
+
return;
|
|
2790
|
+
}
|
|
2791
|
+
}
|
|
2792
|
+
setCurrentStep(Step.FieldsSelection);
|
|
2793
|
+
} else if (currentStep === Step.FieldsSelection) {
|
|
2794
|
+
if (fieldSelectionMode !== 'imported-csv-template') {
|
|
2795
|
+
setCurrentStep(Step.ConfirmExport);
|
|
2796
|
+
return;
|
|
2797
|
+
}
|
|
2798
|
+
const isUsingImportedCsvLocales = localeOption === 'onlyLocalesFoundInCsvFile';
|
|
2799
|
+
const validationResult = await validateExport({
|
|
2800
|
+
fileName: values.fileName,
|
|
2801
|
+
outputFormat: values.outputFormat,
|
|
2802
|
+
resourceType: props.resourceType,
|
|
2803
|
+
fields: importedHeaders,
|
|
2804
|
+
locales: isUsingImportedCsvLocales ? undefined : values.locales,
|
|
2805
|
+
queryPredicate: values.queryPredicate
|
|
2806
|
+
});
|
|
2807
|
+
if (validationResult?.success) {
|
|
2808
|
+
setCurrentStep(Step.ConfirmExport);
|
|
2809
|
+
} else {
|
|
2810
|
+
setValidationErrors(validationResult?.validationErrors);
|
|
2811
|
+
setCurrentStep(Step.ValidationErrors);
|
|
2812
|
+
}
|
|
2813
|
+
} else {
|
|
2814
|
+
startExportOperation(values, exportType, fieldSelectionMode, localeOption, importedHeaders);
|
|
2815
|
+
}
|
|
2816
|
+
}
|
|
2710
2817
|
});
|
|
2711
2818
|
React.useEffect(() => {
|
|
2712
2819
|
formik.validateForm();
|
|
2713
|
-
}, [currentStep, fieldSelectionMode, importedHeaders]);
|
|
2820
|
+
}, [currentStep, fieldSelectionMode, importedHeaders, exportType]);
|
|
2714
2821
|
return jsx(ExportResourcesContext.Provider, {
|
|
2715
2822
|
value: {
|
|
2716
2823
|
formik,
|
|
@@ -2722,6 +2829,7 @@ const ExportResourcesProvider = _ref => {
|
|
|
2722
2829
|
totalResourcesCount: props.totalResourcesCount,
|
|
2723
2830
|
selectedResourceIds: props.selectedResourceIds,
|
|
2724
2831
|
hideExportSelectedResourcesOption: props.hideExportSelectedResourcesOption,
|
|
2832
|
+
showQueryPredicateOption: props.showQueryPredicateOption,
|
|
2725
2833
|
filters: props.filters,
|
|
2726
2834
|
hasFilters: areFiltersApplied(props.filters),
|
|
2727
2835
|
setExportType,
|
|
@@ -3073,11 +3181,11 @@ function getDefaultDropWrapperStyles(_dropAreaState) {
|
|
|
3073
3181
|
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
3182
|
}
|
|
3075
3183
|
|
|
3076
|
-
var ActiveDragDropArea = /*#__PURE__*/lazy(() => import('./active-drag-drop-area-
|
|
3184
|
+
var ActiveDragDropArea = /*#__PURE__*/lazy(() => import('./active-drag-drop-area-69b691d5.esm.js' /* webpackChunkName: "active-drag-drop-area" */));
|
|
3077
3185
|
|
|
3078
|
-
var EnabledDropArea = /*#__PURE__*/lazy(() => import('./enabled-drop-area-
|
|
3186
|
+
var EnabledDropArea = /*#__PURE__*/lazy(() => import('./enabled-drop-area-48a953a6.esm.js' /* webpackChunkName: "enabled-drop-area" */));
|
|
3079
3187
|
|
|
3080
|
-
var FileDropped = /*#__PURE__*/lazy(() => import('./file-dropped-area-
|
|
3188
|
+
var FileDropped = /*#__PURE__*/lazy(() => import('./file-dropped-area-c8a5f539.esm.js' /* webpackChunkName: "filed-dropped-area" */));
|
|
3081
3189
|
|
|
3082
3190
|
function getDropArea(_ref) {
|
|
3083
3191
|
let dropAreaState = _ref.dropAreaState,
|