@commercetools-frontend-extensions/export-resources-modal 5.10.1 → 5.11.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/README.md CHANGED
@@ -338,7 +338,8 @@ import ExportResourcesModal from '@commercetools-frontend-extensions/export-reso
338
338
  | `onExportSuccess` | `function` | | | Callback function that is called when the export operation is successful |
339
339
  | `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 |
340
340
  | `resourceType` | `string` | ✅ | | The type of the resource, example: `category`, `product`...
341
- | `filters` | `Filters` | | | Filters can be set as filters object with a `query` property or array of strings. It can also be set as a simple string for the `where` property. Lastly, another option is to set Filters as `fulltext` object with `text` and locale` string properties.
341
+ | `filters` | `Filters` | | | Filters can be set as filters object with a `query` property or array of strings. It can also be set as a simple string for the `where` property. Lastly, another option is to set Filters as `fulltext` object with `text` and `locale` string properties.
342
+ | `baseFilters` | `Pick<Filters, 'where'>` | | | These filters are always forwarded to the API (merged with `filters` prop if exists) and cannot be bypassed by users.
342
343
  | `totalResourcesCount` | `number` | ✅ | | The count of all resources of identified `resourceType` |
343
344
  | `selectedResourceIds` | `array` | | | Array of Ids of the selected resources |
344
345
  | `fieldGroups` | `array` | ✅ | | Array of the grouped `fields` to export. |
@@ -1755,6 +1755,12 @@ function validateExportOperation(params, asyncDispatchFn) {
1755
1755
  }), asyncDispatchFn);
1756
1756
  }
1757
1757
 
1758
+ const mergeWhereClause = (base, user) => {
1759
+ if (!base && !user) return undefined;
1760
+ if (base && !user) return base;
1761
+ if (!base && user) return user;
1762
+ return `(${base}) and (${user})`;
1763
+ };
1758
1764
  const useStartExportOperation = props => {
1759
1765
  const intl = reactIntl.useIntl();
1760
1766
  const asyncDispatch = sdk.useAsyncDispatch();
@@ -1788,6 +1794,7 @@ const useStartExportOperation = props => {
1788
1794
  var _context;
1789
1795
  where = _trimInstanceProperty__default["default"](_context = values.queryPredicate).call(_context);
1790
1796
  }
1797
+ where = mergeWhereClause(props.baseFilters?.where, where);
1791
1798
  let locales = undefined;
1792
1799
  if (localeOption !== 'onlyLocalesFoundInCsvFile') {
1793
1800
  locales = values.locales;
@@ -1755,6 +1755,12 @@ function validateExportOperation(params, asyncDispatchFn) {
1755
1755
  }), asyncDispatchFn);
1756
1756
  }
1757
1757
 
1758
+ const mergeWhereClause = (base, user) => {
1759
+ if (!base && !user) return undefined;
1760
+ if (base && !user) return base;
1761
+ if (!base && user) return user;
1762
+ return `(${base}) and (${user})`;
1763
+ };
1758
1764
  const useStartExportOperation = props => {
1759
1765
  const intl = reactIntl.useIntl();
1760
1766
  const asyncDispatch = sdk.useAsyncDispatch();
@@ -1788,6 +1794,7 @@ const useStartExportOperation = props => {
1788
1794
  var _context;
1789
1795
  where = _trimInstanceProperty__default["default"](_context = values.queryPredicate).call(_context);
1790
1796
  }
1797
+ where = mergeWhereClause(props.baseFilters?.where, where);
1791
1798
  let locales = undefined;
1792
1799
  if (localeOption !== 'onlyLocalesFoundInCsvFile') {
1793
1800
  locales = values.locales;
@@ -1712,6 +1712,12 @@ function validateExportOperation(params, asyncDispatchFn) {
1712
1712
  }), asyncDispatchFn);
1713
1713
  }
1714
1714
 
1715
+ const mergeWhereClause = (base, user) => {
1716
+ if (!base && !user) return undefined;
1717
+ if (base && !user) return base;
1718
+ if (!base && user) return user;
1719
+ return `(${base}) and (${user})`;
1720
+ };
1715
1721
  const useStartExportOperation = props => {
1716
1722
  const intl = useIntl();
1717
1723
  const asyncDispatch = useAsyncDispatch();
@@ -1745,6 +1751,7 @@ const useStartExportOperation = props => {
1745
1751
  var _context;
1746
1752
  where = _trimInstanceProperty(_context = values.queryPredicate).call(_context);
1747
1753
  }
1754
+ where = mergeWhereClause(props.baseFilters?.where, where);
1748
1755
  let locales = undefined;
1749
1756
  if (localeOption !== 'onlyLocalesFoundInCsvFile') {
1750
1757
  locales = values.locales;
@@ -24,6 +24,7 @@ export interface ExportResourcesModalProps {
24
24
  isOpen?: boolean;
25
25
  resourceType: ResourceType;
26
26
  outputFormat?: string;
27
+ baseFilters?: Pick<Filters, 'where'>;
27
28
  filters?: Filters;
28
29
  totalResourcesCount: number;
29
30
  selectedResourceIds?: string[];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@commercetools-frontend-extensions/export-resources-modal",
3
3
  "description": "Shared export modal for exporting resources",
4
- "version": "5.10.1",
4
+ "version": "5.11.1",
5
5
  "license": "BSD-3-Clause",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -26,7 +26,7 @@
26
26
  "moment": "2.30.1",
27
27
  "omit-empty-es": "^1.1.3",
28
28
  "prop-types": "15.8.1",
29
- "@commercetools-frontend-extensions/operations": "3.5.0"
29
+ "@commercetools-frontend-extensions/operations": "3.6.0"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@commercetools-frontend/actions-global": "25.1.0",