@contentful/field-editor-reference 4.6.10 → 5.1.1
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/helpers.d.ts +3 -3
- package/dist/field-editor-reference.cjs.development.js +972 -540
- 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 +969 -541
- package/dist/field-editor-reference.esm.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/resources/Cards/ContentfulEntryCard.d.ts +21 -0
- package/dist/resources/Cards/ResourceCard.d.ts +12 -0
- package/dist/resources/Cards/UnsupportedEntityCard.d.ts +4 -0
- package/dist/resources/MultipleResourceReferenceEditor.d.ts +7 -0
- package/dist/resources/SingleResourceReferenceEditor.d.ts +7 -0
- package/dist/resources/index.d.ts +2 -0
- package/dist/resources/testHelpers/resourceEditorHelpers.d.ts +50 -0
- package/dist/resources/useResourceLinkActions.d.ts +7 -0
- package/dist/types.d.ts +10 -0
- package/package.json +7 -3
|
@@ -12,14 +12,17 @@ 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');
|
|
22
24
|
var mimetype = _interopDefault(require('@contentful/mimetype'));
|
|
25
|
+
var reactIntersectionObserver = require('react-intersection-observer');
|
|
23
26
|
|
|
24
27
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
25
28
|
try {
|
|
@@ -75,57 +78,110 @@ function _extends() {
|
|
|
75
78
|
return _extends.apply(this, arguments);
|
|
76
79
|
}
|
|
77
80
|
|
|
78
|
-
function
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
var sourceKeys = Object.keys(source);
|
|
82
|
-
var key, i;
|
|
81
|
+
function _inheritsLoose(subClass, superClass) {
|
|
82
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
83
|
+
subClass.prototype.constructor = subClass;
|
|
83
84
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
_setPrototypeOf(subClass, superClass);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function _getPrototypeOf(o) {
|
|
89
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
90
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
91
|
+
};
|
|
92
|
+
return _getPrototypeOf(o);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function _setPrototypeOf(o, p) {
|
|
96
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
97
|
+
o.__proto__ = p;
|
|
98
|
+
return o;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
return _setPrototypeOf(o, p);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function _isNativeReflectConstruct() {
|
|
105
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
106
|
+
if (Reflect.construct.sham) return false;
|
|
107
|
+
if (typeof Proxy === "function") return true;
|
|
108
|
+
|
|
109
|
+
try {
|
|
110
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
111
|
+
return true;
|
|
112
|
+
} catch (e) {
|
|
113
|
+
return false;
|
|
88
114
|
}
|
|
115
|
+
}
|
|
89
116
|
|
|
90
|
-
|
|
117
|
+
function _construct(Parent, args, Class) {
|
|
118
|
+
if (_isNativeReflectConstruct()) {
|
|
119
|
+
_construct = Reflect.construct;
|
|
120
|
+
} else {
|
|
121
|
+
_construct = function _construct(Parent, args, Class) {
|
|
122
|
+
var a = [null];
|
|
123
|
+
a.push.apply(a, args);
|
|
124
|
+
var Constructor = Function.bind.apply(Parent, a);
|
|
125
|
+
var instance = new Constructor();
|
|
126
|
+
if (Class) _setPrototypeOf(instance, Class.prototype);
|
|
127
|
+
return instance;
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return _construct.apply(null, arguments);
|
|
91
132
|
}
|
|
92
133
|
|
|
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);
|
|
134
|
+
function _isNativeFunction(fn) {
|
|
135
|
+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
100
136
|
}
|
|
101
137
|
|
|
102
|
-
function
|
|
103
|
-
|
|
138
|
+
function _wrapNativeSuper(Class) {
|
|
139
|
+
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
140
|
+
|
|
141
|
+
_wrapNativeSuper = function _wrapNativeSuper(Class) {
|
|
142
|
+
if (Class === null || !_isNativeFunction(Class)) return Class;
|
|
143
|
+
|
|
144
|
+
if (typeof Class !== "function") {
|
|
145
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (typeof _cache !== "undefined") {
|
|
149
|
+
if (_cache.has(Class)) return _cache.get(Class);
|
|
104
150
|
|
|
105
|
-
|
|
151
|
+
_cache.set(Class, Wrapper);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function Wrapper() {
|
|
155
|
+
return _construct(Class, arguments, _getPrototypeOf(this).constructor);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
Wrapper.prototype = Object.create(Class.prototype, {
|
|
159
|
+
constructor: {
|
|
160
|
+
value: Wrapper,
|
|
161
|
+
enumerable: false,
|
|
162
|
+
writable: true,
|
|
163
|
+
configurable: true
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
return _setPrototypeOf(Wrapper, Class);
|
|
167
|
+
};
|
|
106
168
|
|
|
107
|
-
return
|
|
169
|
+
return _wrapNativeSuper(Class);
|
|
108
170
|
}
|
|
109
171
|
|
|
110
|
-
function
|
|
111
|
-
|
|
112
|
-
|
|
172
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
173
|
+
if (source == null) return {};
|
|
174
|
+
var target = {};
|
|
175
|
+
var sourceKeys = Object.keys(source);
|
|
176
|
+
var key, i;
|
|
113
177
|
|
|
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
|
-
};
|
|
178
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
179
|
+
key = sourceKeys[i];
|
|
180
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
181
|
+
target[key] = source[key];
|
|
126
182
|
}
|
|
127
183
|
|
|
128
|
-
|
|
184
|
+
return target;
|
|
129
185
|
}
|
|
130
186
|
|
|
131
187
|
var container = /*#__PURE__*/emotion.css({
|
|
@@ -505,7 +561,7 @@ function CombinedLinkActions(props) {
|
|
|
505
561
|
var hideEmptyCard = props.entityType === 'Asset' && !props.isEmpty;
|
|
506
562
|
return React.createElement("div", {
|
|
507
563
|
className: hideEmptyCard ? '' : container
|
|
508
|
-
}, !props.canCreateEntity && !props.canLinkEntity && React.createElement(NoLinkPermissionsInfo, null), props.entityType === 'Entry' && React.createElement(CombinedEntryLinkActions,
|
|
564
|
+
}, !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
565
|
}
|
|
510
566
|
|
|
511
567
|
function CombinedEntryLinkActions(props) {
|
|
@@ -1745,7 +1801,7 @@ function LinkEntityActions(_ref4) {
|
|
|
1745
1801
|
props = _objectWithoutPropertiesLoose(_ref4, _excluded);
|
|
1746
1802
|
|
|
1747
1803
|
var renderLinkActions = renderCustomActions ? renderCustomActions : function (props) {
|
|
1748
|
-
return React.createElement(LinkActions,
|
|
1804
|
+
return React.createElement(LinkActions, _extends({}, props));
|
|
1749
1805
|
};
|
|
1750
1806
|
return renderLinkActions(props);
|
|
1751
1807
|
}
|
|
@@ -1806,6 +1862,8 @@ var ScheduleTooltip = function ScheduleTooltip(_ref2) {
|
|
|
1806
1862
|
};
|
|
1807
1863
|
|
|
1808
1864
|
var ScheduledIconWithTooltip = function ScheduledIconWithTooltip(_ref) {
|
|
1865
|
+
var _status$jobs;
|
|
1866
|
+
|
|
1809
1867
|
var entityType = _ref.entityType,
|
|
1810
1868
|
entityId = _ref.entityId,
|
|
1811
1869
|
getEntityScheduledActions = _ref.getEntityScheduledActions,
|
|
@@ -1837,7 +1895,7 @@ var ScheduledIconWithTooltip = function ScheduledIconWithTooltip(_ref) {
|
|
|
1837
1895
|
return null;
|
|
1838
1896
|
}
|
|
1839
1897
|
|
|
1840
|
-
var jobs = status.jobs ?
|
|
1898
|
+
var jobs = (_status$jobs = status.jobs) != null ? _status$jobs : [];
|
|
1841
1899
|
|
|
1842
1900
|
if (jobs.length === 0) {
|
|
1843
1901
|
return null;
|
|
@@ -1863,502 +1921,426 @@ function AssetThumbnail(props) {
|
|
|
1863
1921
|
});
|
|
1864
1922
|
}
|
|
1865
1923
|
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
switch (action.type) {
|
|
1870
|
-
case 'set_entry':
|
|
1871
|
-
return _extends({}, state, {
|
|
1872
|
-
entries: _extends({}, state.entries, (_extends2 = {}, _extends2[action.id] = action.entry, _extends2))
|
|
1873
|
-
});
|
|
1874
|
-
|
|
1875
|
-
case 'set_entry_failed':
|
|
1876
|
-
return _extends({}, state, {
|
|
1877
|
-
entries: _extends({}, state.entries, (_extends3 = {}, _extends3[action.id] = 'failed', _extends3))
|
|
1878
|
-
});
|
|
1879
|
-
|
|
1880
|
-
case 'set_asset':
|
|
1881
|
-
return _extends({}, state, {
|
|
1882
|
-
assets: _extends({}, state.assets, (_extends4 = {}, _extends4[action.id] = action.asset, _extends4))
|
|
1883
|
-
});
|
|
1884
|
-
|
|
1885
|
-
case 'set_asset_failed':
|
|
1886
|
-
return _extends({}, state, {
|
|
1887
|
-
assets: _extends({}, state.assets, (_extends5 = {}, _extends5[action.id] = 'failed', _extends5))
|
|
1888
|
-
});
|
|
1924
|
+
var _excluded$1 = ["priority"],
|
|
1925
|
+
_excluded2 = ["children"];
|
|
1889
1926
|
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
case 'set_resource':
|
|
1896
|
-
return _extends({}, state, {
|
|
1897
|
-
resources: _extends({}, state.resources, (_extends7 = {}, _extends7[action.resourceType + "." + action.urn] = action.resourceInfo, _extends7))
|
|
1898
|
-
});
|
|
1927
|
+
var globalQueue = /*#__PURE__*/new PQueue({
|
|
1928
|
+
concurrency: 20
|
|
1929
|
+
});
|
|
1930
|
+
var UnsupportedError = /*#__PURE__*/function (_Error) {
|
|
1931
|
+
_inheritsLoose(UnsupportedError, _Error);
|
|
1899
1932
|
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
resources: _extends({}, state.resources, (_extends8 = {}, _extends8[action.resourceType + "." + action.urn] = 'failed', _extends8))
|
|
1903
|
-
});
|
|
1933
|
+
function UnsupportedError(message) {
|
|
1934
|
+
var _this;
|
|
1904
1935
|
|
|
1905
|
-
|
|
1906
|
-
|
|
1936
|
+
_this = _Error.call(this, message) || this;
|
|
1937
|
+
_this.isUnsupportedError = void 0;
|
|
1938
|
+
_this.isUnsupportedError = true;
|
|
1939
|
+
return _this;
|
|
1907
1940
|
}
|
|
1908
|
-
}
|
|
1909
|
-
|
|
1910
|
-
var initialState = {
|
|
1911
|
-
entries: {},
|
|
1912
|
-
assets: {},
|
|
1913
|
-
scheduledActions: {},
|
|
1914
|
-
resources: {}
|
|
1915
|
-
};
|
|
1916
1941
|
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1942
|
+
return UnsupportedError;
|
|
1943
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
1944
|
+
function isUnsupportedError(value) {
|
|
1945
|
+
return typeof value === 'object' && (value == null ? void 0 : value.isUnsupportedError) === true;
|
|
1946
|
+
}
|
|
1920
1947
|
|
|
1921
|
-
var
|
|
1922
|
-
return
|
|
1923
|
-
var value = _ref[1];
|
|
1924
|
-
return isNotNil(value);
|
|
1925
|
-
});
|
|
1948
|
+
var isEntityQueryKey = function isEntityQueryKey(queryKey) {
|
|
1949
|
+
return Array.isArray(queryKey) && (queryKey[0] === 'Entry' || queryKey[0] === 'Asset') && queryKey.length === 4;
|
|
1926
1950
|
};
|
|
1927
1951
|
|
|
1928
|
-
function
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
var _React$useState = React.useState(function () {
|
|
1933
|
-
return contentfulManagement.createClient({
|
|
1934
|
-
apiAdapter: props.sdk.cmaAdapter
|
|
1935
|
-
}, {
|
|
1936
|
-
type: 'plain'
|
|
1937
|
-
});
|
|
1938
|
-
}),
|
|
1939
|
-
cmaClient = _React$useState[0];
|
|
1940
|
-
|
|
1941
|
-
var _React$useReducer = React.useReducer(reducer, initialState),
|
|
1942
|
-
state = _React$useReducer[0],
|
|
1943
|
-
dispatch = _React$useReducer[1];
|
|
1944
|
-
|
|
1945
|
-
var loadEntityScheduledActions = React.useCallback(function (entityType, id) {
|
|
1946
|
-
var key = entityType + ":" + id;
|
|
1947
|
-
|
|
1948
|
-
if (state.scheduledActions[key]) {
|
|
1949
|
-
return Promise.resolve(state.scheduledActions[key]);
|
|
1950
|
-
}
|
|
1951
|
-
|
|
1952
|
-
return props.sdk.space.getEntityScheduledActions(entityType, id).then(function (data) {
|
|
1953
|
-
dispatch({
|
|
1954
|
-
type: 'set_scheduled_actions',
|
|
1955
|
-
key: key,
|
|
1956
|
-
actions: data
|
|
1957
|
-
});
|
|
1958
|
-
return data;
|
|
1959
|
-
})["catch"](function () {
|
|
1960
|
-
dispatch({
|
|
1961
|
-
type: 'set_scheduled_actions',
|
|
1962
|
-
key: key,
|
|
1963
|
-
actions: undefined
|
|
1964
|
-
});
|
|
1965
|
-
return [];
|
|
1966
|
-
});
|
|
1967
|
-
}, [props.sdk.space, state.scheduledActions]);
|
|
1968
|
-
var loadEntry = React.useCallback( /*#__PURE__*/function () {
|
|
1969
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(entryId) {
|
|
1970
|
-
var entry;
|
|
1971
|
-
return runtime_1.wrap(function _callee$(_context) {
|
|
1972
|
-
while (1) {
|
|
1973
|
-
switch (_context.prev = _context.next) {
|
|
1974
|
-
case 0:
|
|
1975
|
-
_context.prev = 0;
|
|
1976
|
-
_context.next = 3;
|
|
1977
|
-
return cmaClient.entry.get({
|
|
1978
|
-
spaceId: spaceId,
|
|
1979
|
-
environmentId: environmentId,
|
|
1980
|
-
entryId: entryId
|
|
1981
|
-
});
|
|
1982
|
-
|
|
1983
|
-
case 3:
|
|
1984
|
-
entry = _context.sent;
|
|
1985
|
-
dispatch({
|
|
1986
|
-
type: 'set_entry',
|
|
1987
|
-
id: entryId,
|
|
1988
|
-
entry: entry
|
|
1989
|
-
});
|
|
1990
|
-
return _context.abrupt("return", entry);
|
|
1991
|
-
|
|
1992
|
-
case 8:
|
|
1993
|
-
_context.prev = 8;
|
|
1994
|
-
_context.t0 = _context["catch"](0);
|
|
1995
|
-
dispatch({
|
|
1996
|
-
type: 'set_entry_failed',
|
|
1997
|
-
id: entryId
|
|
1998
|
-
});
|
|
1999
|
-
return _context.abrupt("return");
|
|
2000
|
-
|
|
2001
|
-
case 12:
|
|
2002
|
-
case "end":
|
|
2003
|
-
return _context.stop();
|
|
2004
|
-
}
|
|
2005
|
-
}
|
|
2006
|
-
}, _callee, null, [[0, 8]]);
|
|
2007
|
-
}));
|
|
2008
|
-
|
|
2009
|
-
return function (_x) {
|
|
2010
|
-
return _ref2.apply(this, arguments);
|
|
2011
|
-
};
|
|
2012
|
-
}(), [cmaClient, spaceId, environmentId]);
|
|
2013
|
-
var getEntry = React.useCallback( /*#__PURE__*/function () {
|
|
2014
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(entryId) {
|
|
2015
|
-
var cachedEntry;
|
|
2016
|
-
return runtime_1.wrap(function _callee2$(_context2) {
|
|
2017
|
-
while (1) {
|
|
2018
|
-
switch (_context2.prev = _context2.next) {
|
|
2019
|
-
case 0:
|
|
2020
|
-
cachedEntry = state.entries[entryId];
|
|
2021
|
-
|
|
2022
|
-
if (!isNotNil(cachedEntry)) {
|
|
2023
|
-
_context2.next = 3;
|
|
2024
|
-
break;
|
|
2025
|
-
}
|
|
2026
|
-
|
|
2027
|
-
return _context2.abrupt("return", cachedEntry);
|
|
2028
|
-
|
|
2029
|
-
case 3:
|
|
2030
|
-
return _context2.abrupt("return", loadEntry(entryId));
|
|
2031
|
-
|
|
2032
|
-
case 4:
|
|
2033
|
-
case "end":
|
|
2034
|
-
return _context2.stop();
|
|
2035
|
-
}
|
|
2036
|
-
}
|
|
2037
|
-
}, _callee2);
|
|
2038
|
-
}));
|
|
2039
|
-
|
|
2040
|
-
return function (_x2) {
|
|
2041
|
-
return _ref3.apply(this, arguments);
|
|
2042
|
-
};
|
|
2043
|
-
}(), [loadEntry, state.entries]);
|
|
2044
|
-
var loadAsset = React.useCallback( /*#__PURE__*/function () {
|
|
2045
|
-
var _ref4 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(assetId) {
|
|
2046
|
-
var asset;
|
|
2047
|
-
return runtime_1.wrap(function _callee3$(_context3) {
|
|
2048
|
-
while (1) {
|
|
2049
|
-
switch (_context3.prev = _context3.next) {
|
|
2050
|
-
case 0:
|
|
2051
|
-
_context3.prev = 0;
|
|
2052
|
-
_context3.next = 3;
|
|
2053
|
-
return cmaClient.asset.get({
|
|
2054
|
-
spaceId: spaceId,
|
|
2055
|
-
environmentId: environmentId,
|
|
2056
|
-
assetId: assetId
|
|
2057
|
-
});
|
|
2058
|
-
|
|
2059
|
-
case 3:
|
|
2060
|
-
asset = _context3.sent;
|
|
2061
|
-
dispatch({
|
|
2062
|
-
type: 'set_asset',
|
|
2063
|
-
id: assetId,
|
|
2064
|
-
asset: asset
|
|
2065
|
-
});
|
|
2066
|
-
return _context3.abrupt("return", asset);
|
|
2067
|
-
|
|
2068
|
-
case 8:
|
|
2069
|
-
_context3.prev = 8;
|
|
2070
|
-
_context3.t0 = _context3["catch"](0);
|
|
2071
|
-
dispatch({
|
|
2072
|
-
type: 'set_asset_failed',
|
|
2073
|
-
id: assetId
|
|
2074
|
-
});
|
|
2075
|
-
return _context3.abrupt("return");
|
|
2076
|
-
|
|
2077
|
-
case 12:
|
|
2078
|
-
case "end":
|
|
2079
|
-
return _context3.stop();
|
|
2080
|
-
}
|
|
2081
|
-
}
|
|
2082
|
-
}, _callee3, null, [[0, 8]]);
|
|
2083
|
-
}));
|
|
2084
|
-
|
|
2085
|
-
return function (_x3) {
|
|
2086
|
-
return _ref4.apply(this, arguments);
|
|
2087
|
-
};
|
|
2088
|
-
}(), [cmaClient, spaceId, environmentId]);
|
|
2089
|
-
var getAsset = React.useCallback( /*#__PURE__*/function () {
|
|
2090
|
-
var _ref5 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(assetId) {
|
|
2091
|
-
var cachedAsset;
|
|
2092
|
-
return runtime_1.wrap(function _callee4$(_context4) {
|
|
2093
|
-
while (1) {
|
|
2094
|
-
switch (_context4.prev = _context4.next) {
|
|
2095
|
-
case 0:
|
|
2096
|
-
cachedAsset = state.assets[assetId];
|
|
2097
|
-
|
|
2098
|
-
if (!isNotNil(cachedAsset)) {
|
|
2099
|
-
_context4.next = 3;
|
|
2100
|
-
break;
|
|
2101
|
-
}
|
|
2102
|
-
|
|
2103
|
-
return _context4.abrupt("return", cachedAsset);
|
|
2104
|
-
|
|
2105
|
-
case 3:
|
|
2106
|
-
return _context4.abrupt("return", loadAsset(assetId));
|
|
2107
|
-
|
|
2108
|
-
case 4:
|
|
2109
|
-
case "end":
|
|
2110
|
-
return _context4.stop();
|
|
2111
|
-
}
|
|
2112
|
-
}
|
|
2113
|
-
}, _callee4);
|
|
2114
|
-
}));
|
|
2115
|
-
|
|
2116
|
-
return function (_x4) {
|
|
2117
|
-
return _ref5.apply(this, arguments);
|
|
2118
|
-
};
|
|
2119
|
-
}(), [loadAsset, state.assets]);
|
|
2120
|
-
var loadContentfulEntry = React.useCallback( /*#__PURE__*/function () {
|
|
2121
|
-
var _ref6 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(urn) {
|
|
2122
|
-
var _locales$items$find;
|
|
1952
|
+
function fetchContentfulEntry(_x) {
|
|
1953
|
+
return _fetchContentfulEntry.apply(this, arguments);
|
|
1954
|
+
}
|
|
2123
1955
|
|
|
2124
|
-
|
|
1956
|
+
function _fetchContentfulEntry() {
|
|
1957
|
+
_fetchContentfulEntry = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(params) {
|
|
1958
|
+
var urn, fetch, options, resourceId, _resourceId$split, spaceId, entryId, environmentId, _yield$Promise$all, space, entry, contentTypeId, _yield$Promise$all2, contentType, defaultLocaleCode;
|
|
2125
1959
|
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
1960
|
+
return runtime_1.wrap(function _callee3$(_context3) {
|
|
1961
|
+
while (1) {
|
|
1962
|
+
switch (_context3.prev = _context3.next) {
|
|
1963
|
+
case 0:
|
|
1964
|
+
urn = params.urn, fetch = params.fetch, options = params.options;
|
|
1965
|
+
resourceId = urn.split(':', 6)[5];
|
|
1966
|
+
_resourceId$split = resourceId.split('/'), spaceId = _resourceId$split[1], entryId = _resourceId$split[3];
|
|
1967
|
+
environmentId = 'master';
|
|
1968
|
+
_context3.next = 6;
|
|
1969
|
+
return Promise.all([fetch(['space', spaceId], function (_ref9) {
|
|
1970
|
+
var cmaClient = _ref9.cmaClient;
|
|
2135
1971
|
return cmaClient.space.get({
|
|
2136
1972
|
spaceId: spaceId
|
|
2137
1973
|
});
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
_context5.t1 = _context5.sent;
|
|
2141
|
-
_context5.next = 9;
|
|
1974
|
+
}, options), fetch(['entry', spaceId, environmentId, entryId], function (_ref10) {
|
|
1975
|
+
var cmaClient = _ref10.cmaClient;
|
|
2142
1976
|
return cmaClient.entry.get({
|
|
2143
1977
|
spaceId: spaceId,
|
|
2144
1978
|
environmentId: environmentId,
|
|
2145
1979
|
entryId: entryId
|
|
2146
1980
|
});
|
|
1981
|
+
}, options)]);
|
|
2147
1982
|
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
space = _yield$Promise$all[0];
|
|
2157
|
-
entry = _yield$Promise$all[1];
|
|
2158
|
-
contentTypeId = entry.sys.contentType.sys.id;
|
|
2159
|
-
_context5.t4 = Promise;
|
|
2160
|
-
_context5.next = 20;
|
|
1983
|
+
case 6:
|
|
1984
|
+
_yield$Promise$all = _context3.sent;
|
|
1985
|
+
space = _yield$Promise$all[0];
|
|
1986
|
+
entry = _yield$Promise$all[1];
|
|
1987
|
+
contentTypeId = entry.sys.contentType.sys.id;
|
|
1988
|
+
_context3.next = 12;
|
|
1989
|
+
return Promise.all([fetch(['contentType', spaceId, environmentId, contentTypeId], function (_ref11) {
|
|
1990
|
+
var cmaClient = _ref11.cmaClient;
|
|
2161
1991
|
return cmaClient.contentType.get({
|
|
2162
1992
|
contentTypeId: contentTypeId,
|
|
2163
1993
|
spaceId: spaceId,
|
|
2164
1994
|
environmentId: environmentId
|
|
2165
1995
|
});
|
|
1996
|
+
}, options), fetch(['defaultLocale', spaceId, environmentId], /*#__PURE__*/function () {
|
|
1997
|
+
var _ref13 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(_ref12) {
|
|
1998
|
+
var _locales$items$find;
|
|
2166
1999
|
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2000
|
+
var cmaClient, locales, defaultLocaleCode;
|
|
2001
|
+
return runtime_1.wrap(function _callee2$(_context2) {
|
|
2002
|
+
while (1) {
|
|
2003
|
+
switch (_context2.prev = _context2.next) {
|
|
2004
|
+
case 0:
|
|
2005
|
+
cmaClient = _ref12.cmaClient;
|
|
2006
|
+
_context2.next = 3;
|
|
2007
|
+
return cmaClient.locale.getMany({
|
|
2008
|
+
spaceId: spaceId,
|
|
2009
|
+
environmentId: environmentId,
|
|
2010
|
+
query: {
|
|
2011
|
+
limit: 100
|
|
2012
|
+
}
|
|
2013
|
+
});
|
|
2014
|
+
|
|
2015
|
+
case 3:
|
|
2016
|
+
locales = _context2.sent;
|
|
2017
|
+
defaultLocaleCode = (_locales$items$find = locales.items.find(function (locale) {
|
|
2018
|
+
return locale["default"];
|
|
2019
|
+
})) == null ? void 0 : _locales$items$find.code;
|
|
2020
|
+
return _context2.abrupt("return", defaultLocaleCode);
|
|
2177
2021
|
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
_yield$Promise$all2 = _context5.sent;
|
|
2186
|
-
contentType = _yield$Promise$all2[0];
|
|
2187
|
-
locales = _yield$Promise$all2[1];
|
|
2188
|
-
defaultLocaleCode = (_locales$items$find = locales.items.find(function (locale) {
|
|
2189
|
-
return locale["default"];
|
|
2190
|
-
})) == null ? void 0 : _locales$items$find.code;
|
|
2191
|
-
return _context5.abrupt("return", {
|
|
2192
|
-
resource: entry,
|
|
2193
|
-
defaultLocaleCode: defaultLocaleCode,
|
|
2194
|
-
space: space,
|
|
2195
|
-
contentType: contentType
|
|
2196
|
-
});
|
|
2022
|
+
case 6:
|
|
2023
|
+
case "end":
|
|
2024
|
+
return _context2.stop();
|
|
2025
|
+
}
|
|
2026
|
+
}
|
|
2027
|
+
}, _callee2);
|
|
2028
|
+
}));
|
|
2197
2029
|
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2030
|
+
return function (_x3) {
|
|
2031
|
+
return _ref13.apply(this, arguments);
|
|
2032
|
+
};
|
|
2033
|
+
}(), options)]);
|
|
2034
|
+
|
|
2035
|
+
case 12:
|
|
2036
|
+
_yield$Promise$all2 = _context3.sent;
|
|
2037
|
+
contentType = _yield$Promise$all2[0];
|
|
2038
|
+
defaultLocaleCode = _yield$Promise$all2[1];
|
|
2039
|
+
return _context3.abrupt("return", {
|
|
2040
|
+
defaultLocaleCode: defaultLocaleCode,
|
|
2041
|
+
resource: entry,
|
|
2042
|
+
space: space,
|
|
2043
|
+
contentType: contentType
|
|
2044
|
+
});
|
|
2205
2045
|
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
switch (_context6.prev = _context6.next) {
|
|
2216
|
-
case 0:
|
|
2217
|
-
cachedResource = state.resources[resourceType + "." + urn];
|
|
2046
|
+
case 16:
|
|
2047
|
+
case "end":
|
|
2048
|
+
return _context3.stop();
|
|
2049
|
+
}
|
|
2050
|
+
}
|
|
2051
|
+
}, _callee3);
|
|
2052
|
+
}));
|
|
2053
|
+
return _fetchContentfulEntry.apply(this, arguments);
|
|
2054
|
+
}
|
|
2218
2055
|
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2056
|
+
var _constate = /*#__PURE__*/constate(function useInitServices(props) {
|
|
2057
|
+
var currentSpaceId = props.sdk.ids.space;
|
|
2058
|
+
var currentEnvironmentId = props.sdk.ids.environment;
|
|
2059
|
+
var queryClient = reactQuery.useQueryClient();
|
|
2060
|
+
var queryCache = queryClient.getQueryCache();
|
|
2061
|
+
var entityChangeUnsubscribers = React.useRef({});
|
|
2062
|
+
var cmaClient = React.useMemo(function () {
|
|
2063
|
+
return contentfulManagement.createClient({
|
|
2064
|
+
apiAdapter: props.sdk.cmaAdapter
|
|
2065
|
+
}, {
|
|
2066
|
+
type: 'plain'
|
|
2067
|
+
});
|
|
2068
|
+
}, [props.sdk.cmaAdapter]);
|
|
2069
|
+
var queryQueue = React.useMemo(function () {
|
|
2070
|
+
if (props.queryConcurrency) {
|
|
2071
|
+
return new PQueue({
|
|
2072
|
+
concurrency: props.queryConcurrency
|
|
2073
|
+
});
|
|
2074
|
+
}
|
|
2223
2075
|
|
|
2224
|
-
|
|
2076
|
+
return globalQueue;
|
|
2077
|
+
}, [props.queryConcurrency]);
|
|
2078
|
+
var fetch = React.useCallback(function fetch(queryKey, fn, options) {
|
|
2079
|
+
if (options === void 0) {
|
|
2080
|
+
options = {};
|
|
2081
|
+
}
|
|
2225
2082
|
|
|
2226
|
-
|
|
2227
|
-
|
|
2083
|
+
var _options = options,
|
|
2084
|
+
priority = _options.priority,
|
|
2085
|
+
queryOptions = _objectWithoutPropertiesLoose(_options, _excluded$1);
|
|
2228
2086
|
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2087
|
+
return queryClient.fetchQuery(queryKey, function () {
|
|
2088
|
+
return queryQueue.add(function () {
|
|
2089
|
+
return fn({
|
|
2090
|
+
cmaClient: cmaClient
|
|
2091
|
+
});
|
|
2092
|
+
}, {
|
|
2093
|
+
priority: priority
|
|
2094
|
+
});
|
|
2095
|
+
}, queryOptions);
|
|
2096
|
+
}, [queryClient, queryQueue, cmaClient]);
|
|
2097
|
+
var getEntity = React.useCallback(function getEntity(entityType, entityId, options) {
|
|
2098
|
+
var _options$spaceId, _options$environmentI;
|
|
2099
|
+
|
|
2100
|
+
var spaceId = (_options$spaceId = options == null ? void 0 : options.spaceId) != null ? _options$spaceId : currentSpaceId;
|
|
2101
|
+
var environmentId = (_options$environmentI = options == null ? void 0 : options.environmentId) != null ? _options$environmentI : currentEnvironmentId;
|
|
2102
|
+
var queryKey = [entityType, entityId, spaceId, environmentId];
|
|
2103
|
+
return fetch(queryKey, function (_ref) {
|
|
2104
|
+
var cmaClient = _ref.cmaClient;
|
|
2105
|
+
|
|
2106
|
+
if (entityType === 'Entry') {
|
|
2107
|
+
return cmaClient.entry.get({
|
|
2108
|
+
entryId: entityId,
|
|
2109
|
+
spaceId: spaceId,
|
|
2110
|
+
environmentId: environmentId
|
|
2111
|
+
});
|
|
2112
|
+
}
|
|
2233
2113
|
|
|
2234
|
-
|
|
2235
|
-
|
|
2114
|
+
if (entityType === 'Asset') {
|
|
2115
|
+
return cmaClient.asset.get({
|
|
2116
|
+
assetId: entityId,
|
|
2117
|
+
spaceId: spaceId,
|
|
2118
|
+
environmentId: environmentId
|
|
2119
|
+
});
|
|
2120
|
+
}
|
|
2236
2121
|
|
|
2237
|
-
|
|
2238
|
-
|
|
2122
|
+
throw new UnsupportedError('Unsupported entity type');
|
|
2123
|
+
}, options);
|
|
2124
|
+
}, [fetch, currentSpaceId, currentEnvironmentId]);
|
|
2125
|
+
var getEntityScheduledActions = React.useCallback(function getEntityScheduledActions(entityType, entityId, options) {
|
|
2126
|
+
var _options$spaceId2, _options$environmentI2;
|
|
2127
|
+
|
|
2128
|
+
var spaceId = (_options$spaceId2 = options == null ? void 0 : options.spaceId) != null ? _options$spaceId2 : currentSpaceId;
|
|
2129
|
+
var environmentId = (_options$environmentI2 = options == null ? void 0 : options.environmentId) != null ? _options$environmentI2 : currentEnvironmentId;
|
|
2130
|
+
var queryKey = ['scheduled-actions', entityType, entityId, spaceId, environmentId];
|
|
2131
|
+
return fetch(queryKey, /*#__PURE__*/function () {
|
|
2132
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(_ref2) {
|
|
2133
|
+
var cmaClient, response;
|
|
2134
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
2135
|
+
while (1) {
|
|
2136
|
+
switch (_context.prev = _context.next) {
|
|
2137
|
+
case 0:
|
|
2138
|
+
cmaClient = _ref2.cmaClient;
|
|
2139
|
+
_context.next = 3;
|
|
2140
|
+
return cmaClient.scheduledActions.getMany({
|
|
2141
|
+
spaceId: spaceId,
|
|
2142
|
+
query: {
|
|
2143
|
+
'environment.sys.id': environmentId,
|
|
2144
|
+
'entity.sys.id': entityId,
|
|
2145
|
+
'sys.status[in]': 'scheduled',
|
|
2146
|
+
order: 'scheduledFor.datetime'
|
|
2147
|
+
}
|
|
2148
|
+
});
|
|
2239
2149
|
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
resourceType: resourceType,
|
|
2244
|
-
urn: urn,
|
|
2245
|
-
resourceInfo: resourceInfo
|
|
2246
|
-
});
|
|
2247
|
-
return _context6.abrupt("return", resourceInfo);
|
|
2248
|
-
|
|
2249
|
-
case 12:
|
|
2250
|
-
_context6.prev = 12;
|
|
2251
|
-
_context6.t0 = _context6["catch"](3);
|
|
2252
|
-
dispatch({
|
|
2253
|
-
type: 'set_resource_failed',
|
|
2254
|
-
resourceType: resourceType,
|
|
2255
|
-
urn: urn
|
|
2256
|
-
});
|
|
2257
|
-
return _context6.abrupt("return");
|
|
2150
|
+
case 3:
|
|
2151
|
+
response = _context.sent;
|
|
2152
|
+
return _context.abrupt("return", response.items);
|
|
2258
2153
|
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2154
|
+
case 5:
|
|
2155
|
+
case "end":
|
|
2156
|
+
return _context.stop();
|
|
2157
|
+
}
|
|
2262
2158
|
}
|
|
2263
|
-
}
|
|
2264
|
-
}
|
|
2265
|
-
}));
|
|
2159
|
+
}, _callee);
|
|
2160
|
+
}));
|
|
2266
2161
|
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
};
|
|
2270
|
-
}(), [loadContentfulEntry, state.resources]);
|
|
2271
|
-
React.useEffect(function () {
|
|
2272
|
-
// @ts-expect-error
|
|
2273
|
-
if (typeof props.sdk.space.onEntityChanged !== 'undefined') {
|
|
2274
|
-
// @ts-expect-error
|
|
2275
|
-
var onEntityChanged = props.sdk.space.onEntityChanged;
|
|
2276
|
-
var listeners = [];
|
|
2277
|
-
|
|
2278
|
-
var _loop = function _loop() {
|
|
2279
|
-
var _step$value = _step.value,
|
|
2280
|
-
id = _step$value[0];
|
|
2281
|
-
listeners.push(onEntityChanged('Entry', id, function (entry) {
|
|
2282
|
-
return dispatch({
|
|
2283
|
-
type: 'set_entry',
|
|
2284
|
-
id: id,
|
|
2285
|
-
entry: entry
|
|
2286
|
-
});
|
|
2287
|
-
}));
|
|
2162
|
+
return function (_x2) {
|
|
2163
|
+
return _ref3.apply(this, arguments);
|
|
2288
2164
|
};
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2165
|
+
}(), options);
|
|
2166
|
+
}, [fetch, currentSpaceId, currentEnvironmentId]);
|
|
2167
|
+
var getResource = React.useCallback(function getResource(resourceType, urn, options) {
|
|
2168
|
+
var queryKey = ['Resource', resourceType, urn];
|
|
2169
|
+
return fetch(queryKey, function () {
|
|
2170
|
+
if (resourceType === 'Contentful:Entry') {
|
|
2171
|
+
return fetchContentfulEntry({
|
|
2172
|
+
fetch: fetch,
|
|
2173
|
+
urn: urn,
|
|
2174
|
+
options: options
|
|
2175
|
+
});
|
|
2292
2176
|
}
|
|
2293
2177
|
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2178
|
+
throw new UnsupportedError('Unsupported resource type');
|
|
2179
|
+
}, options);
|
|
2180
|
+
}, [fetch]);
|
|
2181
|
+
var isSameSpaceEntityQueryKey = React.useCallback(function (queryKey) {
|
|
2182
|
+
var isEntityKey = isEntityQueryKey(queryKey);
|
|
2183
|
+
var isSameSpaceEntityKey = isEntityKey && queryKey[2] === currentSpaceId && queryKey[3] === currentEnvironmentId;
|
|
2184
|
+
return isSameSpaceEntityKey;
|
|
2185
|
+
}, [currentSpaceId, currentEnvironmentId]); // @ts-expect-error ...
|
|
2186
|
+
|
|
2187
|
+
// @ts-expect-error ...
|
|
2188
|
+
var onEntityChanged = props.sdk.space.onEntityChanged;
|
|
2189
|
+
React.useEffect(function () {
|
|
2190
|
+
if (typeof onEntityChanged !== 'function') {
|
|
2191
|
+
return;
|
|
2192
|
+
}
|
|
2193
|
+
|
|
2194
|
+
var subscribeQuery = function subscribeQuery(_ref4) {
|
|
2195
|
+
var queryKey = _ref4.queryKey,
|
|
2196
|
+
queryHash = _ref4.queryHash;
|
|
2197
|
+
var entityType = queryKey[0],
|
|
2198
|
+
entityId = queryKey[1];
|
|
2199
|
+
entityChangeUnsubscribers.current[queryHash] = onEntityChanged(entityType, entityId, function (data) {
|
|
2200
|
+
queryClient.setQueryData(queryKey, data);
|
|
2201
|
+
});
|
|
2202
|
+
};
|
|
2305
2203
|
|
|
2306
|
-
|
|
2307
|
-
|
|
2204
|
+
var queries = queryCache.findAll({
|
|
2205
|
+
type: 'active',
|
|
2206
|
+
predicate: function predicate(query) {
|
|
2207
|
+
return isSameSpaceEntityQueryKey(query.queryKey);
|
|
2208
|
+
}
|
|
2209
|
+
});
|
|
2210
|
+
queries.forEach(subscribeQuery);
|
|
2211
|
+
var unsubscribe = queryCache.subscribe(function (event) {
|
|
2212
|
+
if (!event) {
|
|
2213
|
+
return;
|
|
2308
2214
|
}
|
|
2309
2215
|
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2216
|
+
var type = event.type,
|
|
2217
|
+
query = event.query;
|
|
2218
|
+
var queryKey = query.queryKey,
|
|
2219
|
+
queryHash = query.queryHash;
|
|
2220
|
+
|
|
2221
|
+
if (!isSameSpaceEntityQueryKey(queryKey)) {
|
|
2222
|
+
return;
|
|
2223
|
+
}
|
|
2316
2224
|
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2225
|
+
if (type === 'added') {
|
|
2226
|
+
subscribeQuery(query);
|
|
2227
|
+
}
|
|
2320
2228
|
|
|
2321
|
-
if (
|
|
2322
|
-
|
|
2323
|
-
var _step3$value = _step3.value,
|
|
2324
|
-
id = _step3$value[0];
|
|
2325
|
-
loadEntry(id);
|
|
2326
|
-
}
|
|
2229
|
+
if (type === 'removed') {
|
|
2230
|
+
var _entityChangeUnsubscr, _entityChangeUnsubscr2;
|
|
2327
2231
|
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
_id = _step4$value[0];
|
|
2331
|
-
loadAsset(_id);
|
|
2332
|
-
}
|
|
2232
|
+
// calling unsubscribe
|
|
2233
|
+
(_entityChangeUnsubscr = (_entityChangeUnsubscr2 = entityChangeUnsubscribers.current)[queryHash]) == null ? void 0 : _entityChangeUnsubscr.call(_entityChangeUnsubscr2);
|
|
2333
2234
|
}
|
|
2334
|
-
});
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
getOrLoadEntry: getEntry,
|
|
2342
|
-
|
|
2343
|
-
/**
|
|
2344
|
-
* @deprecated use `getAsset` instead
|
|
2345
|
-
*/
|
|
2346
|
-
getOrLoadAsset: getAsset,
|
|
2347
|
-
getResource: getResource,
|
|
2348
|
-
getEntry: getEntry,
|
|
2349
|
-
getAsset: getAsset,
|
|
2350
|
-
loadEntityScheduledActions: loadEntityScheduledActions,
|
|
2351
|
-
entries: state.entries,
|
|
2352
|
-
assets: state.assets,
|
|
2353
|
-
scheduledActions: state.scheduledActions,
|
|
2354
|
-
resources: state.resources
|
|
2235
|
+
});
|
|
2236
|
+
return function () {
|
|
2237
|
+
unsubscribe();
|
|
2238
|
+
Object.values(entityChangeUnsubscribers.current).forEach(function (off) {
|
|
2239
|
+
return off();
|
|
2240
|
+
});
|
|
2241
|
+
entityChangeUnsubscribers.current = {};
|
|
2355
2242
|
};
|
|
2356
|
-
}, [
|
|
2243
|
+
}, [onEntityChanged, queryCache, isSameSpaceEntityQueryKey, queryClient]);
|
|
2244
|
+
return {
|
|
2245
|
+
cmaClient: cmaClient,
|
|
2246
|
+
fetch: fetch,
|
|
2247
|
+
getResource: getResource,
|
|
2248
|
+
getEntity: getEntity,
|
|
2249
|
+
ids: props.sdk.ids,
|
|
2250
|
+
getEntityScheduledActions: getEntityScheduledActions
|
|
2251
|
+
};
|
|
2252
|
+
}, function (_ref5) {
|
|
2253
|
+
var fetch = _ref5.fetch;
|
|
2254
|
+
return fetch;
|
|
2255
|
+
}, function (_ref6) {
|
|
2256
|
+
var getResource = _ref6.getResource,
|
|
2257
|
+
getEntity = _ref6.getEntity,
|
|
2258
|
+
getEntityScheduledActions = _ref6.getEntityScheduledActions;
|
|
2259
|
+
return {
|
|
2260
|
+
getResource: getResource,
|
|
2261
|
+
getEntity: getEntity,
|
|
2262
|
+
getEntityScheduledActions: getEntityScheduledActions
|
|
2263
|
+
};
|
|
2264
|
+
}, function (_ref7) {
|
|
2265
|
+
var ids = _ref7.ids;
|
|
2266
|
+
return ids;
|
|
2267
|
+
}),
|
|
2268
|
+
InternalServiceProvider = _constate[0],
|
|
2269
|
+
useEntityLoader = _constate[2],
|
|
2270
|
+
useCurrentIds = _constate[3];
|
|
2271
|
+
|
|
2272
|
+
function useEntity(entityType, entityId, options) {
|
|
2273
|
+
var _options$spaceId3, _options$environmentI3;
|
|
2274
|
+
|
|
2275
|
+
var _useCurrentIds = useCurrentIds(),
|
|
2276
|
+
space = _useCurrentIds.space,
|
|
2277
|
+
environment = _useCurrentIds.environment;
|
|
2278
|
+
|
|
2279
|
+
var _useEntityLoader = useEntityLoader(),
|
|
2280
|
+
getEntity = _useEntityLoader.getEntity;
|
|
2281
|
+
|
|
2282
|
+
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];
|
|
2283
|
+
|
|
2284
|
+
var _useQuery = reactQuery.useQuery(queryKey, function () {
|
|
2285
|
+
return getEntity(entityType, entityId, options);
|
|
2286
|
+
}, {
|
|
2287
|
+
enabled: options == null ? void 0 : options.enabled
|
|
2288
|
+
}),
|
|
2289
|
+
status = _useQuery.status,
|
|
2290
|
+
data = _useQuery.data;
|
|
2291
|
+
|
|
2292
|
+
return {
|
|
2293
|
+
status: status,
|
|
2294
|
+
data: data
|
|
2295
|
+
};
|
|
2296
|
+
}
|
|
2297
|
+
function useResource(resourceType, urn, options) {
|
|
2298
|
+
var queryKey = ['Resource', resourceType, urn];
|
|
2299
|
+
|
|
2300
|
+
var _useEntityLoader2 = useEntityLoader(),
|
|
2301
|
+
getResource = _useEntityLoader2.getResource;
|
|
2302
|
+
|
|
2303
|
+
var _useQuery2 = reactQuery.useQuery(queryKey, function () {
|
|
2304
|
+
return getResource(resourceType, urn, options);
|
|
2305
|
+
}, {
|
|
2306
|
+
enabled: options == null ? void 0 : options.enabled
|
|
2307
|
+
}),
|
|
2308
|
+
status = _useQuery2.status,
|
|
2309
|
+
data = _useQuery2.data,
|
|
2310
|
+
error = _useQuery2.error;
|
|
2311
|
+
|
|
2312
|
+
return {
|
|
2313
|
+
status: status,
|
|
2314
|
+
data: data,
|
|
2315
|
+
error: error
|
|
2316
|
+
};
|
|
2357
2317
|
}
|
|
2358
2318
|
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2319
|
+
function EntityProvider(_ref8) {
|
|
2320
|
+
var children = _ref8.children,
|
|
2321
|
+
props = _objectWithoutPropertiesLoose(_ref8, _excluded2);
|
|
2322
|
+
|
|
2323
|
+
var reactQueryClient = React.useMemo(function () {
|
|
2324
|
+
var queryCache = new reactQuery.QueryCache();
|
|
2325
|
+
var queryClient = new reactQuery.QueryClient({
|
|
2326
|
+
queryCache: queryCache,
|
|
2327
|
+
defaultOptions: {
|
|
2328
|
+
queries: {
|
|
2329
|
+
useErrorBoundary: false,
|
|
2330
|
+
refetchOnWindowFocus: false,
|
|
2331
|
+
refetchOnReconnect: true,
|
|
2332
|
+
refetchOnMount: false,
|
|
2333
|
+
staleTime: Infinity,
|
|
2334
|
+
retry: false
|
|
2335
|
+
}
|
|
2336
|
+
}
|
|
2337
|
+
});
|
|
2338
|
+
return queryClient;
|
|
2339
|
+
}, []);
|
|
2340
|
+
return React__default.createElement(reactQuery.QueryClientProvider, {
|
|
2341
|
+
client: reactQueryClient
|
|
2342
|
+
}, React__default.createElement(InternalServiceProvider, _extends({}, props), children));
|
|
2343
|
+
}
|
|
2362
2344
|
|
|
2363
2345
|
function ReferenceEditor(props) {
|
|
2364
2346
|
return React.createElement(EntityProvider, {
|
|
@@ -2580,7 +2562,10 @@ function fromFieldValidations(field) {
|
|
|
2580
2562
|
var result = {
|
|
2581
2563
|
contentTypes: (_linkContentTypeValid = linkContentTypeValidations == null ? void 0 : linkContentTypeValidations.linkContentType) != null ? _linkContentTypeValid : undefined,
|
|
2582
2564
|
mimetypeGroups: (_linkMimetypeGroupVal = linkMimetypeGroupValidations == null ? void 0 : linkMimetypeGroupValidations.linkMimetypeGroup) != null ? _linkMimetypeGroupVal : undefined,
|
|
2583
|
-
numberOfLinks: numberOfLinks
|
|
2565
|
+
numberOfLinks: numberOfLinks // todo: there are multiple BE problems that need to be solved first, for now we don't want to apply size constraints
|
|
2566
|
+
// linkedFileSize: findValidation(field, 'assetFileSize', {}),
|
|
2567
|
+
// linkedImageDimensions: findValidation(field, 'assetImageDimensions', {})
|
|
2568
|
+
|
|
2584
2569
|
};
|
|
2585
2570
|
return result;
|
|
2586
2571
|
}
|
|
@@ -2779,7 +2764,7 @@ function Editor(props) {
|
|
|
2779
2764
|
[linkActionsProps]);
|
|
2780
2765
|
|
|
2781
2766
|
if (!props.entityId) {
|
|
2782
|
-
return React.createElement(LinkEntityActions,
|
|
2767
|
+
return React.createElement(LinkEntityActions, _extends({
|
|
2783
2768
|
renderCustomActions: props.renderCustomActions
|
|
2784
2769
|
}, linkActionsProps));
|
|
2785
2770
|
}
|
|
@@ -2791,12 +2776,12 @@ function Editor(props) {
|
|
|
2791
2776
|
|
|
2792
2777
|
function SingleReferenceEditor(props) {
|
|
2793
2778
|
var allContentTypes = props.sdk.space.getCachedContentTypes();
|
|
2794
|
-
return React.createElement(ReferenceEditor,
|
|
2779
|
+
return React.createElement(ReferenceEditor, _extends({}, props), function (_ref) {
|
|
2795
2780
|
var value = _ref.value,
|
|
2796
2781
|
setValue = _ref.setValue,
|
|
2797
2782
|
disabled = _ref.disabled,
|
|
2798
2783
|
externalReset = _ref.externalReset;
|
|
2799
|
-
return React.createElement(Editor,
|
|
2784
|
+
return React.createElement(Editor, _extends({}, props, {
|
|
2800
2785
|
key: externalReset + "-reference",
|
|
2801
2786
|
entityId: value ? value.sys.id : '',
|
|
2802
2787
|
isDisabled: disabled,
|
|
@@ -3026,18 +3011,24 @@ function _openEntry() {
|
|
|
3026
3011
|
}
|
|
3027
3012
|
|
|
3028
3013
|
function FetchingWrappedEntryCard(props) {
|
|
3029
|
-
var
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
loadEntityScheduledActions = _useEntities.loadEntityScheduledActions,
|
|
3033
|
-
entries = _useEntities.entries;
|
|
3014
|
+
var _useEntity = useEntity('Entry', props.entryId),
|
|
3015
|
+
entry = _useEntity.data,
|
|
3016
|
+
status = _useEntity.status;
|
|
3034
3017
|
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3018
|
+
var _useEntityLoader = useEntityLoader(),
|
|
3019
|
+
getEntityScheduledActions = _useEntityLoader.getEntityScheduledActions;
|
|
3020
|
+
|
|
3021
|
+
var loadEntityScheduledActions = React.useCallback(function () {
|
|
3022
|
+
return getEntityScheduledActions('Entry', props.entryId);
|
|
3023
|
+
}, [getEntityScheduledActions, props.entryId]);
|
|
3038
3024
|
var size = props.viewType === 'link' ? 'small' : 'default';
|
|
3039
|
-
|
|
3040
|
-
var
|
|
3025
|
+
|
|
3026
|
+
var _useEntityLoader2 = useEntityLoader(),
|
|
3027
|
+
getEntity = _useEntityLoader2.getEntity;
|
|
3028
|
+
|
|
3029
|
+
var getAsset = function getAsset(assetId) {
|
|
3030
|
+
return getEntity('Asset', assetId);
|
|
3031
|
+
};
|
|
3041
3032
|
|
|
3042
3033
|
var onEdit = /*#__PURE__*/function () {
|
|
3043
3034
|
var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
|
|
@@ -3095,7 +3086,7 @@ function FetchingWrappedEntryCard(props) {
|
|
|
3095
3086
|
|
|
3096
3087
|
}, [entry]);
|
|
3097
3088
|
return React.useMemo(function () {
|
|
3098
|
-
if (
|
|
3089
|
+
if (status === 'error') {
|
|
3099
3090
|
var card = React.createElement(MissingEntityCard, {
|
|
3100
3091
|
entityType: "Entry",
|
|
3101
3092
|
isDisabled: props.isDisabled,
|
|
@@ -3115,7 +3106,7 @@ function FetchingWrappedEntryCard(props) {
|
|
|
3115
3106
|
return card;
|
|
3116
3107
|
}
|
|
3117
3108
|
|
|
3118
|
-
if (
|
|
3109
|
+
if (status === 'loading') {
|
|
3119
3110
|
return React.createElement(f36Components.EntryCard, {
|
|
3120
3111
|
size: size,
|
|
3121
3112
|
isLoading: true
|
|
@@ -3154,7 +3145,7 @@ function FetchingWrappedEntryCard(props) {
|
|
|
3154
3145
|
entryUrl: (props == null ? void 0 : props.entityUrl) || sharedCardProps.entityUrl
|
|
3155
3146
|
});
|
|
3156
3147
|
|
|
3157
|
-
return React.createElement(WrappedEntryCard,
|
|
3148
|
+
return React.createElement(WrappedEntryCard, _extends({}, builtinCardProps));
|
|
3158
3149
|
}
|
|
3159
3150
|
|
|
3160
3151
|
if (props.renderCustomCard) {
|
|
@@ -3167,11 +3158,11 @@ function FetchingWrappedEntryCard(props) {
|
|
|
3167
3158
|
}
|
|
3168
3159
|
|
|
3169
3160
|
return renderDefaultCard(); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
|
|
3170
|
-
}, [props,
|
|
3161
|
+
}, [props, status, entry]);
|
|
3171
3162
|
}
|
|
3172
3163
|
|
|
3173
3164
|
function SingleEntryReferenceEditor(props) {
|
|
3174
|
-
return React.createElement(SingleReferenceEditor,
|
|
3165
|
+
return React.createElement(SingleReferenceEditor, _extends({}, props, {
|
|
3175
3166
|
entityType: "Entry"
|
|
3176
3167
|
}), function (_ref) {
|
|
3177
3168
|
var allContentTypes = _ref.allContentTypes,
|
|
@@ -3181,7 +3172,7 @@ function SingleEntryReferenceEditor(props) {
|
|
|
3181
3172
|
renderCustomCard = _ref.renderCustomCard,
|
|
3182
3173
|
hasCardRemoveActions = _ref.hasCardRemoveActions,
|
|
3183
3174
|
hasCardEditActions = _ref.hasCardEditActions;
|
|
3184
|
-
return React.createElement(FetchingWrappedEntryCard,
|
|
3175
|
+
return React.createElement(FetchingWrappedEntryCard, _extends({}, props, {
|
|
3185
3176
|
allContentTypes: allContentTypes,
|
|
3186
3177
|
isDisabled: isDisabled,
|
|
3187
3178
|
entryId: entityId,
|
|
@@ -3272,19 +3263,19 @@ function Editor$1(props) {
|
|
|
3272
3263
|
onSortEnd: onSortEnd,
|
|
3273
3264
|
onMove: onMove,
|
|
3274
3265
|
renderCustomCard: props.renderCustomCard && customCardRenderer
|
|
3275
|
-
})), React.createElement(LinkEntityActions,
|
|
3266
|
+
})), React.createElement(LinkEntityActions, _extends({
|
|
3276
3267
|
renderCustomActions: props.renderCustomActions
|
|
3277
3268
|
}, linkActionsProps)));
|
|
3278
3269
|
}
|
|
3279
3270
|
|
|
3280
3271
|
function MultipleReferenceEditor(props) {
|
|
3281
3272
|
var allContentTypes = props.sdk.space.getCachedContentTypes();
|
|
3282
|
-
return React.createElement(ReferenceEditor,
|
|
3273
|
+
return React.createElement(ReferenceEditor, _extends({}, props), function (_ref2) {
|
|
3283
3274
|
var value = _ref2.value,
|
|
3284
3275
|
disabled = _ref2.disabled,
|
|
3285
3276
|
setValue = _ref2.setValue,
|
|
3286
3277
|
externalReset = _ref2.externalReset;
|
|
3287
|
-
return React.createElement(Editor$1,
|
|
3278
|
+
return React.createElement(Editor$1, _extends({}, props, {
|
|
3288
3279
|
items: value || emptyArray,
|
|
3289
3280
|
isDisabled: disabled,
|
|
3290
3281
|
setValue: setValue,
|
|
@@ -3341,16 +3332,16 @@ var SortableLinkListInternal = /*#__PURE__*/reactSortableHoc.SortableContainer(f
|
|
|
3341
3332
|
function SortableLinkList(props) {
|
|
3342
3333
|
// with the default distance of 0 the drag start event is "confused" with the click event,
|
|
3343
3334
|
// so the latter one isn't fired and click handlers on child elements don't work
|
|
3344
|
-
return React__default.createElement(SortableLinkListInternal,
|
|
3335
|
+
return React__default.createElement(SortableLinkListInternal, _extends({
|
|
3345
3336
|
distance: 1
|
|
3346
3337
|
}, props), props.children);
|
|
3347
3338
|
}
|
|
3348
3339
|
|
|
3349
3340
|
function MultipleEntryReferenceEditor(props) {
|
|
3350
|
-
return React.createElement(MultipleReferenceEditor,
|
|
3341
|
+
return React.createElement(MultipleReferenceEditor, _extends({}, props, {
|
|
3351
3342
|
entityType: "Entry"
|
|
3352
3343
|
}), function (childrenProps) {
|
|
3353
|
-
return React.createElement(SortableLinkList,
|
|
3344
|
+
return React.createElement(SortableLinkList, _extends({}, childrenProps, {
|
|
3354
3345
|
axis: "y",
|
|
3355
3346
|
useDragHandle: true
|
|
3356
3347
|
}), function (_ref) {
|
|
@@ -3360,7 +3351,7 @@ function MultipleEntryReferenceEditor(props) {
|
|
|
3360
3351
|
isDisabled = _ref.isDisabled,
|
|
3361
3352
|
DragHandle = _ref.DragHandle;
|
|
3362
3353
|
var lastIndex = items.length - 1;
|
|
3363
|
-
return React.createElement(FetchingWrappedEntryCard,
|
|
3354
|
+
return React.createElement(FetchingWrappedEntryCard, _extends({}, childrenProps, {
|
|
3364
3355
|
key: item.sys.id + "-" + index,
|
|
3365
3356
|
index: index,
|
|
3366
3357
|
allContentTypes: childrenProps.allContentTypes,
|
|
@@ -3615,20 +3606,16 @@ var WrappedAssetLink = function WrappedAssetLink(props) {
|
|
|
3615
3606
|
};
|
|
3616
3607
|
|
|
3617
3608
|
function FetchingWrappedAssetCard(props) {
|
|
3618
|
-
var
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
assets = _useEntities.assets;
|
|
3609
|
+
var _useEntity = useEntity('Asset', props.assetId),
|
|
3610
|
+
asset = _useEntity.data,
|
|
3611
|
+
status = _useEntity.status;
|
|
3622
3612
|
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
return;
|
|
3626
|
-
}
|
|
3613
|
+
var _useEntityLoader = useEntityLoader(),
|
|
3614
|
+
getEntityScheduledActions = _useEntityLoader.getEntityScheduledActions;
|
|
3627
3615
|
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
var entityKey = asset === 'failed' ? 'failed' : asset === undefined ? 'undefined' : ":" + asset.sys.id + ":" + asset.sys.version;
|
|
3616
|
+
var loadEntityScheduledActions = React.useCallback(function () {
|
|
3617
|
+
return getEntityScheduledActions('Asset', props.assetId);
|
|
3618
|
+
}, [getEntityScheduledActions, props.assetId]);
|
|
3632
3619
|
React.useEffect(function () {
|
|
3633
3620
|
if (asset) {
|
|
3634
3621
|
props.onAction && props.onAction({
|
|
@@ -3687,7 +3674,7 @@ function FetchingWrappedAssetCard(props) {
|
|
|
3687
3674
|
};
|
|
3688
3675
|
|
|
3689
3676
|
return React.useMemo(function () {
|
|
3690
|
-
if (
|
|
3677
|
+
if (status === 'error') {
|
|
3691
3678
|
var card = React.createElement(MissingEntityCard, {
|
|
3692
3679
|
entityType: "Asset",
|
|
3693
3680
|
asSquare: props.viewType !== 'link',
|
|
@@ -3708,8 +3695,7 @@ function FetchingWrappedAssetCard(props) {
|
|
|
3708
3695
|
return card;
|
|
3709
3696
|
}
|
|
3710
3697
|
|
|
3711
|
-
var getEntityUrl = props.getEntityUrl
|
|
3712
|
-
sdk = props.sdk;
|
|
3698
|
+
var getEntityUrl = props.getEntityUrl;
|
|
3713
3699
|
var size = props.viewType === 'big_card' ? 'default' : 'small';
|
|
3714
3700
|
var commonProps = {
|
|
3715
3701
|
asset: asset,
|
|
@@ -3724,20 +3710,20 @@ function FetchingWrappedAssetCard(props) {
|
|
|
3724
3710
|
};
|
|
3725
3711
|
|
|
3726
3712
|
if (props.viewType === 'link') {
|
|
3727
|
-
if (
|
|
3713
|
+
if (status === 'loading') {
|
|
3728
3714
|
return React.createElement(f36Components.EntryCard, {
|
|
3729
3715
|
size: "small",
|
|
3730
3716
|
isLoading: true
|
|
3731
3717
|
});
|
|
3732
3718
|
}
|
|
3733
3719
|
|
|
3734
|
-
return React.createElement(WrappedAssetLink,
|
|
3720
|
+
return React.createElement(WrappedAssetLink, _extends({}, commonProps, {
|
|
3735
3721
|
href: commonProps.entityUrl,
|
|
3736
|
-
getEntityScheduledActions:
|
|
3722
|
+
getEntityScheduledActions: loadEntityScheduledActions
|
|
3737
3723
|
}));
|
|
3738
3724
|
}
|
|
3739
3725
|
|
|
3740
|
-
if (
|
|
3726
|
+
if (status === 'loading') {
|
|
3741
3727
|
return React.createElement(f36Components.AssetCard, {
|
|
3742
3728
|
size: size,
|
|
3743
3729
|
isLoading: true
|
|
@@ -3752,7 +3738,7 @@ function FetchingWrappedAssetCard(props) {
|
|
|
3752
3738
|
getAssetUrl: getEntityUrl
|
|
3753
3739
|
});
|
|
3754
3740
|
|
|
3755
|
-
return React.createElement(WrappedAssetCard,
|
|
3741
|
+
return React.createElement(WrappedAssetCard, _extends({}, builtinCardProps));
|
|
3756
3742
|
}
|
|
3757
3743
|
|
|
3758
3744
|
if (props.renderCustomCard) {
|
|
@@ -3769,17 +3755,17 @@ function FetchingWrappedAssetCard(props) {
|
|
|
3769
3755
|
}
|
|
3770
3756
|
|
|
3771
3757
|
return renderDefaultCard(); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
|
|
3772
|
-
}, [props,
|
|
3758
|
+
}, [props, status, asset]);
|
|
3773
3759
|
}
|
|
3774
3760
|
|
|
3775
3761
|
function SingleMediaEditor(props) {
|
|
3776
|
-
return React.createElement(SingleReferenceEditor,
|
|
3762
|
+
return React.createElement(SingleReferenceEditor, _extends({}, props, {
|
|
3777
3763
|
entityType: "Asset"
|
|
3778
3764
|
}), function (_ref) {
|
|
3779
3765
|
var entityId = _ref.entityId,
|
|
3780
3766
|
isDisabled = _ref.isDisabled,
|
|
3781
3767
|
setValue = _ref.setValue;
|
|
3782
|
-
return React.createElement(FetchingWrappedAssetCard,
|
|
3768
|
+
return React.createElement(FetchingWrappedAssetCard, _extends({}, props, {
|
|
3783
3769
|
viewType: "big_card",
|
|
3784
3770
|
assetId: entityId,
|
|
3785
3771
|
isDisabled: isDisabled,
|
|
@@ -3801,12 +3787,12 @@ var styles$6 = {
|
|
|
3801
3787
|
})
|
|
3802
3788
|
};
|
|
3803
3789
|
function MultipleMediaEditor(props) {
|
|
3804
|
-
return React.createElement(MultipleReferenceEditor,
|
|
3790
|
+
return React.createElement(MultipleReferenceEditor, _extends({}, props, {
|
|
3805
3791
|
entityType: "Asset"
|
|
3806
3792
|
}), function (childrenProps) {
|
|
3807
3793
|
var _cx;
|
|
3808
3794
|
|
|
3809
|
-
return React.createElement(SortableLinkList,
|
|
3795
|
+
return React.createElement(SortableLinkList, _extends({}, childrenProps, {
|
|
3810
3796
|
className: emotion.cx((_cx = {}, _cx[styles$6.gridContainer] = childrenProps.viewType === 'card', _cx)),
|
|
3811
3797
|
axis: childrenProps.viewType === 'card' ? 'xy' : 'y',
|
|
3812
3798
|
useDragHandle: true
|
|
@@ -3816,7 +3802,7 @@ function MultipleMediaEditor(props) {
|
|
|
3816
3802
|
index = _ref.index,
|
|
3817
3803
|
isDisabled = _ref.isDisabled,
|
|
3818
3804
|
DragHandle = _ref.DragHandle;
|
|
3819
|
-
return React.createElement(FetchingWrappedAssetCard,
|
|
3805
|
+
return React.createElement(FetchingWrappedAssetCard, _extends({}, childrenProps, {
|
|
3820
3806
|
isDisabled: isDisabled,
|
|
3821
3807
|
key: item.sys.id + "-" + index,
|
|
3822
3808
|
assetId: item.sys.id,
|
|
@@ -3834,6 +3820,448 @@ MultipleMediaEditor.defaultProps = {
|
|
|
3834
3820
|
isInitiallyDisabled: true
|
|
3835
3821
|
};
|
|
3836
3822
|
|
|
3823
|
+
var resolveAsset = function resolveAsset() {
|
|
3824
|
+
return Promise.resolve();
|
|
3825
|
+
}; // we don't want to show scheduled actions for resources
|
|
3826
|
+
|
|
3827
|
+
|
|
3828
|
+
var resolveScheduledActions = function resolveScheduledActions() {
|
|
3829
|
+
return Promise.resolve([]);
|
|
3830
|
+
};
|
|
3831
|
+
|
|
3832
|
+
function ContentfulEntryCard(_ref) {
|
|
3833
|
+
var info = _ref.info,
|
|
3834
|
+
isDisabled = _ref.isDisabled,
|
|
3835
|
+
renderDragHandle = _ref.renderDragHandle,
|
|
3836
|
+
onRemove = _ref.onRemove,
|
|
3837
|
+
onMoveTop = _ref.onMoveTop,
|
|
3838
|
+
onMoveBottom = _ref.onMoveBottom,
|
|
3839
|
+
getEntryRouteHref = _ref.getEntryRouteHref;
|
|
3840
|
+
var resourceSys = info.resource.sys;
|
|
3841
|
+
var spaceId = resourceSys.space.sys.id;
|
|
3842
|
+
var environmentId = resourceSys.environment.sys.id;
|
|
3843
|
+
var entryId = resourceSys.id;
|
|
3844
|
+
var resourceHref = getEntryRouteHref({
|
|
3845
|
+
spaceId: spaceId,
|
|
3846
|
+
environmentId: environmentId,
|
|
3847
|
+
entryId: entryId
|
|
3848
|
+
}); // TODO: move this into `sdk.navigator.openEntry()`, note that it's signature only include the entry id (not a space or environment)
|
|
3849
|
+
|
|
3850
|
+
var openEntryDetail = function openEntryDetail() {
|
|
3851
|
+
window.open(resourceHref, '_blank', 'noopener,noreferrer');
|
|
3852
|
+
};
|
|
3853
|
+
|
|
3854
|
+
return React.createElement(WrappedEntryCard, {
|
|
3855
|
+
entry: info.resource,
|
|
3856
|
+
isDisabled: isDisabled,
|
|
3857
|
+
hasCardEditActions: false,
|
|
3858
|
+
contentType: info.contentType,
|
|
3859
|
+
// we use the default locale from the space the entry belongs to
|
|
3860
|
+
// as we assume this gives a more consistent behaviour.
|
|
3861
|
+
// locales will inevitably differ from space to space, so it's likely
|
|
3862
|
+
// that the current locale does not exist in the "remote" space
|
|
3863
|
+
localeCode: info.defaultLocaleCode,
|
|
3864
|
+
defaultLocaleCode: info.defaultLocaleCode,
|
|
3865
|
+
size: "small",
|
|
3866
|
+
getAsset: resolveAsset,
|
|
3867
|
+
getEntityScheduledActions: resolveScheduledActions,
|
|
3868
|
+
spaceName: info.space.name,
|
|
3869
|
+
renderDragHandle: renderDragHandle,
|
|
3870
|
+
isClickable: true,
|
|
3871
|
+
onEdit: openEntryDetail,
|
|
3872
|
+
hasCardRemoveActions: Boolean(onRemove),
|
|
3873
|
+
onRemove: onRemove,
|
|
3874
|
+
onMoveBottom: onMoveBottom,
|
|
3875
|
+
onMoveTop: onMoveTop,
|
|
3876
|
+
entryUrl: resourceHref
|
|
3877
|
+
});
|
|
3878
|
+
}
|
|
3879
|
+
|
|
3880
|
+
var styles$7 = {
|
|
3881
|
+
card: /*#__PURE__*/emotion.css({
|
|
3882
|
+
position: 'relative'
|
|
3883
|
+
})
|
|
3884
|
+
};
|
|
3885
|
+
function UnsupportedEntityCard(props) {
|
|
3886
|
+
return React__default.createElement(f36Components.Card, {
|
|
3887
|
+
className: styles$7.card
|
|
3888
|
+
}, React__default.createElement(f36Components.SectionHeading, {
|
|
3889
|
+
marginBottom: "none"
|
|
3890
|
+
}, "Resource type ", props.entityType, " is currently not supported"));
|
|
3891
|
+
}
|
|
3892
|
+
|
|
3893
|
+
function ResourceCardSkeleton() {
|
|
3894
|
+
return React.createElement(f36Components.EntryCard, {
|
|
3895
|
+
size: "small",
|
|
3896
|
+
isLoading: true
|
|
3897
|
+
});
|
|
3898
|
+
}
|
|
3899
|
+
|
|
3900
|
+
function ExistingResourceCard(props) {
|
|
3901
|
+
var resourceLink = props.resourceLink,
|
|
3902
|
+
inView = props.inView,
|
|
3903
|
+
_props$index = props.index,
|
|
3904
|
+
index = _props$index === void 0 ? 0 : _props$index;
|
|
3905
|
+
var resourceOptions = {
|
|
3906
|
+
priority: index * -1,
|
|
3907
|
+
enabled: inView
|
|
3908
|
+
};
|
|
3909
|
+
|
|
3910
|
+
var _useResource = useResource(resourceLink.sys.linkType, resourceLink.sys.urn, resourceOptions),
|
|
3911
|
+
data = _useResource.data,
|
|
3912
|
+
error = _useResource.error;
|
|
3913
|
+
|
|
3914
|
+
if (!data && !error) {
|
|
3915
|
+
return React.createElement(ResourceCardSkeleton, null);
|
|
3916
|
+
}
|
|
3917
|
+
|
|
3918
|
+
if (data) {
|
|
3919
|
+
return React.createElement(ContentfulEntryCard, _extends({
|
|
3920
|
+
info: data
|
|
3921
|
+
}, props));
|
|
3922
|
+
}
|
|
3923
|
+
|
|
3924
|
+
if (isUnsupportedError(error)) {
|
|
3925
|
+
return React.createElement(UnsupportedEntityCard, {
|
|
3926
|
+
entityType: resourceLink.sys.linkType
|
|
3927
|
+
});
|
|
3928
|
+
}
|
|
3929
|
+
|
|
3930
|
+
return React.createElement(MissingEntityCard, {
|
|
3931
|
+
entityType: "Entry",
|
|
3932
|
+
isDisabled: props.isDisabled,
|
|
3933
|
+
onRemove: props.onRemove
|
|
3934
|
+
});
|
|
3935
|
+
}
|
|
3936
|
+
|
|
3937
|
+
function ResourceCardWrapper(props) {
|
|
3938
|
+
if (!props.resourceLink) {
|
|
3939
|
+
return null;
|
|
3940
|
+
}
|
|
3941
|
+
|
|
3942
|
+
return React.createElement(ExistingResourceCard, _extends({}, props, {
|
|
3943
|
+
resourceLink: props.resourceLink,
|
|
3944
|
+
getEntryRouteHref: props.getEntryRouteHref
|
|
3945
|
+
}));
|
|
3946
|
+
}
|
|
3947
|
+
|
|
3948
|
+
function ResourceCard(props) {
|
|
3949
|
+
var _useInView = reactIntersectionObserver.useInView({
|
|
3950
|
+
triggerOnce: true,
|
|
3951
|
+
rootMargin: '300px 0px 0px 300px'
|
|
3952
|
+
}),
|
|
3953
|
+
ref = _useInView.ref,
|
|
3954
|
+
inView = _useInView.inView; // Forma does not offer us to pass refs, so we need an additional wrapper here
|
|
3955
|
+
|
|
3956
|
+
|
|
3957
|
+
return React.createElement("div", {
|
|
3958
|
+
ref: ref
|
|
3959
|
+
}, React.createElement(ResourceCardWrapper, _extends({}, props, {
|
|
3960
|
+
inView: inView
|
|
3961
|
+
})));
|
|
3962
|
+
}
|
|
3963
|
+
|
|
3964
|
+
function useResourceLinkActions(_ref) {
|
|
3965
|
+
var apiUrl = _ref.apiUrl,
|
|
3966
|
+
dialogs = _ref.dialogs,
|
|
3967
|
+
field = _ref.field,
|
|
3968
|
+
onAfterLink = _ref.onAfterLink;
|
|
3969
|
+
var handleAfterLink = React.useCallback(function (entries) {
|
|
3970
|
+
if (!onAfterLink) {
|
|
3971
|
+
return;
|
|
3972
|
+
}
|
|
3973
|
+
|
|
3974
|
+
entries.forEach(onAfterLink);
|
|
3975
|
+
}, [onAfterLink]);
|
|
3976
|
+
var multiple = field.type === 'Array';
|
|
3977
|
+
var toLinkItem = React.useMemo(function () {
|
|
3978
|
+
function toUrn(entry) {
|
|
3979
|
+
return "crn:" + apiUrl + ":::content:spaces/" + entry.sys.space.sys.id + "/entries/" + entry.sys.id;
|
|
3980
|
+
}
|
|
3981
|
+
|
|
3982
|
+
return function (entry) {
|
|
3983
|
+
return {
|
|
3984
|
+
sys: {
|
|
3985
|
+
type: 'ResourceLink',
|
|
3986
|
+
linkType: 'Contentful:Entry',
|
|
3987
|
+
urn: toUrn(entry)
|
|
3988
|
+
}
|
|
3989
|
+
};
|
|
3990
|
+
};
|
|
3991
|
+
}, [apiUrl]);
|
|
3992
|
+
var onLinkedExisting = React.useMemo(function () {
|
|
3993
|
+
if (multiple) {
|
|
3994
|
+
return function (entries) {
|
|
3995
|
+
var linkItems = entries.map(toLinkItem);
|
|
3996
|
+
var prevValue = field.getValue() || [];
|
|
3997
|
+
var updatedValue = [].concat(prevValue, linkItems);
|
|
3998
|
+
field.setValue(updatedValue);
|
|
3999
|
+
handleAfterLink(entries);
|
|
4000
|
+
};
|
|
4001
|
+
} else {
|
|
4002
|
+
return function (entries) {
|
|
4003
|
+
var entry = entries[0];
|
|
4004
|
+
field.setValue(toLinkItem(entry));
|
|
4005
|
+
handleAfterLink([entry]);
|
|
4006
|
+
};
|
|
4007
|
+
}
|
|
4008
|
+
}, [field, handleAfterLink, multiple, toLinkItem]);
|
|
4009
|
+
var onLinkExisting = React.useMemo(function () {
|
|
4010
|
+
var promptSelection = multiple ? /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
|
|
4011
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
4012
|
+
while (1) {
|
|
4013
|
+
switch (_context.prev = _context.next) {
|
|
4014
|
+
case 0:
|
|
4015
|
+
_context.next = 2;
|
|
4016
|
+
return dialogs.selectMultipleResourceEntries({
|
|
4017
|
+
// @ts-expect-error wait for update of app-sdk version
|
|
4018
|
+
allowedResources: field.allowedResources
|
|
4019
|
+
});
|
|
4020
|
+
|
|
4021
|
+
case 2:
|
|
4022
|
+
return _context.abrupt("return", _context.sent);
|
|
4023
|
+
|
|
4024
|
+
case 3:
|
|
4025
|
+
case "end":
|
|
4026
|
+
return _context.stop();
|
|
4027
|
+
}
|
|
4028
|
+
}
|
|
4029
|
+
}, _callee);
|
|
4030
|
+
})) : /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
|
|
4031
|
+
return runtime_1.wrap(function _callee2$(_context2) {
|
|
4032
|
+
while (1) {
|
|
4033
|
+
switch (_context2.prev = _context2.next) {
|
|
4034
|
+
case 0:
|
|
4035
|
+
_context2.next = 2;
|
|
4036
|
+
return dialogs.selectSingleResourceEntry({
|
|
4037
|
+
// @ts-expect-error wait for update of app-sdk version
|
|
4038
|
+
allowedResources: field.allowedResources
|
|
4039
|
+
});
|
|
4040
|
+
|
|
4041
|
+
case 2:
|
|
4042
|
+
_context2.t0 = _context2.sent;
|
|
4043
|
+
return _context2.abrupt("return", [_context2.t0]);
|
|
4044
|
+
|
|
4045
|
+
case 4:
|
|
4046
|
+
case "end":
|
|
4047
|
+
return _context2.stop();
|
|
4048
|
+
}
|
|
4049
|
+
}
|
|
4050
|
+
}, _callee2);
|
|
4051
|
+
}));
|
|
4052
|
+
return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3() {
|
|
4053
|
+
var res;
|
|
4054
|
+
return runtime_1.wrap(function _callee3$(_context3) {
|
|
4055
|
+
while (1) {
|
|
4056
|
+
switch (_context3.prev = _context3.next) {
|
|
4057
|
+
case 0:
|
|
4058
|
+
_context3.next = 2;
|
|
4059
|
+
return promptSelection();
|
|
4060
|
+
|
|
4061
|
+
case 2:
|
|
4062
|
+
res = _context3.sent;
|
|
4063
|
+
|
|
4064
|
+
if (res) {
|
|
4065
|
+
_context3.next = 5;
|
|
4066
|
+
break;
|
|
4067
|
+
}
|
|
4068
|
+
|
|
4069
|
+
return _context3.abrupt("return");
|
|
4070
|
+
|
|
4071
|
+
case 5:
|
|
4072
|
+
onLinkedExisting(res);
|
|
4073
|
+
|
|
4074
|
+
case 6:
|
|
4075
|
+
case "end":
|
|
4076
|
+
return _context3.stop();
|
|
4077
|
+
}
|
|
4078
|
+
}
|
|
4079
|
+
}, _callee3);
|
|
4080
|
+
})); // @ts-expect-error wait for update of app-sdk version
|
|
4081
|
+
}, [dialogs, field.allowedResources, multiple, onLinkedExisting]);
|
|
4082
|
+
return {
|
|
4083
|
+
onLinkExisting: onLinkExisting,
|
|
4084
|
+
onLinkedExisting: onLinkedExisting,
|
|
4085
|
+
// hardcoded values to match interface for standard reference field actions
|
|
4086
|
+
entityType: 'Entry',
|
|
4087
|
+
contentTypes: [],
|
|
4088
|
+
canCreateEntity: false,
|
|
4089
|
+
canLinkMultiple: multiple,
|
|
4090
|
+
canLinkEntity: true,
|
|
4091
|
+
isDisabled: false,
|
|
4092
|
+
isEmpty: false,
|
|
4093
|
+
isFull: false,
|
|
4094
|
+
// eslint-disable-next-line -- hardcoded values to match interface for standard reference field actions
|
|
4095
|
+
onCreate: function () {
|
|
4096
|
+
var _onCreate = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4() {
|
|
4097
|
+
return runtime_1.wrap(function _callee4$(_context4) {
|
|
4098
|
+
while (1) {
|
|
4099
|
+
switch (_context4.prev = _context4.next) {
|
|
4100
|
+
case 0:
|
|
4101
|
+
case "end":
|
|
4102
|
+
return _context4.stop();
|
|
4103
|
+
}
|
|
4104
|
+
}
|
|
4105
|
+
}, _callee4);
|
|
4106
|
+
}));
|
|
4107
|
+
|
|
4108
|
+
function onCreate() {
|
|
4109
|
+
return _onCreate.apply(this, arguments);
|
|
4110
|
+
}
|
|
4111
|
+
|
|
4112
|
+
return onCreate;
|
|
4113
|
+
}(),
|
|
4114
|
+
// eslint-disable-next-line -- hardcoded values to match interface for standard reference field actions
|
|
4115
|
+
onCreated: function onCreated() {}
|
|
4116
|
+
};
|
|
4117
|
+
}
|
|
4118
|
+
|
|
4119
|
+
function ResourceEditor(props) {
|
|
4120
|
+
var setValue = props.setValue,
|
|
4121
|
+
items = props.items,
|
|
4122
|
+
apiUrl = props.apiUrl;
|
|
4123
|
+
var onSortStart = React.useCallback(function (_, event) {
|
|
4124
|
+
return event.preventDefault();
|
|
4125
|
+
}, []);
|
|
4126
|
+
var onSortEnd = React.useCallback(function (_ref) {
|
|
4127
|
+
var oldIndex = _ref.oldIndex,
|
|
4128
|
+
newIndex = _ref.newIndex;
|
|
4129
|
+
var newItems = arrayMove(items, oldIndex, newIndex);
|
|
4130
|
+
setValue(newItems);
|
|
4131
|
+
}, [items, setValue]);
|
|
4132
|
+
var onMove = React.useCallback(function (oldIndex, newIndex) {
|
|
4133
|
+
var newItems = arrayMove(items, oldIndex, newIndex);
|
|
4134
|
+
setValue(newItems);
|
|
4135
|
+
}, [items, setValue]);
|
|
4136
|
+
var onRemoteItemAtIndex = React.useCallback(function (index) {
|
|
4137
|
+
setValue(items.filter(function (_v, i) {
|
|
4138
|
+
return i !== index;
|
|
4139
|
+
}));
|
|
4140
|
+
}, [items, setValue]);
|
|
4141
|
+
var _props$sdk = props.sdk,
|
|
4142
|
+
dialogs = _props$sdk.dialogs,
|
|
4143
|
+
field = _props$sdk.field;
|
|
4144
|
+
var linkActionsProps = useResourceLinkActions({
|
|
4145
|
+
dialogs: dialogs,
|
|
4146
|
+
field: field,
|
|
4147
|
+
apiUrl: apiUrl
|
|
4148
|
+
});
|
|
4149
|
+
return React.createElement(React.Fragment, null, props.children(_extends({}, props, {
|
|
4150
|
+
onSortStart: onSortStart,
|
|
4151
|
+
onSortEnd: onSortEnd,
|
|
4152
|
+
onMove: onMove,
|
|
4153
|
+
onRemoteItemAtIndex: onRemoteItemAtIndex
|
|
4154
|
+
})), React.createElement(CombinedLinkActions, _extends({}, linkActionsProps)));
|
|
4155
|
+
} // provides memoized callbacks bound to a given item
|
|
4156
|
+
|
|
4157
|
+
|
|
4158
|
+
function WithPerItemCallbacks(_ref2) {
|
|
4159
|
+
var listLength = _ref2.listLength,
|
|
4160
|
+
index = _ref2.index,
|
|
4161
|
+
onMove = _ref2.onMove,
|
|
4162
|
+
onRemoteItemAtIndex = _ref2.onRemoteItemAtIndex,
|
|
4163
|
+
children = _ref2.children;
|
|
4164
|
+
var handleMoveTop = React.useMemo(function () {
|
|
4165
|
+
return index > 0 ? function () {
|
|
4166
|
+
return onMove(index, 0);
|
|
4167
|
+
} : undefined;
|
|
4168
|
+
}, [index, onMove]);
|
|
4169
|
+
var handleMoveBottom = React.useMemo(function () {
|
|
4170
|
+
return index < listLength - 1 ? function () {
|
|
4171
|
+
return onMove(index, listLength - 1);
|
|
4172
|
+
} : undefined;
|
|
4173
|
+
}, [index, onMove, listLength]);
|
|
4174
|
+
var handleRemove = React.useCallback(function () {
|
|
4175
|
+
return onRemoteItemAtIndex(index);
|
|
4176
|
+
}, [index, onRemoteItemAtIndex]);
|
|
4177
|
+
return React.createElement(React.Fragment, null, children({
|
|
4178
|
+
onMoveBottom: handleMoveBottom,
|
|
4179
|
+
onMoveTop: handleMoveTop,
|
|
4180
|
+
onRemove: handleRemove
|
|
4181
|
+
}));
|
|
4182
|
+
}
|
|
4183
|
+
|
|
4184
|
+
var EMPTY_ARRAY = [];
|
|
4185
|
+
function MultipleResourceReferenceEditor(props) {
|
|
4186
|
+
return React.createElement(EntityProvider, {
|
|
4187
|
+
sdk: props.sdk
|
|
4188
|
+
}, React.createElement(fieldEditorShared.FieldConnector, {
|
|
4189
|
+
throttle: 0,
|
|
4190
|
+
field: props.sdk.field,
|
|
4191
|
+
isInitiallyDisabled: props.isInitiallyDisabled,
|
|
4192
|
+
isEqualValues: deepEqual
|
|
4193
|
+
}, function (_ref3) {
|
|
4194
|
+
var value = _ref3.value,
|
|
4195
|
+
disabled = _ref3.disabled,
|
|
4196
|
+
setValue = _ref3.setValue,
|
|
4197
|
+
externalReset = _ref3.externalReset;
|
|
4198
|
+
return React.createElement(ResourceEditor, _extends({}, props, {
|
|
4199
|
+
items: value || EMPTY_ARRAY,
|
|
4200
|
+
isDisabled: disabled,
|
|
4201
|
+
setValue: setValue,
|
|
4202
|
+
key: externalReset + "-list"
|
|
4203
|
+
}), function (editorProps) {
|
|
4204
|
+
return React.createElement(SortableLinkList, _extends({}, editorProps), function (_ref4) {
|
|
4205
|
+
var item = _ref4.item,
|
|
4206
|
+
isDisabled = _ref4.isDisabled,
|
|
4207
|
+
DragHandle = _ref4.DragHandle,
|
|
4208
|
+
index = _ref4.index;
|
|
4209
|
+
return React.createElement(WithPerItemCallbacks, {
|
|
4210
|
+
index: index,
|
|
4211
|
+
onMove: editorProps.onMove,
|
|
4212
|
+
onRemoteItemAtIndex: editorProps.onRemoteItemAtIndex,
|
|
4213
|
+
listLength: (value == null ? void 0 : value.length) || 0
|
|
4214
|
+
}, function (_ref5) {
|
|
4215
|
+
var onMoveBottom = _ref5.onMoveBottom,
|
|
4216
|
+
onMoveTop = _ref5.onMoveTop,
|
|
4217
|
+
onRemove = _ref5.onRemove;
|
|
4218
|
+
return React.createElement(ResourceCard, {
|
|
4219
|
+
index: index,
|
|
4220
|
+
resourceLink: item,
|
|
4221
|
+
isDisabled: isDisabled,
|
|
4222
|
+
renderDragHandle: DragHandle,
|
|
4223
|
+
onMoveTop: onMoveTop,
|
|
4224
|
+
onMoveBottom: onMoveBottom,
|
|
4225
|
+
onRemove: onRemove,
|
|
4226
|
+
getEntryRouteHref: props.getEntryRouteHref
|
|
4227
|
+
});
|
|
4228
|
+
});
|
|
4229
|
+
});
|
|
4230
|
+
});
|
|
4231
|
+
}));
|
|
4232
|
+
}
|
|
4233
|
+
|
|
4234
|
+
function SingleResourceReferenceEditor(props) {
|
|
4235
|
+
var _props$sdk = props.sdk,
|
|
4236
|
+
dialogs = _props$sdk.dialogs,
|
|
4237
|
+
field = _props$sdk.field;
|
|
4238
|
+
var linkActionsProps = useResourceLinkActions({
|
|
4239
|
+
dialogs: dialogs,
|
|
4240
|
+
field: field,
|
|
4241
|
+
apiUrl: props.apiUrl
|
|
4242
|
+
});
|
|
4243
|
+
return React.createElement(EntityProvider, {
|
|
4244
|
+
sdk: props.sdk
|
|
4245
|
+
}, React.createElement(fieldEditorShared.FieldConnector, {
|
|
4246
|
+
throttle: 0,
|
|
4247
|
+
field: props.sdk.field,
|
|
4248
|
+
isInitiallyDisabled: props.isInitiallyDisabled,
|
|
4249
|
+
isEqualValues: deepEqual
|
|
4250
|
+
}, function (_ref) {
|
|
4251
|
+
var value = _ref.value,
|
|
4252
|
+
disabled = _ref.disabled;
|
|
4253
|
+
return value ? React.createElement(ResourceCard, {
|
|
4254
|
+
onRemove: function onRemove() {
|
|
4255
|
+
return props.sdk.field.removeValue();
|
|
4256
|
+
},
|
|
4257
|
+
resourceLink: value,
|
|
4258
|
+
isDisabled: disabled,
|
|
4259
|
+
getEntryRouteHref: props.getEntryRouteHref
|
|
4260
|
+
}) : // TODO: support custom actions once publicly available
|
|
4261
|
+
React.createElement(CombinedLinkActions, _extends({}, linkActionsProps));
|
|
4262
|
+
}));
|
|
4263
|
+
}
|
|
4264
|
+
|
|
3837
4265
|
exports.AssetThumbnail = AssetThumbnail;
|
|
3838
4266
|
exports.CombinedLinkActions = CombinedLinkActions;
|
|
3839
4267
|
exports.CreateEntryLinkButton = CreateEntryLinkButton;
|
|
@@ -3842,12 +4270,16 @@ exports.EntityProvider = EntityProvider;
|
|
|
3842
4270
|
exports.MissingEntityCard = MissingEntityCard;
|
|
3843
4271
|
exports.MultipleEntryReferenceEditor = MultipleEntryReferenceEditor;
|
|
3844
4272
|
exports.MultipleMediaEditor = MultipleMediaEditor;
|
|
4273
|
+
exports.MultipleResourceReferenceEditor = MultipleResourceReferenceEditor;
|
|
3845
4274
|
exports.ScheduledIconWithTooltip = ScheduledIconWithTooltip;
|
|
3846
4275
|
exports.SingleEntryReferenceEditor = SingleEntryReferenceEditor;
|
|
3847
4276
|
exports.SingleMediaEditor = SingleMediaEditor;
|
|
4277
|
+
exports.SingleResourceReferenceEditor = SingleResourceReferenceEditor;
|
|
3848
4278
|
exports.SortableLinkList = SortableLinkList;
|
|
3849
4279
|
exports.WrappedAssetCard = WrappedAssetCard;
|
|
3850
4280
|
exports.WrappedEntryCard = WrappedEntryCard;
|
|
3851
4281
|
exports.getScheduleTooltipContent = getScheduleTooltipContent;
|
|
3852
|
-
exports.
|
|
4282
|
+
exports.useEntity = useEntity;
|
|
4283
|
+
exports.useEntityLoader = useEntityLoader;
|
|
4284
|
+
exports.useResource = useResource;
|
|
3853
4285
|
//# sourceMappingURL=field-editor-reference.cjs.development.js.map
|