@contentful/field-editor-reference 5.1.2 → 5.1.5

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/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [5.1.5](https://github.com/contentful/field-editors/compare/@contentful/field-editor-reference@5.1.4...@contentful/field-editor-reference@5.1.5) (2022-09-06)
7
+
8
+ **Note:** Version bump only for package @contentful/field-editor-reference
9
+
10
+ ## [5.1.4](https://github.com/contentful/field-editors/compare/@contentful/field-editor-reference@5.1.3...@contentful/field-editor-reference@5.1.4) (2022-08-30)
11
+
12
+ ### Bug Fixes
13
+
14
+ - **EntityStore:** use fixed cache key for scheduled actions [SPA-871] ([#1224](https://github.com/contentful/field-editors/issues/1224)) ([6b78132](https://github.com/contentful/field-editors/commit/6b78132d0c7643a88c2f15f8d14563355c65f30c))
15
+
16
+ ## [5.1.3](https://github.com/contentful/field-editors/compare/@contentful/field-editor-reference@5.1.2...@contentful/field-editor-reference@5.1.3) (2022-08-26)
17
+
18
+ ### Bug Fixes
19
+
20
+ - **EntityStore:** respect environment alias ([#1223](https://github.com/contentful/field-editors/issues/1223)) ([f66a6b9](https://github.com/contentful/field-editors/commit/f66a6b994f107341251a0ea335457a6b0148439f))
21
+
6
22
  ## [5.1.2](https://github.com/contentful/field-editors/compare/@contentful/field-editor-reference@5.1.1...@contentful/field-editor-reference@5.1.2) (2022-08-26)
7
23
 
8
24
  ### Bug Fixes
@@ -686,7 +686,8 @@ var squareCard = /*#__PURE__*/emotion.css({
686
686
 
687
687
  function MissingEntityCard(props) {
688
688
  return React__default.createElement(f36Components.Card, {
689
- className: card
689
+ className: card,
690
+ testId: "cf-ui-missing-entry-card"
690
691
  }, React__default.createElement(f36Components.Flex, {
691
692
  alignItems: "center",
692
693
  justifyContent: "space-between"
@@ -1844,7 +1845,7 @@ var formatDateAndTime = function formatDateAndTime(date, _short2) {
1844
1845
  var getScheduleTooltipContent = function getScheduleTooltipContent(_ref) {
1845
1846
  var job = _ref.job,
1846
1847
  jobsCount = _ref.jobsCount;
1847
- return "Will " + job.action.toLowerCase() + " " + formatDateAndTime(job.scheduledFor.datetime).toLowerCase() + "\n " + (jobsCount > 1 && "+ " + (jobsCount - 1) + " more");
1848
+ return "Will " + job.action.toLowerCase() + " " + formatDateAndTime(job.scheduledFor.datetime).toLowerCase() + "\n " + (jobsCount > 1 ? "+ " + (jobsCount - 1) + " more" : '');
1848
1849
  };
1849
1850
  var ScheduleTooltip = function ScheduleTooltip(_ref2) {
1850
1851
  var job = _ref2.job,
@@ -2054,8 +2055,10 @@ function _fetchContentfulEntry() {
2054
2055
  }
2055
2056
 
2056
2057
  var _constate = /*#__PURE__*/constate(function useInitServices(props) {
2058
+ var _props$sdk$ids$enviro;
2059
+
2057
2060
  var currentSpaceId = props.sdk.ids.space;
2058
- var currentEnvironmentId = props.sdk.ids.environment;
2061
+ var currentEnvironmentId = (_props$sdk$ids$enviro = props.sdk.ids.environmentAlias) != null ? _props$sdk$ids$enviro : props.sdk.ids.environment;
2059
2062
  var queryClient = reactQuery.useQueryClient();
2060
2063
  var queryCache = queryClient.getQueryCache();
2061
2064
  var entityChangeUnsubscribers = React.useRef({});
@@ -2122,12 +2125,38 @@ var _constate = /*#__PURE__*/constate(function useInitServices(props) {
2122
2125
  throw new UnsupportedError('Unsupported entity type');
2123
2126
  }, options);
2124
2127
  }, [fetch, currentSpaceId, currentEnvironmentId]);
2128
+ /**
2129
+ * Fetch all scheduled actions for a given entity.
2130
+ * This function fetches all schedules for all entries and then returns
2131
+ * a filtered result based on the entityID provided.
2132
+ *
2133
+ * The result is then reused/cached for subsequent calls to this function.
2134
+ */
2135
+
2136
+ /**
2137
+ * Fetch all scheduled actions for a given entity.
2138
+ * This function fetches all schedules for all entries and then returns
2139
+ * a filtered result based on the entityID provided.
2140
+ *
2141
+ * The result is then reused/cached for subsequent calls to this function.
2142
+ */
2125
2143
  var getEntityScheduledActions = React.useCallback(function getEntityScheduledActions(entityType, entityId, options) {
2126
2144
  var _options$spaceId2, _options$environmentI2;
2127
2145
 
2146
+ // This is fixed to force the cache to reuse previous results
2147
+ var fixedEntityCacheId = 'scheduledActionEntityId'; // A space+environment combo can only have up to 500 scheduled actions
2148
+ // With this request we fetch all schedules and can reuse the results.
2149
+ // See https://www.contentful.com/developers/docs/references/content-management-api/#/reference/scheduled-actions/limitations
2150
+
2151
+ // A space+environment combo can only have up to 500 scheduled actions
2152
+ // With this request we fetch all schedules and can reuse the results.
2153
+ // See https://www.contentful.com/developers/docs/references/content-management-api/#/reference/scheduled-actions/limitations
2154
+ var maxScheduledActions = 500;
2128
2155
  var spaceId = (_options$spaceId2 = options == null ? void 0 : options.spaceId) != null ? _options$spaceId2 : currentSpaceId;
2129
2156
  var environmentId = (_options$environmentI2 = options == null ? void 0 : options.environmentId) != null ? _options$environmentI2 : currentEnvironmentId;
2130
- var queryKey = ['scheduled-actions', entityType, entityId, spaceId, environmentId];
2157
+ var queryKey = ['scheduled-actions', entityType, fixedEntityCacheId, spaceId, environmentId]; // Fetch + Filter by entity ID in the end
2158
+
2159
+ // Fetch + Filter by entity ID in the end
2131
2160
  return fetch(queryKey, /*#__PURE__*/function () {
2132
2161
  var _ref3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(_ref2) {
2133
2162
  var cmaClient, response;
@@ -2141,9 +2170,9 @@ var _constate = /*#__PURE__*/constate(function useInitServices(props) {
2141
2170
  spaceId: spaceId,
2142
2171
  query: {
2143
2172
  'environment.sys.id': environmentId,
2144
- 'entity.sys.id': entityId,
2145
2173
  'sys.status[in]': 'scheduled',
2146
- order: 'scheduledFor.datetime'
2174
+ order: 'scheduledFor.datetime',
2175
+ limit: maxScheduledActions
2147
2176
  }
2148
2177
  });
2149
2178
 
@@ -2162,7 +2191,11 @@ var _constate = /*#__PURE__*/constate(function useInitServices(props) {
2162
2191
  return function (_x2) {
2163
2192
  return _ref3.apply(this, arguments);
2164
2193
  };
2165
- }(), options);
2194
+ }(), options).then(function (items) {
2195
+ return items.filter(function (action) {
2196
+ return action.entity.sys.id === entityId;
2197
+ });
2198
+ });
2166
2199
  }, [fetch, currentSpaceId, currentEnvironmentId]);
2167
2200
  var getResource = React.useCallback(function getResource(resourceType, urn, options) {
2168
2201
  var queryKey = ['Resource', resourceType, urn];