@contentful/field-editor-reference 4.6.8 → 5.0.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/CHANGELOG.md +24 -0
- package/dist/assets/WrappedAssetCard/AssetCardActions.d.ts +1 -1
- package/dist/common/EntityStore.d.ts +55 -5
- package/dist/common/ReferenceEditor.d.ts +1 -1
- package/dist/common/useAccessApi.d.ts +1 -1
- package/dist/components/LinkActions/LinkEntityActions.d.ts +1 -1
- package/dist/components/LinkActions/helpers.d.ts +3 -3
- package/dist/field-editor-reference.cjs.development.js +537 -547
- 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 +536 -548
- package/dist/field-editor-reference.esm.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/package.json +3 -2
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import React__default, { useState, useRef, useEffect, createElement, Fragment, useMemo, useCallback
|
|
1
|
+
import React__default, { useState, useRef, useEffect, createElement, Fragment, useMemo, useCallback } from 'react';
|
|
2
2
|
import { css, cx } from 'emotion';
|
|
3
3
|
import tokens from '@contentful/f36-tokens';
|
|
4
4
|
import get from 'lodash-es/get';
|
|
5
5
|
import { Menu, TextInput, Button, Paragraph, Card, Flex, SectionHeading, IconButton, Tooltip, Text, EntryCard, MenuItem, MenuDivider, AssetCard } from '@contentful/f36-components';
|
|
6
6
|
import { SearchIcon, PlusIcon, ChevronDownIcon, LinkIcon, CloseIcon, FolderOpenTrimmedIcon, ClockIcon } from '@contentful/f36-icons';
|
|
7
7
|
import moment from 'moment';
|
|
8
|
-
import deepEqual from 'deep-equal';
|
|
9
8
|
import { FieldConnector, isValidImage, entityHelpers, shortenStorageUnit } from '@contentful/field-editor-shared';
|
|
9
|
+
import deepEqual from 'deep-equal';
|
|
10
|
+
import { useQuery, QueryCache, QueryClient, QueryClientProvider, useQueryClient } from '@tanstack/react-query';
|
|
10
11
|
import constate from 'constate';
|
|
11
12
|
import { createClient } from 'contentful-management';
|
|
13
|
+
import PQueue from 'p-queue';
|
|
12
14
|
import isNumber from 'lodash-es/isNumber';
|
|
13
15
|
import arrayMove from 'array-move';
|
|
14
16
|
import { SortableContainer, SortableHandle, SortableElement } from 'react-sortable-hoc';
|
|
@@ -68,57 +70,110 @@ function _extends() {
|
|
|
68
70
|
return _extends.apply(this, arguments);
|
|
69
71
|
}
|
|
70
72
|
|
|
71
|
-
function
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
var sourceKeys = Object.keys(source);
|
|
75
|
-
var key, i;
|
|
73
|
+
function _inheritsLoose(subClass, superClass) {
|
|
74
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
75
|
+
subClass.prototype.constructor = subClass;
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
_setPrototypeOf(subClass, superClass);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function _getPrototypeOf(o) {
|
|
81
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
82
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
83
|
+
};
|
|
84
|
+
return _getPrototypeOf(o);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function _setPrototypeOf(o, p) {
|
|
88
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
89
|
+
o.__proto__ = p;
|
|
90
|
+
return o;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
return _setPrototypeOf(o, p);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function _isNativeReflectConstruct() {
|
|
97
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
98
|
+
if (Reflect.construct.sham) return false;
|
|
99
|
+
if (typeof Proxy === "function") return true;
|
|
100
|
+
|
|
101
|
+
try {
|
|
102
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
103
|
+
return true;
|
|
104
|
+
} catch (e) {
|
|
105
|
+
return false;
|
|
81
106
|
}
|
|
107
|
+
}
|
|
82
108
|
|
|
83
|
-
|
|
109
|
+
function _construct(Parent, args, Class) {
|
|
110
|
+
if (_isNativeReflectConstruct()) {
|
|
111
|
+
_construct = Reflect.construct;
|
|
112
|
+
} else {
|
|
113
|
+
_construct = function _construct(Parent, args, Class) {
|
|
114
|
+
var a = [null];
|
|
115
|
+
a.push.apply(a, args);
|
|
116
|
+
var Constructor = Function.bind.apply(Parent, a);
|
|
117
|
+
var instance = new Constructor();
|
|
118
|
+
if (Class) _setPrototypeOf(instance, Class.prototype);
|
|
119
|
+
return instance;
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return _construct.apply(null, arguments);
|
|
84
124
|
}
|
|
85
125
|
|
|
86
|
-
function
|
|
87
|
-
|
|
88
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
89
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
90
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
91
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
92
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
126
|
+
function _isNativeFunction(fn) {
|
|
127
|
+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
93
128
|
}
|
|
94
129
|
|
|
95
|
-
function
|
|
96
|
-
|
|
130
|
+
function _wrapNativeSuper(Class) {
|
|
131
|
+
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
132
|
+
|
|
133
|
+
_wrapNativeSuper = function _wrapNativeSuper(Class) {
|
|
134
|
+
if (Class === null || !_isNativeFunction(Class)) return Class;
|
|
135
|
+
|
|
136
|
+
if (typeof Class !== "function") {
|
|
137
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (typeof _cache !== "undefined") {
|
|
141
|
+
if (_cache.has(Class)) return _cache.get(Class);
|
|
142
|
+
|
|
143
|
+
_cache.set(Class, Wrapper);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function Wrapper() {
|
|
147
|
+
return _construct(Class, arguments, _getPrototypeOf(this).constructor);
|
|
148
|
+
}
|
|
97
149
|
|
|
98
|
-
|
|
150
|
+
Wrapper.prototype = Object.create(Class.prototype, {
|
|
151
|
+
constructor: {
|
|
152
|
+
value: Wrapper,
|
|
153
|
+
enumerable: false,
|
|
154
|
+
writable: true,
|
|
155
|
+
configurable: true
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
return _setPrototypeOf(Wrapper, Class);
|
|
159
|
+
};
|
|
99
160
|
|
|
100
|
-
return
|
|
161
|
+
return _wrapNativeSuper(Class);
|
|
101
162
|
}
|
|
102
163
|
|
|
103
|
-
function
|
|
104
|
-
|
|
105
|
-
|
|
164
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
165
|
+
if (source == null) return {};
|
|
166
|
+
var target = {};
|
|
167
|
+
var sourceKeys = Object.keys(source);
|
|
168
|
+
var key, i;
|
|
106
169
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if (i >= o.length) return {
|
|
112
|
-
done: true
|
|
113
|
-
};
|
|
114
|
-
return {
|
|
115
|
-
done: false,
|
|
116
|
-
value: o[i++]
|
|
117
|
-
};
|
|
118
|
-
};
|
|
170
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
171
|
+
key = sourceKeys[i];
|
|
172
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
173
|
+
target[key] = source[key];
|
|
119
174
|
}
|
|
120
175
|
|
|
121
|
-
|
|
176
|
+
return target;
|
|
122
177
|
}
|
|
123
178
|
|
|
124
179
|
var container = /*#__PURE__*/css({
|
|
@@ -498,7 +553,7 @@ function CombinedLinkActions(props) {
|
|
|
498
553
|
var hideEmptyCard = props.entityType === 'Asset' && !props.isEmpty;
|
|
499
554
|
return createElement("div", {
|
|
500
555
|
className: hideEmptyCard ? '' : container
|
|
501
|
-
}, !props.canCreateEntity && !props.canLinkEntity && createElement(NoLinkPermissionsInfo, null), props.entityType === 'Entry' && createElement(CombinedEntryLinkActions,
|
|
556
|
+
}, !props.canCreateEntity && !props.canLinkEntity && createElement(NoLinkPermissionsInfo, null), props.entityType === 'Entry' && createElement(CombinedEntryLinkActions, _extends({}, props)), props.entityType === 'Asset' && createElement(CombinedAssetLinkActions, _extends({}, props)));
|
|
502
557
|
}
|
|
503
558
|
|
|
504
559
|
function CombinedEntryLinkActions(props) {
|
|
@@ -1628,9 +1683,8 @@ function useLinkActionsProps(props) {
|
|
|
1628
1683
|
return function (_x, _x2) {
|
|
1629
1684
|
return _ref.apply(this, arguments);
|
|
1630
1685
|
};
|
|
1631
|
-
}(), [sdk, entityType, onCreated]);
|
|
1632
|
-
|
|
1633
|
-
var onLinkExisting = /*#__PURE__*/function () {
|
|
1686
|
+
}(), [sdk, entityType, onCreated]);
|
|
1687
|
+
var onLinkExisting = useCallback( /*#__PURE__*/function () {
|
|
1634
1688
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(index) {
|
|
1635
1689
|
var entity;
|
|
1636
1690
|
return runtime_1.wrap(function _callee2$(_context2) {
|
|
@@ -1665,12 +1719,12 @@ function useLinkActionsProps(props) {
|
|
|
1665
1719
|
}, _callee2);
|
|
1666
1720
|
}));
|
|
1667
1721
|
|
|
1668
|
-
return function
|
|
1722
|
+
return function (_x3) {
|
|
1669
1723
|
return _ref2.apply(this, arguments);
|
|
1670
1724
|
};
|
|
1671
|
-
}()
|
|
1672
|
-
|
|
1673
|
-
var onLinkSeveralExisting = /*#__PURE__*/function () {
|
|
1725
|
+
}(), // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
|
|
1726
|
+
[sdk, entityType, onLinkedExisting]);
|
|
1727
|
+
var onLinkSeveralExisting = useCallback( /*#__PURE__*/function () {
|
|
1674
1728
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(index) {
|
|
1675
1729
|
var entities;
|
|
1676
1730
|
return runtime_1.wrap(function _callee3$(_context3) {
|
|
@@ -1705,11 +1759,11 @@ function useLinkActionsProps(props) {
|
|
|
1705
1759
|
}, _callee3);
|
|
1706
1760
|
}));
|
|
1707
1761
|
|
|
1708
|
-
return function
|
|
1762
|
+
return function (_x4) {
|
|
1709
1763
|
return _ref3.apply(this, arguments);
|
|
1710
1764
|
};
|
|
1711
|
-
}()
|
|
1712
|
-
|
|
1765
|
+
}(), // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
|
|
1766
|
+
[sdk, entityType, onLinkedExisting]); // FIXME: The memoization might rerun every time due to the always changing callback identities above
|
|
1713
1767
|
|
|
1714
1768
|
return useMemo(function () {
|
|
1715
1769
|
return {
|
|
@@ -1739,7 +1793,7 @@ function LinkEntityActions(_ref4) {
|
|
|
1739
1793
|
props = _objectWithoutPropertiesLoose(_ref4, _excluded);
|
|
1740
1794
|
|
|
1741
1795
|
var renderLinkActions = renderCustomActions ? renderCustomActions : function (props) {
|
|
1742
|
-
return createElement(LinkActions,
|
|
1796
|
+
return createElement(LinkActions, _extends({}, props));
|
|
1743
1797
|
};
|
|
1744
1798
|
return renderLinkActions(props);
|
|
1745
1799
|
}
|
|
@@ -1800,6 +1854,8 @@ var ScheduleTooltip = function ScheduleTooltip(_ref2) {
|
|
|
1800
1854
|
};
|
|
1801
1855
|
|
|
1802
1856
|
var ScheduledIconWithTooltip = function ScheduledIconWithTooltip(_ref) {
|
|
1857
|
+
var _status$jobs;
|
|
1858
|
+
|
|
1803
1859
|
var entityType = _ref.entityType,
|
|
1804
1860
|
entityId = _ref.entityId,
|
|
1805
1861
|
getEntityScheduledActions = _ref.getEntityScheduledActions,
|
|
@@ -1831,7 +1887,7 @@ var ScheduledIconWithTooltip = function ScheduledIconWithTooltip(_ref) {
|
|
|
1831
1887
|
return null;
|
|
1832
1888
|
}
|
|
1833
1889
|
|
|
1834
|
-
var jobs = status.jobs ?
|
|
1890
|
+
var jobs = (_status$jobs = status.jobs) != null ? _status$jobs : [];
|
|
1835
1891
|
|
|
1836
1892
|
if (jobs.length === 0) {
|
|
1837
1893
|
return null;
|
|
@@ -1857,502 +1913,426 @@ function AssetThumbnail(props) {
|
|
|
1857
1913
|
});
|
|
1858
1914
|
}
|
|
1859
1915
|
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
switch (action.type) {
|
|
1864
|
-
case 'set_entry':
|
|
1865
|
-
return _extends({}, state, {
|
|
1866
|
-
entries: _extends({}, state.entries, (_extends2 = {}, _extends2[action.id] = action.entry, _extends2))
|
|
1867
|
-
});
|
|
1868
|
-
|
|
1869
|
-
case 'set_entry_failed':
|
|
1870
|
-
return _extends({}, state, {
|
|
1871
|
-
entries: _extends({}, state.entries, (_extends3 = {}, _extends3[action.id] = 'failed', _extends3))
|
|
1872
|
-
});
|
|
1873
|
-
|
|
1874
|
-
case 'set_asset':
|
|
1875
|
-
return _extends({}, state, {
|
|
1876
|
-
assets: _extends({}, state.assets, (_extends4 = {}, _extends4[action.id] = action.asset, _extends4))
|
|
1877
|
-
});
|
|
1878
|
-
|
|
1879
|
-
case 'set_asset_failed':
|
|
1880
|
-
return _extends({}, state, {
|
|
1881
|
-
assets: _extends({}, state.assets, (_extends5 = {}, _extends5[action.id] = 'failed', _extends5))
|
|
1882
|
-
});
|
|
1883
|
-
|
|
1884
|
-
case 'set_scheduled_actions':
|
|
1885
|
-
return _extends({}, state, {
|
|
1886
|
-
scheduledActions: _extends({}, state.scheduledActions, (_extends6 = {}, _extends6[action.key] = action.actions, _extends6))
|
|
1887
|
-
});
|
|
1916
|
+
var _excluded$1 = ["priority"],
|
|
1917
|
+
_excluded2 = ["children"];
|
|
1888
1918
|
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1919
|
+
var globalQueue = /*#__PURE__*/new PQueue({
|
|
1920
|
+
concurrency: 20
|
|
1921
|
+
});
|
|
1922
|
+
var UnsupportedError = /*#__PURE__*/function (_Error) {
|
|
1923
|
+
_inheritsLoose(UnsupportedError, _Error);
|
|
1893
1924
|
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
resources: _extends({}, state.resources, (_extends8 = {}, _extends8[action.resourceType + "." + action.urn] = 'failed', _extends8))
|
|
1897
|
-
});
|
|
1925
|
+
function UnsupportedError(message) {
|
|
1926
|
+
var _this;
|
|
1898
1927
|
|
|
1899
|
-
|
|
1900
|
-
|
|
1928
|
+
_this = _Error.call(this, message) || this;
|
|
1929
|
+
_this.isUnsupportedError = void 0;
|
|
1930
|
+
_this.isUnsupportedError = true;
|
|
1931
|
+
return _this;
|
|
1901
1932
|
}
|
|
1902
|
-
}
|
|
1903
1933
|
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
assets: {},
|
|
1907
|
-
scheduledActions: {},
|
|
1908
|
-
resources: {}
|
|
1909
|
-
};
|
|
1910
|
-
|
|
1911
|
-
var isNotNil = function isNotNil(entity) {
|
|
1912
|
-
return Boolean(entity && entity !== 'failed');
|
|
1913
|
-
};
|
|
1934
|
+
return UnsupportedError;
|
|
1935
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
1914
1936
|
|
|
1915
|
-
var
|
|
1916
|
-
return
|
|
1917
|
-
var value = _ref[1];
|
|
1918
|
-
return isNotNil(value);
|
|
1919
|
-
});
|
|
1937
|
+
var isEntityQueryKey = function isEntityQueryKey(queryKey) {
|
|
1938
|
+
return Array.isArray(queryKey) && (queryKey[0] === 'Entry' || queryKey[0] === 'Asset') && queryKey.length === 4;
|
|
1920
1939
|
};
|
|
1921
1940
|
|
|
1922
|
-
function
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
var _React$useState = useState(function () {
|
|
1927
|
-
return createClient({
|
|
1928
|
-
apiAdapter: props.sdk.cmaAdapter
|
|
1929
|
-
}, {
|
|
1930
|
-
type: 'plain'
|
|
1931
|
-
});
|
|
1932
|
-
}),
|
|
1933
|
-
cmaClient = _React$useState[0];
|
|
1934
|
-
|
|
1935
|
-
var _React$useReducer = useReducer(reducer, initialState),
|
|
1936
|
-
state = _React$useReducer[0],
|
|
1937
|
-
dispatch = _React$useReducer[1];
|
|
1938
|
-
|
|
1939
|
-
var loadEntityScheduledActions = useCallback(function (entityType, id) {
|
|
1940
|
-
var key = entityType + ":" + id;
|
|
1941
|
-
|
|
1942
|
-
if (state.scheduledActions[key]) {
|
|
1943
|
-
return Promise.resolve(state.scheduledActions[key]);
|
|
1944
|
-
}
|
|
1945
|
-
|
|
1946
|
-
return props.sdk.space.getEntityScheduledActions(entityType, id).then(function (data) {
|
|
1947
|
-
dispatch({
|
|
1948
|
-
type: 'set_scheduled_actions',
|
|
1949
|
-
key: key,
|
|
1950
|
-
actions: data
|
|
1951
|
-
});
|
|
1952
|
-
return data;
|
|
1953
|
-
})["catch"](function () {
|
|
1954
|
-
dispatch({
|
|
1955
|
-
type: 'set_scheduled_actions',
|
|
1956
|
-
key: key,
|
|
1957
|
-
actions: undefined
|
|
1958
|
-
});
|
|
1959
|
-
return [];
|
|
1960
|
-
});
|
|
1961
|
-
}, [props.sdk.space, state.scheduledActions]);
|
|
1962
|
-
var loadEntry = useCallback( /*#__PURE__*/function () {
|
|
1963
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(entryId) {
|
|
1964
|
-
var entry;
|
|
1965
|
-
return runtime_1.wrap(function _callee$(_context) {
|
|
1966
|
-
while (1) {
|
|
1967
|
-
switch (_context.prev = _context.next) {
|
|
1968
|
-
case 0:
|
|
1969
|
-
_context.prev = 0;
|
|
1970
|
-
_context.next = 3;
|
|
1971
|
-
return cmaClient.entry.get({
|
|
1972
|
-
spaceId: spaceId,
|
|
1973
|
-
environmentId: environmentId,
|
|
1974
|
-
entryId: entryId
|
|
1975
|
-
});
|
|
1976
|
-
|
|
1977
|
-
case 3:
|
|
1978
|
-
entry = _context.sent;
|
|
1979
|
-
dispatch({
|
|
1980
|
-
type: 'set_entry',
|
|
1981
|
-
id: entryId,
|
|
1982
|
-
entry: entry
|
|
1983
|
-
});
|
|
1984
|
-
return _context.abrupt("return", entry);
|
|
1985
|
-
|
|
1986
|
-
case 8:
|
|
1987
|
-
_context.prev = 8;
|
|
1988
|
-
_context.t0 = _context["catch"](0);
|
|
1989
|
-
dispatch({
|
|
1990
|
-
type: 'set_entry_failed',
|
|
1991
|
-
id: entryId
|
|
1992
|
-
});
|
|
1993
|
-
return _context.abrupt("return");
|
|
1994
|
-
|
|
1995
|
-
case 12:
|
|
1996
|
-
case "end":
|
|
1997
|
-
return _context.stop();
|
|
1998
|
-
}
|
|
1999
|
-
}
|
|
2000
|
-
}, _callee, null, [[0, 8]]);
|
|
2001
|
-
}));
|
|
2002
|
-
|
|
2003
|
-
return function (_x) {
|
|
2004
|
-
return _ref2.apply(this, arguments);
|
|
2005
|
-
};
|
|
2006
|
-
}(), [cmaClient, spaceId, environmentId]);
|
|
2007
|
-
var getEntry = useCallback( /*#__PURE__*/function () {
|
|
2008
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(entryId) {
|
|
2009
|
-
var cachedEntry;
|
|
2010
|
-
return runtime_1.wrap(function _callee2$(_context2) {
|
|
2011
|
-
while (1) {
|
|
2012
|
-
switch (_context2.prev = _context2.next) {
|
|
2013
|
-
case 0:
|
|
2014
|
-
cachedEntry = state.entries[entryId];
|
|
2015
|
-
|
|
2016
|
-
if (!isNotNil(cachedEntry)) {
|
|
2017
|
-
_context2.next = 3;
|
|
2018
|
-
break;
|
|
2019
|
-
}
|
|
2020
|
-
|
|
2021
|
-
return _context2.abrupt("return", cachedEntry);
|
|
2022
|
-
|
|
2023
|
-
case 3:
|
|
2024
|
-
return _context2.abrupt("return", loadEntry(entryId));
|
|
2025
|
-
|
|
2026
|
-
case 4:
|
|
2027
|
-
case "end":
|
|
2028
|
-
return _context2.stop();
|
|
2029
|
-
}
|
|
2030
|
-
}
|
|
2031
|
-
}, _callee2);
|
|
2032
|
-
}));
|
|
2033
|
-
|
|
2034
|
-
return function (_x2) {
|
|
2035
|
-
return _ref3.apply(this, arguments);
|
|
2036
|
-
};
|
|
2037
|
-
}(), [loadEntry, state.entries]);
|
|
2038
|
-
var loadAsset = useCallback( /*#__PURE__*/function () {
|
|
2039
|
-
var _ref4 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(assetId) {
|
|
2040
|
-
var asset;
|
|
2041
|
-
return runtime_1.wrap(function _callee3$(_context3) {
|
|
2042
|
-
while (1) {
|
|
2043
|
-
switch (_context3.prev = _context3.next) {
|
|
2044
|
-
case 0:
|
|
2045
|
-
_context3.prev = 0;
|
|
2046
|
-
_context3.next = 3;
|
|
2047
|
-
return cmaClient.asset.get({
|
|
2048
|
-
spaceId: spaceId,
|
|
2049
|
-
environmentId: environmentId,
|
|
2050
|
-
assetId: assetId
|
|
2051
|
-
});
|
|
2052
|
-
|
|
2053
|
-
case 3:
|
|
2054
|
-
asset = _context3.sent;
|
|
2055
|
-
dispatch({
|
|
2056
|
-
type: 'set_asset',
|
|
2057
|
-
id: assetId,
|
|
2058
|
-
asset: asset
|
|
2059
|
-
});
|
|
2060
|
-
return _context3.abrupt("return", asset);
|
|
2061
|
-
|
|
2062
|
-
case 8:
|
|
2063
|
-
_context3.prev = 8;
|
|
2064
|
-
_context3.t0 = _context3["catch"](0);
|
|
2065
|
-
dispatch({
|
|
2066
|
-
type: 'set_asset_failed',
|
|
2067
|
-
id: assetId
|
|
2068
|
-
});
|
|
2069
|
-
return _context3.abrupt("return");
|
|
2070
|
-
|
|
2071
|
-
case 12:
|
|
2072
|
-
case "end":
|
|
2073
|
-
return _context3.stop();
|
|
2074
|
-
}
|
|
2075
|
-
}
|
|
2076
|
-
}, _callee3, null, [[0, 8]]);
|
|
2077
|
-
}));
|
|
2078
|
-
|
|
2079
|
-
return function (_x3) {
|
|
2080
|
-
return _ref4.apply(this, arguments);
|
|
2081
|
-
};
|
|
2082
|
-
}(), [cmaClient, spaceId, environmentId]);
|
|
2083
|
-
var getAsset = useCallback( /*#__PURE__*/function () {
|
|
2084
|
-
var _ref5 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(assetId) {
|
|
2085
|
-
var cachedAsset;
|
|
2086
|
-
return runtime_1.wrap(function _callee4$(_context4) {
|
|
2087
|
-
while (1) {
|
|
2088
|
-
switch (_context4.prev = _context4.next) {
|
|
2089
|
-
case 0:
|
|
2090
|
-
cachedAsset = state.assets[assetId];
|
|
2091
|
-
|
|
2092
|
-
if (!isNotNil(cachedAsset)) {
|
|
2093
|
-
_context4.next = 3;
|
|
2094
|
-
break;
|
|
2095
|
-
}
|
|
2096
|
-
|
|
2097
|
-
return _context4.abrupt("return", cachedAsset);
|
|
2098
|
-
|
|
2099
|
-
case 3:
|
|
2100
|
-
return _context4.abrupt("return", loadAsset(assetId));
|
|
2101
|
-
|
|
2102
|
-
case 4:
|
|
2103
|
-
case "end":
|
|
2104
|
-
return _context4.stop();
|
|
2105
|
-
}
|
|
2106
|
-
}
|
|
2107
|
-
}, _callee4);
|
|
2108
|
-
}));
|
|
2109
|
-
|
|
2110
|
-
return function (_x4) {
|
|
2111
|
-
return _ref5.apply(this, arguments);
|
|
2112
|
-
};
|
|
2113
|
-
}(), [loadAsset, state.assets]);
|
|
2114
|
-
var loadContentfulEntry = useCallback( /*#__PURE__*/function () {
|
|
2115
|
-
var _ref6 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(urn) {
|
|
2116
|
-
var _locales$items$find;
|
|
1941
|
+
function fetchContentfulEntry(_x) {
|
|
1942
|
+
return _fetchContentfulEntry.apply(this, arguments);
|
|
1943
|
+
}
|
|
2117
1944
|
|
|
2118
|
-
|
|
1945
|
+
function _fetchContentfulEntry() {
|
|
1946
|
+
_fetchContentfulEntry = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(params) {
|
|
1947
|
+
var urn, fetch, options, resourceId, _resourceId$split, spaceId, entryId, environmentId, _yield$Promise$all, space, entry, contentTypeId, _yield$Promise$all2, contentType, defaultLocaleCode;
|
|
2119
1948
|
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
1949
|
+
return runtime_1.wrap(function _callee3$(_context3) {
|
|
1950
|
+
while (1) {
|
|
1951
|
+
switch (_context3.prev = _context3.next) {
|
|
1952
|
+
case 0:
|
|
1953
|
+
urn = params.urn, fetch = params.fetch, options = params.options;
|
|
1954
|
+
resourceId = urn.split(':', 6)[5];
|
|
1955
|
+
_resourceId$split = resourceId.split('/'), spaceId = _resourceId$split[1], entryId = _resourceId$split[3];
|
|
1956
|
+
environmentId = 'master';
|
|
1957
|
+
_context3.next = 6;
|
|
1958
|
+
return Promise.all([fetch(['space', spaceId], function (_ref9) {
|
|
1959
|
+
var cmaClient = _ref9.cmaClient;
|
|
2129
1960
|
return cmaClient.space.get({
|
|
2130
1961
|
spaceId: spaceId
|
|
2131
1962
|
});
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
_context5.t1 = _context5.sent;
|
|
2135
|
-
_context5.next = 9;
|
|
1963
|
+
}, options), fetch(['entry', spaceId, environmentId, entryId], function (_ref10) {
|
|
1964
|
+
var cmaClient = _ref10.cmaClient;
|
|
2136
1965
|
return cmaClient.entry.get({
|
|
2137
1966
|
spaceId: spaceId,
|
|
2138
1967
|
environmentId: environmentId,
|
|
2139
1968
|
entryId: entryId
|
|
2140
1969
|
});
|
|
1970
|
+
}, options)]);
|
|
2141
1971
|
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
space = _yield$Promise$all[0];
|
|
2151
|
-
entry = _yield$Promise$all[1];
|
|
2152
|
-
contentTypeId = entry.sys.contentType.sys.id;
|
|
2153
|
-
_context5.t4 = Promise;
|
|
2154
|
-
_context5.next = 20;
|
|
1972
|
+
case 6:
|
|
1973
|
+
_yield$Promise$all = _context3.sent;
|
|
1974
|
+
space = _yield$Promise$all[0];
|
|
1975
|
+
entry = _yield$Promise$all[1];
|
|
1976
|
+
contentTypeId = entry.sys.contentType.sys.id;
|
|
1977
|
+
_context3.next = 12;
|
|
1978
|
+
return Promise.all([fetch(['contentType', spaceId, environmentId, contentTypeId], function (_ref11) {
|
|
1979
|
+
var cmaClient = _ref11.cmaClient;
|
|
2155
1980
|
return cmaClient.contentType.get({
|
|
2156
1981
|
contentTypeId: contentTypeId,
|
|
2157
1982
|
spaceId: spaceId,
|
|
2158
1983
|
environmentId: environmentId
|
|
2159
1984
|
});
|
|
1985
|
+
}, options), fetch(['defaultLocale', spaceId, environmentId], /*#__PURE__*/function () {
|
|
1986
|
+
var _ref13 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(_ref12) {
|
|
1987
|
+
var _locales$items$find;
|
|
2160
1988
|
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
1989
|
+
var cmaClient, locales, defaultLocaleCode;
|
|
1990
|
+
return runtime_1.wrap(function _callee2$(_context2) {
|
|
1991
|
+
while (1) {
|
|
1992
|
+
switch (_context2.prev = _context2.next) {
|
|
1993
|
+
case 0:
|
|
1994
|
+
cmaClient = _ref12.cmaClient;
|
|
1995
|
+
_context2.next = 3;
|
|
1996
|
+
return cmaClient.locale.getMany({
|
|
1997
|
+
spaceId: spaceId,
|
|
1998
|
+
environmentId: environmentId,
|
|
1999
|
+
query: {
|
|
2000
|
+
limit: 100
|
|
2001
|
+
}
|
|
2002
|
+
});
|
|
2003
|
+
|
|
2004
|
+
case 3:
|
|
2005
|
+
locales = _context2.sent;
|
|
2006
|
+
defaultLocaleCode = (_locales$items$find = locales.items.find(function (locale) {
|
|
2007
|
+
return locale["default"];
|
|
2008
|
+
})) == null ? void 0 : _locales$items$find.code;
|
|
2009
|
+
return _context2.abrupt("return", defaultLocaleCode);
|
|
2171
2010
|
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
_yield$Promise$all2 = _context5.sent;
|
|
2180
|
-
contentType = _yield$Promise$all2[0];
|
|
2181
|
-
locales = _yield$Promise$all2[1];
|
|
2182
|
-
defaultLocaleCode = (_locales$items$find = locales.items.find(function (locale) {
|
|
2183
|
-
return locale["default"];
|
|
2184
|
-
})) == null ? void 0 : _locales$items$find.code;
|
|
2185
|
-
return _context5.abrupt("return", {
|
|
2186
|
-
resource: entry,
|
|
2187
|
-
defaultLocaleCode: defaultLocaleCode,
|
|
2188
|
-
space: space,
|
|
2189
|
-
contentType: contentType
|
|
2190
|
-
});
|
|
2011
|
+
case 6:
|
|
2012
|
+
case "end":
|
|
2013
|
+
return _context2.stop();
|
|
2014
|
+
}
|
|
2015
|
+
}
|
|
2016
|
+
}, _callee2);
|
|
2017
|
+
}));
|
|
2191
2018
|
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2019
|
+
return function (_x3) {
|
|
2020
|
+
return _ref13.apply(this, arguments);
|
|
2021
|
+
};
|
|
2022
|
+
}(), options)]);
|
|
2023
|
+
|
|
2024
|
+
case 12:
|
|
2025
|
+
_yield$Promise$all2 = _context3.sent;
|
|
2026
|
+
contentType = _yield$Promise$all2[0];
|
|
2027
|
+
defaultLocaleCode = _yield$Promise$all2[1];
|
|
2028
|
+
return _context3.abrupt("return", {
|
|
2029
|
+
defaultLocaleCode: defaultLocaleCode,
|
|
2030
|
+
resource: entry,
|
|
2031
|
+
space: space,
|
|
2032
|
+
contentType: contentType
|
|
2033
|
+
});
|
|
2199
2034
|
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
switch (_context6.prev = _context6.next) {
|
|
2210
|
-
case 0:
|
|
2211
|
-
cachedResource = state.resources[resourceType + "." + urn];
|
|
2035
|
+
case 16:
|
|
2036
|
+
case "end":
|
|
2037
|
+
return _context3.stop();
|
|
2038
|
+
}
|
|
2039
|
+
}
|
|
2040
|
+
}, _callee3);
|
|
2041
|
+
}));
|
|
2042
|
+
return _fetchContentfulEntry.apply(this, arguments);
|
|
2043
|
+
}
|
|
2212
2044
|
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2045
|
+
var _constate = /*#__PURE__*/constate(function useInitServices(props) {
|
|
2046
|
+
var currentSpaceId = props.sdk.ids.space;
|
|
2047
|
+
var currentEnvironmentId = props.sdk.ids.environment;
|
|
2048
|
+
var queryClient = useQueryClient();
|
|
2049
|
+
var queryCache = queryClient.getQueryCache();
|
|
2050
|
+
var entityChangeUnsubscribers = useRef({});
|
|
2051
|
+
var cmaClient = useMemo(function () {
|
|
2052
|
+
return createClient({
|
|
2053
|
+
apiAdapter: props.sdk.cmaAdapter
|
|
2054
|
+
}, {
|
|
2055
|
+
type: 'plain'
|
|
2056
|
+
});
|
|
2057
|
+
}, [props.sdk.cmaAdapter]);
|
|
2058
|
+
var queryQueue = useMemo(function () {
|
|
2059
|
+
if (props.queryConcurrency) {
|
|
2060
|
+
return new PQueue({
|
|
2061
|
+
concurrency: props.queryConcurrency
|
|
2062
|
+
});
|
|
2063
|
+
}
|
|
2217
2064
|
|
|
2218
|
-
|
|
2065
|
+
return globalQueue;
|
|
2066
|
+
}, [props.queryConcurrency]);
|
|
2067
|
+
var fetch = useCallback(function fetch(queryKey, fn, options) {
|
|
2068
|
+
if (options === void 0) {
|
|
2069
|
+
options = {};
|
|
2070
|
+
}
|
|
2219
2071
|
|
|
2220
|
-
|
|
2221
|
-
|
|
2072
|
+
var _options = options,
|
|
2073
|
+
priority = _options.priority,
|
|
2074
|
+
queryOptions = _objectWithoutPropertiesLoose(_options, _excluded$1);
|
|
2222
2075
|
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2076
|
+
return queryClient.fetchQuery(queryKey, function () {
|
|
2077
|
+
return queryQueue.add(function () {
|
|
2078
|
+
return fn({
|
|
2079
|
+
cmaClient: cmaClient
|
|
2080
|
+
});
|
|
2081
|
+
}, {
|
|
2082
|
+
priority: priority
|
|
2083
|
+
});
|
|
2084
|
+
}, queryOptions);
|
|
2085
|
+
}, [queryClient, queryQueue, cmaClient]);
|
|
2086
|
+
var getEntity = useCallback(function getEntity(entityType, entityId, options) {
|
|
2087
|
+
var _options$spaceId, _options$environmentI;
|
|
2088
|
+
|
|
2089
|
+
var spaceId = (_options$spaceId = options == null ? void 0 : options.spaceId) != null ? _options$spaceId : currentSpaceId;
|
|
2090
|
+
var environmentId = (_options$environmentI = options == null ? void 0 : options.environmentId) != null ? _options$environmentI : currentEnvironmentId;
|
|
2091
|
+
var queryKey = [entityType, entityId, spaceId, environmentId];
|
|
2092
|
+
return fetch(queryKey, function (_ref) {
|
|
2093
|
+
var cmaClient = _ref.cmaClient;
|
|
2094
|
+
|
|
2095
|
+
if (entityType === 'Entry') {
|
|
2096
|
+
return cmaClient.entry.get({
|
|
2097
|
+
entryId: entityId,
|
|
2098
|
+
spaceId: spaceId,
|
|
2099
|
+
environmentId: environmentId
|
|
2100
|
+
});
|
|
2101
|
+
}
|
|
2227
2102
|
|
|
2228
|
-
|
|
2229
|
-
|
|
2103
|
+
if (entityType === 'Asset') {
|
|
2104
|
+
return cmaClient.asset.get({
|
|
2105
|
+
assetId: entityId,
|
|
2106
|
+
spaceId: spaceId,
|
|
2107
|
+
environmentId: environmentId
|
|
2108
|
+
});
|
|
2109
|
+
}
|
|
2230
2110
|
|
|
2231
|
-
|
|
2232
|
-
|
|
2111
|
+
throw new UnsupportedError('Unsupported entity type');
|
|
2112
|
+
}, options);
|
|
2113
|
+
}, [fetch, currentSpaceId, currentEnvironmentId]);
|
|
2114
|
+
var getEntityScheduledActions = useCallback(function getEntityScheduledActions(entityType, entityId, options) {
|
|
2115
|
+
var _options$spaceId2, _options$environmentI2;
|
|
2116
|
+
|
|
2117
|
+
var spaceId = (_options$spaceId2 = options == null ? void 0 : options.spaceId) != null ? _options$spaceId2 : currentSpaceId;
|
|
2118
|
+
var environmentId = (_options$environmentI2 = options == null ? void 0 : options.environmentId) != null ? _options$environmentI2 : currentEnvironmentId;
|
|
2119
|
+
var queryKey = ['scheduled-actions', entityType, entityId, spaceId, environmentId];
|
|
2120
|
+
return fetch(queryKey, /*#__PURE__*/function () {
|
|
2121
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(_ref2) {
|
|
2122
|
+
var cmaClient, response;
|
|
2123
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
2124
|
+
while (1) {
|
|
2125
|
+
switch (_context.prev = _context.next) {
|
|
2126
|
+
case 0:
|
|
2127
|
+
cmaClient = _ref2.cmaClient;
|
|
2128
|
+
_context.next = 3;
|
|
2129
|
+
return cmaClient.scheduledActions.getMany({
|
|
2130
|
+
spaceId: spaceId,
|
|
2131
|
+
query: {
|
|
2132
|
+
'environment.sys.id': environmentId,
|
|
2133
|
+
'entity.sys.id': entityId,
|
|
2134
|
+
'sys.status[in]': 'scheduled',
|
|
2135
|
+
order: 'scheduledFor.datetime'
|
|
2136
|
+
}
|
|
2137
|
+
});
|
|
2233
2138
|
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
resourceType: resourceType,
|
|
2238
|
-
urn: urn,
|
|
2239
|
-
resourceInfo: resourceInfo
|
|
2240
|
-
});
|
|
2241
|
-
return _context6.abrupt("return", resourceInfo);
|
|
2242
|
-
|
|
2243
|
-
case 12:
|
|
2244
|
-
_context6.prev = 12;
|
|
2245
|
-
_context6.t0 = _context6["catch"](3);
|
|
2246
|
-
dispatch({
|
|
2247
|
-
type: 'set_resource_failed',
|
|
2248
|
-
resourceType: resourceType,
|
|
2249
|
-
urn: urn
|
|
2250
|
-
});
|
|
2251
|
-
return _context6.abrupt("return");
|
|
2139
|
+
case 3:
|
|
2140
|
+
response = _context.sent;
|
|
2141
|
+
return _context.abrupt("return", response.items);
|
|
2252
2142
|
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2143
|
+
case 5:
|
|
2144
|
+
case "end":
|
|
2145
|
+
return _context.stop();
|
|
2146
|
+
}
|
|
2256
2147
|
}
|
|
2257
|
-
}
|
|
2258
|
-
}
|
|
2259
|
-
}));
|
|
2148
|
+
}, _callee);
|
|
2149
|
+
}));
|
|
2260
2150
|
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
};
|
|
2264
|
-
}(), [loadContentfulEntry, state.resources]);
|
|
2265
|
-
useEffect(function () {
|
|
2266
|
-
// @ts-expect-error
|
|
2267
|
-
if (typeof props.sdk.space.onEntityChanged !== 'undefined') {
|
|
2268
|
-
// @ts-expect-error
|
|
2269
|
-
var onEntityChanged = props.sdk.space.onEntityChanged;
|
|
2270
|
-
var listeners = [];
|
|
2271
|
-
|
|
2272
|
-
var _loop = function _loop() {
|
|
2273
|
-
var _step$value = _step.value,
|
|
2274
|
-
id = _step$value[0];
|
|
2275
|
-
listeners.push(onEntityChanged('Entry', id, function (entry) {
|
|
2276
|
-
return dispatch({
|
|
2277
|
-
type: 'set_entry',
|
|
2278
|
-
id: id,
|
|
2279
|
-
entry: entry
|
|
2280
|
-
});
|
|
2281
|
-
}));
|
|
2151
|
+
return function (_x2) {
|
|
2152
|
+
return _ref3.apply(this, arguments);
|
|
2282
2153
|
};
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2154
|
+
}(), options);
|
|
2155
|
+
}, [fetch, currentSpaceId, currentEnvironmentId]);
|
|
2156
|
+
var getResource = useCallback(function getResource(resourceType, urn, options) {
|
|
2157
|
+
var queryKey = ['Resource', resourceType, urn];
|
|
2158
|
+
return fetch(queryKey, function () {
|
|
2159
|
+
if (resourceType === 'Contentful:Entry') {
|
|
2160
|
+
return fetchContentfulEntry({
|
|
2161
|
+
fetch: fetch,
|
|
2162
|
+
urn: urn,
|
|
2163
|
+
options: options
|
|
2164
|
+
});
|
|
2286
2165
|
}
|
|
2287
2166
|
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2167
|
+
throw new UnsupportedError('Unsupported resource type');
|
|
2168
|
+
}, options);
|
|
2169
|
+
}, [fetch]);
|
|
2170
|
+
var isSameSpaceEntityQueryKey = useCallback(function (queryKey) {
|
|
2171
|
+
var isEntityKey = isEntityQueryKey(queryKey);
|
|
2172
|
+
var isSameSpaceEntityKey = isEntityKey && queryKey[2] === currentSpaceId && queryKey[3] === currentEnvironmentId;
|
|
2173
|
+
return isSameSpaceEntityKey;
|
|
2174
|
+
}, [currentSpaceId, currentEnvironmentId]); // @ts-expect-error ...
|
|
2175
|
+
|
|
2176
|
+
// @ts-expect-error ...
|
|
2177
|
+
var onEntityChanged = props.sdk.space.onEntityChanged;
|
|
2178
|
+
useEffect(function () {
|
|
2179
|
+
if (typeof onEntityChanged !== 'function') {
|
|
2180
|
+
return;
|
|
2181
|
+
}
|
|
2182
|
+
|
|
2183
|
+
var subscribeQuery = function subscribeQuery(_ref4) {
|
|
2184
|
+
var queryKey = _ref4.queryKey,
|
|
2185
|
+
queryHash = _ref4.queryHash;
|
|
2186
|
+
var entityType = queryKey[0],
|
|
2187
|
+
entityId = queryKey[1];
|
|
2188
|
+
entityChangeUnsubscribers.current[queryHash] = onEntityChanged(entityType, entityId, function (data) {
|
|
2189
|
+
queryClient.setQueryData(queryKey, data);
|
|
2190
|
+
});
|
|
2191
|
+
};
|
|
2299
2192
|
|
|
2300
|
-
|
|
2301
|
-
|
|
2193
|
+
var queries = queryCache.findAll({
|
|
2194
|
+
type: 'active',
|
|
2195
|
+
predicate: function predicate(query) {
|
|
2196
|
+
return isSameSpaceEntityQueryKey(query.queryKey);
|
|
2197
|
+
}
|
|
2198
|
+
});
|
|
2199
|
+
queries.forEach(subscribeQuery);
|
|
2200
|
+
var unsubscribe = queryCache.subscribe(function (event) {
|
|
2201
|
+
if (!event) {
|
|
2202
|
+
return;
|
|
2302
2203
|
}
|
|
2303
2204
|
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
};
|
|
2309
|
-
}
|
|
2205
|
+
var type = event.type,
|
|
2206
|
+
query = event.query;
|
|
2207
|
+
var queryKey = query.queryKey,
|
|
2208
|
+
queryHash = query.queryHash;
|
|
2310
2209
|
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2210
|
+
if (!isSameSpaceEntityQueryKey(queryKey)) {
|
|
2211
|
+
return;
|
|
2212
|
+
}
|
|
2314
2213
|
|
|
2315
|
-
if (
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
id = _step3$value[0];
|
|
2319
|
-
loadEntry(id);
|
|
2320
|
-
}
|
|
2214
|
+
if (type === 'added') {
|
|
2215
|
+
subscribeQuery(query);
|
|
2216
|
+
}
|
|
2321
2217
|
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2218
|
+
if (type === 'removed') {
|
|
2219
|
+
var _entityChangeUnsubscr, _entityChangeUnsubscr2;
|
|
2220
|
+
|
|
2221
|
+
// calling unsubscribe
|
|
2222
|
+
(_entityChangeUnsubscr = (_entityChangeUnsubscr2 = entityChangeUnsubscribers.current)[queryHash]) == null ? void 0 : _entityChangeUnsubscr.call(_entityChangeUnsubscr2);
|
|
2327
2223
|
}
|
|
2328
|
-
});
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
getOrLoadEntry: getEntry,
|
|
2336
|
-
|
|
2337
|
-
/**
|
|
2338
|
-
* @deprecated use `getAsset` instead
|
|
2339
|
-
*/
|
|
2340
|
-
getOrLoadAsset: getAsset,
|
|
2341
|
-
getResource: getResource,
|
|
2342
|
-
getEntry: getEntry,
|
|
2343
|
-
getAsset: getAsset,
|
|
2344
|
-
loadEntityScheduledActions: loadEntityScheduledActions,
|
|
2345
|
-
entries: state.entries,
|
|
2346
|
-
assets: state.assets,
|
|
2347
|
-
scheduledActions: state.scheduledActions,
|
|
2348
|
-
resources: state.resources
|
|
2224
|
+
});
|
|
2225
|
+
return function () {
|
|
2226
|
+
unsubscribe();
|
|
2227
|
+
Object.values(entityChangeUnsubscribers.current).forEach(function (off) {
|
|
2228
|
+
return off();
|
|
2229
|
+
});
|
|
2230
|
+
entityChangeUnsubscribers.current = {};
|
|
2349
2231
|
};
|
|
2350
|
-
}, [
|
|
2232
|
+
}, [onEntityChanged, queryCache, isSameSpaceEntityQueryKey, queryClient]);
|
|
2233
|
+
return {
|
|
2234
|
+
cmaClient: cmaClient,
|
|
2235
|
+
fetch: fetch,
|
|
2236
|
+
getResource: getResource,
|
|
2237
|
+
getEntity: getEntity,
|
|
2238
|
+
ids: props.sdk.ids,
|
|
2239
|
+
getEntityScheduledActions: getEntityScheduledActions
|
|
2240
|
+
};
|
|
2241
|
+
}, function (_ref5) {
|
|
2242
|
+
var fetch = _ref5.fetch;
|
|
2243
|
+
return fetch;
|
|
2244
|
+
}, function (_ref6) {
|
|
2245
|
+
var getResource = _ref6.getResource,
|
|
2246
|
+
getEntity = _ref6.getEntity,
|
|
2247
|
+
getEntityScheduledActions = _ref6.getEntityScheduledActions;
|
|
2248
|
+
return {
|
|
2249
|
+
getResource: getResource,
|
|
2250
|
+
getEntity: getEntity,
|
|
2251
|
+
getEntityScheduledActions: getEntityScheduledActions
|
|
2252
|
+
};
|
|
2253
|
+
}, function (_ref7) {
|
|
2254
|
+
var ids = _ref7.ids;
|
|
2255
|
+
return ids;
|
|
2256
|
+
}),
|
|
2257
|
+
InternalServiceProvider = _constate[0],
|
|
2258
|
+
useEntityLoader = _constate[2],
|
|
2259
|
+
useCurrentIds = _constate[3];
|
|
2260
|
+
|
|
2261
|
+
function useEntity(entityType, entityId, options) {
|
|
2262
|
+
var _options$spaceId3, _options$environmentI3;
|
|
2263
|
+
|
|
2264
|
+
var _useCurrentIds = useCurrentIds(),
|
|
2265
|
+
space = _useCurrentIds.space,
|
|
2266
|
+
environment = _useCurrentIds.environment;
|
|
2267
|
+
|
|
2268
|
+
var _useEntityLoader = useEntityLoader(),
|
|
2269
|
+
getEntity = _useEntityLoader.getEntity;
|
|
2270
|
+
|
|
2271
|
+
var queryKey = [entityType, entityId, (_options$spaceId3 = options == null ? void 0 : options.spaceId) != null ? _options$spaceId3 : space, (_options$environmentI3 = options == null ? void 0 : options.environmentId) != null ? _options$environmentI3 : environment];
|
|
2272
|
+
|
|
2273
|
+
var _useQuery = useQuery(queryKey, function () {
|
|
2274
|
+
return getEntity(entityType, entityId, options);
|
|
2275
|
+
}, {
|
|
2276
|
+
enabled: options == null ? void 0 : options.enabled,
|
|
2277
|
+
useErrorBoundary: false
|
|
2278
|
+
}),
|
|
2279
|
+
status = _useQuery.status,
|
|
2280
|
+
data = _useQuery.data;
|
|
2281
|
+
|
|
2282
|
+
return {
|
|
2283
|
+
status: status,
|
|
2284
|
+
data: data
|
|
2285
|
+
};
|
|
2351
2286
|
}
|
|
2287
|
+
function useResource(resourceType, urn, options) {
|
|
2288
|
+
var queryKey = ['Resource', resourceType, urn];
|
|
2289
|
+
|
|
2290
|
+
var _useEntityLoader2 = useEntityLoader(),
|
|
2291
|
+
getResource = _useEntityLoader2.getResource;
|
|
2292
|
+
|
|
2293
|
+
var _useQuery2 = useQuery(queryKey, function () {
|
|
2294
|
+
return getResource(resourceType, urn, options);
|
|
2295
|
+
}, {
|
|
2296
|
+
enabled: options == null ? void 0 : options.enabled,
|
|
2297
|
+
// TODO: check if this is ok for all errors
|
|
2298
|
+
useErrorBoundary: false
|
|
2299
|
+
}),
|
|
2300
|
+
status = _useQuery2.status,
|
|
2301
|
+
data = _useQuery2.data,
|
|
2302
|
+
error = _useQuery2.error;
|
|
2352
2303
|
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2304
|
+
return {
|
|
2305
|
+
status: status,
|
|
2306
|
+
data: data,
|
|
2307
|
+
error: error
|
|
2308
|
+
};
|
|
2309
|
+
}
|
|
2310
|
+
|
|
2311
|
+
function EntityProvider(_ref8) {
|
|
2312
|
+
var children = _ref8.children,
|
|
2313
|
+
props = _objectWithoutPropertiesLoose(_ref8, _excluded2);
|
|
2314
|
+
|
|
2315
|
+
var reactQueryClient = useMemo(function () {
|
|
2316
|
+
var queryCache = new QueryCache();
|
|
2317
|
+
var queryClient = new QueryClient({
|
|
2318
|
+
queryCache: queryCache,
|
|
2319
|
+
defaultOptions: {
|
|
2320
|
+
queries: {
|
|
2321
|
+
useErrorBoundary: true,
|
|
2322
|
+
refetchOnWindowFocus: false,
|
|
2323
|
+
refetchOnReconnect: true,
|
|
2324
|
+
refetchOnMount: false,
|
|
2325
|
+
staleTime: Infinity,
|
|
2326
|
+
retry: false
|
|
2327
|
+
}
|
|
2328
|
+
}
|
|
2329
|
+
});
|
|
2330
|
+
return queryClient;
|
|
2331
|
+
}, []);
|
|
2332
|
+
return React__default.createElement(QueryClientProvider, {
|
|
2333
|
+
client: reactQueryClient
|
|
2334
|
+
}, React__default.createElement(InternalServiceProvider, _extends({}, props), children));
|
|
2335
|
+
}
|
|
2356
2336
|
|
|
2357
2337
|
function ReferenceEditor(props) {
|
|
2358
2338
|
return createElement(EntityProvider, {
|
|
@@ -2574,7 +2554,10 @@ function fromFieldValidations(field) {
|
|
|
2574
2554
|
var result = {
|
|
2575
2555
|
contentTypes: (_linkContentTypeValid = linkContentTypeValidations == null ? void 0 : linkContentTypeValidations.linkContentType) != null ? _linkContentTypeValid : undefined,
|
|
2576
2556
|
mimetypeGroups: (_linkMimetypeGroupVal = linkMimetypeGroupValidations == null ? void 0 : linkMimetypeGroupValidations.linkMimetypeGroup) != null ? _linkMimetypeGroupVal : undefined,
|
|
2577
|
-
numberOfLinks: numberOfLinks
|
|
2557
|
+
numberOfLinks: numberOfLinks // todo: there are multiple BE problems that need to be solved first, for now we don't want to apply size constraints
|
|
2558
|
+
// linkedFileSize: findValidation(field, 'assetFileSize', {}),
|
|
2559
|
+
// linkedImageDimensions: findValidation(field, 'assetImageDimensions', {})
|
|
2560
|
+
|
|
2578
2561
|
};
|
|
2579
2562
|
return result;
|
|
2580
2563
|
}
|
|
@@ -2773,7 +2756,7 @@ function Editor(props) {
|
|
|
2773
2756
|
[linkActionsProps]);
|
|
2774
2757
|
|
|
2775
2758
|
if (!props.entityId) {
|
|
2776
|
-
return createElement(LinkEntityActions,
|
|
2759
|
+
return createElement(LinkEntityActions, _extends({
|
|
2777
2760
|
renderCustomActions: props.renderCustomActions
|
|
2778
2761
|
}, linkActionsProps));
|
|
2779
2762
|
}
|
|
@@ -2785,12 +2768,12 @@ function Editor(props) {
|
|
|
2785
2768
|
|
|
2786
2769
|
function SingleReferenceEditor(props) {
|
|
2787
2770
|
var allContentTypes = props.sdk.space.getCachedContentTypes();
|
|
2788
|
-
return createElement(ReferenceEditor,
|
|
2771
|
+
return createElement(ReferenceEditor, _extends({}, props), function (_ref) {
|
|
2789
2772
|
var value = _ref.value,
|
|
2790
2773
|
setValue = _ref.setValue,
|
|
2791
2774
|
disabled = _ref.disabled,
|
|
2792
2775
|
externalReset = _ref.externalReset;
|
|
2793
|
-
return createElement(Editor,
|
|
2776
|
+
return createElement(Editor, _extends({}, props, {
|
|
2794
2777
|
key: externalReset + "-reference",
|
|
2795
2778
|
entityId: value ? value.sys.id : '',
|
|
2796
2779
|
isDisabled: disabled,
|
|
@@ -3020,18 +3003,24 @@ function _openEntry() {
|
|
|
3020
3003
|
}
|
|
3021
3004
|
|
|
3022
3005
|
function FetchingWrappedEntryCard(props) {
|
|
3023
|
-
var
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
loadEntityScheduledActions = _useEntities.loadEntityScheduledActions,
|
|
3027
|
-
entries = _useEntities.entries;
|
|
3006
|
+
var _useEntity = useEntity('Entry', props.entryId),
|
|
3007
|
+
entry = _useEntity.data,
|
|
3008
|
+
status = _useEntity.status;
|
|
3028
3009
|
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3010
|
+
var _useEntityLoader = useEntityLoader(),
|
|
3011
|
+
getEntityScheduledActions = _useEntityLoader.getEntityScheduledActions;
|
|
3012
|
+
|
|
3013
|
+
var loadEntityScheduledActions = useCallback(function () {
|
|
3014
|
+
return getEntityScheduledActions('Entry', props.entryId);
|
|
3015
|
+
}, [getEntityScheduledActions, props.entryId]);
|
|
3032
3016
|
var size = props.viewType === 'link' ? 'small' : 'default';
|
|
3033
|
-
|
|
3034
|
-
var
|
|
3017
|
+
|
|
3018
|
+
var _useEntityLoader2 = useEntityLoader(),
|
|
3019
|
+
getEntity = _useEntityLoader2.getEntity;
|
|
3020
|
+
|
|
3021
|
+
var getAsset = function getAsset(assetId) {
|
|
3022
|
+
return getEntity('Asset', assetId);
|
|
3023
|
+
};
|
|
3035
3024
|
|
|
3036
3025
|
var onEdit = /*#__PURE__*/function () {
|
|
3037
3026
|
var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
|
|
@@ -3089,7 +3078,7 @@ function FetchingWrappedEntryCard(props) {
|
|
|
3089
3078
|
|
|
3090
3079
|
}, [entry]);
|
|
3091
3080
|
return useMemo(function () {
|
|
3092
|
-
if (
|
|
3081
|
+
if (status === 'error') {
|
|
3093
3082
|
var card = createElement(MissingEntityCard, {
|
|
3094
3083
|
entityType: "Entry",
|
|
3095
3084
|
isDisabled: props.isDisabled,
|
|
@@ -3109,7 +3098,7 @@ function FetchingWrappedEntryCard(props) {
|
|
|
3109
3098
|
return card;
|
|
3110
3099
|
}
|
|
3111
3100
|
|
|
3112
|
-
if (
|
|
3101
|
+
if (status === 'loading') {
|
|
3113
3102
|
return createElement(EntryCard, {
|
|
3114
3103
|
size: size,
|
|
3115
3104
|
isLoading: true
|
|
@@ -3148,7 +3137,7 @@ function FetchingWrappedEntryCard(props) {
|
|
|
3148
3137
|
entryUrl: (props == null ? void 0 : props.entityUrl) || sharedCardProps.entityUrl
|
|
3149
3138
|
});
|
|
3150
3139
|
|
|
3151
|
-
return createElement(WrappedEntryCard,
|
|
3140
|
+
return createElement(WrappedEntryCard, _extends({}, builtinCardProps));
|
|
3152
3141
|
}
|
|
3153
3142
|
|
|
3154
3143
|
if (props.renderCustomCard) {
|
|
@@ -3161,11 +3150,11 @@ function FetchingWrappedEntryCard(props) {
|
|
|
3161
3150
|
}
|
|
3162
3151
|
|
|
3163
3152
|
return renderDefaultCard(); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
|
|
3164
|
-
}, [props,
|
|
3153
|
+
}, [props, status, entry]);
|
|
3165
3154
|
}
|
|
3166
3155
|
|
|
3167
3156
|
function SingleEntryReferenceEditor(props) {
|
|
3168
|
-
return createElement(SingleReferenceEditor,
|
|
3157
|
+
return createElement(SingleReferenceEditor, _extends({}, props, {
|
|
3169
3158
|
entityType: "Entry"
|
|
3170
3159
|
}), function (_ref) {
|
|
3171
3160
|
var allContentTypes = _ref.allContentTypes,
|
|
@@ -3175,7 +3164,7 @@ function SingleEntryReferenceEditor(props) {
|
|
|
3175
3164
|
renderCustomCard = _ref.renderCustomCard,
|
|
3176
3165
|
hasCardRemoveActions = _ref.hasCardRemoveActions,
|
|
3177
3166
|
hasCardEditActions = _ref.hasCardEditActions;
|
|
3178
|
-
return createElement(FetchingWrappedEntryCard,
|
|
3167
|
+
return createElement(FetchingWrappedEntryCard, _extends({}, props, {
|
|
3179
3168
|
allContentTypes: allContentTypes,
|
|
3180
3169
|
isDisabled: isDisabled,
|
|
3181
3170
|
entryId: entityId,
|
|
@@ -3266,19 +3255,19 @@ function Editor$1(props) {
|
|
|
3266
3255
|
onSortEnd: onSortEnd,
|
|
3267
3256
|
onMove: onMove,
|
|
3268
3257
|
renderCustomCard: props.renderCustomCard && customCardRenderer
|
|
3269
|
-
})), createElement(LinkEntityActions,
|
|
3258
|
+
})), createElement(LinkEntityActions, _extends({
|
|
3270
3259
|
renderCustomActions: props.renderCustomActions
|
|
3271
3260
|
}, linkActionsProps)));
|
|
3272
3261
|
}
|
|
3273
3262
|
|
|
3274
3263
|
function MultipleReferenceEditor(props) {
|
|
3275
3264
|
var allContentTypes = props.sdk.space.getCachedContentTypes();
|
|
3276
|
-
return createElement(ReferenceEditor,
|
|
3265
|
+
return createElement(ReferenceEditor, _extends({}, props), function (_ref2) {
|
|
3277
3266
|
var value = _ref2.value,
|
|
3278
3267
|
disabled = _ref2.disabled,
|
|
3279
3268
|
setValue = _ref2.setValue,
|
|
3280
3269
|
externalReset = _ref2.externalReset;
|
|
3281
|
-
return createElement(Editor$1,
|
|
3270
|
+
return createElement(Editor$1, _extends({}, props, {
|
|
3282
3271
|
items: value || emptyArray,
|
|
3283
3272
|
isDisabled: disabled,
|
|
3284
3273
|
setValue: setValue,
|
|
@@ -3335,16 +3324,16 @@ var SortableLinkListInternal = /*#__PURE__*/SortableContainer(function (props) {
|
|
|
3335
3324
|
function SortableLinkList(props) {
|
|
3336
3325
|
// with the default distance of 0 the drag start event is "confused" with the click event,
|
|
3337
3326
|
// so the latter one isn't fired and click handlers on child elements don't work
|
|
3338
|
-
return React__default.createElement(SortableLinkListInternal,
|
|
3327
|
+
return React__default.createElement(SortableLinkListInternal, _extends({
|
|
3339
3328
|
distance: 1
|
|
3340
3329
|
}, props), props.children);
|
|
3341
3330
|
}
|
|
3342
3331
|
|
|
3343
3332
|
function MultipleEntryReferenceEditor(props) {
|
|
3344
|
-
return createElement(MultipleReferenceEditor,
|
|
3333
|
+
return createElement(MultipleReferenceEditor, _extends({}, props, {
|
|
3345
3334
|
entityType: "Entry"
|
|
3346
3335
|
}), function (childrenProps) {
|
|
3347
|
-
return createElement(SortableLinkList,
|
|
3336
|
+
return createElement(SortableLinkList, _extends({}, childrenProps, {
|
|
3348
3337
|
axis: "y",
|
|
3349
3338
|
useDragHandle: true
|
|
3350
3339
|
}), function (_ref) {
|
|
@@ -3354,7 +3343,7 @@ function MultipleEntryReferenceEditor(props) {
|
|
|
3354
3343
|
isDisabled = _ref.isDisabled,
|
|
3355
3344
|
DragHandle = _ref.DragHandle;
|
|
3356
3345
|
var lastIndex = items.length - 1;
|
|
3357
|
-
return createElement(FetchingWrappedEntryCard,
|
|
3346
|
+
return createElement(FetchingWrappedEntryCard, _extends({}, childrenProps, {
|
|
3358
3347
|
key: item.sys.id + "-" + index,
|
|
3359
3348
|
index: index,
|
|
3360
3349
|
allContentTypes: childrenProps.allContentTypes,
|
|
@@ -3609,16 +3598,16 @@ var WrappedAssetLink = function WrappedAssetLink(props) {
|
|
|
3609
3598
|
};
|
|
3610
3599
|
|
|
3611
3600
|
function FetchingWrappedAssetCard(props) {
|
|
3612
|
-
var
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
assets = _useEntities.assets;
|
|
3601
|
+
var _useEntity = useEntity('Asset', props.assetId),
|
|
3602
|
+
asset = _useEntity.data,
|
|
3603
|
+
status = _useEntity.status;
|
|
3616
3604
|
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
var
|
|
3621
|
-
|
|
3605
|
+
var _useEntityLoader = useEntityLoader(),
|
|
3606
|
+
getEntityScheduledActions = _useEntityLoader.getEntityScheduledActions;
|
|
3607
|
+
|
|
3608
|
+
var loadEntityScheduledActions = useCallback(function () {
|
|
3609
|
+
return getEntityScheduledActions('Asset', props.assetId);
|
|
3610
|
+
}, [getEntityScheduledActions, props.assetId]);
|
|
3622
3611
|
useEffect(function () {
|
|
3623
3612
|
if (asset) {
|
|
3624
3613
|
props.onAction && props.onAction({
|
|
@@ -3677,7 +3666,7 @@ function FetchingWrappedAssetCard(props) {
|
|
|
3677
3666
|
};
|
|
3678
3667
|
|
|
3679
3668
|
return useMemo(function () {
|
|
3680
|
-
if (
|
|
3669
|
+
if (status === 'error') {
|
|
3681
3670
|
var card = createElement(MissingEntityCard, {
|
|
3682
3671
|
entityType: "Asset",
|
|
3683
3672
|
asSquare: props.viewType !== 'link',
|
|
@@ -3698,8 +3687,7 @@ function FetchingWrappedAssetCard(props) {
|
|
|
3698
3687
|
return card;
|
|
3699
3688
|
}
|
|
3700
3689
|
|
|
3701
|
-
var getEntityUrl = props.getEntityUrl
|
|
3702
|
-
sdk = props.sdk;
|
|
3690
|
+
var getEntityUrl = props.getEntityUrl;
|
|
3703
3691
|
var size = props.viewType === 'big_card' ? 'default' : 'small';
|
|
3704
3692
|
var commonProps = {
|
|
3705
3693
|
asset: asset,
|
|
@@ -3714,20 +3702,20 @@ function FetchingWrappedAssetCard(props) {
|
|
|
3714
3702
|
};
|
|
3715
3703
|
|
|
3716
3704
|
if (props.viewType === 'link') {
|
|
3717
|
-
if (
|
|
3705
|
+
if (status === 'loading') {
|
|
3718
3706
|
return createElement(EntryCard, {
|
|
3719
3707
|
size: "small",
|
|
3720
3708
|
isLoading: true
|
|
3721
3709
|
});
|
|
3722
3710
|
}
|
|
3723
3711
|
|
|
3724
|
-
return createElement(WrappedAssetLink,
|
|
3712
|
+
return createElement(WrappedAssetLink, _extends({}, commonProps, {
|
|
3725
3713
|
href: commonProps.entityUrl,
|
|
3726
|
-
getEntityScheduledActions:
|
|
3714
|
+
getEntityScheduledActions: loadEntityScheduledActions
|
|
3727
3715
|
}));
|
|
3728
3716
|
}
|
|
3729
3717
|
|
|
3730
|
-
if (
|
|
3718
|
+
if (status === 'loading') {
|
|
3731
3719
|
return createElement(AssetCard, {
|
|
3732
3720
|
size: size,
|
|
3733
3721
|
isLoading: true
|
|
@@ -3742,7 +3730,7 @@ function FetchingWrappedAssetCard(props) {
|
|
|
3742
3730
|
getAssetUrl: getEntityUrl
|
|
3743
3731
|
});
|
|
3744
3732
|
|
|
3745
|
-
return createElement(WrappedAssetCard,
|
|
3733
|
+
return createElement(WrappedAssetCard, _extends({}, builtinCardProps));
|
|
3746
3734
|
}
|
|
3747
3735
|
|
|
3748
3736
|
if (props.renderCustomCard) {
|
|
@@ -3759,17 +3747,17 @@ function FetchingWrappedAssetCard(props) {
|
|
|
3759
3747
|
}
|
|
3760
3748
|
|
|
3761
3749
|
return renderDefaultCard(); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
|
|
3762
|
-
}, [props,
|
|
3750
|
+
}, [props, status, asset]);
|
|
3763
3751
|
}
|
|
3764
3752
|
|
|
3765
3753
|
function SingleMediaEditor(props) {
|
|
3766
|
-
return createElement(SingleReferenceEditor,
|
|
3754
|
+
return createElement(SingleReferenceEditor, _extends({}, props, {
|
|
3767
3755
|
entityType: "Asset"
|
|
3768
3756
|
}), function (_ref) {
|
|
3769
3757
|
var entityId = _ref.entityId,
|
|
3770
3758
|
isDisabled = _ref.isDisabled,
|
|
3771
3759
|
setValue = _ref.setValue;
|
|
3772
|
-
return createElement(FetchingWrappedAssetCard,
|
|
3760
|
+
return createElement(FetchingWrappedAssetCard, _extends({}, props, {
|
|
3773
3761
|
viewType: "big_card",
|
|
3774
3762
|
assetId: entityId,
|
|
3775
3763
|
isDisabled: isDisabled,
|
|
@@ -3791,12 +3779,12 @@ var styles$6 = {
|
|
|
3791
3779
|
})
|
|
3792
3780
|
};
|
|
3793
3781
|
function MultipleMediaEditor(props) {
|
|
3794
|
-
return createElement(MultipleReferenceEditor,
|
|
3782
|
+
return createElement(MultipleReferenceEditor, _extends({}, props, {
|
|
3795
3783
|
entityType: "Asset"
|
|
3796
3784
|
}), function (childrenProps) {
|
|
3797
3785
|
var _cx;
|
|
3798
3786
|
|
|
3799
|
-
return createElement(SortableLinkList,
|
|
3787
|
+
return createElement(SortableLinkList, _extends({}, childrenProps, {
|
|
3800
3788
|
className: cx((_cx = {}, _cx[styles$6.gridContainer] = childrenProps.viewType === 'card', _cx)),
|
|
3801
3789
|
axis: childrenProps.viewType === 'card' ? 'xy' : 'y',
|
|
3802
3790
|
useDragHandle: true
|
|
@@ -3806,7 +3794,7 @@ function MultipleMediaEditor(props) {
|
|
|
3806
3794
|
index = _ref.index,
|
|
3807
3795
|
isDisabled = _ref.isDisabled,
|
|
3808
3796
|
DragHandle = _ref.DragHandle;
|
|
3809
|
-
return createElement(FetchingWrappedAssetCard,
|
|
3797
|
+
return createElement(FetchingWrappedAssetCard, _extends({}, childrenProps, {
|
|
3810
3798
|
isDisabled: isDisabled,
|
|
3811
3799
|
key: item.sys.id + "-" + index,
|
|
3812
3800
|
assetId: item.sys.id,
|
|
@@ -3824,5 +3812,5 @@ MultipleMediaEditor.defaultProps = {
|
|
|
3824
3812
|
isInitiallyDisabled: true
|
|
3825
3813
|
};
|
|
3826
3814
|
|
|
3827
|
-
export { AssetThumbnail, CombinedLinkActions, CreateEntryLinkButton, CreateEntryMenuTrigger, EntityProvider, MissingEntityCard, MultipleEntryReferenceEditor, MultipleMediaEditor, ScheduledIconWithTooltip, SingleEntryReferenceEditor, SingleMediaEditor, SortableLinkList, WrappedAssetCard, WrappedEntryCard, getScheduleTooltipContent,
|
|
3815
|
+
export { AssetThumbnail, CombinedLinkActions, CreateEntryLinkButton, CreateEntryMenuTrigger, EntityProvider, MissingEntityCard, MultipleEntryReferenceEditor, MultipleMediaEditor, ScheduledIconWithTooltip, SingleEntryReferenceEditor, SingleMediaEditor, SortableLinkList, WrappedAssetCard, WrappedEntryCard, getScheduleTooltipContent, useEntity, useEntityLoader, useResource };
|
|
3828
3816
|
//# sourceMappingURL=field-editor-reference.esm.js.map
|