@contentful/field-editor-reference 5.21.2 → 5.21.5
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/dist/cjs/__fixtures__/asset/index.js +5 -5
- package/dist/cjs/__fixtures__/content-type/index.js +1 -1
- package/dist/cjs/__fixtures__/entry/index.js +4 -4
- package/dist/cjs/__fixtures__/fixtures.js +5 -5
- package/dist/cjs/__fixtures__/locale/index.js +2 -2
- package/dist/cjs/__fixtures__/space/index.js +1 -1
- package/dist/cjs/assets/MultipleMediaEditor.js +4 -4
- package/dist/cjs/assets/SingleMediaEditor.js +3 -3
- package/dist/cjs/assets/WrappedAssetCard/AssetCardActions.js +13 -13
- package/dist/cjs/assets/WrappedAssetCard/FetchingWrappedAssetCard.js +7 -12
- package/dist/cjs/assets/WrappedAssetCard/WrappedAssetCard.js +9 -16
- package/dist/cjs/assets/WrappedAssetCard/WrappedAssetLink.js +7 -8
- package/dist/cjs/common/EntityStore.js +6 -23
- package/dist/cjs/common/MultipleReferenceEditor.js +7 -14
- package/dist/cjs/common/ReferenceEditor.js +4 -4
- package/dist/cjs/common/SingleReferenceEditor.js +5 -7
- package/dist/cjs/common/SortableLinkList.js +9 -9
- package/dist/cjs/common/customCardTypes.js +1 -1
- package/dist/cjs/common/queryClient.js +3 -6
- package/dist/cjs/common/useContentTypePermissions.js +0 -2
- package/dist/cjs/common/useEditorPermissions.js +0 -12
- package/dist/cjs/common/useEditorPermissions.spec.js +0 -1
- package/dist/cjs/components/AssetThumbnail/AssetThumbnail.js +2 -2
- package/dist/cjs/components/CreateEntryLinkButton/CreateEntryLinkButton.js +7 -9
- package/dist/cjs/components/CreateEntryLinkButton/CreateEntryLinkButton.spec.js +14 -14
- package/dist/cjs/components/CreateEntryLinkButton/CreateEntryMenuTrigger.js +16 -24
- package/dist/cjs/components/CreateEntryLinkButton/CreateEntryMenuTrigger.spec.js +11 -11
- package/dist/cjs/components/LinkActions/CombinedLinkActions.js +20 -25
- package/dist/cjs/components/LinkActions/LinkActions.js +11 -11
- package/dist/cjs/components/LinkActions/LinkEntityActions.js +8 -15
- package/dist/cjs/components/LinkActions/NoLinkPermissionsInfo.js +2 -2
- package/dist/cjs/components/LinkActions/helpers.js +0 -9
- package/dist/cjs/components/LinkActions/redesignStyles.js +1 -1
- package/dist/cjs/components/LinkActions/styles.js +1 -1
- package/dist/cjs/components/MissingEntityCard/MissingEntityCard.js +8 -8
- package/dist/cjs/components/ResourceEntityErrorCard/ResourceEntityErrorCard.js +3 -3
- package/dist/cjs/components/ResourceEntityErrorCard/UnsupportedEntityCard.js +3 -3
- package/dist/cjs/components/ScheduledIconWithTooltip/ScheduleTooltip.js +2 -2
- package/dist/cjs/components/ScheduledIconWithTooltip/ScheduledIconWithTooltip.js +2 -5
- package/dist/cjs/components/ScheduledIconWithTooltip/formatDateAndTime.js +1 -2
- package/dist/cjs/components/SpaceName/SpaceName.js +6 -6
- package/dist/cjs/entries/MultipleEntryReferenceEditor.js +4 -4
- package/dist/cjs/entries/SingleEntryReferenceEditor.js +3 -3
- package/dist/cjs/entries/WrappedEntryCard/FetchingWrappedEntryCard.js +7 -14
- package/dist/cjs/entries/WrappedEntryCard/WrappedEntryCard.js +14 -18
- package/dist/cjs/resources/Cards/ContentfulEntryCard.js +2 -9
- package/dist/cjs/resources/Cards/ResourceCard.js +8 -10
- package/dist/cjs/resources/Cards/ResourceCard.spec.js +7 -8
- package/dist/cjs/resources/MultipleResourceReferenceEditor.js +11 -12
- package/dist/cjs/resources/MultipleResourceReferenceEditor.spec.js +8 -27
- package/dist/cjs/resources/SingleResourceReferenceEditor.js +6 -6
- package/dist/cjs/resources/SingleResourceReferenceEditor.spec.js +5 -10
- package/dist/cjs/resources/testHelpers/resourceEditorHelpers.js +0 -7
- package/dist/cjs/resources/useResourceLinkActions.js +1 -10
- package/dist/cjs/utils/fromFieldValidations.js +1 -2
- package/dist/cjs/utils/useSortIDs.js +1 -1
- package/dist/esm/assets/MultipleMediaEditor.js +3 -3
- package/dist/esm/assets/SingleMediaEditor.js +2 -2
- package/dist/esm/assets/WrappedAssetCard/AssetCardActions.js +10 -10
- package/dist/esm/assets/WrappedAssetCard/FetchingWrappedAssetCard.js +6 -11
- package/dist/esm/assets/WrappedAssetCard/WrappedAssetCard.js +6 -14
- package/dist/esm/assets/WrappedAssetCard/WrappedAssetLink.js +5 -6
- package/dist/esm/common/EntityStore.js +3 -20
- package/dist/esm/common/MultipleReferenceEditor.js +6 -13
- package/dist/esm/common/ReferenceEditor.js +2 -2
- package/dist/esm/common/SingleReferenceEditor.js +4 -6
- package/dist/esm/common/SortableLinkList.js +7 -7
- package/dist/esm/common/queryClient.js +3 -10
- package/dist/esm/common/useContentTypePermissions.js +0 -2
- package/dist/esm/common/useEditorPermissions.js +0 -12
- package/dist/esm/common/useEditorPermissions.spec.js +0 -1
- package/dist/esm/components/AssetThumbnail/AssetThumbnail.js +1 -1
- package/dist/esm/components/CreateEntryLinkButton/CreateEntryLinkButton.js +4 -6
- package/dist/esm/components/CreateEntryLinkButton/CreateEntryLinkButton.spec.js +12 -12
- package/dist/esm/components/CreateEntryLinkButton/CreateEntryMenuTrigger.js +13 -21
- package/dist/esm/components/CreateEntryLinkButton/CreateEntryMenuTrigger.spec.js +8 -9
- package/dist/esm/components/LinkActions/CombinedLinkActions.js +19 -30
- package/dist/esm/components/LinkActions/LinkActions.js +9 -9
- package/dist/esm/components/LinkActions/LinkEntityActions.js +7 -14
- package/dist/esm/components/LinkActions/NoLinkPermissionsInfo.js +1 -1
- package/dist/esm/components/LinkActions/helpers.js +0 -9
- package/dist/esm/components/MissingEntityCard/MissingEntityCard.js +6 -6
- package/dist/esm/components/ResourceEntityErrorCard/ResourceEntityErrorCard.js +2 -2
- package/dist/esm/components/ResourceEntityErrorCard/UnsupportedEntityCard.js +2 -2
- package/dist/esm/components/ScheduledIconWithTooltip/ScheduleTooltip.js +1 -1
- package/dist/esm/components/ScheduledIconWithTooltip/ScheduledIconWithTooltip.js +1 -4
- package/dist/esm/components/ScheduledIconWithTooltip/formatDateAndTime.js +2 -11
- package/dist/esm/components/SpaceName/SpaceName.js +4 -4
- package/dist/esm/entries/MultipleEntryReferenceEditor.js +3 -3
- package/dist/esm/entries/SingleEntryReferenceEditor.js +2 -2
- package/dist/esm/entries/WrappedEntryCard/FetchingWrappedEntryCard.js +5 -12
- package/dist/esm/entries/WrappedEntryCard/WrappedEntryCard.js +12 -16
- package/dist/esm/resources/Cards/ContentfulEntryCard.js +1 -8
- package/dist/esm/resources/Cards/ResourceCard.js +7 -9
- package/dist/esm/resources/Cards/ResourceCard.spec.js +2 -3
- package/dist/esm/resources/MultipleResourceReferenceEditor.js +8 -9
- package/dist/esm/resources/MultipleResourceReferenceEditor.spec.js +7 -26
- package/dist/esm/resources/SingleResourceReferenceEditor.js +4 -4
- package/dist/esm/resources/SingleResourceReferenceEditor.spec.js +4 -9
- package/dist/esm/resources/testHelpers/resourceEditorHelpers.js +0 -7
- package/dist/esm/resources/useResourceLinkActions.js +1 -10
- package/dist/esm/utils/fromFieldValidations.js +0 -1
- package/dist/types/assets/MultipleMediaEditor.d.ts +2 -2
- package/dist/types/assets/SingleMediaEditor.d.ts +2 -2
- package/dist/types/assets/WrappedAssetCard/AssetCardActions.d.ts +3 -3
- package/dist/types/assets/WrappedAssetCard/FetchingWrappedAssetCard.d.ts +2 -2
- package/dist/types/assets/WrappedAssetCard/WrappedAssetCard.d.ts +2 -2
- package/dist/types/assets/WrappedAssetCard/WrappedAssetLink.d.ts +2 -2
- package/dist/types/common/EntityStore.d.ts +1 -1
- package/dist/types/common/MultipleReferenceEditor.d.ts +1 -1
- package/dist/types/common/ReferenceEditor.d.ts +1 -1
- package/dist/types/common/SingleReferenceEditor.d.ts +1 -1
- package/dist/types/common/SortableLinkList.d.ts +1 -1
- package/dist/types/common/queryClient.d.ts +1 -1
- package/dist/types/components/AssetThumbnail/AssetThumbnail.d.ts +2 -2
- package/dist/types/components/CreateEntryLinkButton/CreateEntryLinkButton.d.ts +1 -1
- package/dist/types/components/CreateEntryLinkButton/CreateEntryMenuTrigger.d.ts +1 -1
- package/dist/types/components/LinkActions/CombinedLinkActions.d.ts +2 -2
- package/dist/types/components/LinkActions/LinkActions.d.ts +1 -1
- package/dist/types/components/LinkActions/LinkEntityActions.d.ts +2 -2
- package/dist/types/components/LinkActions/NoLinkPermissionsInfo.d.ts +2 -2
- package/dist/types/components/MissingEntityCard/MissingEntityCard.d.ts +2 -2
- package/dist/types/components/ResourceEntityErrorCard/ResourceEntityErrorCard.d.ts +2 -2
- package/dist/types/components/ResourceEntityErrorCard/UnsupportedEntityCard.d.ts +2 -2
- package/dist/types/components/ScheduledIconWithTooltip/ScheduleTooltip.d.ts +1 -1
- package/dist/types/components/ScheduledIconWithTooltip/ScheduledIconWithTooltip.d.ts +1 -1
- package/dist/types/components/SpaceName/SpaceName.d.ts +2 -2
- package/dist/types/entries/MultipleEntryReferenceEditor.d.ts +2 -2
- package/dist/types/entries/SingleEntryReferenceEditor.d.ts +2 -2
- package/dist/types/entries/WrappedEntryCard/FetchingWrappedEntryCard.d.ts +2 -2
- package/dist/types/entries/WrappedEntryCard/WrappedEntryCard.d.ts +1 -1
- package/dist/types/resources/Cards/ContentfulEntryCard.d.ts +2 -2
- package/dist/types/resources/Cards/ResourceCard.d.ts +2 -2
- package/dist/types/resources/MultipleResourceReferenceEditor.d.ts +2 -2
- package/dist/types/resources/SingleResourceReferenceEditor.d.ts +2 -2
- package/package.json +8 -5
|
@@ -25,8 +25,6 @@ export async function selectSingleEntity(props) {
|
|
|
25
25
|
if (props.entityType === 'Entry') {
|
|
26
26
|
return await props.sdk.dialogs.selectSingleEntry({
|
|
27
27
|
locale: props.sdk.field.locale,
|
|
28
|
-
// readable CTs do not cover cases where user has partial access to a CT entry,
|
|
29
|
-
// e.g. via tags so we're passing in all available CTs (based on field validations)
|
|
30
28
|
contentTypes: getContentTypeIds(props.editorPermissions.availableContentTypes)
|
|
31
29
|
});
|
|
32
30
|
} else {
|
|
@@ -39,18 +37,11 @@ export async function selectSingleEntity(props) {
|
|
|
39
37
|
export async function selectMultipleEntities(props) {
|
|
40
38
|
const value = props.sdk.field.getValue();
|
|
41
39
|
const linkCount = Array.isArray(value) ? value.length : value ? 1 : 0;
|
|
42
|
-
// TODO: Why not always set `min: 1` by default? Does it make sense to enforce
|
|
43
|
-
// user to select as many entities as the field's "min" requires? What if e.g.
|
|
44
|
-
// "min" is 4 and the user wants to insert 2 entities first, then create 2 new ones?
|
|
45
40
|
const min = Math.max((props.editorPermissions.validations.numberOfLinks?.min || 1) - linkCount, 1);
|
|
46
|
-
// TODO: Consider same for max. If e.g. "max" is 4, we disable the button if the
|
|
47
|
-
// user wants to select 5 but we show no information why the button is disabled.
|
|
48
41
|
const max = (props.editorPermissions.validations.numberOfLinks?.max || +Infinity) - linkCount;
|
|
49
42
|
if (props.entityType === 'Entry') {
|
|
50
43
|
return await props.sdk.dialogs.selectMultipleEntries({
|
|
51
44
|
locale: props.sdk.field.locale,
|
|
52
|
-
// readable CTs do not cover cases where user has partial access to a CT entry,
|
|
53
|
-
// e.g. via tags so we're passing in all available CTs (based on field validations)
|
|
54
45
|
contentTypes: getContentTypeIds(props.editorPermissions.availableContentTypes),
|
|
55
46
|
min,
|
|
56
47
|
max
|
|
@@ -3,20 +3,20 @@ import { Card, Flex, IconButton, SectionHeading } from '@contentful/f36-componen
|
|
|
3
3
|
import { CloseIcon } from '@contentful/f36-icons';
|
|
4
4
|
import * as styles from './styles';
|
|
5
5
|
export function MissingEntityCard(props) {
|
|
6
|
-
return
|
|
6
|
+
return React.createElement(Card, {
|
|
7
7
|
className: styles.card,
|
|
8
8
|
testId: "cf-ui-missing-entry-card",
|
|
9
9
|
isSelected: props.isSelected
|
|
10
|
-
},
|
|
10
|
+
}, React.createElement(Flex, {
|
|
11
11
|
alignItems: "center",
|
|
12
12
|
justifyContent: "space-between"
|
|
13
|
-
},
|
|
13
|
+
}, React.createElement("div", {
|
|
14
14
|
className: props.asSquare ? styles.squareCard : ''
|
|
15
|
-
},
|
|
15
|
+
}, React.createElement(SectionHeading, {
|
|
16
16
|
marginBottom: "none"
|
|
17
|
-
}, props.entityType, " is missing or inaccessible")), !props.isDisabled && props.onRemove &&
|
|
17
|
+
}, props.entityType, " is missing or inaccessible")), !props.isDisabled && props.onRemove && React.createElement(IconButton, {
|
|
18
18
|
variant: "transparent",
|
|
19
|
-
icon:
|
|
19
|
+
icon: React.createElement(CloseIcon, {
|
|
20
20
|
variant: "muted"
|
|
21
21
|
}),
|
|
22
22
|
"aria-label": "Delete",
|
|
@@ -4,12 +4,12 @@ import { MissingEntityCard } from '../MissingEntityCard/MissingEntityCard';
|
|
|
4
4
|
import { UnsupportedEntityCard } from './UnsupportedEntityCard';
|
|
5
5
|
export function ResourceEntityErrorCard(props) {
|
|
6
6
|
if (isUnsupportedError(props.error)) {
|
|
7
|
-
return
|
|
7
|
+
return React.createElement(UnsupportedEntityCard, {
|
|
8
8
|
linkType: props.linkType,
|
|
9
9
|
isSelected: props.isSelected
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
|
-
return
|
|
12
|
+
return React.createElement(MissingEntityCard, {
|
|
13
13
|
entityType: "Entry",
|
|
14
14
|
isDisabled: props.isDisabled,
|
|
15
15
|
isSelected: props.isSelected,
|
|
@@ -7,10 +7,10 @@ const styles = {
|
|
|
7
7
|
})
|
|
8
8
|
};
|
|
9
9
|
export function UnsupportedEntityCard(props) {
|
|
10
|
-
return
|
|
10
|
+
return React.createElement(Card, {
|
|
11
11
|
className: styles.card,
|
|
12
12
|
isSelected: props.isSelected
|
|
13
|
-
},
|
|
13
|
+
}, React.createElement(SectionHeading, {
|
|
14
14
|
marginBottom: "none"
|
|
15
15
|
}, "Resource type ", props.linkType, " is currently not supported"));
|
|
16
16
|
}
|
|
@@ -6,7 +6,7 @@ export const getScheduleTooltipContent = ({ job, jobsCount })=>{
|
|
|
6
6
|
${jobsCount > 1 ? `+ ${jobsCount - 1} more` : ''}`;
|
|
7
7
|
};
|
|
8
8
|
export const ScheduleTooltip = ({ job, jobsCount, children })=>{
|
|
9
|
-
return
|
|
9
|
+
return React.createElement(Tooltip, {
|
|
10
10
|
placement: "top",
|
|
11
11
|
testId: job.sys.id,
|
|
12
12
|
as: "div",
|
|
@@ -16,9 +16,6 @@ export const ScheduledIconWithTooltip = ({ entityType, entityId, getEntitySchedu
|
|
|
16
16
|
error: e
|
|
17
17
|
});
|
|
18
18
|
});
|
|
19
|
-
// This should only be ever called once. Following the eslint hint to add used
|
|
20
|
-
// dependencies will cause page freeze (infinite loop)
|
|
21
|
-
// eslint-disable-next-line -- TODO: describe this disable
|
|
22
19
|
}, []);
|
|
23
20
|
if (status.type === 'loading' || status.type === 'error') {
|
|
24
21
|
return null;
|
|
@@ -28,7 +25,7 @@ export const ScheduledIconWithTooltip = ({ entityType, entityId, getEntitySchedu
|
|
|
28
25
|
return null;
|
|
29
26
|
}
|
|
30
27
|
const mostRelevantJob = jobs[0];
|
|
31
|
-
return
|
|
28
|
+
return React.createElement(ScheduleTooltip, {
|
|
32
29
|
job: mostRelevantJob,
|
|
33
30
|
jobsCount: jobs.length
|
|
34
31
|
}, children);
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
// eslint-disable-next-line -- TODO: describe this disable no-restricted-imports
|
|
2
1
|
import moment from 'moment';
|
|
3
|
-
|
|
4
|
-
* @param {Date|string} date A valid constructor argument for moment()
|
|
5
|
-
* @param {boolean=} short Render only Today/Tomorrow/Yesterday if valid. Defaults to false
|
|
6
|
-
*/ export const formatDate = (date, short)=>{
|
|
2
|
+
export const formatDate = (date, short)=>{
|
|
7
3
|
switch(moment().startOf('day').diff(moment(date).startOf('day'), 'days')){
|
|
8
4
|
case 0:
|
|
9
5
|
return short ? 'Today' : `Today, ${moment(date).format('DD MMM YYYY')}`;
|
|
@@ -15,12 +11,7 @@ import moment from 'moment';
|
|
|
15
11
|
return moment(date).format('ddd, DD MMM YYYY');
|
|
16
12
|
}
|
|
17
13
|
};
|
|
18
|
-
|
|
19
|
-
* Returns the time portion of a date in the local time in the format H:MM AM/PM
|
|
20
|
-
*
|
|
21
|
-
* == Examples
|
|
22
|
-
* * `T15:36:45.000Z` => 3:36 PM (if in +0:00 offset)
|
|
23
|
-
*/ export const formatTime = (date)=>{
|
|
14
|
+
export const formatTime = (date)=>{
|
|
24
15
|
return moment.utc(date).local().format('h:mm A');
|
|
25
16
|
};
|
|
26
17
|
export const formatDateAndTime = (date, short)=>{
|
|
@@ -21,18 +21,18 @@ const styles = {
|
|
|
21
21
|
export function SpaceName(props) {
|
|
22
22
|
let content = `Space: ${props.spaceName}`;
|
|
23
23
|
if (props.environmentName) content += ` (Env.: ${props.environmentName})`;
|
|
24
|
-
return
|
|
24
|
+
return React.createElement(Tooltip, {
|
|
25
25
|
placement: "top",
|
|
26
26
|
as: "div",
|
|
27
27
|
content: content
|
|
28
|
-
},
|
|
28
|
+
}, React.createElement(Flex, {
|
|
29
29
|
alignItems: "center",
|
|
30
30
|
gap: "spacingXs"
|
|
31
|
-
},
|
|
31
|
+
}, React.createElement(FolderOpenTrimmedIcon, {
|
|
32
32
|
className: styles.spaceIcon,
|
|
33
33
|
size: "tiny",
|
|
34
34
|
"aria-label": "Source space"
|
|
35
|
-
}),
|
|
35
|
+
}), React.createElement(Text, {
|
|
36
36
|
className: styles.spaceName
|
|
37
37
|
}, props.spaceName)));
|
|
38
38
|
}
|
|
@@ -8,17 +8,17 @@ export function MultipleEntryReferenceEditor(props) {
|
|
|
8
8
|
const updateBeforeSortStart = ({ index })=>{
|
|
9
9
|
setIndexToUpdate(index);
|
|
10
10
|
};
|
|
11
|
-
return
|
|
11
|
+
return React.createElement(MultipleReferenceEditor, {
|
|
12
12
|
...props,
|
|
13
13
|
entityType: "Entry",
|
|
14
14
|
setIndexToUpdate: setIndexToUpdate
|
|
15
|
-
}, (childrenProps)
|
|
15
|
+
}, (childrenProps)=>React.createElement(SortableLinkList, {
|
|
16
16
|
...childrenProps,
|
|
17
17
|
sortingStrategy: verticalListSortingStrategy,
|
|
18
18
|
updateBeforeSortStart: updateBeforeSortStart
|
|
19
19
|
}, ({ items, item, index, isDisabled, DragHandle })=>{
|
|
20
20
|
const lastIndex = items.length - 1;
|
|
21
|
-
return
|
|
21
|
+
return React.createElement(FetchingWrappedEntryCard, {
|
|
22
22
|
...childrenProps,
|
|
23
23
|
key: `${item.sys.id}-${index}`,
|
|
24
24
|
index: index,
|
|
@@ -2,11 +2,11 @@ import * as React from 'react';
|
|
|
2
2
|
import { SingleReferenceEditor } from '../common/SingleReferenceEditor';
|
|
3
3
|
import { FetchingWrappedEntryCard } from './WrappedEntryCard/FetchingWrappedEntryCard';
|
|
4
4
|
export function SingleEntryReferenceEditor(props) {
|
|
5
|
-
return
|
|
5
|
+
return React.createElement(SingleReferenceEditor, {
|
|
6
6
|
...props,
|
|
7
7
|
entityType: "Entry"
|
|
8
8
|
}, ({ allContentTypes, isDisabled, entityId, setValue, renderCustomCard, hasCardRemoveActions, hasCardEditActions })=>{
|
|
9
|
-
return
|
|
9
|
+
return React.createElement(FetchingWrappedEntryCard, {
|
|
10
10
|
...props,
|
|
11
11
|
allContentTypes: allContentTypes,
|
|
12
12
|
isDisabled: isDisabled,
|
|
@@ -15,10 +15,7 @@ async function openEntry(sdk, entryId, options) {
|
|
|
15
15
|
});
|
|
16
16
|
slide = result.slide;
|
|
17
17
|
return slide;
|
|
18
|
-
} catch (e) {
|
|
19
|
-
// we don't allow to open multiple bulk editors for performance reasons
|
|
20
|
-
// proceed with a default openEntry
|
|
21
|
-
}
|
|
18
|
+
} catch (e) {}
|
|
22
19
|
}
|
|
23
20
|
const result = await sdk.navigator.openEntry(entryId, {
|
|
24
21
|
slideIn: true
|
|
@@ -65,13 +62,12 @@ export function FetchingWrappedEntryCard(props) {
|
|
|
65
62
|
entity: 'Entry'
|
|
66
63
|
});
|
|
67
64
|
}
|
|
68
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
|
|
69
65
|
}, [
|
|
70
66
|
entry
|
|
71
67
|
]);
|
|
72
68
|
return React.useMemo(()=>{
|
|
73
69
|
if (status === 'error') {
|
|
74
|
-
const card =
|
|
70
|
+
const card = React.createElement(MissingEntityCard, {
|
|
75
71
|
entityType: "Entry",
|
|
76
72
|
isDisabled: props.isDisabled,
|
|
77
73
|
onRemove: onRemoveEntry
|
|
@@ -88,7 +84,7 @@ export function FetchingWrappedEntryCard(props) {
|
|
|
88
84
|
return card;
|
|
89
85
|
}
|
|
90
86
|
if (status === 'loading') {
|
|
91
|
-
return
|
|
87
|
+
return React.createElement(EntryCard, {
|
|
92
88
|
size: size,
|
|
93
89
|
isLoading: true
|
|
94
90
|
});
|
|
@@ -119,21 +115,18 @@ export function FetchingWrappedEntryCard(props) {
|
|
|
119
115
|
hasCardRemoveActions,
|
|
120
116
|
getAsset,
|
|
121
117
|
getEntityScheduledActions: loadEntityScheduledActions,
|
|
122
|
-
entry:
|
|
118
|
+
entry: props?.entity || sharedCardProps.entity,
|
|
123
119
|
entryUrl: props?.entityUrl || sharedCardProps.entityUrl
|
|
124
120
|
};
|
|
125
|
-
return
|
|
121
|
+
return React.createElement(WrappedEntryCard, builtinCardProps);
|
|
126
122
|
}
|
|
127
123
|
if (props.renderCustomCard) {
|
|
128
|
-
// LinkActionsProps are injected higher SingleReferenceEditor/MultipleReferenceEditor
|
|
129
124
|
const renderedCustomCard = props.renderCustomCard(sharedCardProps, {}, renderDefaultCard);
|
|
130
|
-
// Only `false` indicates to render the original card. E.g. `null` would result in no card.
|
|
131
125
|
if (renderedCustomCard !== false) {
|
|
132
126
|
return renderedCustomCard;
|
|
133
127
|
}
|
|
134
128
|
}
|
|
135
129
|
return renderDefaultCard();
|
|
136
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
|
|
137
130
|
}, [
|
|
138
131
|
props,
|
|
139
132
|
status,
|
|
@@ -43,7 +43,7 @@ export function WrappedEntryCard(props) {
|
|
|
43
43
|
]);
|
|
44
44
|
const status = getEntryStatus(props.entry?.sys);
|
|
45
45
|
if (status === 'deleted') {
|
|
46
|
-
return
|
|
46
|
+
return React.createElement(MissingEntityCard, {
|
|
47
47
|
entityType: "Entry",
|
|
48
48
|
isDisabled: props.isDisabled,
|
|
49
49
|
onRemove: props.onRemove
|
|
@@ -62,7 +62,7 @@ export function WrappedEntryCard(props) {
|
|
|
62
62
|
localeCode: props.localeCode,
|
|
63
63
|
defaultLocaleCode: props.defaultLocaleCode
|
|
64
64
|
});
|
|
65
|
-
return
|
|
65
|
+
return React.createElement(EntryCard, {
|
|
66
66
|
as: props.entryUrl ? 'a' : 'article',
|
|
67
67
|
href: props.entryUrl,
|
|
68
68
|
title: title,
|
|
@@ -71,58 +71,54 @@ export function WrappedEntryCard(props) {
|
|
|
71
71
|
size: props.size,
|
|
72
72
|
isSelected: props.isSelected,
|
|
73
73
|
status: status,
|
|
74
|
-
icon: props.spaceName ?
|
|
74
|
+
icon: props.spaceName ? React.createElement(SpaceName, {
|
|
75
75
|
spaceName: props.spaceName,
|
|
76
76
|
environmentName: props.entry.sys.environment.sys.id
|
|
77
|
-
}) :
|
|
77
|
+
}) : React.createElement(ScheduledIconWithTooltip, {
|
|
78
78
|
getEntityScheduledActions: props.getEntityScheduledActions,
|
|
79
79
|
entityType: "Entry",
|
|
80
80
|
entityId: props.entry.sys.id
|
|
81
|
-
},
|
|
81
|
+
}, React.createElement(ClockIcon, {
|
|
82
82
|
className: styles.scheduleIcon,
|
|
83
83
|
size: "small",
|
|
84
84
|
variant: "muted",
|
|
85
85
|
testId: "schedule-icon"
|
|
86
86
|
})),
|
|
87
|
-
thumbnailElement: file && isValidImage(file) ?
|
|
87
|
+
thumbnailElement: file && isValidImage(file) ? React.createElement(AssetThumbnail, {
|
|
88
88
|
file: file
|
|
89
89
|
}) : undefined,
|
|
90
90
|
dragHandleRender: props.renderDragHandle,
|
|
91
91
|
withDragHandle: !!props.renderDragHandle,
|
|
92
92
|
actions: props.onEdit || props.onRemove ? [
|
|
93
|
-
props.hasCardEditActions && props.onEdit ?
|
|
93
|
+
props.hasCardEditActions && props.onEdit ? React.createElement(MenuItem, {
|
|
94
94
|
key: "edit",
|
|
95
95
|
testId: "edit",
|
|
96
96
|
onClick: ()=>{
|
|
97
97
|
props.onEdit && props.onEdit();
|
|
98
98
|
}
|
|
99
99
|
}, "Edit") : null,
|
|
100
|
-
props.hasCardRemoveActions && props.onRemove ?
|
|
100
|
+
props.hasCardRemoveActions && props.onRemove ? React.createElement(MenuItem, {
|
|
101
101
|
key: "delete",
|
|
102
102
|
testId: "delete",
|
|
103
103
|
onClick: ()=>{
|
|
104
104
|
props.onRemove && props.onRemove();
|
|
105
105
|
}
|
|
106
106
|
}, "Remove") : null,
|
|
107
|
-
props.hasCardMoveActions && (props.onMoveTop || props.onMoveBottom) ?
|
|
107
|
+
props.hasCardMoveActions && (props.onMoveTop || props.onMoveBottom) ? React.createElement(MenuDivider, {
|
|
108
108
|
key: "divider"
|
|
109
109
|
}) : null,
|
|
110
|
-
props.hasCardMoveActions && props.onMoveTop ?
|
|
110
|
+
props.hasCardMoveActions && props.onMoveTop ? React.createElement(MenuItem, {
|
|
111
111
|
key: "move-top",
|
|
112
112
|
onClick: ()=>props.onMoveTop && props.onMoveTop(),
|
|
113
113
|
testId: "move-top"
|
|
114
114
|
}, "Move to top") : null,
|
|
115
|
-
props.hasCardMoveActions && props.onMoveBottom ?
|
|
115
|
+
props.hasCardMoveActions && props.onMoveBottom ? React.createElement(MenuItem, {
|
|
116
116
|
key: "move-bottom",
|
|
117
117
|
onClick: ()=>props.onMoveBottom && props.onMoveBottom(),
|
|
118
118
|
testId: "move-bottom"
|
|
119
119
|
}, "Move to bottom") : null
|
|
120
120
|
].filter((item)=>item) : [],
|
|
121
|
-
onClick:
|
|
122
|
-
// features e.g. pressing ENTER on a card to add a new paragraph
|
|
123
|
-
// underneath. It's crucial not to pass a custom handler when
|
|
124
|
-
// isClickable is disabled which in the case of RT it's.
|
|
125
|
-
props.isClickable ? (e)=>{
|
|
121
|
+
onClick: props.isClickable ? (e)=>{
|
|
126
122
|
e.preventDefault();
|
|
127
123
|
if (props.onClick) return props.onClick(e);
|
|
128
124
|
props.onEdit && props.onEdit();
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { WrappedEntryCard } from '../../entries';
|
|
3
|
-
// assets are not shown for small cards (which we hardcode currently)
|
|
4
3
|
const resolveAsset = ()=>Promise.resolve();
|
|
5
|
-
// we don't want to show scheduled actions for resources
|
|
6
4
|
const resolveScheduledActions = ()=>Promise.resolve([]);
|
|
7
5
|
export function ContentfulEntryCard({ info, isDisabled, renderDragHandle, onRemove, onMoveTop, onMoveBottom, getEntryRouteHref }) {
|
|
8
6
|
const resourceSys = info.resource.sys;
|
|
@@ -14,19 +12,14 @@ export function ContentfulEntryCard({ info, isDisabled, renderDragHandle, onRemo
|
|
|
14
12
|
environmentId,
|
|
15
13
|
entryId
|
|
16
14
|
});
|
|
17
|
-
// TODO: move this into `sdk.navigator.openEntry()`, note that it's signature only include the entry id (not a space or environment)
|
|
18
15
|
const openEntryDetail = ()=>{
|
|
19
16
|
window.open(resourceHref, '_blank', 'noopener,noreferrer');
|
|
20
17
|
};
|
|
21
|
-
return
|
|
18
|
+
return React.createElement(WrappedEntryCard, {
|
|
22
19
|
entry: info.resource,
|
|
23
20
|
isDisabled: isDisabled,
|
|
24
21
|
hasCardEditActions: false,
|
|
25
22
|
contentType: info.contentType,
|
|
26
|
-
// we use the default locale from the space the entry belongs to
|
|
27
|
-
// as we assume this gives a more consistent behaviour.
|
|
28
|
-
// locales will inevitably differ from space to space, so it's likely
|
|
29
|
-
// that the current locale does not exist in the "remote" space
|
|
30
23
|
localeCode: info.defaultLocaleCode,
|
|
31
24
|
defaultLocaleCode: info.defaultLocaleCode,
|
|
32
25
|
size: "small",
|
|
@@ -5,7 +5,7 @@ import { useResource } from '../../common/EntityStore';
|
|
|
5
5
|
import { ResourceEntityErrorCard } from '../../components';
|
|
6
6
|
import { ContentfulEntryCard } from './ContentfulEntryCard';
|
|
7
7
|
function ResourceCardSkeleton() {
|
|
8
|
-
return
|
|
8
|
+
return React.createElement(EntryCard, {
|
|
9
9
|
size: "small",
|
|
10
10
|
isLoading: true
|
|
11
11
|
});
|
|
@@ -18,16 +18,15 @@ function ExistingResourceCard(props) {
|
|
|
18
18
|
};
|
|
19
19
|
const { data, error } = useResource(resourceLink.sys.linkType, resourceLink.sys.urn, resourceOptions);
|
|
20
20
|
if (!data && !error) {
|
|
21
|
-
return
|
|
21
|
+
return React.createElement(ResourceCardSkeleton, null);
|
|
22
22
|
}
|
|
23
23
|
if (data) {
|
|
24
|
-
|
|
25
|
-
return /*#__PURE__*/ React.createElement(ContentfulEntryCard, {
|
|
24
|
+
return React.createElement(ContentfulEntryCard, {
|
|
26
25
|
info: data,
|
|
27
26
|
...props
|
|
28
27
|
});
|
|
29
28
|
}
|
|
30
|
-
return
|
|
29
|
+
return React.createElement(ResourceEntityErrorCard, {
|
|
31
30
|
linkType: resourceLink.sys.linkType,
|
|
32
31
|
error: error,
|
|
33
32
|
isDisabled: props.isDisabled,
|
|
@@ -38,7 +37,7 @@ function ResourceCardWrapper(props) {
|
|
|
38
37
|
if (!props.resourceLink) {
|
|
39
38
|
return null;
|
|
40
39
|
}
|
|
41
|
-
return
|
|
40
|
+
return React.createElement(ExistingResourceCard, {
|
|
42
41
|
...props,
|
|
43
42
|
resourceLink: props.resourceLink,
|
|
44
43
|
getEntryRouteHref: props.getEntryRouteHref
|
|
@@ -49,10 +48,9 @@ export function ResourceCard(props) {
|
|
|
49
48
|
triggerOnce: true,
|
|
50
49
|
rootMargin: '300px 0px 0px 300px'
|
|
51
50
|
});
|
|
52
|
-
|
|
53
|
-
return /*#__PURE__*/ React.createElement("div", {
|
|
51
|
+
return React.createElement("div", {
|
|
54
52
|
ref: ref
|
|
55
|
-
},
|
|
53
|
+
}, React.createElement(ResourceCardWrapper, {
|
|
56
54
|
...props,
|
|
57
55
|
inView: inView
|
|
58
56
|
}));
|
|
@@ -14,7 +14,6 @@ configure({
|
|
|
14
14
|
jest.mock('react-intersection-observer', ()=>({
|
|
15
15
|
useInView: jest.fn().mockReturnValue({})
|
|
16
16
|
}));
|
|
17
|
-
// explicit master
|
|
18
17
|
const resolvableEntryUrn = 'crn:contentful:::content:spaces/space-id/entries/linked-entry-urn';
|
|
19
18
|
const resolvableEntryUrnWithExplicitMaster = 'crn:contentful:::content:spaces/space-id/environments/master/entries/linked-entry-urn';
|
|
20
19
|
const resolvableEntryUrnWithAnotherEnvironment = 'crn:contentful:::content:spaces/space-id/environments/my-test-environment/entries/linked-entry-urn';
|
|
@@ -68,9 +67,9 @@ const sdk = {
|
|
|
68
67
|
}
|
|
69
68
|
};
|
|
70
69
|
function renderResourceCard({ linkType = 'Contentful:Entry', entryUrn = resolvableEntryUrn } = {}) {
|
|
71
|
-
return render(
|
|
70
|
+
return render(React.createElement(EntityProvider, {
|
|
72
71
|
sdk: sdk
|
|
73
|
-
},
|
|
72
|
+
}, React.createElement(ResourceCard, {
|
|
74
73
|
isDisabled: false,
|
|
75
74
|
getEntryRouteHref: ()=>'',
|
|
76
75
|
resourceLink: {
|
|
@@ -38,18 +38,17 @@ function ResourceEditor(props) {
|
|
|
38
38
|
field,
|
|
39
39
|
apiUrl
|
|
40
40
|
});
|
|
41
|
-
return
|
|
41
|
+
return React.createElement(React.Fragment, null, props.children({
|
|
42
42
|
...props,
|
|
43
43
|
onSortStart,
|
|
44
44
|
onSortEnd,
|
|
45
45
|
onMove,
|
|
46
46
|
onRemoteItemAtIndex
|
|
47
|
-
}),
|
|
47
|
+
}), React.createElement(CombinedLinkEntityActions, {
|
|
48
48
|
...linkActionsProps,
|
|
49
49
|
renderCustomActions: props.renderCustomActions
|
|
50
50
|
}));
|
|
51
51
|
}
|
|
52
|
-
// provides memoized callbacks bound to a given item
|
|
53
52
|
function WithPerItemCallbacks({ listLength, index, onMove, onRemoteItemAtIndex, children }) {
|
|
54
53
|
const handleMoveTop = React.useMemo(()=>index > 0 ? ()=>onMove(index, 0) : undefined, [
|
|
55
54
|
index,
|
|
@@ -64,7 +63,7 @@ function WithPerItemCallbacks({ listLength, index, onMove, onRemoteItemAtIndex,
|
|
|
64
63
|
index,
|
|
65
64
|
onRemoteItemAtIndex
|
|
66
65
|
]);
|
|
67
|
-
return
|
|
66
|
+
return React.createElement(React.Fragment, null, children({
|
|
68
67
|
onMoveBottom: handleMoveBottom,
|
|
69
68
|
onMoveTop: handleMoveTop,
|
|
70
69
|
onRemove: handleRemove
|
|
@@ -72,28 +71,28 @@ function WithPerItemCallbacks({ listLength, index, onMove, onRemoteItemAtIndex,
|
|
|
72
71
|
}
|
|
73
72
|
const EMPTY_ARRAY = [];
|
|
74
73
|
export function MultipleResourceReferenceEditor(props) {
|
|
75
|
-
return
|
|
74
|
+
return React.createElement(EntityProvider, {
|
|
76
75
|
sdk: props.sdk
|
|
77
|
-
},
|
|
76
|
+
}, React.createElement(FieldConnector, {
|
|
78
77
|
debounce: 0,
|
|
79
78
|
field: props.sdk.field,
|
|
80
79
|
isInitiallyDisabled: props.isInitiallyDisabled,
|
|
81
80
|
isEqualValues: deepEqual
|
|
82
81
|
}, ({ value, disabled, setValue, externalReset })=>{
|
|
83
|
-
return
|
|
82
|
+
return React.createElement(ResourceEditor, {
|
|
84
83
|
...props,
|
|
85
84
|
items: value || EMPTY_ARRAY,
|
|
86
85
|
isDisabled: disabled,
|
|
87
86
|
setValue: setValue,
|
|
88
87
|
renderCustomActions: props.renderCustomActions,
|
|
89
88
|
key: `${externalReset}-list`
|
|
90
|
-
}, (editorProps)
|
|
89
|
+
}, (editorProps)=>React.createElement(SortableLinkList, editorProps, ({ item, isDisabled, DragHandle, index })=>React.createElement(WithPerItemCallbacks, {
|
|
91
90
|
key: index,
|
|
92
91
|
index: index,
|
|
93
92
|
onMove: editorProps.onMove,
|
|
94
93
|
onRemoteItemAtIndex: editorProps.onRemoteItemAtIndex,
|
|
95
94
|
listLength: value?.length || 0
|
|
96
|
-
}, ({ onMoveBottom, onMoveTop, onRemove })
|
|
95
|
+
}, ({ onMoveBottom, onMoveTop, onRemove })=>React.createElement(ResourceCard, {
|
|
97
96
|
key: index,
|
|
98
97
|
index: index,
|
|
99
98
|
resourceLink: item,
|