@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
|
@@ -12,10 +12,12 @@ var get = _interopDefault(require('lodash/get'));
|
|
|
12
12
|
var f36Components = require('@contentful/f36-components');
|
|
13
13
|
var f36Icons = require('@contentful/f36-icons');
|
|
14
14
|
var moment = _interopDefault(require('moment'));
|
|
15
|
-
var deepEqual = _interopDefault(require('deep-equal'));
|
|
16
15
|
var fieldEditorShared = require('@contentful/field-editor-shared');
|
|
16
|
+
var deepEqual = _interopDefault(require('deep-equal'));
|
|
17
|
+
var reactQuery = require('@tanstack/react-query');
|
|
17
18
|
var constate = _interopDefault(require('constate'));
|
|
18
19
|
var contentfulManagement = require('contentful-management');
|
|
20
|
+
var PQueue = _interopDefault(require('p-queue'));
|
|
19
21
|
var isNumber = _interopDefault(require('lodash/isNumber'));
|
|
20
22
|
var arrayMove = _interopDefault(require('array-move'));
|
|
21
23
|
var reactSortableHoc = require('react-sortable-hoc');
|
|
@@ -75,57 +77,110 @@ function _extends() {
|
|
|
75
77
|
return _extends.apply(this, arguments);
|
|
76
78
|
}
|
|
77
79
|
|
|
78
|
-
function
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
var sourceKeys = Object.keys(source);
|
|
82
|
-
var key, i;
|
|
80
|
+
function _inheritsLoose(subClass, superClass) {
|
|
81
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
82
|
+
subClass.prototype.constructor = subClass;
|
|
83
83
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
84
|
+
_setPrototypeOf(subClass, superClass);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function _getPrototypeOf(o) {
|
|
88
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
89
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
90
|
+
};
|
|
91
|
+
return _getPrototypeOf(o);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function _setPrototypeOf(o, p) {
|
|
95
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
96
|
+
o.__proto__ = p;
|
|
97
|
+
return o;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
return _setPrototypeOf(o, p);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function _isNativeReflectConstruct() {
|
|
104
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
105
|
+
if (Reflect.construct.sham) return false;
|
|
106
|
+
if (typeof Proxy === "function") return true;
|
|
107
|
+
|
|
108
|
+
try {
|
|
109
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
110
|
+
return true;
|
|
111
|
+
} catch (e) {
|
|
112
|
+
return false;
|
|
88
113
|
}
|
|
114
|
+
}
|
|
89
115
|
|
|
90
|
-
|
|
116
|
+
function _construct(Parent, args, Class) {
|
|
117
|
+
if (_isNativeReflectConstruct()) {
|
|
118
|
+
_construct = Reflect.construct;
|
|
119
|
+
} else {
|
|
120
|
+
_construct = function _construct(Parent, args, Class) {
|
|
121
|
+
var a = [null];
|
|
122
|
+
a.push.apply(a, args);
|
|
123
|
+
var Constructor = Function.bind.apply(Parent, a);
|
|
124
|
+
var instance = new Constructor();
|
|
125
|
+
if (Class) _setPrototypeOf(instance, Class.prototype);
|
|
126
|
+
return instance;
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return _construct.apply(null, arguments);
|
|
91
131
|
}
|
|
92
132
|
|
|
93
|
-
function
|
|
94
|
-
|
|
95
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
96
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
97
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
98
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
99
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
133
|
+
function _isNativeFunction(fn) {
|
|
134
|
+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
100
135
|
}
|
|
101
136
|
|
|
102
|
-
function
|
|
103
|
-
|
|
137
|
+
function _wrapNativeSuper(Class) {
|
|
138
|
+
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
139
|
+
|
|
140
|
+
_wrapNativeSuper = function _wrapNativeSuper(Class) {
|
|
141
|
+
if (Class === null || !_isNativeFunction(Class)) return Class;
|
|
142
|
+
|
|
143
|
+
if (typeof Class !== "function") {
|
|
144
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (typeof _cache !== "undefined") {
|
|
148
|
+
if (_cache.has(Class)) return _cache.get(Class);
|
|
149
|
+
|
|
150
|
+
_cache.set(Class, Wrapper);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function Wrapper() {
|
|
154
|
+
return _construct(Class, arguments, _getPrototypeOf(this).constructor);
|
|
155
|
+
}
|
|
104
156
|
|
|
105
|
-
|
|
157
|
+
Wrapper.prototype = Object.create(Class.prototype, {
|
|
158
|
+
constructor: {
|
|
159
|
+
value: Wrapper,
|
|
160
|
+
enumerable: false,
|
|
161
|
+
writable: true,
|
|
162
|
+
configurable: true
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
return _setPrototypeOf(Wrapper, Class);
|
|
166
|
+
};
|
|
106
167
|
|
|
107
|
-
return
|
|
168
|
+
return _wrapNativeSuper(Class);
|
|
108
169
|
}
|
|
109
170
|
|
|
110
|
-
function
|
|
111
|
-
|
|
112
|
-
|
|
171
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
172
|
+
if (source == null) return {};
|
|
173
|
+
var target = {};
|
|
174
|
+
var sourceKeys = Object.keys(source);
|
|
175
|
+
var key, i;
|
|
113
176
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
if (i >= o.length) return {
|
|
119
|
-
done: true
|
|
120
|
-
};
|
|
121
|
-
return {
|
|
122
|
-
done: false,
|
|
123
|
-
value: o[i++]
|
|
124
|
-
};
|
|
125
|
-
};
|
|
177
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
178
|
+
key = sourceKeys[i];
|
|
179
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
180
|
+
target[key] = source[key];
|
|
126
181
|
}
|
|
127
182
|
|
|
128
|
-
|
|
183
|
+
return target;
|
|
129
184
|
}
|
|
130
185
|
|
|
131
186
|
var container = /*#__PURE__*/emotion.css({
|
|
@@ -505,7 +560,7 @@ function CombinedLinkActions(props) {
|
|
|
505
560
|
var hideEmptyCard = props.entityType === 'Asset' && !props.isEmpty;
|
|
506
561
|
return React.createElement("div", {
|
|
507
562
|
className: hideEmptyCard ? '' : container
|
|
508
|
-
}, !props.canCreateEntity && !props.canLinkEntity && React.createElement(NoLinkPermissionsInfo, null), props.entityType === 'Entry' && React.createElement(CombinedEntryLinkActions,
|
|
563
|
+
}, !props.canCreateEntity && !props.canLinkEntity && React.createElement(NoLinkPermissionsInfo, null), props.entityType === 'Entry' && React.createElement(CombinedEntryLinkActions, _extends({}, props)), props.entityType === 'Asset' && React.createElement(CombinedAssetLinkActions, _extends({}, props)));
|
|
509
564
|
}
|
|
510
565
|
|
|
511
566
|
function CombinedEntryLinkActions(props) {
|
|
@@ -1635,9 +1690,8 @@ function useLinkActionsProps(props) {
|
|
|
1635
1690
|
return function (_x, _x2) {
|
|
1636
1691
|
return _ref.apply(this, arguments);
|
|
1637
1692
|
};
|
|
1638
|
-
}(), [sdk, entityType, onCreated]);
|
|
1639
|
-
|
|
1640
|
-
var onLinkExisting = /*#__PURE__*/function () {
|
|
1693
|
+
}(), [sdk, entityType, onCreated]);
|
|
1694
|
+
var onLinkExisting = React.useCallback( /*#__PURE__*/function () {
|
|
1641
1695
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(index) {
|
|
1642
1696
|
var entity;
|
|
1643
1697
|
return runtime_1.wrap(function _callee2$(_context2) {
|
|
@@ -1672,12 +1726,12 @@ function useLinkActionsProps(props) {
|
|
|
1672
1726
|
}, _callee2);
|
|
1673
1727
|
}));
|
|
1674
1728
|
|
|
1675
|
-
return function
|
|
1729
|
+
return function (_x3) {
|
|
1676
1730
|
return _ref2.apply(this, arguments);
|
|
1677
1731
|
};
|
|
1678
|
-
}()
|
|
1679
|
-
|
|
1680
|
-
var onLinkSeveralExisting = /*#__PURE__*/function () {
|
|
1732
|
+
}(), // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
|
|
1733
|
+
[sdk, entityType, onLinkedExisting]);
|
|
1734
|
+
var onLinkSeveralExisting = React.useCallback( /*#__PURE__*/function () {
|
|
1681
1735
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(index) {
|
|
1682
1736
|
var entities;
|
|
1683
1737
|
return runtime_1.wrap(function _callee3$(_context3) {
|
|
@@ -1712,11 +1766,11 @@ function useLinkActionsProps(props) {
|
|
|
1712
1766
|
}, _callee3);
|
|
1713
1767
|
}));
|
|
1714
1768
|
|
|
1715
|
-
return function
|
|
1769
|
+
return function (_x4) {
|
|
1716
1770
|
return _ref3.apply(this, arguments);
|
|
1717
1771
|
};
|
|
1718
|
-
}()
|
|
1719
|
-
|
|
1772
|
+
}(), // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
|
|
1773
|
+
[sdk, entityType, onLinkedExisting]); // FIXME: The memoization might rerun every time due to the always changing callback identities above
|
|
1720
1774
|
|
|
1721
1775
|
return React.useMemo(function () {
|
|
1722
1776
|
return {
|
|
@@ -1746,7 +1800,7 @@ function LinkEntityActions(_ref4) {
|
|
|
1746
1800
|
props = _objectWithoutPropertiesLoose(_ref4, _excluded);
|
|
1747
1801
|
|
|
1748
1802
|
var renderLinkActions = renderCustomActions ? renderCustomActions : function (props) {
|
|
1749
|
-
return React.createElement(LinkActions,
|
|
1803
|
+
return React.createElement(LinkActions, _extends({}, props));
|
|
1750
1804
|
};
|
|
1751
1805
|
return renderLinkActions(props);
|
|
1752
1806
|
}
|
|
@@ -1807,6 +1861,8 @@ var ScheduleTooltip = function ScheduleTooltip(_ref2) {
|
|
|
1807
1861
|
};
|
|
1808
1862
|
|
|
1809
1863
|
var ScheduledIconWithTooltip = function ScheduledIconWithTooltip(_ref) {
|
|
1864
|
+
var _status$jobs;
|
|
1865
|
+
|
|
1810
1866
|
var entityType = _ref.entityType,
|
|
1811
1867
|
entityId = _ref.entityId,
|
|
1812
1868
|
getEntityScheduledActions = _ref.getEntityScheduledActions,
|
|
@@ -1838,7 +1894,7 @@ var ScheduledIconWithTooltip = function ScheduledIconWithTooltip(_ref) {
|
|
|
1838
1894
|
return null;
|
|
1839
1895
|
}
|
|
1840
1896
|
|
|
1841
|
-
var jobs = status.jobs ?
|
|
1897
|
+
var jobs = (_status$jobs = status.jobs) != null ? _status$jobs : [];
|
|
1842
1898
|
|
|
1843
1899
|
if (jobs.length === 0) {
|
|
1844
1900
|
return null;
|
|
@@ -1864,502 +1920,426 @@ function AssetThumbnail(props) {
|
|
|
1864
1920
|
});
|
|
1865
1921
|
}
|
|
1866
1922
|
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
switch (action.type) {
|
|
1871
|
-
case 'set_entry':
|
|
1872
|
-
return _extends({}, state, {
|
|
1873
|
-
entries: _extends({}, state.entries, (_extends2 = {}, _extends2[action.id] = action.entry, _extends2))
|
|
1874
|
-
});
|
|
1875
|
-
|
|
1876
|
-
case 'set_entry_failed':
|
|
1877
|
-
return _extends({}, state, {
|
|
1878
|
-
entries: _extends({}, state.entries, (_extends3 = {}, _extends3[action.id] = 'failed', _extends3))
|
|
1879
|
-
});
|
|
1880
|
-
|
|
1881
|
-
case 'set_asset':
|
|
1882
|
-
return _extends({}, state, {
|
|
1883
|
-
assets: _extends({}, state.assets, (_extends4 = {}, _extends4[action.id] = action.asset, _extends4))
|
|
1884
|
-
});
|
|
1885
|
-
|
|
1886
|
-
case 'set_asset_failed':
|
|
1887
|
-
return _extends({}, state, {
|
|
1888
|
-
assets: _extends({}, state.assets, (_extends5 = {}, _extends5[action.id] = 'failed', _extends5))
|
|
1889
|
-
});
|
|
1890
|
-
|
|
1891
|
-
case 'set_scheduled_actions':
|
|
1892
|
-
return _extends({}, state, {
|
|
1893
|
-
scheduledActions: _extends({}, state.scheduledActions, (_extends6 = {}, _extends6[action.key] = action.actions, _extends6))
|
|
1894
|
-
});
|
|
1923
|
+
var _excluded$1 = ["priority"],
|
|
1924
|
+
_excluded2 = ["children"];
|
|
1895
1925
|
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1926
|
+
var globalQueue = /*#__PURE__*/new PQueue({
|
|
1927
|
+
concurrency: 20
|
|
1928
|
+
});
|
|
1929
|
+
var UnsupportedError = /*#__PURE__*/function (_Error) {
|
|
1930
|
+
_inheritsLoose(UnsupportedError, _Error);
|
|
1900
1931
|
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
resources: _extends({}, state.resources, (_extends8 = {}, _extends8[action.resourceType + "." + action.urn] = 'failed', _extends8))
|
|
1904
|
-
});
|
|
1932
|
+
function UnsupportedError(message) {
|
|
1933
|
+
var _this;
|
|
1905
1934
|
|
|
1906
|
-
|
|
1907
|
-
|
|
1935
|
+
_this = _Error.call(this, message) || this;
|
|
1936
|
+
_this.isUnsupportedError = void 0;
|
|
1937
|
+
_this.isUnsupportedError = true;
|
|
1938
|
+
return _this;
|
|
1908
1939
|
}
|
|
1909
|
-
}
|
|
1910
1940
|
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
assets: {},
|
|
1914
|
-
scheduledActions: {},
|
|
1915
|
-
resources: {}
|
|
1916
|
-
};
|
|
1917
|
-
|
|
1918
|
-
var isNotNil = function isNotNil(entity) {
|
|
1919
|
-
return Boolean(entity && entity !== 'failed');
|
|
1920
|
-
};
|
|
1941
|
+
return UnsupportedError;
|
|
1942
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
1921
1943
|
|
|
1922
|
-
var
|
|
1923
|
-
return
|
|
1924
|
-
var value = _ref[1];
|
|
1925
|
-
return isNotNil(value);
|
|
1926
|
-
});
|
|
1944
|
+
var isEntityQueryKey = function isEntityQueryKey(queryKey) {
|
|
1945
|
+
return Array.isArray(queryKey) && (queryKey[0] === 'Entry' || queryKey[0] === 'Asset') && queryKey.length === 4;
|
|
1927
1946
|
};
|
|
1928
1947
|
|
|
1929
|
-
function
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
var _React$useState = React.useState(function () {
|
|
1934
|
-
return contentfulManagement.createClient({
|
|
1935
|
-
apiAdapter: props.sdk.cmaAdapter
|
|
1936
|
-
}, {
|
|
1937
|
-
type: 'plain'
|
|
1938
|
-
});
|
|
1939
|
-
}),
|
|
1940
|
-
cmaClient = _React$useState[0];
|
|
1941
|
-
|
|
1942
|
-
var _React$useReducer = React.useReducer(reducer, initialState),
|
|
1943
|
-
state = _React$useReducer[0],
|
|
1944
|
-
dispatch = _React$useReducer[1];
|
|
1945
|
-
|
|
1946
|
-
var loadEntityScheduledActions = React.useCallback(function (entityType, id) {
|
|
1947
|
-
var key = entityType + ":" + id;
|
|
1948
|
-
|
|
1949
|
-
if (state.scheduledActions[key]) {
|
|
1950
|
-
return Promise.resolve(state.scheduledActions[key]);
|
|
1951
|
-
}
|
|
1952
|
-
|
|
1953
|
-
return props.sdk.space.getEntityScheduledActions(entityType, id).then(function (data) {
|
|
1954
|
-
dispatch({
|
|
1955
|
-
type: 'set_scheduled_actions',
|
|
1956
|
-
key: key,
|
|
1957
|
-
actions: data
|
|
1958
|
-
});
|
|
1959
|
-
return data;
|
|
1960
|
-
})["catch"](function () {
|
|
1961
|
-
dispatch({
|
|
1962
|
-
type: 'set_scheduled_actions',
|
|
1963
|
-
key: key,
|
|
1964
|
-
actions: undefined
|
|
1965
|
-
});
|
|
1966
|
-
return [];
|
|
1967
|
-
});
|
|
1968
|
-
}, [props.sdk.space, state.scheduledActions]);
|
|
1969
|
-
var loadEntry = React.useCallback( /*#__PURE__*/function () {
|
|
1970
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(entryId) {
|
|
1971
|
-
var entry;
|
|
1972
|
-
return runtime_1.wrap(function _callee$(_context) {
|
|
1973
|
-
while (1) {
|
|
1974
|
-
switch (_context.prev = _context.next) {
|
|
1975
|
-
case 0:
|
|
1976
|
-
_context.prev = 0;
|
|
1977
|
-
_context.next = 3;
|
|
1978
|
-
return cmaClient.entry.get({
|
|
1979
|
-
spaceId: spaceId,
|
|
1980
|
-
environmentId: environmentId,
|
|
1981
|
-
entryId: entryId
|
|
1982
|
-
});
|
|
1983
|
-
|
|
1984
|
-
case 3:
|
|
1985
|
-
entry = _context.sent;
|
|
1986
|
-
dispatch({
|
|
1987
|
-
type: 'set_entry',
|
|
1988
|
-
id: entryId,
|
|
1989
|
-
entry: entry
|
|
1990
|
-
});
|
|
1991
|
-
return _context.abrupt("return", entry);
|
|
1992
|
-
|
|
1993
|
-
case 8:
|
|
1994
|
-
_context.prev = 8;
|
|
1995
|
-
_context.t0 = _context["catch"](0);
|
|
1996
|
-
dispatch({
|
|
1997
|
-
type: 'set_entry_failed',
|
|
1998
|
-
id: entryId
|
|
1999
|
-
});
|
|
2000
|
-
return _context.abrupt("return");
|
|
2001
|
-
|
|
2002
|
-
case 12:
|
|
2003
|
-
case "end":
|
|
2004
|
-
return _context.stop();
|
|
2005
|
-
}
|
|
2006
|
-
}
|
|
2007
|
-
}, _callee, null, [[0, 8]]);
|
|
2008
|
-
}));
|
|
2009
|
-
|
|
2010
|
-
return function (_x) {
|
|
2011
|
-
return _ref2.apply(this, arguments);
|
|
2012
|
-
};
|
|
2013
|
-
}(), [cmaClient, spaceId, environmentId]);
|
|
2014
|
-
var getEntry = React.useCallback( /*#__PURE__*/function () {
|
|
2015
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(entryId) {
|
|
2016
|
-
var cachedEntry;
|
|
2017
|
-
return runtime_1.wrap(function _callee2$(_context2) {
|
|
2018
|
-
while (1) {
|
|
2019
|
-
switch (_context2.prev = _context2.next) {
|
|
2020
|
-
case 0:
|
|
2021
|
-
cachedEntry = state.entries[entryId];
|
|
2022
|
-
|
|
2023
|
-
if (!isNotNil(cachedEntry)) {
|
|
2024
|
-
_context2.next = 3;
|
|
2025
|
-
break;
|
|
2026
|
-
}
|
|
2027
|
-
|
|
2028
|
-
return _context2.abrupt("return", cachedEntry);
|
|
2029
|
-
|
|
2030
|
-
case 3:
|
|
2031
|
-
return _context2.abrupt("return", loadEntry(entryId));
|
|
2032
|
-
|
|
2033
|
-
case 4:
|
|
2034
|
-
case "end":
|
|
2035
|
-
return _context2.stop();
|
|
2036
|
-
}
|
|
2037
|
-
}
|
|
2038
|
-
}, _callee2);
|
|
2039
|
-
}));
|
|
2040
|
-
|
|
2041
|
-
return function (_x2) {
|
|
2042
|
-
return _ref3.apply(this, arguments);
|
|
2043
|
-
};
|
|
2044
|
-
}(), [loadEntry, state.entries]);
|
|
2045
|
-
var loadAsset = React.useCallback( /*#__PURE__*/function () {
|
|
2046
|
-
var _ref4 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(assetId) {
|
|
2047
|
-
var asset;
|
|
2048
|
-
return runtime_1.wrap(function _callee3$(_context3) {
|
|
2049
|
-
while (1) {
|
|
2050
|
-
switch (_context3.prev = _context3.next) {
|
|
2051
|
-
case 0:
|
|
2052
|
-
_context3.prev = 0;
|
|
2053
|
-
_context3.next = 3;
|
|
2054
|
-
return cmaClient.asset.get({
|
|
2055
|
-
spaceId: spaceId,
|
|
2056
|
-
environmentId: environmentId,
|
|
2057
|
-
assetId: assetId
|
|
2058
|
-
});
|
|
2059
|
-
|
|
2060
|
-
case 3:
|
|
2061
|
-
asset = _context3.sent;
|
|
2062
|
-
dispatch({
|
|
2063
|
-
type: 'set_asset',
|
|
2064
|
-
id: assetId,
|
|
2065
|
-
asset: asset
|
|
2066
|
-
});
|
|
2067
|
-
return _context3.abrupt("return", asset);
|
|
2068
|
-
|
|
2069
|
-
case 8:
|
|
2070
|
-
_context3.prev = 8;
|
|
2071
|
-
_context3.t0 = _context3["catch"](0);
|
|
2072
|
-
dispatch({
|
|
2073
|
-
type: 'set_asset_failed',
|
|
2074
|
-
id: assetId
|
|
2075
|
-
});
|
|
2076
|
-
return _context3.abrupt("return");
|
|
2077
|
-
|
|
2078
|
-
case 12:
|
|
2079
|
-
case "end":
|
|
2080
|
-
return _context3.stop();
|
|
2081
|
-
}
|
|
2082
|
-
}
|
|
2083
|
-
}, _callee3, null, [[0, 8]]);
|
|
2084
|
-
}));
|
|
2085
|
-
|
|
2086
|
-
return function (_x3) {
|
|
2087
|
-
return _ref4.apply(this, arguments);
|
|
2088
|
-
};
|
|
2089
|
-
}(), [cmaClient, spaceId, environmentId]);
|
|
2090
|
-
var getAsset = React.useCallback( /*#__PURE__*/function () {
|
|
2091
|
-
var _ref5 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(assetId) {
|
|
2092
|
-
var cachedAsset;
|
|
2093
|
-
return runtime_1.wrap(function _callee4$(_context4) {
|
|
2094
|
-
while (1) {
|
|
2095
|
-
switch (_context4.prev = _context4.next) {
|
|
2096
|
-
case 0:
|
|
2097
|
-
cachedAsset = state.assets[assetId];
|
|
2098
|
-
|
|
2099
|
-
if (!isNotNil(cachedAsset)) {
|
|
2100
|
-
_context4.next = 3;
|
|
2101
|
-
break;
|
|
2102
|
-
}
|
|
2103
|
-
|
|
2104
|
-
return _context4.abrupt("return", cachedAsset);
|
|
2105
|
-
|
|
2106
|
-
case 3:
|
|
2107
|
-
return _context4.abrupt("return", loadAsset(assetId));
|
|
2108
|
-
|
|
2109
|
-
case 4:
|
|
2110
|
-
case "end":
|
|
2111
|
-
return _context4.stop();
|
|
2112
|
-
}
|
|
2113
|
-
}
|
|
2114
|
-
}, _callee4);
|
|
2115
|
-
}));
|
|
2116
|
-
|
|
2117
|
-
return function (_x4) {
|
|
2118
|
-
return _ref5.apply(this, arguments);
|
|
2119
|
-
};
|
|
2120
|
-
}(), [loadAsset, state.assets]);
|
|
2121
|
-
var loadContentfulEntry = React.useCallback( /*#__PURE__*/function () {
|
|
2122
|
-
var _ref6 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(urn) {
|
|
2123
|
-
var _locales$items$find;
|
|
1948
|
+
function fetchContentfulEntry(_x) {
|
|
1949
|
+
return _fetchContentfulEntry.apply(this, arguments);
|
|
1950
|
+
}
|
|
2124
1951
|
|
|
2125
|
-
|
|
1952
|
+
function _fetchContentfulEntry() {
|
|
1953
|
+
_fetchContentfulEntry = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(params) {
|
|
1954
|
+
var urn, fetch, options, resourceId, _resourceId$split, spaceId, entryId, environmentId, _yield$Promise$all, space, entry, contentTypeId, _yield$Promise$all2, contentType, defaultLocaleCode;
|
|
2126
1955
|
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
1956
|
+
return runtime_1.wrap(function _callee3$(_context3) {
|
|
1957
|
+
while (1) {
|
|
1958
|
+
switch (_context3.prev = _context3.next) {
|
|
1959
|
+
case 0:
|
|
1960
|
+
urn = params.urn, fetch = params.fetch, options = params.options;
|
|
1961
|
+
resourceId = urn.split(':', 6)[5];
|
|
1962
|
+
_resourceId$split = resourceId.split('/'), spaceId = _resourceId$split[1], entryId = _resourceId$split[3];
|
|
1963
|
+
environmentId = 'master';
|
|
1964
|
+
_context3.next = 6;
|
|
1965
|
+
return Promise.all([fetch(['space', spaceId], function (_ref9) {
|
|
1966
|
+
var cmaClient = _ref9.cmaClient;
|
|
2136
1967
|
return cmaClient.space.get({
|
|
2137
1968
|
spaceId: spaceId
|
|
2138
1969
|
});
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
_context5.t1 = _context5.sent;
|
|
2142
|
-
_context5.next = 9;
|
|
1970
|
+
}, options), fetch(['entry', spaceId, environmentId, entryId], function (_ref10) {
|
|
1971
|
+
var cmaClient = _ref10.cmaClient;
|
|
2143
1972
|
return cmaClient.entry.get({
|
|
2144
1973
|
spaceId: spaceId,
|
|
2145
1974
|
environmentId: environmentId,
|
|
2146
1975
|
entryId: entryId
|
|
2147
1976
|
});
|
|
1977
|
+
}, options)]);
|
|
2148
1978
|
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
space = _yield$Promise$all[0];
|
|
2158
|
-
entry = _yield$Promise$all[1];
|
|
2159
|
-
contentTypeId = entry.sys.contentType.sys.id;
|
|
2160
|
-
_context5.t4 = Promise;
|
|
2161
|
-
_context5.next = 20;
|
|
1979
|
+
case 6:
|
|
1980
|
+
_yield$Promise$all = _context3.sent;
|
|
1981
|
+
space = _yield$Promise$all[0];
|
|
1982
|
+
entry = _yield$Promise$all[1];
|
|
1983
|
+
contentTypeId = entry.sys.contentType.sys.id;
|
|
1984
|
+
_context3.next = 12;
|
|
1985
|
+
return Promise.all([fetch(['contentType', spaceId, environmentId, contentTypeId], function (_ref11) {
|
|
1986
|
+
var cmaClient = _ref11.cmaClient;
|
|
2162
1987
|
return cmaClient.contentType.get({
|
|
2163
1988
|
contentTypeId: contentTypeId,
|
|
2164
1989
|
spaceId: spaceId,
|
|
2165
1990
|
environmentId: environmentId
|
|
2166
1991
|
});
|
|
1992
|
+
}, options), fetch(['defaultLocale', spaceId, environmentId], /*#__PURE__*/function () {
|
|
1993
|
+
var _ref13 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(_ref12) {
|
|
1994
|
+
var _locales$items$find;
|
|
2167
1995
|
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
1996
|
+
var cmaClient, locales, defaultLocaleCode;
|
|
1997
|
+
return runtime_1.wrap(function _callee2$(_context2) {
|
|
1998
|
+
while (1) {
|
|
1999
|
+
switch (_context2.prev = _context2.next) {
|
|
2000
|
+
case 0:
|
|
2001
|
+
cmaClient = _ref12.cmaClient;
|
|
2002
|
+
_context2.next = 3;
|
|
2003
|
+
return cmaClient.locale.getMany({
|
|
2004
|
+
spaceId: spaceId,
|
|
2005
|
+
environmentId: environmentId,
|
|
2006
|
+
query: {
|
|
2007
|
+
limit: 100
|
|
2008
|
+
}
|
|
2009
|
+
});
|
|
2010
|
+
|
|
2011
|
+
case 3:
|
|
2012
|
+
locales = _context2.sent;
|
|
2013
|
+
defaultLocaleCode = (_locales$items$find = locales.items.find(function (locale) {
|
|
2014
|
+
return locale["default"];
|
|
2015
|
+
})) == null ? void 0 : _locales$items$find.code;
|
|
2016
|
+
return _context2.abrupt("return", defaultLocaleCode);
|
|
2178
2017
|
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
_yield$Promise$all2 = _context5.sent;
|
|
2187
|
-
contentType = _yield$Promise$all2[0];
|
|
2188
|
-
locales = _yield$Promise$all2[1];
|
|
2189
|
-
defaultLocaleCode = (_locales$items$find = locales.items.find(function (locale) {
|
|
2190
|
-
return locale["default"];
|
|
2191
|
-
})) == null ? void 0 : _locales$items$find.code;
|
|
2192
|
-
return _context5.abrupt("return", {
|
|
2193
|
-
resource: entry,
|
|
2194
|
-
defaultLocaleCode: defaultLocaleCode,
|
|
2195
|
-
space: space,
|
|
2196
|
-
contentType: contentType
|
|
2197
|
-
});
|
|
2018
|
+
case 6:
|
|
2019
|
+
case "end":
|
|
2020
|
+
return _context2.stop();
|
|
2021
|
+
}
|
|
2022
|
+
}
|
|
2023
|
+
}, _callee2);
|
|
2024
|
+
}));
|
|
2198
2025
|
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2026
|
+
return function (_x3) {
|
|
2027
|
+
return _ref13.apply(this, arguments);
|
|
2028
|
+
};
|
|
2029
|
+
}(), options)]);
|
|
2030
|
+
|
|
2031
|
+
case 12:
|
|
2032
|
+
_yield$Promise$all2 = _context3.sent;
|
|
2033
|
+
contentType = _yield$Promise$all2[0];
|
|
2034
|
+
defaultLocaleCode = _yield$Promise$all2[1];
|
|
2035
|
+
return _context3.abrupt("return", {
|
|
2036
|
+
defaultLocaleCode: defaultLocaleCode,
|
|
2037
|
+
resource: entry,
|
|
2038
|
+
space: space,
|
|
2039
|
+
contentType: contentType
|
|
2040
|
+
});
|
|
2206
2041
|
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
switch (_context6.prev = _context6.next) {
|
|
2217
|
-
case 0:
|
|
2218
|
-
cachedResource = state.resources[resourceType + "." + urn];
|
|
2042
|
+
case 16:
|
|
2043
|
+
case "end":
|
|
2044
|
+
return _context3.stop();
|
|
2045
|
+
}
|
|
2046
|
+
}
|
|
2047
|
+
}, _callee3);
|
|
2048
|
+
}));
|
|
2049
|
+
return _fetchContentfulEntry.apply(this, arguments);
|
|
2050
|
+
}
|
|
2219
2051
|
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2052
|
+
var _constate = /*#__PURE__*/constate(function useInitServices(props) {
|
|
2053
|
+
var currentSpaceId = props.sdk.ids.space;
|
|
2054
|
+
var currentEnvironmentId = props.sdk.ids.environment;
|
|
2055
|
+
var queryClient = reactQuery.useQueryClient();
|
|
2056
|
+
var queryCache = queryClient.getQueryCache();
|
|
2057
|
+
var entityChangeUnsubscribers = React.useRef({});
|
|
2058
|
+
var cmaClient = React.useMemo(function () {
|
|
2059
|
+
return contentfulManagement.createClient({
|
|
2060
|
+
apiAdapter: props.sdk.cmaAdapter
|
|
2061
|
+
}, {
|
|
2062
|
+
type: 'plain'
|
|
2063
|
+
});
|
|
2064
|
+
}, [props.sdk.cmaAdapter]);
|
|
2065
|
+
var queryQueue = React.useMemo(function () {
|
|
2066
|
+
if (props.queryConcurrency) {
|
|
2067
|
+
return new PQueue({
|
|
2068
|
+
concurrency: props.queryConcurrency
|
|
2069
|
+
});
|
|
2070
|
+
}
|
|
2224
2071
|
|
|
2225
|
-
|
|
2072
|
+
return globalQueue;
|
|
2073
|
+
}, [props.queryConcurrency]);
|
|
2074
|
+
var fetch = React.useCallback(function fetch(queryKey, fn, options) {
|
|
2075
|
+
if (options === void 0) {
|
|
2076
|
+
options = {};
|
|
2077
|
+
}
|
|
2226
2078
|
|
|
2227
|
-
|
|
2228
|
-
|
|
2079
|
+
var _options = options,
|
|
2080
|
+
priority = _options.priority,
|
|
2081
|
+
queryOptions = _objectWithoutPropertiesLoose(_options, _excluded$1);
|
|
2229
2082
|
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2083
|
+
return queryClient.fetchQuery(queryKey, function () {
|
|
2084
|
+
return queryQueue.add(function () {
|
|
2085
|
+
return fn({
|
|
2086
|
+
cmaClient: cmaClient
|
|
2087
|
+
});
|
|
2088
|
+
}, {
|
|
2089
|
+
priority: priority
|
|
2090
|
+
});
|
|
2091
|
+
}, queryOptions);
|
|
2092
|
+
}, [queryClient, queryQueue, cmaClient]);
|
|
2093
|
+
var getEntity = React.useCallback(function getEntity(entityType, entityId, options) {
|
|
2094
|
+
var _options$spaceId, _options$environmentI;
|
|
2095
|
+
|
|
2096
|
+
var spaceId = (_options$spaceId = options == null ? void 0 : options.spaceId) != null ? _options$spaceId : currentSpaceId;
|
|
2097
|
+
var environmentId = (_options$environmentI = options == null ? void 0 : options.environmentId) != null ? _options$environmentI : currentEnvironmentId;
|
|
2098
|
+
var queryKey = [entityType, entityId, spaceId, environmentId];
|
|
2099
|
+
return fetch(queryKey, function (_ref) {
|
|
2100
|
+
var cmaClient = _ref.cmaClient;
|
|
2101
|
+
|
|
2102
|
+
if (entityType === 'Entry') {
|
|
2103
|
+
return cmaClient.entry.get({
|
|
2104
|
+
entryId: entityId,
|
|
2105
|
+
spaceId: spaceId,
|
|
2106
|
+
environmentId: environmentId
|
|
2107
|
+
});
|
|
2108
|
+
}
|
|
2234
2109
|
|
|
2235
|
-
|
|
2236
|
-
|
|
2110
|
+
if (entityType === 'Asset') {
|
|
2111
|
+
return cmaClient.asset.get({
|
|
2112
|
+
assetId: entityId,
|
|
2113
|
+
spaceId: spaceId,
|
|
2114
|
+
environmentId: environmentId
|
|
2115
|
+
});
|
|
2116
|
+
}
|
|
2237
2117
|
|
|
2238
|
-
|
|
2239
|
-
|
|
2118
|
+
throw new UnsupportedError('Unsupported entity type');
|
|
2119
|
+
}, options);
|
|
2120
|
+
}, [fetch, currentSpaceId, currentEnvironmentId]);
|
|
2121
|
+
var getEntityScheduledActions = React.useCallback(function getEntityScheduledActions(entityType, entityId, options) {
|
|
2122
|
+
var _options$spaceId2, _options$environmentI2;
|
|
2123
|
+
|
|
2124
|
+
var spaceId = (_options$spaceId2 = options == null ? void 0 : options.spaceId) != null ? _options$spaceId2 : currentSpaceId;
|
|
2125
|
+
var environmentId = (_options$environmentI2 = options == null ? void 0 : options.environmentId) != null ? _options$environmentI2 : currentEnvironmentId;
|
|
2126
|
+
var queryKey = ['scheduled-actions', entityType, entityId, spaceId, environmentId];
|
|
2127
|
+
return fetch(queryKey, /*#__PURE__*/function () {
|
|
2128
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(_ref2) {
|
|
2129
|
+
var cmaClient, response;
|
|
2130
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
2131
|
+
while (1) {
|
|
2132
|
+
switch (_context.prev = _context.next) {
|
|
2133
|
+
case 0:
|
|
2134
|
+
cmaClient = _ref2.cmaClient;
|
|
2135
|
+
_context.next = 3;
|
|
2136
|
+
return cmaClient.scheduledActions.getMany({
|
|
2137
|
+
spaceId: spaceId,
|
|
2138
|
+
query: {
|
|
2139
|
+
'environment.sys.id': environmentId,
|
|
2140
|
+
'entity.sys.id': entityId,
|
|
2141
|
+
'sys.status[in]': 'scheduled',
|
|
2142
|
+
order: 'scheduledFor.datetime'
|
|
2143
|
+
}
|
|
2144
|
+
});
|
|
2240
2145
|
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
resourceType: resourceType,
|
|
2245
|
-
urn: urn,
|
|
2246
|
-
resourceInfo: resourceInfo
|
|
2247
|
-
});
|
|
2248
|
-
return _context6.abrupt("return", resourceInfo);
|
|
2249
|
-
|
|
2250
|
-
case 12:
|
|
2251
|
-
_context6.prev = 12;
|
|
2252
|
-
_context6.t0 = _context6["catch"](3);
|
|
2253
|
-
dispatch({
|
|
2254
|
-
type: 'set_resource_failed',
|
|
2255
|
-
resourceType: resourceType,
|
|
2256
|
-
urn: urn
|
|
2257
|
-
});
|
|
2258
|
-
return _context6.abrupt("return");
|
|
2146
|
+
case 3:
|
|
2147
|
+
response = _context.sent;
|
|
2148
|
+
return _context.abrupt("return", response.items);
|
|
2259
2149
|
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2150
|
+
case 5:
|
|
2151
|
+
case "end":
|
|
2152
|
+
return _context.stop();
|
|
2153
|
+
}
|
|
2263
2154
|
}
|
|
2264
|
-
}
|
|
2265
|
-
}
|
|
2266
|
-
}));
|
|
2155
|
+
}, _callee);
|
|
2156
|
+
}));
|
|
2267
2157
|
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
};
|
|
2271
|
-
}(), [loadContentfulEntry, state.resources]);
|
|
2272
|
-
React.useEffect(function () {
|
|
2273
|
-
// @ts-expect-error
|
|
2274
|
-
if (typeof props.sdk.space.onEntityChanged !== 'undefined') {
|
|
2275
|
-
// @ts-expect-error
|
|
2276
|
-
var onEntityChanged = props.sdk.space.onEntityChanged;
|
|
2277
|
-
var listeners = [];
|
|
2278
|
-
|
|
2279
|
-
var _loop = function _loop() {
|
|
2280
|
-
var _step$value = _step.value,
|
|
2281
|
-
id = _step$value[0];
|
|
2282
|
-
listeners.push(onEntityChanged('Entry', id, function (entry) {
|
|
2283
|
-
return dispatch({
|
|
2284
|
-
type: 'set_entry',
|
|
2285
|
-
id: id,
|
|
2286
|
-
entry: entry
|
|
2287
|
-
});
|
|
2288
|
-
}));
|
|
2158
|
+
return function (_x2) {
|
|
2159
|
+
return _ref3.apply(this, arguments);
|
|
2289
2160
|
};
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2161
|
+
}(), options);
|
|
2162
|
+
}, [fetch, currentSpaceId, currentEnvironmentId]);
|
|
2163
|
+
var getResource = React.useCallback(function getResource(resourceType, urn, options) {
|
|
2164
|
+
var queryKey = ['Resource', resourceType, urn];
|
|
2165
|
+
return fetch(queryKey, function () {
|
|
2166
|
+
if (resourceType === 'Contentful:Entry') {
|
|
2167
|
+
return fetchContentfulEntry({
|
|
2168
|
+
fetch: fetch,
|
|
2169
|
+
urn: urn,
|
|
2170
|
+
options: options
|
|
2171
|
+
});
|
|
2293
2172
|
}
|
|
2294
2173
|
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2174
|
+
throw new UnsupportedError('Unsupported resource type');
|
|
2175
|
+
}, options);
|
|
2176
|
+
}, [fetch]);
|
|
2177
|
+
var isSameSpaceEntityQueryKey = React.useCallback(function (queryKey) {
|
|
2178
|
+
var isEntityKey = isEntityQueryKey(queryKey);
|
|
2179
|
+
var isSameSpaceEntityKey = isEntityKey && queryKey[2] === currentSpaceId && queryKey[3] === currentEnvironmentId;
|
|
2180
|
+
return isSameSpaceEntityKey;
|
|
2181
|
+
}, [currentSpaceId, currentEnvironmentId]); // @ts-expect-error ...
|
|
2182
|
+
|
|
2183
|
+
// @ts-expect-error ...
|
|
2184
|
+
var onEntityChanged = props.sdk.space.onEntityChanged;
|
|
2185
|
+
React.useEffect(function () {
|
|
2186
|
+
if (typeof onEntityChanged !== 'function') {
|
|
2187
|
+
return;
|
|
2188
|
+
}
|
|
2189
|
+
|
|
2190
|
+
var subscribeQuery = function subscribeQuery(_ref4) {
|
|
2191
|
+
var queryKey = _ref4.queryKey,
|
|
2192
|
+
queryHash = _ref4.queryHash;
|
|
2193
|
+
var entityType = queryKey[0],
|
|
2194
|
+
entityId = queryKey[1];
|
|
2195
|
+
entityChangeUnsubscribers.current[queryHash] = onEntityChanged(entityType, entityId, function (data) {
|
|
2196
|
+
queryClient.setQueryData(queryKey, data);
|
|
2197
|
+
});
|
|
2198
|
+
};
|
|
2306
2199
|
|
|
2307
|
-
|
|
2308
|
-
|
|
2200
|
+
var queries = queryCache.findAll({
|
|
2201
|
+
type: 'active',
|
|
2202
|
+
predicate: function predicate(query) {
|
|
2203
|
+
return isSameSpaceEntityQueryKey(query.queryKey);
|
|
2204
|
+
}
|
|
2205
|
+
});
|
|
2206
|
+
queries.forEach(subscribeQuery);
|
|
2207
|
+
var unsubscribe = queryCache.subscribe(function (event) {
|
|
2208
|
+
if (!event) {
|
|
2209
|
+
return;
|
|
2309
2210
|
}
|
|
2310
2211
|
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
};
|
|
2316
|
-
}
|
|
2212
|
+
var type = event.type,
|
|
2213
|
+
query = event.query;
|
|
2214
|
+
var queryKey = query.queryKey,
|
|
2215
|
+
queryHash = query.queryHash;
|
|
2317
2216
|
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2217
|
+
if (!isSameSpaceEntityQueryKey(queryKey)) {
|
|
2218
|
+
return;
|
|
2219
|
+
}
|
|
2321
2220
|
|
|
2322
|
-
if (
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
id = _step3$value[0];
|
|
2326
|
-
loadEntry(id);
|
|
2327
|
-
}
|
|
2221
|
+
if (type === 'added') {
|
|
2222
|
+
subscribeQuery(query);
|
|
2223
|
+
}
|
|
2328
2224
|
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2225
|
+
if (type === 'removed') {
|
|
2226
|
+
var _entityChangeUnsubscr, _entityChangeUnsubscr2;
|
|
2227
|
+
|
|
2228
|
+
// calling unsubscribe
|
|
2229
|
+
(_entityChangeUnsubscr = (_entityChangeUnsubscr2 = entityChangeUnsubscribers.current)[queryHash]) == null ? void 0 : _entityChangeUnsubscr.call(_entityChangeUnsubscr2);
|
|
2334
2230
|
}
|
|
2335
|
-
});
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
getOrLoadEntry: getEntry,
|
|
2343
|
-
|
|
2344
|
-
/**
|
|
2345
|
-
* @deprecated use `getAsset` instead
|
|
2346
|
-
*/
|
|
2347
|
-
getOrLoadAsset: getAsset,
|
|
2348
|
-
getResource: getResource,
|
|
2349
|
-
getEntry: getEntry,
|
|
2350
|
-
getAsset: getAsset,
|
|
2351
|
-
loadEntityScheduledActions: loadEntityScheduledActions,
|
|
2352
|
-
entries: state.entries,
|
|
2353
|
-
assets: state.assets,
|
|
2354
|
-
scheduledActions: state.scheduledActions,
|
|
2355
|
-
resources: state.resources
|
|
2231
|
+
});
|
|
2232
|
+
return function () {
|
|
2233
|
+
unsubscribe();
|
|
2234
|
+
Object.values(entityChangeUnsubscribers.current).forEach(function (off) {
|
|
2235
|
+
return off();
|
|
2236
|
+
});
|
|
2237
|
+
entityChangeUnsubscribers.current = {};
|
|
2356
2238
|
};
|
|
2357
|
-
}, [
|
|
2239
|
+
}, [onEntityChanged, queryCache, isSameSpaceEntityQueryKey, queryClient]);
|
|
2240
|
+
return {
|
|
2241
|
+
cmaClient: cmaClient,
|
|
2242
|
+
fetch: fetch,
|
|
2243
|
+
getResource: getResource,
|
|
2244
|
+
getEntity: getEntity,
|
|
2245
|
+
ids: props.sdk.ids,
|
|
2246
|
+
getEntityScheduledActions: getEntityScheduledActions
|
|
2247
|
+
};
|
|
2248
|
+
}, function (_ref5) {
|
|
2249
|
+
var fetch = _ref5.fetch;
|
|
2250
|
+
return fetch;
|
|
2251
|
+
}, function (_ref6) {
|
|
2252
|
+
var getResource = _ref6.getResource,
|
|
2253
|
+
getEntity = _ref6.getEntity,
|
|
2254
|
+
getEntityScheduledActions = _ref6.getEntityScheduledActions;
|
|
2255
|
+
return {
|
|
2256
|
+
getResource: getResource,
|
|
2257
|
+
getEntity: getEntity,
|
|
2258
|
+
getEntityScheduledActions: getEntityScheduledActions
|
|
2259
|
+
};
|
|
2260
|
+
}, function (_ref7) {
|
|
2261
|
+
var ids = _ref7.ids;
|
|
2262
|
+
return ids;
|
|
2263
|
+
}),
|
|
2264
|
+
InternalServiceProvider = _constate[0],
|
|
2265
|
+
useEntityLoader = _constate[2],
|
|
2266
|
+
useCurrentIds = _constate[3];
|
|
2267
|
+
|
|
2268
|
+
function useEntity(entityType, entityId, options) {
|
|
2269
|
+
var _options$spaceId3, _options$environmentI3;
|
|
2270
|
+
|
|
2271
|
+
var _useCurrentIds = useCurrentIds(),
|
|
2272
|
+
space = _useCurrentIds.space,
|
|
2273
|
+
environment = _useCurrentIds.environment;
|
|
2274
|
+
|
|
2275
|
+
var _useEntityLoader = useEntityLoader(),
|
|
2276
|
+
getEntity = _useEntityLoader.getEntity;
|
|
2277
|
+
|
|
2278
|
+
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];
|
|
2279
|
+
|
|
2280
|
+
var _useQuery = reactQuery.useQuery(queryKey, function () {
|
|
2281
|
+
return getEntity(entityType, entityId, options);
|
|
2282
|
+
}, {
|
|
2283
|
+
enabled: options == null ? void 0 : options.enabled,
|
|
2284
|
+
useErrorBoundary: false
|
|
2285
|
+
}),
|
|
2286
|
+
status = _useQuery.status,
|
|
2287
|
+
data = _useQuery.data;
|
|
2288
|
+
|
|
2289
|
+
return {
|
|
2290
|
+
status: status,
|
|
2291
|
+
data: data
|
|
2292
|
+
};
|
|
2358
2293
|
}
|
|
2294
|
+
function useResource(resourceType, urn, options) {
|
|
2295
|
+
var queryKey = ['Resource', resourceType, urn];
|
|
2296
|
+
|
|
2297
|
+
var _useEntityLoader2 = useEntityLoader(),
|
|
2298
|
+
getResource = _useEntityLoader2.getResource;
|
|
2299
|
+
|
|
2300
|
+
var _useQuery2 = reactQuery.useQuery(queryKey, function () {
|
|
2301
|
+
return getResource(resourceType, urn, options);
|
|
2302
|
+
}, {
|
|
2303
|
+
enabled: options == null ? void 0 : options.enabled,
|
|
2304
|
+
// TODO: check if this is ok for all errors
|
|
2305
|
+
useErrorBoundary: false
|
|
2306
|
+
}),
|
|
2307
|
+
status = _useQuery2.status,
|
|
2308
|
+
data = _useQuery2.data,
|
|
2309
|
+
error = _useQuery2.error;
|
|
2359
2310
|
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2311
|
+
return {
|
|
2312
|
+
status: status,
|
|
2313
|
+
data: data,
|
|
2314
|
+
error: error
|
|
2315
|
+
};
|
|
2316
|
+
}
|
|
2317
|
+
|
|
2318
|
+
function EntityProvider(_ref8) {
|
|
2319
|
+
var children = _ref8.children,
|
|
2320
|
+
props = _objectWithoutPropertiesLoose(_ref8, _excluded2);
|
|
2321
|
+
|
|
2322
|
+
var reactQueryClient = React.useMemo(function () {
|
|
2323
|
+
var queryCache = new reactQuery.QueryCache();
|
|
2324
|
+
var queryClient = new reactQuery.QueryClient({
|
|
2325
|
+
queryCache: queryCache,
|
|
2326
|
+
defaultOptions: {
|
|
2327
|
+
queries: {
|
|
2328
|
+
useErrorBoundary: true,
|
|
2329
|
+
refetchOnWindowFocus: false,
|
|
2330
|
+
refetchOnReconnect: true,
|
|
2331
|
+
refetchOnMount: false,
|
|
2332
|
+
staleTime: Infinity,
|
|
2333
|
+
retry: false
|
|
2334
|
+
}
|
|
2335
|
+
}
|
|
2336
|
+
});
|
|
2337
|
+
return queryClient;
|
|
2338
|
+
}, []);
|
|
2339
|
+
return React__default.createElement(reactQuery.QueryClientProvider, {
|
|
2340
|
+
client: reactQueryClient
|
|
2341
|
+
}, React__default.createElement(InternalServiceProvider, _extends({}, props), children));
|
|
2342
|
+
}
|
|
2363
2343
|
|
|
2364
2344
|
function ReferenceEditor(props) {
|
|
2365
2345
|
return React.createElement(EntityProvider, {
|
|
@@ -2581,7 +2561,10 @@ function fromFieldValidations(field) {
|
|
|
2581
2561
|
var result = {
|
|
2582
2562
|
contentTypes: (_linkContentTypeValid = linkContentTypeValidations == null ? void 0 : linkContentTypeValidations.linkContentType) != null ? _linkContentTypeValid : undefined,
|
|
2583
2563
|
mimetypeGroups: (_linkMimetypeGroupVal = linkMimetypeGroupValidations == null ? void 0 : linkMimetypeGroupValidations.linkMimetypeGroup) != null ? _linkMimetypeGroupVal : undefined,
|
|
2584
|
-
numberOfLinks: numberOfLinks
|
|
2564
|
+
numberOfLinks: numberOfLinks // todo: there are multiple BE problems that need to be solved first, for now we don't want to apply size constraints
|
|
2565
|
+
// linkedFileSize: findValidation(field, 'assetFileSize', {}),
|
|
2566
|
+
// linkedImageDimensions: findValidation(field, 'assetImageDimensions', {})
|
|
2567
|
+
|
|
2585
2568
|
};
|
|
2586
2569
|
return result;
|
|
2587
2570
|
}
|
|
@@ -2780,7 +2763,7 @@ function Editor(props) {
|
|
|
2780
2763
|
[linkActionsProps]);
|
|
2781
2764
|
|
|
2782
2765
|
if (!props.entityId) {
|
|
2783
|
-
return React.createElement(LinkEntityActions,
|
|
2766
|
+
return React.createElement(LinkEntityActions, _extends({
|
|
2784
2767
|
renderCustomActions: props.renderCustomActions
|
|
2785
2768
|
}, linkActionsProps));
|
|
2786
2769
|
}
|
|
@@ -2792,12 +2775,12 @@ function Editor(props) {
|
|
|
2792
2775
|
|
|
2793
2776
|
function SingleReferenceEditor(props) {
|
|
2794
2777
|
var allContentTypes = props.sdk.space.getCachedContentTypes();
|
|
2795
|
-
return React.createElement(ReferenceEditor,
|
|
2778
|
+
return React.createElement(ReferenceEditor, _extends({}, props), function (_ref) {
|
|
2796
2779
|
var value = _ref.value,
|
|
2797
2780
|
setValue = _ref.setValue,
|
|
2798
2781
|
disabled = _ref.disabled,
|
|
2799
2782
|
externalReset = _ref.externalReset;
|
|
2800
|
-
return React.createElement(Editor,
|
|
2783
|
+
return React.createElement(Editor, _extends({}, props, {
|
|
2801
2784
|
key: externalReset + "-reference",
|
|
2802
2785
|
entityId: value ? value.sys.id : '',
|
|
2803
2786
|
isDisabled: disabled,
|
|
@@ -3027,18 +3010,24 @@ function _openEntry() {
|
|
|
3027
3010
|
}
|
|
3028
3011
|
|
|
3029
3012
|
function FetchingWrappedEntryCard(props) {
|
|
3030
|
-
var
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
loadEntityScheduledActions = _useEntities.loadEntityScheduledActions,
|
|
3034
|
-
entries = _useEntities.entries;
|
|
3013
|
+
var _useEntity = useEntity('Entry', props.entryId),
|
|
3014
|
+
entry = _useEntity.data,
|
|
3015
|
+
status = _useEntity.status;
|
|
3035
3016
|
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3017
|
+
var _useEntityLoader = useEntityLoader(),
|
|
3018
|
+
getEntityScheduledActions = _useEntityLoader.getEntityScheduledActions;
|
|
3019
|
+
|
|
3020
|
+
var loadEntityScheduledActions = React.useCallback(function () {
|
|
3021
|
+
return getEntityScheduledActions('Entry', props.entryId);
|
|
3022
|
+
}, [getEntityScheduledActions, props.entryId]);
|
|
3039
3023
|
var size = props.viewType === 'link' ? 'small' : 'default';
|
|
3040
|
-
|
|
3041
|
-
var
|
|
3024
|
+
|
|
3025
|
+
var _useEntityLoader2 = useEntityLoader(),
|
|
3026
|
+
getEntity = _useEntityLoader2.getEntity;
|
|
3027
|
+
|
|
3028
|
+
var getAsset = function getAsset(assetId) {
|
|
3029
|
+
return getEntity('Asset', assetId);
|
|
3030
|
+
};
|
|
3042
3031
|
|
|
3043
3032
|
var onEdit = /*#__PURE__*/function () {
|
|
3044
3033
|
var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
|
|
@@ -3096,7 +3085,7 @@ function FetchingWrappedEntryCard(props) {
|
|
|
3096
3085
|
|
|
3097
3086
|
}, [entry]);
|
|
3098
3087
|
return React.useMemo(function () {
|
|
3099
|
-
if (
|
|
3088
|
+
if (status === 'error') {
|
|
3100
3089
|
var card = React.createElement(MissingEntityCard, {
|
|
3101
3090
|
entityType: "Entry",
|
|
3102
3091
|
isDisabled: props.isDisabled,
|
|
@@ -3116,7 +3105,7 @@ function FetchingWrappedEntryCard(props) {
|
|
|
3116
3105
|
return card;
|
|
3117
3106
|
}
|
|
3118
3107
|
|
|
3119
|
-
if (
|
|
3108
|
+
if (status === 'loading') {
|
|
3120
3109
|
return React.createElement(f36Components.EntryCard, {
|
|
3121
3110
|
size: size,
|
|
3122
3111
|
isLoading: true
|
|
@@ -3155,7 +3144,7 @@ function FetchingWrappedEntryCard(props) {
|
|
|
3155
3144
|
entryUrl: (props == null ? void 0 : props.entityUrl) || sharedCardProps.entityUrl
|
|
3156
3145
|
});
|
|
3157
3146
|
|
|
3158
|
-
return React.createElement(WrappedEntryCard,
|
|
3147
|
+
return React.createElement(WrappedEntryCard, _extends({}, builtinCardProps));
|
|
3159
3148
|
}
|
|
3160
3149
|
|
|
3161
3150
|
if (props.renderCustomCard) {
|
|
@@ -3168,11 +3157,11 @@ function FetchingWrappedEntryCard(props) {
|
|
|
3168
3157
|
}
|
|
3169
3158
|
|
|
3170
3159
|
return renderDefaultCard(); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
|
|
3171
|
-
}, [props,
|
|
3160
|
+
}, [props, status, entry]);
|
|
3172
3161
|
}
|
|
3173
3162
|
|
|
3174
3163
|
function SingleEntryReferenceEditor(props) {
|
|
3175
|
-
return React.createElement(SingleReferenceEditor,
|
|
3164
|
+
return React.createElement(SingleReferenceEditor, _extends({}, props, {
|
|
3176
3165
|
entityType: "Entry"
|
|
3177
3166
|
}), function (_ref) {
|
|
3178
3167
|
var allContentTypes = _ref.allContentTypes,
|
|
@@ -3182,7 +3171,7 @@ function SingleEntryReferenceEditor(props) {
|
|
|
3182
3171
|
renderCustomCard = _ref.renderCustomCard,
|
|
3183
3172
|
hasCardRemoveActions = _ref.hasCardRemoveActions,
|
|
3184
3173
|
hasCardEditActions = _ref.hasCardEditActions;
|
|
3185
|
-
return React.createElement(FetchingWrappedEntryCard,
|
|
3174
|
+
return React.createElement(FetchingWrappedEntryCard, _extends({}, props, {
|
|
3186
3175
|
allContentTypes: allContentTypes,
|
|
3187
3176
|
isDisabled: isDisabled,
|
|
3188
3177
|
entryId: entityId,
|
|
@@ -3273,19 +3262,19 @@ function Editor$1(props) {
|
|
|
3273
3262
|
onSortEnd: onSortEnd,
|
|
3274
3263
|
onMove: onMove,
|
|
3275
3264
|
renderCustomCard: props.renderCustomCard && customCardRenderer
|
|
3276
|
-
})), React.createElement(LinkEntityActions,
|
|
3265
|
+
})), React.createElement(LinkEntityActions, _extends({
|
|
3277
3266
|
renderCustomActions: props.renderCustomActions
|
|
3278
3267
|
}, linkActionsProps)));
|
|
3279
3268
|
}
|
|
3280
3269
|
|
|
3281
3270
|
function MultipleReferenceEditor(props) {
|
|
3282
3271
|
var allContentTypes = props.sdk.space.getCachedContentTypes();
|
|
3283
|
-
return React.createElement(ReferenceEditor,
|
|
3272
|
+
return React.createElement(ReferenceEditor, _extends({}, props), function (_ref2) {
|
|
3284
3273
|
var value = _ref2.value,
|
|
3285
3274
|
disabled = _ref2.disabled,
|
|
3286
3275
|
setValue = _ref2.setValue,
|
|
3287
3276
|
externalReset = _ref2.externalReset;
|
|
3288
|
-
return React.createElement(Editor$1,
|
|
3277
|
+
return React.createElement(Editor$1, _extends({}, props, {
|
|
3289
3278
|
items: value || emptyArray,
|
|
3290
3279
|
isDisabled: disabled,
|
|
3291
3280
|
setValue: setValue,
|
|
@@ -3342,16 +3331,16 @@ var SortableLinkListInternal = /*#__PURE__*/reactSortableHoc.SortableContainer(f
|
|
|
3342
3331
|
function SortableLinkList(props) {
|
|
3343
3332
|
// with the default distance of 0 the drag start event is "confused" with the click event,
|
|
3344
3333
|
// so the latter one isn't fired and click handlers on child elements don't work
|
|
3345
|
-
return React__default.createElement(SortableLinkListInternal,
|
|
3334
|
+
return React__default.createElement(SortableLinkListInternal, _extends({
|
|
3346
3335
|
distance: 1
|
|
3347
3336
|
}, props), props.children);
|
|
3348
3337
|
}
|
|
3349
3338
|
|
|
3350
3339
|
function MultipleEntryReferenceEditor(props) {
|
|
3351
|
-
return React.createElement(MultipleReferenceEditor,
|
|
3340
|
+
return React.createElement(MultipleReferenceEditor, _extends({}, props, {
|
|
3352
3341
|
entityType: "Entry"
|
|
3353
3342
|
}), function (childrenProps) {
|
|
3354
|
-
return React.createElement(SortableLinkList,
|
|
3343
|
+
return React.createElement(SortableLinkList, _extends({}, childrenProps, {
|
|
3355
3344
|
axis: "y",
|
|
3356
3345
|
useDragHandle: true
|
|
3357
3346
|
}), function (_ref) {
|
|
@@ -3361,7 +3350,7 @@ function MultipleEntryReferenceEditor(props) {
|
|
|
3361
3350
|
isDisabled = _ref.isDisabled,
|
|
3362
3351
|
DragHandle = _ref.DragHandle;
|
|
3363
3352
|
var lastIndex = items.length - 1;
|
|
3364
|
-
return React.createElement(FetchingWrappedEntryCard,
|
|
3353
|
+
return React.createElement(FetchingWrappedEntryCard, _extends({}, childrenProps, {
|
|
3365
3354
|
key: item.sys.id + "-" + index,
|
|
3366
3355
|
index: index,
|
|
3367
3356
|
allContentTypes: childrenProps.allContentTypes,
|
|
@@ -3616,16 +3605,16 @@ var WrappedAssetLink = function WrappedAssetLink(props) {
|
|
|
3616
3605
|
};
|
|
3617
3606
|
|
|
3618
3607
|
function FetchingWrappedAssetCard(props) {
|
|
3619
|
-
var
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
assets = _useEntities.assets;
|
|
3608
|
+
var _useEntity = useEntity('Asset', props.assetId),
|
|
3609
|
+
asset = _useEntity.data,
|
|
3610
|
+
status = _useEntity.status;
|
|
3623
3611
|
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
var
|
|
3628
|
-
|
|
3612
|
+
var _useEntityLoader = useEntityLoader(),
|
|
3613
|
+
getEntityScheduledActions = _useEntityLoader.getEntityScheduledActions;
|
|
3614
|
+
|
|
3615
|
+
var loadEntityScheduledActions = React.useCallback(function () {
|
|
3616
|
+
return getEntityScheduledActions('Asset', props.assetId);
|
|
3617
|
+
}, [getEntityScheduledActions, props.assetId]);
|
|
3629
3618
|
React.useEffect(function () {
|
|
3630
3619
|
if (asset) {
|
|
3631
3620
|
props.onAction && props.onAction({
|
|
@@ -3684,7 +3673,7 @@ function FetchingWrappedAssetCard(props) {
|
|
|
3684
3673
|
};
|
|
3685
3674
|
|
|
3686
3675
|
return React.useMemo(function () {
|
|
3687
|
-
if (
|
|
3676
|
+
if (status === 'error') {
|
|
3688
3677
|
var card = React.createElement(MissingEntityCard, {
|
|
3689
3678
|
entityType: "Asset",
|
|
3690
3679
|
asSquare: props.viewType !== 'link',
|
|
@@ -3705,8 +3694,7 @@ function FetchingWrappedAssetCard(props) {
|
|
|
3705
3694
|
return card;
|
|
3706
3695
|
}
|
|
3707
3696
|
|
|
3708
|
-
var getEntityUrl = props.getEntityUrl
|
|
3709
|
-
sdk = props.sdk;
|
|
3697
|
+
var getEntityUrl = props.getEntityUrl;
|
|
3710
3698
|
var size = props.viewType === 'big_card' ? 'default' : 'small';
|
|
3711
3699
|
var commonProps = {
|
|
3712
3700
|
asset: asset,
|
|
@@ -3721,20 +3709,20 @@ function FetchingWrappedAssetCard(props) {
|
|
|
3721
3709
|
};
|
|
3722
3710
|
|
|
3723
3711
|
if (props.viewType === 'link') {
|
|
3724
|
-
if (
|
|
3712
|
+
if (status === 'loading') {
|
|
3725
3713
|
return React.createElement(f36Components.EntryCard, {
|
|
3726
3714
|
size: "small",
|
|
3727
3715
|
isLoading: true
|
|
3728
3716
|
});
|
|
3729
3717
|
}
|
|
3730
3718
|
|
|
3731
|
-
return React.createElement(WrappedAssetLink,
|
|
3719
|
+
return React.createElement(WrappedAssetLink, _extends({}, commonProps, {
|
|
3732
3720
|
href: commonProps.entityUrl,
|
|
3733
|
-
getEntityScheduledActions:
|
|
3721
|
+
getEntityScheduledActions: loadEntityScheduledActions
|
|
3734
3722
|
}));
|
|
3735
3723
|
}
|
|
3736
3724
|
|
|
3737
|
-
if (
|
|
3725
|
+
if (status === 'loading') {
|
|
3738
3726
|
return React.createElement(f36Components.AssetCard, {
|
|
3739
3727
|
size: size,
|
|
3740
3728
|
isLoading: true
|
|
@@ -3749,7 +3737,7 @@ function FetchingWrappedAssetCard(props) {
|
|
|
3749
3737
|
getAssetUrl: getEntityUrl
|
|
3750
3738
|
});
|
|
3751
3739
|
|
|
3752
|
-
return React.createElement(WrappedAssetCard,
|
|
3740
|
+
return React.createElement(WrappedAssetCard, _extends({}, builtinCardProps));
|
|
3753
3741
|
}
|
|
3754
3742
|
|
|
3755
3743
|
if (props.renderCustomCard) {
|
|
@@ -3766,17 +3754,17 @@ function FetchingWrappedAssetCard(props) {
|
|
|
3766
3754
|
}
|
|
3767
3755
|
|
|
3768
3756
|
return renderDefaultCard(); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
|
|
3769
|
-
}, [props,
|
|
3757
|
+
}, [props, status, asset]);
|
|
3770
3758
|
}
|
|
3771
3759
|
|
|
3772
3760
|
function SingleMediaEditor(props) {
|
|
3773
|
-
return React.createElement(SingleReferenceEditor,
|
|
3761
|
+
return React.createElement(SingleReferenceEditor, _extends({}, props, {
|
|
3774
3762
|
entityType: "Asset"
|
|
3775
3763
|
}), function (_ref) {
|
|
3776
3764
|
var entityId = _ref.entityId,
|
|
3777
3765
|
isDisabled = _ref.isDisabled,
|
|
3778
3766
|
setValue = _ref.setValue;
|
|
3779
|
-
return React.createElement(FetchingWrappedAssetCard,
|
|
3767
|
+
return React.createElement(FetchingWrappedAssetCard, _extends({}, props, {
|
|
3780
3768
|
viewType: "big_card",
|
|
3781
3769
|
assetId: entityId,
|
|
3782
3770
|
isDisabled: isDisabled,
|
|
@@ -3798,12 +3786,12 @@ var styles$6 = {
|
|
|
3798
3786
|
})
|
|
3799
3787
|
};
|
|
3800
3788
|
function MultipleMediaEditor(props) {
|
|
3801
|
-
return React.createElement(MultipleReferenceEditor,
|
|
3789
|
+
return React.createElement(MultipleReferenceEditor, _extends({}, props, {
|
|
3802
3790
|
entityType: "Asset"
|
|
3803
3791
|
}), function (childrenProps) {
|
|
3804
3792
|
var _cx;
|
|
3805
3793
|
|
|
3806
|
-
return React.createElement(SortableLinkList,
|
|
3794
|
+
return React.createElement(SortableLinkList, _extends({}, childrenProps, {
|
|
3807
3795
|
className: emotion.cx((_cx = {}, _cx[styles$6.gridContainer] = childrenProps.viewType === 'card', _cx)),
|
|
3808
3796
|
axis: childrenProps.viewType === 'card' ? 'xy' : 'y',
|
|
3809
3797
|
useDragHandle: true
|
|
@@ -3813,7 +3801,7 @@ function MultipleMediaEditor(props) {
|
|
|
3813
3801
|
index = _ref.index,
|
|
3814
3802
|
isDisabled = _ref.isDisabled,
|
|
3815
3803
|
DragHandle = _ref.DragHandle;
|
|
3816
|
-
return React.createElement(FetchingWrappedAssetCard,
|
|
3804
|
+
return React.createElement(FetchingWrappedAssetCard, _extends({}, childrenProps, {
|
|
3817
3805
|
isDisabled: isDisabled,
|
|
3818
3806
|
key: item.sys.id + "-" + index,
|
|
3819
3807
|
assetId: item.sys.id,
|
|
@@ -3846,5 +3834,7 @@ exports.SortableLinkList = SortableLinkList;
|
|
|
3846
3834
|
exports.WrappedAssetCard = WrappedAssetCard;
|
|
3847
3835
|
exports.WrappedEntryCard = WrappedEntryCard;
|
|
3848
3836
|
exports.getScheduleTooltipContent = getScheduleTooltipContent;
|
|
3849
|
-
exports.
|
|
3837
|
+
exports.useEntity = useEntity;
|
|
3838
|
+
exports.useEntityLoader = useEntityLoader;
|
|
3839
|
+
exports.useResource = useResource;
|
|
3850
3840
|
//# sourceMappingURL=field-editor-reference.cjs.development.js.map
|