@commercetools-frontend-extensions/export-resources-modal 3.0.0 → 3.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/README.md +5 -1
- package/dist/commercetools-frontend-extensions-export-resources-modal.cjs.dev.js +5 -1
- package/dist/commercetools-frontend-extensions-export-resources-modal.cjs.prod.js +5 -1
- package/dist/commercetools-frontend-extensions-export-resources-modal.esm.js +5 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -26,6 +26,7 @@ import { ExportResourcesModal } from '@commercetools-frontend-extensions/export-
|
|
|
26
26
|
|
|
27
27
|
// in case export all the resources
|
|
28
28
|
<ExportResourcesModal
|
|
29
|
+
isOpen={true}
|
|
29
30
|
outputFormat="csv"
|
|
30
31
|
resourceType="category"
|
|
31
32
|
totalResourcesCount={143}
|
|
@@ -76,6 +77,7 @@ import { ExportResourcesModal } from '@commercetools-frontend-extensions/export-
|
|
|
76
77
|
|
|
77
78
|
// in case export only selected resources
|
|
78
79
|
<ExportResourcesModal
|
|
80
|
+
isOpen={true}
|
|
79
81
|
outputFormat="csv"
|
|
80
82
|
resourceType="category"
|
|
81
83
|
totalResourcesCount={143}
|
|
@@ -130,8 +132,10 @@ import { ExportResourcesModal } from '@commercetools-frontend-extensions/export-
|
|
|
130
132
|
|
|
131
133
|
| Props | Type | Required | Default | Description |
|
|
132
134
|
| ------------------------------ | ------------------------------------------------------- | :----------------------------------------------: | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
135
|
+
| `isOpen` | `boolean` | | `false` | Controls whether the export modal is open or closed |
|
|
133
136
|
| `outputFormat` | `string`<br/>Possible values: `csv`, `json` | | `csv` | The file format to export |
|
|
134
|
-
| `
|
|
137
|
+
| `onExportSuccess` | `function` | | | Callback function that is called when the export operation is successful |
|
|
138
|
+
| `onClose` | `function` | | | Callback function invoked when the modal is requested to close (on overlay click, close button click or `ESC` press). This function is also called after an export operation regardless of its success or failure |
|
|
135
139
|
| `resourceType` | `string` | ✅ | | The type of the resource, example: `category`, `product`... |
|
|
136
140
|
| `totalResourcesCount` | `Number` | ✅ | | The count of all resources of identified `resourceType` |
|
|
137
141
|
| `exportType` | `string` <br/>Possible values:<br/>`all` and `selected` | | `all` | The type of export, so either export `all` resources or export only `selected` resources |
|
|
@@ -679,6 +679,7 @@ const useStartExportOperation = props => {
|
|
|
679
679
|
}, {
|
|
680
680
|
dismissAfter: 5000
|
|
681
681
|
});
|
|
682
|
+
if (typeof props.onExportSuccess === 'function') props.onExportSuccess();
|
|
682
683
|
break;
|
|
683
684
|
default:
|
|
684
685
|
throw new UnexpectedExportOperationStateError(response.state);
|
|
@@ -939,9 +940,11 @@ process.env.NODE_ENV !== "production" ? {
|
|
|
939
940
|
const ExportResourcesContext = /*#__PURE__*/React.createContext();
|
|
940
941
|
|
|
941
942
|
const ExportResourcesModalShape = PropTypes__default["default"].shape({
|
|
943
|
+
isOpen: PropTypes__default["default"].bool,
|
|
942
944
|
resourceType: PropTypes__default["default"].string.isRequired,
|
|
943
945
|
outputFormat: PropTypes__default["default"].string,
|
|
944
946
|
onClose: PropTypes__default["default"].func,
|
|
947
|
+
onExportSuccess: PropTypes__default["default"].func,
|
|
945
948
|
totalResourcesCount: PropTypes__default["default"].number.isRequired,
|
|
946
949
|
selectedResourceIds: PropTypes__default["default"].array,
|
|
947
950
|
// TODO: Circular reference
|
|
@@ -1026,7 +1029,7 @@ const ExportResourcesModal = props => {
|
|
|
1026
1029
|
});
|
|
1027
1030
|
return jsxRuntime.jsx(ExportResourcesProvider, _objectSpread(_objectSpread({}, props), {}, {
|
|
1028
1031
|
children: jsxRuntime.jsx(applicationComponents.InfoDialog, {
|
|
1029
|
-
isOpen:
|
|
1032
|
+
isOpen: props.isOpen,
|
|
1030
1033
|
title: intl.formatMessage(messages.modalTitle, {
|
|
1031
1034
|
resourceType: resourceTypePlural
|
|
1032
1035
|
}),
|
|
@@ -1039,6 +1042,7 @@ const ExportResourcesModal = props => {
|
|
|
1039
1042
|
ExportResourcesModal.displayName = 'ExportResourcesModal';
|
|
1040
1043
|
ExportResourcesModal.propTypes = process.env.NODE_ENV !== "production" ? ExportResourcesModalShape : {};
|
|
1041
1044
|
ExportResourcesModal.defaultProps = {
|
|
1045
|
+
isOpen: false,
|
|
1042
1046
|
selectedResourceIds: [],
|
|
1043
1047
|
exportType: EXPORT_TYPES.ALL,
|
|
1044
1048
|
outputFormat: OUTPUT_FORMATS.CSV
|
|
@@ -679,6 +679,7 @@ const useStartExportOperation = props => {
|
|
|
679
679
|
}, {
|
|
680
680
|
dismissAfter: 5000
|
|
681
681
|
});
|
|
682
|
+
if (typeof props.onExportSuccess === 'function') props.onExportSuccess();
|
|
682
683
|
break;
|
|
683
684
|
default:
|
|
684
685
|
throw new UnexpectedExportOperationStateError(response.state);
|
|
@@ -910,9 +911,11 @@ const ExportFieldsSelectionStep = () => {
|
|
|
910
911
|
const ExportResourcesContext = /*#__PURE__*/React.createContext();
|
|
911
912
|
|
|
912
913
|
PropTypes__default["default"].shape({
|
|
914
|
+
isOpen: PropTypes__default["default"].bool,
|
|
913
915
|
resourceType: PropTypes__default["default"].string.isRequired,
|
|
914
916
|
outputFormat: PropTypes__default["default"].string,
|
|
915
917
|
onClose: PropTypes__default["default"].func,
|
|
918
|
+
onExportSuccess: PropTypes__default["default"].func,
|
|
916
919
|
totalResourcesCount: PropTypes__default["default"].number.isRequired,
|
|
917
920
|
selectedResourceIds: PropTypes__default["default"].array,
|
|
918
921
|
// TODO: Circular reference
|
|
@@ -993,7 +996,7 @@ const ExportResourcesModal = props => {
|
|
|
993
996
|
});
|
|
994
997
|
return jsxRuntime.jsx(ExportResourcesProvider, _objectSpread(_objectSpread({}, props), {}, {
|
|
995
998
|
children: jsxRuntime.jsx(applicationComponents.InfoDialog, {
|
|
996
|
-
isOpen:
|
|
999
|
+
isOpen: props.isOpen,
|
|
997
1000
|
title: intl.formatMessage(messages.modalTitle, {
|
|
998
1001
|
resourceType: resourceTypePlural
|
|
999
1002
|
}),
|
|
@@ -1006,6 +1009,7 @@ const ExportResourcesModal = props => {
|
|
|
1006
1009
|
ExportResourcesModal.displayName = 'ExportResourcesModal';
|
|
1007
1010
|
ExportResourcesModal.propTypes = {};
|
|
1008
1011
|
ExportResourcesModal.defaultProps = {
|
|
1012
|
+
isOpen: false,
|
|
1009
1013
|
selectedResourceIds: [],
|
|
1010
1014
|
exportType: EXPORT_TYPES.ALL,
|
|
1011
1015
|
outputFormat: OUTPUT_FORMATS.CSV
|
|
@@ -647,6 +647,7 @@ const useStartExportOperation = props => {
|
|
|
647
647
|
}, {
|
|
648
648
|
dismissAfter: 5000
|
|
649
649
|
});
|
|
650
|
+
if (typeof props.onExportSuccess === 'function') props.onExportSuccess();
|
|
650
651
|
break;
|
|
651
652
|
default:
|
|
652
653
|
throw new UnexpectedExportOperationStateError(response.state);
|
|
@@ -907,9 +908,11 @@ process.env.NODE_ENV !== "production" ? {
|
|
|
907
908
|
const ExportResourcesContext = /*#__PURE__*/createContext();
|
|
908
909
|
|
|
909
910
|
const ExportResourcesModalShape = PropTypes.shape({
|
|
911
|
+
isOpen: PropTypes.bool,
|
|
910
912
|
resourceType: PropTypes.string.isRequired,
|
|
911
913
|
outputFormat: PropTypes.string,
|
|
912
914
|
onClose: PropTypes.func,
|
|
915
|
+
onExportSuccess: PropTypes.func,
|
|
913
916
|
totalResourcesCount: PropTypes.number.isRequired,
|
|
914
917
|
selectedResourceIds: PropTypes.array,
|
|
915
918
|
// TODO: Circular reference
|
|
@@ -994,7 +997,7 @@ const ExportResourcesModal = props => {
|
|
|
994
997
|
});
|
|
995
998
|
return jsx(ExportResourcesProvider, _objectSpread(_objectSpread({}, props), {}, {
|
|
996
999
|
children: jsx(InfoDialog, {
|
|
997
|
-
isOpen:
|
|
1000
|
+
isOpen: props.isOpen,
|
|
998
1001
|
title: intl.formatMessage(messages.modalTitle, {
|
|
999
1002
|
resourceType: resourceTypePlural
|
|
1000
1003
|
}),
|
|
@@ -1007,6 +1010,7 @@ const ExportResourcesModal = props => {
|
|
|
1007
1010
|
ExportResourcesModal.displayName = 'ExportResourcesModal';
|
|
1008
1011
|
ExportResourcesModal.propTypes = process.env.NODE_ENV !== "production" ? ExportResourcesModalShape : {};
|
|
1009
1012
|
ExportResourcesModal.defaultProps = {
|
|
1013
|
+
isOpen: false,
|
|
1010
1014
|
selectedResourceIds: [],
|
|
1011
1015
|
exportType: EXPORT_TYPES.ALL,
|
|
1012
1016
|
outputFormat: OUTPUT_FORMATS.CSV
|
package/package.json
CHANGED