@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
|
@@ -679,7 +679,8 @@ var squareCard = /*#__PURE__*/css({
|
|
|
679
679
|
|
|
680
680
|
function MissingEntityCard(props) {
|
|
681
681
|
return React__default.createElement(Card, {
|
|
682
|
-
className: card
|
|
682
|
+
className: card,
|
|
683
|
+
testId: "cf-ui-missing-entry-card"
|
|
683
684
|
}, React__default.createElement(Flex, {
|
|
684
685
|
alignItems: "center",
|
|
685
686
|
justifyContent: "space-between"
|
|
@@ -1837,7 +1838,7 @@ var formatDateAndTime = function formatDateAndTime(date, _short2) {
|
|
|
1837
1838
|
var getScheduleTooltipContent = function getScheduleTooltipContent(_ref) {
|
|
1838
1839
|
var job = _ref.job,
|
|
1839
1840
|
jobsCount = _ref.jobsCount;
|
|
1840
|
-
return "Will " + job.action.toLowerCase() + " " + formatDateAndTime(job.scheduledFor.datetime).toLowerCase() + "\n " + (jobsCount > 1
|
|
1841
|
+
return "Will " + job.action.toLowerCase() + " " + formatDateAndTime(job.scheduledFor.datetime).toLowerCase() + "\n " + (jobsCount > 1 ? "+ " + (jobsCount - 1) + " more" : '');
|
|
1841
1842
|
};
|
|
1842
1843
|
var ScheduleTooltip = function ScheduleTooltip(_ref2) {
|
|
1843
1844
|
var job = _ref2.job,
|
|
@@ -2051,6 +2052,9 @@ var _constate = /*#__PURE__*/constate(function useInitServices(props) {
|
|
|
2051
2052
|
|
|
2052
2053
|
var currentSpaceId = props.sdk.ids.space;
|
|
2053
2054
|
var currentEnvironmentId = (_props$sdk$ids$enviro = props.sdk.ids.environmentAlias) != null ? _props$sdk$ids$enviro : props.sdk.ids.environment;
|
|
2055
|
+
var environmentIds = useMemo(function () {
|
|
2056
|
+
return [props.sdk.ids.environmentAlias, props.sdk.ids.environment];
|
|
2057
|
+
}, [props.sdk.ids.environmentAlias, props.sdk.ids.environment]);
|
|
2054
2058
|
var queryClient = useQueryClient();
|
|
2055
2059
|
var queryCache = queryClient.getQueryCache();
|
|
2056
2060
|
var entityChangeUnsubscribers = useRef({});
|
|
@@ -2117,12 +2121,38 @@ var _constate = /*#__PURE__*/constate(function useInitServices(props) {
|
|
|
2117
2121
|
throw new UnsupportedError('Unsupported entity type');
|
|
2118
2122
|
}, options);
|
|
2119
2123
|
}, [fetch, currentSpaceId, currentEnvironmentId]);
|
|
2124
|
+
/**
|
|
2125
|
+
* Fetch all scheduled actions for a given entity.
|
|
2126
|
+
* This function fetches all schedules for all entries and then returns
|
|
2127
|
+
* a filtered result based on the entityID provided.
|
|
2128
|
+
*
|
|
2129
|
+
* The result is then reused/cached for subsequent calls to this function.
|
|
2130
|
+
*/
|
|
2131
|
+
|
|
2132
|
+
/**
|
|
2133
|
+
* Fetch all scheduled actions for a given entity.
|
|
2134
|
+
* This function fetches all schedules for all entries and then returns
|
|
2135
|
+
* a filtered result based on the entityID provided.
|
|
2136
|
+
*
|
|
2137
|
+
* The result is then reused/cached for subsequent calls to this function.
|
|
2138
|
+
*/
|
|
2120
2139
|
var getEntityScheduledActions = useCallback(function getEntityScheduledActions(entityType, entityId, options) {
|
|
2121
2140
|
var _options$spaceId2, _options$environmentI2;
|
|
2122
2141
|
|
|
2142
|
+
// This is fixed to force the cache to reuse previous results
|
|
2143
|
+
var fixedEntityCacheId = 'scheduledActionEntityId'; // A space+environment combo can only have up to 500 scheduled actions
|
|
2144
|
+
// With this request we fetch all schedules and can reuse the results.
|
|
2145
|
+
// See https://www.contentful.com/developers/docs/references/content-management-api/#/reference/scheduled-actions/limitations
|
|
2146
|
+
|
|
2147
|
+
// 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
|
+
var maxScheduledActions = 500;
|
|
2123
2151
|
var spaceId = (_options$spaceId2 = options == null ? void 0 : options.spaceId) != null ? _options$spaceId2 : currentSpaceId;
|
|
2124
2152
|
var environmentId = (_options$environmentI2 = options == null ? void 0 : options.environmentId) != null ? _options$environmentI2 : currentEnvironmentId;
|
|
2125
|
-
var queryKey = ['scheduled-actions', entityType,
|
|
2153
|
+
var queryKey = ['scheduled-actions', entityType, fixedEntityCacheId, spaceId, environmentId]; // Fetch + Filter by entity ID in the end
|
|
2154
|
+
|
|
2155
|
+
// Fetch + Filter by entity ID in the end
|
|
2126
2156
|
return fetch(queryKey, /*#__PURE__*/function () {
|
|
2127
2157
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(_ref2) {
|
|
2128
2158
|
var cmaClient, response;
|
|
@@ -2136,9 +2166,9 @@ var _constate = /*#__PURE__*/constate(function useInitServices(props) {
|
|
|
2136
2166
|
spaceId: spaceId,
|
|
2137
2167
|
query: {
|
|
2138
2168
|
'environment.sys.id': environmentId,
|
|
2139
|
-
'entity.sys.id': entityId,
|
|
2140
2169
|
'sys.status[in]': 'scheduled',
|
|
2141
|
-
order: 'scheduledFor.datetime'
|
|
2170
|
+
order: 'scheduledFor.datetime',
|
|
2171
|
+
limit: maxScheduledActions
|
|
2142
2172
|
}
|
|
2143
2173
|
});
|
|
2144
2174
|
|
|
@@ -2157,7 +2187,11 @@ var _constate = /*#__PURE__*/constate(function useInitServices(props) {
|
|
|
2157
2187
|
return function (_x2) {
|
|
2158
2188
|
return _ref3.apply(this, arguments);
|
|
2159
2189
|
};
|
|
2160
|
-
}(), options)
|
|
2190
|
+
}(), options).then(function (items) {
|
|
2191
|
+
return items.filter(function (action) {
|
|
2192
|
+
return action.entity.sys.id === entityId;
|
|
2193
|
+
});
|
|
2194
|
+
});
|
|
2161
2195
|
}, [fetch, currentSpaceId, currentEnvironmentId]);
|
|
2162
2196
|
var getResource = useCallback(function getResource(resourceType, urn, options) {
|
|
2163
2197
|
var queryKey = ['Resource', resourceType, urn];
|
|
@@ -2175,9 +2209,9 @@ var _constate = /*#__PURE__*/constate(function useInitServices(props) {
|
|
|
2175
2209
|
}, [fetch]);
|
|
2176
2210
|
var isSameSpaceEntityQueryKey = useCallback(function (queryKey) {
|
|
2177
2211
|
var isEntityKey = isEntityQueryKey(queryKey);
|
|
2178
|
-
var isSameSpaceEntityKey = isEntityKey && queryKey[2] === currentSpaceId && queryKey[3]
|
|
2212
|
+
var isSameSpaceEntityKey = isEntityKey && queryKey[2] === currentSpaceId && environmentIds.includes(queryKey[3]);
|
|
2179
2213
|
return isSameSpaceEntityKey;
|
|
2180
|
-
}, [currentSpaceId,
|
|
2214
|
+
}, [currentSpaceId, environmentIds]); // @ts-expect-error ...
|
|
2181
2215
|
|
|
2182
2216
|
// @ts-expect-error ...
|
|
2183
2217
|
var onEntityChanged = props.sdk.space.onEntityChanged;
|