@contentful/field-editor-reference 4.3.10 → 4.5.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 +18 -0
- package/dist/__fixtures__/FakeSdk.d.ts +20 -151
- package/dist/assets/WrappedAssetCard/FetchingWrappedAssetCard.d.ts +1 -1
- package/dist/common/EntityStore.d.ts +7 -1
- package/dist/components/SpaceName/SpaceName.d.ts +6 -0
- package/dist/entries/SortableElements.d.ts +1 -1
- package/dist/entries/WrappedEntryCard/FetchingWrappedEntryCard.d.ts +2 -2
- package/dist/entries/WrappedEntryCard/WrappedEntryCard.d.ts +1 -0
- package/dist/field-editor-reference.cjs.development.js +504 -120
- 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 +505 -121
- package/dist/field-editor-reference.esm.js.map +1 -1
- package/dist/types.d.ts +29 -1
- package/package.json +4 -3
|
@@ -2,12 +2,13 @@ import React__default, { useState, useRef, useEffect, createElement, Fragment, u
|
|
|
2
2
|
import { css } from 'emotion';
|
|
3
3
|
import tokens from '@contentful/f36-tokens';
|
|
4
4
|
import get from 'lodash-es/get';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { Menu, TextInput, Button, Paragraph, Card, SectionHeading, IconButton, Tooltip, Flex, Text, EntryCard, MenuItem, MenuDivider, AssetCard } from '@contentful/f36-components';
|
|
6
|
+
import { SearchIcon, PlusIcon, ChevronDownIcon, LinkIcon, CloseIcon, FolderOpenTrimmedIcon, ClockIcon } from '@contentful/f36-icons';
|
|
7
7
|
import moment from 'moment';
|
|
8
8
|
import deepEqual from 'deep-equal';
|
|
9
9
|
import { FieldConnector, isValidImage, entityHelpers, shortenStorageUnit } from '@contentful/field-editor-shared';
|
|
10
10
|
import constate from 'constate';
|
|
11
|
+
import { createClient } from 'contentful-management';
|
|
11
12
|
import isNumber from 'lodash-es/isNumber';
|
|
12
13
|
import arrayMove from 'array-move';
|
|
13
14
|
import { SortableContainer, SortableHandle, SortableElement } from 'react-sortable-hoc';
|
|
@@ -82,6 +83,44 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
82
83
|
return target;
|
|
83
84
|
}
|
|
84
85
|
|
|
86
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
87
|
+
if (!o) return;
|
|
88
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
89
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
90
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
91
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
92
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function _arrayLikeToArray(arr, len) {
|
|
96
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
97
|
+
|
|
98
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
99
|
+
|
|
100
|
+
return arr2;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
104
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
105
|
+
if (it) return (it = it.call(o)).next.bind(it);
|
|
106
|
+
|
|
107
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
108
|
+
if (it) o = it;
|
|
109
|
+
var i = 0;
|
|
110
|
+
return function () {
|
|
111
|
+
if (i >= o.length) return {
|
|
112
|
+
done: true
|
|
113
|
+
};
|
|
114
|
+
return {
|
|
115
|
+
done: false,
|
|
116
|
+
value: o[i++]
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
122
|
+
}
|
|
123
|
+
|
|
85
124
|
var container = /*#__PURE__*/css({
|
|
86
125
|
display: 'flex',
|
|
87
126
|
border: "1px dashed " + tokens.gray500,
|
|
@@ -108,20 +147,10 @@ var styles = {
|
|
|
108
147
|
position: 'relative',
|
|
109
148
|
padding: "0 " + tokens.spacing2Xs
|
|
110
149
|
}),
|
|
111
|
-
searchInput:
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
borderRadius: parentHasDropdown ? 0 : undefined,
|
|
116
|
-
borderLeft: parentHasDropdown ? 'none' : undefined,
|
|
117
|
-
borderRight: parentHasDropdown ? 'none' : undefined,
|
|
118
|
-
paddingRight: tokens.spacing2Xl,
|
|
119
|
-
'::placeholder': {
|
|
120
|
-
color: tokens.gray600
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
},
|
|
150
|
+
searchInput: /*#__PURE__*/css({
|
|
151
|
+
paddingRight: tokens.spacingXl,
|
|
152
|
+
textOverflow: 'ellipsis'
|
|
153
|
+
}),
|
|
125
154
|
searchIcon: /*#__PURE__*/css({
|
|
126
155
|
position: 'absolute',
|
|
127
156
|
right: tokens.spacingM,
|
|
@@ -270,7 +299,7 @@ var CreateEntryMenuTrigger = function CreateEntryMenuTrigger(_ref) {
|
|
|
270
299
|
ref: textField,
|
|
271
300
|
className: styles.inputWrapper
|
|
272
301
|
}, React__default.createElement(TextInput, {
|
|
273
|
-
className: styles.searchInput
|
|
302
|
+
className: styles.searchInput,
|
|
274
303
|
placeholder: "Search all content types",
|
|
275
304
|
testId: "add-entry-menu-search",
|
|
276
305
|
value: searchInput,
|
|
@@ -1832,7 +1861,7 @@ function AssetThumbnail(props) {
|
|
|
1832
1861
|
}
|
|
1833
1862
|
|
|
1834
1863
|
function reducer(state, action) {
|
|
1835
|
-
var _extends2, _extends3, _extends4, _extends5, _extends6;
|
|
1864
|
+
var _extends2, _extends3, _extends4, _extends5, _extends6, _extends7, _extends8;
|
|
1836
1865
|
|
|
1837
1866
|
switch (action.type) {
|
|
1838
1867
|
case 'set_entry':
|
|
@@ -1860,6 +1889,16 @@ function reducer(state, action) {
|
|
|
1860
1889
|
scheduledActions: _extends({}, state.scheduledActions, (_extends6 = {}, _extends6[action.key] = action.actions, _extends6))
|
|
1861
1890
|
});
|
|
1862
1891
|
|
|
1892
|
+
case 'set_resource':
|
|
1893
|
+
return _extends({}, state, {
|
|
1894
|
+
resources: _extends({}, state.resources, (_extends7 = {}, _extends7[action.resourceType + "." + action.urn] = action.resourceInfo, _extends7))
|
|
1895
|
+
});
|
|
1896
|
+
|
|
1897
|
+
case 'set_resource_failed':
|
|
1898
|
+
return _extends({}, state, {
|
|
1899
|
+
resources: _extends({}, state.resources, (_extends8 = {}, _extends8[action.resourceType + "." + action.urn] = 'failed', _extends8))
|
|
1900
|
+
});
|
|
1901
|
+
|
|
1863
1902
|
default:
|
|
1864
1903
|
return state;
|
|
1865
1904
|
}
|
|
@@ -1868,10 +1907,34 @@ function reducer(state, action) {
|
|
|
1868
1907
|
var initialState = {
|
|
1869
1908
|
entries: {},
|
|
1870
1909
|
assets: {},
|
|
1871
|
-
scheduledActions: {}
|
|
1910
|
+
scheduledActions: {},
|
|
1911
|
+
resources: {}
|
|
1912
|
+
};
|
|
1913
|
+
|
|
1914
|
+
var isNotNil = function isNotNil(entity) {
|
|
1915
|
+
return Boolean(entity && entity !== 'failed');
|
|
1916
|
+
};
|
|
1917
|
+
|
|
1918
|
+
var nonNilResources = function nonNilResources(map) {
|
|
1919
|
+
return Object.entries(map).filter(function (_ref) {
|
|
1920
|
+
var value = _ref[1];
|
|
1921
|
+
return isNotNil(value);
|
|
1922
|
+
});
|
|
1872
1923
|
};
|
|
1873
1924
|
|
|
1874
1925
|
function useEntitiesStore(props) {
|
|
1926
|
+
var spaceId = props.sdk.ids.space;
|
|
1927
|
+
var environmentId = props.sdk.ids.environment;
|
|
1928
|
+
|
|
1929
|
+
var _React$useState = useState(function () {
|
|
1930
|
+
return createClient({
|
|
1931
|
+
apiAdapter: props.sdk.cmaAdapter
|
|
1932
|
+
}, {
|
|
1933
|
+
type: 'plain'
|
|
1934
|
+
});
|
|
1935
|
+
}),
|
|
1936
|
+
cmaClient = _React$useState[0];
|
|
1937
|
+
|
|
1875
1938
|
var _React$useReducer = useReducer(reducer, initialState),
|
|
1876
1939
|
state = _React$useReducer[0],
|
|
1877
1940
|
dispatch = _React$useReducer[1];
|
|
@@ -1899,78 +1962,348 @@ function useEntitiesStore(props) {
|
|
|
1899
1962
|
return [];
|
|
1900
1963
|
});
|
|
1901
1964
|
}, [props.sdk.space, state.scheduledActions]);
|
|
1902
|
-
var loadEntry = useCallback(function (
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
}, [props.sdk.space]);
|
|
1917
|
-
var loadAsset = useCallback(function (id) {
|
|
1918
|
-
return props.sdk.space.getAsset(id).then(function (asset) {
|
|
1919
|
-
dispatch({
|
|
1920
|
-
type: 'set_asset',
|
|
1921
|
-
id: id,
|
|
1922
|
-
asset: asset
|
|
1923
|
-
});
|
|
1924
|
-
return asset;
|
|
1925
|
-
})["catch"](function () {
|
|
1926
|
-
dispatch({
|
|
1927
|
-
type: 'set_asset_failed',
|
|
1928
|
-
id: id
|
|
1929
|
-
});
|
|
1930
|
-
});
|
|
1931
|
-
}, [props.sdk.space]);
|
|
1932
|
-
var getOrLoadAsset = useCallback(function (id) {
|
|
1933
|
-
if (state.assets[id] && state.assets[id] !== 'failed') {
|
|
1934
|
-
return Promise.resolve(state.assets[id]);
|
|
1935
|
-
}
|
|
1965
|
+
var loadEntry = useCallback( /*#__PURE__*/function () {
|
|
1966
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(entryId) {
|
|
1967
|
+
var entry;
|
|
1968
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
1969
|
+
while (1) {
|
|
1970
|
+
switch (_context.prev = _context.next) {
|
|
1971
|
+
case 0:
|
|
1972
|
+
_context.prev = 0;
|
|
1973
|
+
_context.next = 3;
|
|
1974
|
+
return cmaClient.entry.get({
|
|
1975
|
+
spaceId: spaceId,
|
|
1976
|
+
environmentId: environmentId,
|
|
1977
|
+
entryId: entryId
|
|
1978
|
+
});
|
|
1936
1979
|
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1980
|
+
case 3:
|
|
1981
|
+
entry = _context.sent;
|
|
1982
|
+
dispatch({
|
|
1983
|
+
type: 'set_entry',
|
|
1984
|
+
id: entryId,
|
|
1985
|
+
entry: entry
|
|
1986
|
+
});
|
|
1987
|
+
return _context.abrupt("return", entry);
|
|
1988
|
+
|
|
1989
|
+
case 8:
|
|
1990
|
+
_context.prev = 8;
|
|
1991
|
+
_context.t0 = _context["catch"](0);
|
|
1992
|
+
dispatch({
|
|
1993
|
+
type: 'set_entry_failed',
|
|
1994
|
+
id: entryId
|
|
1995
|
+
});
|
|
1996
|
+
return _context.abrupt("return");
|
|
1997
|
+
|
|
1998
|
+
case 12:
|
|
1999
|
+
case "end":
|
|
2000
|
+
return _context.stop();
|
|
2001
|
+
}
|
|
2002
|
+
}
|
|
2003
|
+
}, _callee, null, [[0, 8]]);
|
|
2004
|
+
}));
|
|
2005
|
+
|
|
2006
|
+
return function (_x) {
|
|
2007
|
+
return _ref2.apply(this, arguments);
|
|
2008
|
+
};
|
|
2009
|
+
}(), [cmaClient, spaceId, environmentId]);
|
|
2010
|
+
var getEntry = useCallback( /*#__PURE__*/function () {
|
|
2011
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(entryId) {
|
|
2012
|
+
var cachedEntry;
|
|
2013
|
+
return runtime_1.wrap(function _callee2$(_context2) {
|
|
2014
|
+
while (1) {
|
|
2015
|
+
switch (_context2.prev = _context2.next) {
|
|
2016
|
+
case 0:
|
|
2017
|
+
cachedEntry = state.entries[entryId];
|
|
2018
|
+
|
|
2019
|
+
if (!isNotNil(cachedEntry)) {
|
|
2020
|
+
_context2.next = 3;
|
|
2021
|
+
break;
|
|
2022
|
+
}
|
|
2023
|
+
|
|
2024
|
+
return _context2.abrupt("return", cachedEntry);
|
|
2025
|
+
|
|
2026
|
+
case 3:
|
|
2027
|
+
return _context2.abrupt("return", loadEntry(entryId));
|
|
1943
2028
|
|
|
1944
|
-
|
|
1945
|
-
|
|
2029
|
+
case 4:
|
|
2030
|
+
case "end":
|
|
2031
|
+
return _context2.stop();
|
|
2032
|
+
}
|
|
2033
|
+
}
|
|
2034
|
+
}, _callee2);
|
|
2035
|
+
}));
|
|
2036
|
+
|
|
2037
|
+
return function (_x2) {
|
|
2038
|
+
return _ref3.apply(this, arguments);
|
|
2039
|
+
};
|
|
2040
|
+
}(), [loadEntry, state.entries]);
|
|
2041
|
+
var loadAsset = useCallback( /*#__PURE__*/function () {
|
|
2042
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(assetId) {
|
|
2043
|
+
var asset;
|
|
2044
|
+
return runtime_1.wrap(function _callee3$(_context3) {
|
|
2045
|
+
while (1) {
|
|
2046
|
+
switch (_context3.prev = _context3.next) {
|
|
2047
|
+
case 0:
|
|
2048
|
+
_context3.prev = 0;
|
|
2049
|
+
_context3.next = 3;
|
|
2050
|
+
return cmaClient.asset.get({
|
|
2051
|
+
spaceId: spaceId,
|
|
2052
|
+
environmentId: environmentId,
|
|
2053
|
+
assetId: assetId
|
|
2054
|
+
});
|
|
2055
|
+
|
|
2056
|
+
case 3:
|
|
2057
|
+
asset = _context3.sent;
|
|
2058
|
+
dispatch({
|
|
2059
|
+
type: 'set_asset',
|
|
2060
|
+
id: assetId,
|
|
2061
|
+
asset: asset
|
|
2062
|
+
});
|
|
2063
|
+
return _context3.abrupt("return", asset);
|
|
2064
|
+
|
|
2065
|
+
case 8:
|
|
2066
|
+
_context3.prev = 8;
|
|
2067
|
+
_context3.t0 = _context3["catch"](0);
|
|
2068
|
+
dispatch({
|
|
2069
|
+
type: 'set_asset_failed',
|
|
2070
|
+
id: assetId
|
|
2071
|
+
});
|
|
2072
|
+
return _context3.abrupt("return");
|
|
2073
|
+
|
|
2074
|
+
case 12:
|
|
2075
|
+
case "end":
|
|
2076
|
+
return _context3.stop();
|
|
2077
|
+
}
|
|
2078
|
+
}
|
|
2079
|
+
}, _callee3, null, [[0, 8]]);
|
|
2080
|
+
}));
|
|
2081
|
+
|
|
2082
|
+
return function (_x3) {
|
|
2083
|
+
return _ref4.apply(this, arguments);
|
|
2084
|
+
};
|
|
2085
|
+
}(), [cmaClient, spaceId, environmentId]);
|
|
2086
|
+
var getAsset = useCallback( /*#__PURE__*/function () {
|
|
2087
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(assetId) {
|
|
2088
|
+
var cachedAsset;
|
|
2089
|
+
return runtime_1.wrap(function _callee4$(_context4) {
|
|
2090
|
+
while (1) {
|
|
2091
|
+
switch (_context4.prev = _context4.next) {
|
|
2092
|
+
case 0:
|
|
2093
|
+
cachedAsset = state.assets[assetId];
|
|
2094
|
+
|
|
2095
|
+
if (!isNotNil(cachedAsset)) {
|
|
2096
|
+
_context4.next = 3;
|
|
2097
|
+
break;
|
|
2098
|
+
}
|
|
2099
|
+
|
|
2100
|
+
return _context4.abrupt("return", cachedAsset);
|
|
2101
|
+
|
|
2102
|
+
case 3:
|
|
2103
|
+
return _context4.abrupt("return", loadAsset(assetId));
|
|
2104
|
+
|
|
2105
|
+
case 4:
|
|
2106
|
+
case "end":
|
|
2107
|
+
return _context4.stop();
|
|
2108
|
+
}
|
|
2109
|
+
}
|
|
2110
|
+
}, _callee4);
|
|
2111
|
+
}));
|
|
2112
|
+
|
|
2113
|
+
return function (_x4) {
|
|
2114
|
+
return _ref5.apply(this, arguments);
|
|
2115
|
+
};
|
|
2116
|
+
}(), [loadAsset, state.assets]);
|
|
2117
|
+
var loadContentfulEntry = useCallback( /*#__PURE__*/function () {
|
|
2118
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(urn) {
|
|
2119
|
+
var _locales$items$find;
|
|
2120
|
+
|
|
2121
|
+
var resourceId, _resourceId$split, spaceId, entryId, environmentId, _yield$Promise$all, space, entry, contentTypeId, _yield$Promise$all2, contentType, locales, defaultLocaleCode;
|
|
2122
|
+
|
|
2123
|
+
return runtime_1.wrap(function _callee5$(_context5) {
|
|
2124
|
+
while (1) {
|
|
2125
|
+
switch (_context5.prev = _context5.next) {
|
|
2126
|
+
case 0:
|
|
2127
|
+
resourceId = urn.split(':', 6)[5];
|
|
2128
|
+
_resourceId$split = resourceId.split('/'), spaceId = _resourceId$split[1], entryId = _resourceId$split[3];
|
|
2129
|
+
environmentId = 'master';
|
|
2130
|
+
_context5.t0 = Promise;
|
|
2131
|
+
_context5.next = 6;
|
|
2132
|
+
return cmaClient.space.get({
|
|
2133
|
+
spaceId: spaceId
|
|
2134
|
+
});
|
|
2135
|
+
|
|
2136
|
+
case 6:
|
|
2137
|
+
_context5.t1 = _context5.sent;
|
|
2138
|
+
_context5.next = 9;
|
|
2139
|
+
return cmaClient.entry.get({
|
|
2140
|
+
spaceId: spaceId,
|
|
2141
|
+
environmentId: environmentId,
|
|
2142
|
+
entryId: entryId
|
|
2143
|
+
});
|
|
2144
|
+
|
|
2145
|
+
case 9:
|
|
2146
|
+
_context5.t2 = _context5.sent;
|
|
2147
|
+
_context5.t3 = [_context5.t1, _context5.t2];
|
|
2148
|
+
_context5.next = 13;
|
|
2149
|
+
return _context5.t0.all.call(_context5.t0, _context5.t3);
|
|
2150
|
+
|
|
2151
|
+
case 13:
|
|
2152
|
+
_yield$Promise$all = _context5.sent;
|
|
2153
|
+
space = _yield$Promise$all[0];
|
|
2154
|
+
entry = _yield$Promise$all[1];
|
|
2155
|
+
contentTypeId = entry.sys.contentType.sys.id;
|
|
2156
|
+
_context5.t4 = Promise;
|
|
2157
|
+
_context5.next = 20;
|
|
2158
|
+
return cmaClient.contentType.get({
|
|
2159
|
+
contentTypeId: contentTypeId,
|
|
2160
|
+
spaceId: spaceId,
|
|
2161
|
+
environmentId: environmentId
|
|
2162
|
+
});
|
|
2163
|
+
|
|
2164
|
+
case 20:
|
|
2165
|
+
_context5.t5 = _context5.sent;
|
|
2166
|
+
_context5.next = 23;
|
|
2167
|
+
return cmaClient.locale.getMany({
|
|
2168
|
+
spaceId: spaceId,
|
|
2169
|
+
environmentId: environmentId,
|
|
2170
|
+
query: {
|
|
2171
|
+
limit: 100
|
|
2172
|
+
}
|
|
2173
|
+
});
|
|
2174
|
+
|
|
2175
|
+
case 23:
|
|
2176
|
+
_context5.t6 = _context5.sent;
|
|
2177
|
+
_context5.t7 = [_context5.t5, _context5.t6];
|
|
2178
|
+
_context5.next = 27;
|
|
2179
|
+
return _context5.t4.all.call(_context5.t4, _context5.t7);
|
|
2180
|
+
|
|
2181
|
+
case 27:
|
|
2182
|
+
_yield$Promise$all2 = _context5.sent;
|
|
2183
|
+
contentType = _yield$Promise$all2[0];
|
|
2184
|
+
locales = _yield$Promise$all2[1];
|
|
2185
|
+
defaultLocaleCode = (_locales$items$find = locales.items.find(function (locale) {
|
|
2186
|
+
return locale["default"];
|
|
2187
|
+
})) == null ? void 0 : _locales$items$find.code;
|
|
2188
|
+
return _context5.abrupt("return", {
|
|
2189
|
+
resource: entry,
|
|
2190
|
+
defaultLocaleCode: defaultLocaleCode,
|
|
2191
|
+
space: space,
|
|
2192
|
+
contentType: contentType
|
|
2193
|
+
});
|
|
2194
|
+
|
|
2195
|
+
case 32:
|
|
2196
|
+
case "end":
|
|
2197
|
+
return _context5.stop();
|
|
2198
|
+
}
|
|
2199
|
+
}
|
|
2200
|
+
}, _callee5);
|
|
2201
|
+
}));
|
|
2202
|
+
|
|
2203
|
+
return function (_x5) {
|
|
2204
|
+
return _ref6.apply(this, arguments);
|
|
2205
|
+
};
|
|
2206
|
+
}(), [cmaClient]);
|
|
2207
|
+
var getResource = useCallback( /*#__PURE__*/function () {
|
|
2208
|
+
var _ref7 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(resourceType, urn) {
|
|
2209
|
+
var cachedResource, resourceInfo;
|
|
2210
|
+
return runtime_1.wrap(function _callee6$(_context6) {
|
|
2211
|
+
while (1) {
|
|
2212
|
+
switch (_context6.prev = _context6.next) {
|
|
2213
|
+
case 0:
|
|
2214
|
+
cachedResource = state.resources[resourceType + "." + urn];
|
|
2215
|
+
|
|
2216
|
+
if (!isNotNil(cachedResource)) {
|
|
2217
|
+
_context6.next = 3;
|
|
2218
|
+
break;
|
|
2219
|
+
}
|
|
2220
|
+
|
|
2221
|
+
return _context6.abrupt("return", cachedResource);
|
|
2222
|
+
|
|
2223
|
+
case 3:
|
|
2224
|
+
_context6.prev = 3;
|
|
2225
|
+
|
|
2226
|
+
if (!(resourceType === 'Contentful:Entry')) {
|
|
2227
|
+
_context6.next = 8;
|
|
2228
|
+
break;
|
|
2229
|
+
}
|
|
2230
|
+
|
|
2231
|
+
_context6.next = 7;
|
|
2232
|
+
return loadContentfulEntry(urn);
|
|
2233
|
+
|
|
2234
|
+
case 7:
|
|
2235
|
+
resourceInfo = _context6.sent;
|
|
2236
|
+
|
|
2237
|
+
case 8:
|
|
2238
|
+
dispatch({
|
|
2239
|
+
type: 'set_resource',
|
|
2240
|
+
resourceType: resourceType,
|
|
2241
|
+
urn: urn,
|
|
2242
|
+
resourceInfo: resourceInfo
|
|
2243
|
+
});
|
|
2244
|
+
return _context6.abrupt("return", resourceInfo);
|
|
2245
|
+
|
|
2246
|
+
case 12:
|
|
2247
|
+
_context6.prev = 12;
|
|
2248
|
+
_context6.t0 = _context6["catch"](3);
|
|
2249
|
+
dispatch({
|
|
2250
|
+
type: 'set_resource_failed',
|
|
2251
|
+
resourceType: resourceType,
|
|
2252
|
+
urn: urn
|
|
2253
|
+
});
|
|
2254
|
+
return _context6.abrupt("return");
|
|
2255
|
+
|
|
2256
|
+
case 16:
|
|
2257
|
+
case "end":
|
|
2258
|
+
return _context6.stop();
|
|
2259
|
+
}
|
|
2260
|
+
}
|
|
2261
|
+
}, _callee6, null, [[3, 12]]);
|
|
2262
|
+
}));
|
|
2263
|
+
|
|
2264
|
+
return function (_x6, _x7) {
|
|
2265
|
+
return _ref7.apply(this, arguments);
|
|
2266
|
+
};
|
|
2267
|
+
}(), [loadContentfulEntry, state.resources]);
|
|
1946
2268
|
useEffect(function () {
|
|
1947
2269
|
// @ts-expect-error
|
|
1948
2270
|
if (typeof props.sdk.space.onEntityChanged !== 'undefined') {
|
|
1949
2271
|
// @ts-expect-error
|
|
1950
2272
|
var onEntityChanged = props.sdk.space.onEntityChanged;
|
|
1951
2273
|
var listeners = [];
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
2274
|
+
|
|
2275
|
+
var _loop = function _loop() {
|
|
2276
|
+
var _step$value = _step.value,
|
|
2277
|
+
id = _step$value[0];
|
|
2278
|
+
listeners.push(onEntityChanged('Entry', id, function (entry) {
|
|
2279
|
+
return dispatch({
|
|
2280
|
+
type: 'set_entry',
|
|
2281
|
+
id: id,
|
|
2282
|
+
entry: entry
|
|
2283
|
+
});
|
|
2284
|
+
}));
|
|
2285
|
+
};
|
|
2286
|
+
|
|
2287
|
+
for (var _iterator = _createForOfIteratorHelperLoose(nonNilResources(state.entries)), _step; !(_step = _iterator()).done;) {
|
|
2288
|
+
_loop();
|
|
2289
|
+
}
|
|
2290
|
+
|
|
2291
|
+
var _loop2 = function _loop2() {
|
|
2292
|
+
var _step2$value = _step2.value,
|
|
2293
|
+
id = _step2$value[0];
|
|
2294
|
+
listeners.push(onEntityChanged('Asset', id, function (asset) {
|
|
2295
|
+
return dispatch({
|
|
2296
|
+
type: 'set_asset',
|
|
2297
|
+
id: id,
|
|
2298
|
+
asset: asset
|
|
2299
|
+
});
|
|
2300
|
+
}));
|
|
2301
|
+
};
|
|
2302
|
+
|
|
2303
|
+
for (var _iterator2 = _createForOfIteratorHelperLoose(nonNilResources(state.assets)), _step2; !(_step2 = _iterator2()).done;) {
|
|
2304
|
+
_loop2();
|
|
2305
|
+
}
|
|
2306
|
+
|
|
1974
2307
|
return function () {
|
|
1975
2308
|
return listeners.forEach(function (off) {
|
|
1976
2309
|
return off();
|
|
@@ -1978,29 +2311,46 @@ function useEntitiesStore(props) {
|
|
|
1978
2311
|
};
|
|
1979
2312
|
}
|
|
1980
2313
|
|
|
1981
|
-
return props.sdk.navigator.onSlideInNavigation(function (
|
|
1982
|
-
var oldSlideLevel =
|
|
1983
|
-
newSlideLevel =
|
|
2314
|
+
return props.sdk.navigator.onSlideInNavigation(function (_ref8) {
|
|
2315
|
+
var oldSlideLevel = _ref8.oldSlideLevel,
|
|
2316
|
+
newSlideLevel = _ref8.newSlideLevel;
|
|
1984
2317
|
|
|
1985
2318
|
if (oldSlideLevel > newSlideLevel) {
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
}
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
2319
|
+
for (var _iterator3 = _createForOfIteratorHelperLoose(nonNilResources(state.entries)), _step3; !(_step3 = _iterator3()).done;) {
|
|
2320
|
+
var _step3$value = _step3.value,
|
|
2321
|
+
id = _step3$value[0];
|
|
2322
|
+
loadEntry(id);
|
|
2323
|
+
}
|
|
2324
|
+
|
|
2325
|
+
for (var _iterator4 = _createForOfIteratorHelperLoose(nonNilResources(state.assets)), _step4; !(_step4 = _iterator4()).done;) {
|
|
2326
|
+
var _step4$value = _step4.value,
|
|
2327
|
+
_id = _step4$value[0];
|
|
2328
|
+
loadAsset(_id);
|
|
2329
|
+
}
|
|
1996
2330
|
}
|
|
1997
2331
|
}); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
|
|
1998
2332
|
}, [props.sdk, state.assets, state.entries]);
|
|
1999
|
-
return
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2333
|
+
return useMemo(function () {
|
|
2334
|
+
return {
|
|
2335
|
+
/**
|
|
2336
|
+
* @deprecated use `getEntry` instead
|
|
2337
|
+
*/
|
|
2338
|
+
getOrLoadEntry: getEntry,
|
|
2339
|
+
|
|
2340
|
+
/**
|
|
2341
|
+
* @deprecated use `getAsset` instead
|
|
2342
|
+
*/
|
|
2343
|
+
getOrLoadAsset: getAsset,
|
|
2344
|
+
getResource: getResource,
|
|
2345
|
+
getEntry: getEntry,
|
|
2346
|
+
getAsset: getAsset,
|
|
2347
|
+
loadEntityScheduledActions: loadEntityScheduledActions,
|
|
2348
|
+
entries: state.entries,
|
|
2349
|
+
assets: state.assets,
|
|
2350
|
+
scheduledActions: state.scheduledActions,
|
|
2351
|
+
resources: state.resources
|
|
2352
|
+
};
|
|
2353
|
+
}, [getResource, getEntry, getAsset, loadEntityScheduledActions, state.entries, state.assets, state.scheduledActions, state.resources]);
|
|
2004
2354
|
}
|
|
2005
2355
|
|
|
2006
2356
|
var _constate = /*#__PURE__*/constate(useEntitiesStore),
|
|
@@ -2457,11 +2807,40 @@ SingleReferenceEditor.defaultProps = {
|
|
|
2457
2807
|
hasCardRemoveActions: true
|
|
2458
2808
|
};
|
|
2459
2809
|
|
|
2810
|
+
var styles$1 = {
|
|
2811
|
+
spaceIcon: /*#__PURE__*/css({
|
|
2812
|
+
flexShrink: 0,
|
|
2813
|
+
fill: tokens.purple600
|
|
2814
|
+
}),
|
|
2815
|
+
spaceName: /*#__PURE__*/css({
|
|
2816
|
+
color: tokens.gray700,
|
|
2817
|
+
fontSize: tokens.fontSizeS,
|
|
2818
|
+
fontWeight: tokens.fontWeightDemiBold
|
|
2819
|
+
})
|
|
2820
|
+
};
|
|
2821
|
+
function SpaceName(props) {
|
|
2822
|
+
return createElement(Tooltip, {
|
|
2823
|
+
placement: "top",
|
|
2824
|
+
as: "div",
|
|
2825
|
+
content: "Space"
|
|
2826
|
+
}, createElement(Flex, {
|
|
2827
|
+
alignItems: "center",
|
|
2828
|
+
gap: "spacingXs",
|
|
2829
|
+
marginRight: "spacingS"
|
|
2830
|
+
}, createElement(FolderOpenTrimmedIcon, {
|
|
2831
|
+
className: styles$1.spaceIcon,
|
|
2832
|
+
size: "tiny",
|
|
2833
|
+
"aria-label": "Source space"
|
|
2834
|
+
}), createElement(Text, {
|
|
2835
|
+
className: styles$1.spaceName
|
|
2836
|
+
}, props.spaceName)));
|
|
2837
|
+
}
|
|
2838
|
+
|
|
2460
2839
|
var getEntryTitle = entityHelpers.getEntryTitle,
|
|
2461
2840
|
getEntityDescription = entityHelpers.getEntityDescription,
|
|
2462
2841
|
getEntryStatus = entityHelpers.getEntryStatus,
|
|
2463
2842
|
getEntryImage = entityHelpers.getEntryImage;
|
|
2464
|
-
var styles$
|
|
2843
|
+
var styles$2 = {
|
|
2465
2844
|
scheduleIcon: /*#__PURE__*/css({
|
|
2466
2845
|
marginRight: tokens.spacing2Xs
|
|
2467
2846
|
})
|
|
@@ -2526,12 +2905,17 @@ function WrappedEntryCard(props) {
|
|
|
2526
2905
|
size: props.size,
|
|
2527
2906
|
isSelected: props.isSelected,
|
|
2528
2907
|
status: status,
|
|
2529
|
-
|
|
2908
|
+
style: props.spaceName ? {
|
|
2909
|
+
backgroundColor: tokens.gray100
|
|
2910
|
+
} : undefined,
|
|
2911
|
+
icon: props.spaceName ? createElement(SpaceName, {
|
|
2912
|
+
spaceName: props.spaceName
|
|
2913
|
+
}) : createElement(ScheduledIconWithTooltip, {
|
|
2530
2914
|
getEntityScheduledActions: props.getEntityScheduledActions,
|
|
2531
2915
|
entityType: "Entry",
|
|
2532
2916
|
entityId: props.entry.sys.id
|
|
2533
2917
|
}, createElement(ClockIcon, {
|
|
2534
|
-
className: styles$
|
|
2918
|
+
className: styles$2.scheduleIcon,
|
|
2535
2919
|
size: "small",
|
|
2536
2920
|
variant: "muted",
|
|
2537
2921
|
testId: "schedule-icon"
|
|
@@ -2636,13 +3020,13 @@ function _openEntry() {
|
|
|
2636
3020
|
|
|
2637
3021
|
function FetchingWrappedEntryCard(props) {
|
|
2638
3022
|
var _useEntities = useEntities(),
|
|
2639
|
-
|
|
2640
|
-
|
|
3023
|
+
getEntry = _useEntities.getEntry,
|
|
3024
|
+
getAsset = _useEntities.getAsset,
|
|
2641
3025
|
loadEntityScheduledActions = _useEntities.loadEntityScheduledActions,
|
|
2642
3026
|
entries = _useEntities.entries;
|
|
2643
3027
|
|
|
2644
3028
|
useEffect(function () {
|
|
2645
|
-
|
|
3029
|
+
getEntry(props.entryId); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
|
|
2646
3030
|
}, [props.entryId]);
|
|
2647
3031
|
var size = props.viewType === 'link' ? 'small' : 'default';
|
|
2648
3032
|
var entry = entries[props.entryId];
|
|
@@ -2757,7 +3141,7 @@ function FetchingWrappedEntryCard(props) {
|
|
|
2757
3141
|
hasCardEditActions: hasCardEditActions,
|
|
2758
3142
|
hasCardMoveActions: hasCardMoveActions,
|
|
2759
3143
|
hasCardRemoveActions: hasCardRemoveActions,
|
|
2760
|
-
getAsset:
|
|
3144
|
+
getAsset: getAsset,
|
|
2761
3145
|
getEntityScheduledActions: loadEntityScheduledActions,
|
|
2762
3146
|
entry: (props == null ? void 0 : props.entity) || sharedCardProps.entity,
|
|
2763
3147
|
entryUrl: (props == null ? void 0 : props.entityUrl) || sharedCardProps.entityUrl
|
|
@@ -2906,8 +3290,8 @@ MultipleReferenceEditor.defaultProps = {
|
|
|
2906
3290
|
hasCardEditActions: true
|
|
2907
3291
|
};
|
|
2908
3292
|
|
|
2909
|
-
var styles$
|
|
2910
|
-
|
|
3293
|
+
var styles$3 = {
|
|
3294
|
+
container: /*#__PURE__*/css({
|
|
2911
3295
|
position: 'relative'
|
|
2912
3296
|
}),
|
|
2913
3297
|
item: /*#__PURE__*/css({
|
|
@@ -2924,13 +3308,13 @@ var DragHandle = function DragHandle(props) {
|
|
|
2924
3308
|
|
|
2925
3309
|
var SortableLink = /*#__PURE__*/SortableElement(function (props) {
|
|
2926
3310
|
return React__default.createElement("div", {
|
|
2927
|
-
className: styles$
|
|
3311
|
+
className: styles$3.item
|
|
2928
3312
|
}, props.children);
|
|
2929
3313
|
});
|
|
2930
3314
|
var SortableLinkList = /*#__PURE__*/SortableContainer(function (props) {
|
|
2931
3315
|
var lastIndex = props.items.length - 1;
|
|
2932
3316
|
return React__default.createElement("div", {
|
|
2933
|
-
className: styles$
|
|
3317
|
+
className: styles$3.container
|
|
2934
3318
|
}, props.items.map(function (item, index) {
|
|
2935
3319
|
return React__default.createElement(SortableLink, {
|
|
2936
3320
|
disabled: props.isDisabled,
|
|
@@ -3039,7 +3423,7 @@ var groupToIconMap = {
|
|
|
3039
3423
|
code: 'code',
|
|
3040
3424
|
markup: 'markup'
|
|
3041
3425
|
};
|
|
3042
|
-
var styles$
|
|
3426
|
+
var styles$4 = {
|
|
3043
3427
|
scheduleIcon: /*#__PURE__*/css({
|
|
3044
3428
|
marginRight: tokens.spacing2Xs
|
|
3045
3429
|
})
|
|
@@ -3101,7 +3485,7 @@ var WrappedAssetCard = function WrappedAssetCard(props) {
|
|
|
3101
3485
|
entityType: "Asset",
|
|
3102
3486
|
entityId: props.asset.sys.id
|
|
3103
3487
|
}, React__default.createElement(ClockIcon, {
|
|
3104
|
-
className: styles$
|
|
3488
|
+
className: styles$4.scheduleIcon,
|
|
3105
3489
|
size: "small",
|
|
3106
3490
|
variant: "muted",
|
|
3107
3491
|
testId: "schedule-icon"
|
|
@@ -3132,7 +3516,7 @@ var WrappedAssetCard = function WrappedAssetCard(props) {
|
|
|
3132
3516
|
};
|
|
3133
3517
|
WrappedAssetCard.defaultProps = defaultProps$1;
|
|
3134
3518
|
|
|
3135
|
-
var styles$
|
|
3519
|
+
var styles$5 = {
|
|
3136
3520
|
scheduleIcon: /*#__PURE__*/css({
|
|
3137
3521
|
marginRight: tokens.spacing2Xs
|
|
3138
3522
|
})
|
|
@@ -3176,7 +3560,7 @@ var WrappedAssetLink = function WrappedAssetLink(props) {
|
|
|
3176
3560
|
entityType: "Asset",
|
|
3177
3561
|
entityId: props.asset.sys.id
|
|
3178
3562
|
}, React__default.createElement(ClockIcon, {
|
|
3179
|
-
className: styles$
|
|
3563
|
+
className: styles$5.scheduleIcon,
|
|
3180
3564
|
size: "small",
|
|
3181
3565
|
variant: "muted",
|
|
3182
3566
|
testId: "schedule-icon"
|
|
@@ -3202,12 +3586,12 @@ var WrappedAssetLink = function WrappedAssetLink(props) {
|
|
|
3202
3586
|
|
|
3203
3587
|
function FetchingWrappedAssetCard(props) {
|
|
3204
3588
|
var _useEntities = useEntities(),
|
|
3205
|
-
|
|
3589
|
+
getAsset = _useEntities.getAsset,
|
|
3206
3590
|
loadEntityScheduledActions = _useEntities.loadEntityScheduledActions,
|
|
3207
3591
|
assets = _useEntities.assets;
|
|
3208
3592
|
|
|
3209
3593
|
useEffect(function () {
|
|
3210
|
-
|
|
3594
|
+
getAsset(props.assetId); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
|
|
3211
3595
|
}, [props.assetId]);
|
|
3212
3596
|
var asset = assets[props.assetId];
|
|
3213
3597
|
var entityKey = asset === 'failed' ? 'failed' : asset === undefined ? 'undefined' : ":" + asset.sys.id + ":" + asset.sys.version;
|
|
@@ -3375,7 +3759,7 @@ SingleMediaEditor.defaultProps = {
|
|
|
3375
3759
|
isInitiallyDisabled: true
|
|
3376
3760
|
};
|
|
3377
3761
|
|
|
3378
|
-
var styles$
|
|
3762
|
+
var styles$6 = {
|
|
3379
3763
|
gridContainter: /*#__PURE__*/css({
|
|
3380
3764
|
position: 'relative',
|
|
3381
3765
|
display: 'flex',
|
|
@@ -3399,12 +3783,12 @@ var DragHandle$1 = function DragHandle(props) {
|
|
|
3399
3783
|
|
|
3400
3784
|
var SortableLink$1 = /*#__PURE__*/SortableElement(function (props) {
|
|
3401
3785
|
return React__default.createElement("div", {
|
|
3402
|
-
className: styles$
|
|
3786
|
+
className: styles$6.item
|
|
3403
3787
|
}, props.children);
|
|
3404
3788
|
});
|
|
3405
3789
|
var SortableLinkList$1 = /*#__PURE__*/SortableContainer(function (props) {
|
|
3406
3790
|
return React__default.createElement("div", {
|
|
3407
|
-
className: props.viewType === 'card' ? styles$
|
|
3791
|
+
className: props.viewType === 'card' ? styles$6.gridContainter : styles$6.container
|
|
3408
3792
|
}, props.items.map(function (item, index) {
|
|
3409
3793
|
return React__default.createElement(SortableLink$1, {
|
|
3410
3794
|
disabled: props.isDisabled,
|