@contentful/field-editor-reference 5.1.3 → 5.1.6
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 +16 -0
- package/dist/field-editor-reference.cjs.development.js +42 -8
- package/dist/field-editor-reference.cjs.development.js.map +1 -1
- package/dist/field-editor-reference.cjs.production.min.js +1 -1
- package/dist/field-editor-reference.cjs.production.min.js.map +1 -1
- package/dist/field-editor-reference.esm.js +42 -8
- package/dist/field-editor-reference.esm.js.map +1 -1
- package/dist/resources/Cards/ResourceCard.d.ts +1 -1
- package/package.json +2 -2
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.6](https://github.com/contentful/field-editors/compare/@contentful/field-editor-reference@5.1.5...@contentful/field-editor-reference@5.1.6) (2022-09-07)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- **reference-editor:** accept pubsub messages from alias and non-alias environments ([#1227](https://github.com/contentful/field-editors/issues/1227)) ([2d7d93a](https://github.com/contentful/field-editors/commit/2d7d93a2d3aa089f7ecdfec48c53c7839856ba0d))
|
|
11
|
+
|
|
12
|
+
## [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)
|
|
13
|
+
|
|
14
|
+
**Note:** Version bump only for package @contentful/field-editor-reference
|
|
15
|
+
|
|
16
|
+
## [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)
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
- **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))
|
|
21
|
+
|
|
6
22
|
## [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)
|
|
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
|
|
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,
|
|
@@ -2058,6 +2059,9 @@ var _constate = /*#__PURE__*/constate(function useInitServices(props) {
|
|
|
2058
2059
|
|
|
2059
2060
|
var currentSpaceId = props.sdk.ids.space;
|
|
2060
2061
|
var currentEnvironmentId = (_props$sdk$ids$enviro = props.sdk.ids.environmentAlias) != null ? _props$sdk$ids$enviro : props.sdk.ids.environment;
|
|
2062
|
+
var environmentIds = React.useMemo(function () {
|
|
2063
|
+
return [props.sdk.ids.environmentAlias, props.sdk.ids.environment];
|
|
2064
|
+
}, [props.sdk.ids.environmentAlias, props.sdk.ids.environment]);
|
|
2061
2065
|
var queryClient = reactQuery.useQueryClient();
|
|
2062
2066
|
var queryCache = queryClient.getQueryCache();
|
|
2063
2067
|
var entityChangeUnsubscribers = React.useRef({});
|
|
@@ -2124,12 +2128,38 @@ var _constate = /*#__PURE__*/constate(function useInitServices(props) {
|
|
|
2124
2128
|
throw new UnsupportedError('Unsupported entity type');
|
|
2125
2129
|
}, options);
|
|
2126
2130
|
}, [fetch, currentSpaceId, currentEnvironmentId]);
|
|
2131
|
+
/**
|
|
2132
|
+
* Fetch all scheduled actions for a given entity.
|
|
2133
|
+
* This function fetches all schedules for all entries and then returns
|
|
2134
|
+
* a filtered result based on the entityID provided.
|
|
2135
|
+
*
|
|
2136
|
+
* The result is then reused/cached for subsequent calls to this function.
|
|
2137
|
+
*/
|
|
2138
|
+
|
|
2139
|
+
/**
|
|
2140
|
+
* Fetch all scheduled actions for a given entity.
|
|
2141
|
+
* This function fetches all schedules for all entries and then returns
|
|
2142
|
+
* a filtered result based on the entityID provided.
|
|
2143
|
+
*
|
|
2144
|
+
* The result is then reused/cached for subsequent calls to this function.
|
|
2145
|
+
*/
|
|
2127
2146
|
var getEntityScheduledActions = React.useCallback(function getEntityScheduledActions(entityType, entityId, options) {
|
|
2128
2147
|
var _options$spaceId2, _options$environmentI2;
|
|
2129
2148
|
|
|
2149
|
+
// This is fixed to force the cache to reuse previous results
|
|
2150
|
+
var fixedEntityCacheId = 'scheduledActionEntityId'; // A space+environment combo can only have up to 500 scheduled actions
|
|
2151
|
+
// With this request we fetch all schedules and can reuse the results.
|
|
2152
|
+
// See https://www.contentful.com/developers/docs/references/content-management-api/#/reference/scheduled-actions/limitations
|
|
2153
|
+
|
|
2154
|
+
// A space+environment combo can only have up to 500 scheduled actions
|
|
2155
|
+
// With this request we fetch all schedules and can reuse the results.
|
|
2156
|
+
// See https://www.contentful.com/developers/docs/references/content-management-api/#/reference/scheduled-actions/limitations
|
|
2157
|
+
var maxScheduledActions = 500;
|
|
2130
2158
|
var spaceId = (_options$spaceId2 = options == null ? void 0 : options.spaceId) != null ? _options$spaceId2 : currentSpaceId;
|
|
2131
2159
|
var environmentId = (_options$environmentI2 = options == null ? void 0 : options.environmentId) != null ? _options$environmentI2 : currentEnvironmentId;
|
|
2132
|
-
var queryKey = ['scheduled-actions', entityType,
|
|
2160
|
+
var queryKey = ['scheduled-actions', entityType, fixedEntityCacheId, spaceId, environmentId]; // Fetch + Filter by entity ID in the end
|
|
2161
|
+
|
|
2162
|
+
// Fetch + Filter by entity ID in the end
|
|
2133
2163
|
return fetch(queryKey, /*#__PURE__*/function () {
|
|
2134
2164
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(_ref2) {
|
|
2135
2165
|
var cmaClient, response;
|
|
@@ -2143,9 +2173,9 @@ var _constate = /*#__PURE__*/constate(function useInitServices(props) {
|
|
|
2143
2173
|
spaceId: spaceId,
|
|
2144
2174
|
query: {
|
|
2145
2175
|
'environment.sys.id': environmentId,
|
|
2146
|
-
'entity.sys.id': entityId,
|
|
2147
2176
|
'sys.status[in]': 'scheduled',
|
|
2148
|
-
order: 'scheduledFor.datetime'
|
|
2177
|
+
order: 'scheduledFor.datetime',
|
|
2178
|
+
limit: maxScheduledActions
|
|
2149
2179
|
}
|
|
2150
2180
|
});
|
|
2151
2181
|
|
|
@@ -2164,7 +2194,11 @@ var _constate = /*#__PURE__*/constate(function useInitServices(props) {
|
|
|
2164
2194
|
return function (_x2) {
|
|
2165
2195
|
return _ref3.apply(this, arguments);
|
|
2166
2196
|
};
|
|
2167
|
-
}(), options)
|
|
2197
|
+
}(), options).then(function (items) {
|
|
2198
|
+
return items.filter(function (action) {
|
|
2199
|
+
return action.entity.sys.id === entityId;
|
|
2200
|
+
});
|
|
2201
|
+
});
|
|
2168
2202
|
}, [fetch, currentSpaceId, currentEnvironmentId]);
|
|
2169
2203
|
var getResource = React.useCallback(function getResource(resourceType, urn, options) {
|
|
2170
2204
|
var queryKey = ['Resource', resourceType, urn];
|
|
@@ -2182,9 +2216,9 @@ var _constate = /*#__PURE__*/constate(function useInitServices(props) {
|
|
|
2182
2216
|
}, [fetch]);
|
|
2183
2217
|
var isSameSpaceEntityQueryKey = React.useCallback(function (queryKey) {
|
|
2184
2218
|
var isEntityKey = isEntityQueryKey(queryKey);
|
|
2185
|
-
var isSameSpaceEntityKey = isEntityKey && queryKey[2] === currentSpaceId && queryKey[3]
|
|
2219
|
+
var isSameSpaceEntityKey = isEntityKey && queryKey[2] === currentSpaceId && environmentIds.includes(queryKey[3]);
|
|
2186
2220
|
return isSameSpaceEntityKey;
|
|
2187
|
-
}, [currentSpaceId,
|
|
2221
|
+
}, [currentSpaceId, environmentIds]); // @ts-expect-error ...
|
|
2188
2222
|
|
|
2189
2223
|
// @ts-expect-error ...
|
|
2190
2224
|
var onEntityChanged = props.sdk.space.onEntityChanged;
|