@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
|
@@ -21,20 +21,15 @@ export function useEditorPermissions(props) {
|
|
|
21
21
|
}
|
|
22
22
|
async function checkCreateAccess() {
|
|
23
23
|
if (entityType === 'Asset') {
|
|
24
|
-
// Hardcoded `true` value following https://contentful.atlassian.net/browse/DANTE-486
|
|
25
|
-
// TODO: refine permissions check in order to account for tags in rules
|
|
26
24
|
const canCreate = await canPerformAction('create', 'Asset') || true;
|
|
27
25
|
setCanCreateEntity(canCreate);
|
|
28
26
|
}
|
|
29
27
|
if (entityType === 'Entry') {
|
|
30
|
-
// Hardcoded `true` value following https://contentful.atlassian.net/browse/DANTE-486
|
|
31
|
-
// TODO: refine permissions check in order to account for tags in rules
|
|
32
28
|
const canCreate = creatableContentTypes.length > 0 || true;
|
|
33
29
|
setCanCreateEntity(canCreate);
|
|
34
30
|
}
|
|
35
31
|
}
|
|
36
32
|
void checkCreateAccess();
|
|
37
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
|
|
38
33
|
}, [
|
|
39
34
|
entityType,
|
|
40
35
|
parameters.instance,
|
|
@@ -47,22 +42,15 @@ export function useEditorPermissions(props) {
|
|
|
47
42
|
}
|
|
48
43
|
async function checkLinkAccess() {
|
|
49
44
|
if (entityType === 'Asset') {
|
|
50
|
-
// Hardcoded `true` value following https://contentful.atlassian.net/browse/DANTE-486
|
|
51
|
-
// TODO: refine permissions check in order to account for tags in rules
|
|
52
45
|
const canRead = await canPerformAction('read', 'Asset') || true;
|
|
53
46
|
setCanLinkEntity(canRead);
|
|
54
47
|
}
|
|
55
48
|
if (entityType === 'Entry') {
|
|
56
|
-
// Hardcoded `true` value following https://contentful.atlassian.net/browse/DANTE-486
|
|
57
|
-
// TODO: refine permissions check in order to account for tags in rules
|
|
58
|
-
// TODO: always show every content type (it's just a filter) to avoid people not seeing
|
|
59
|
-
// their (partly limited) content types
|
|
60
49
|
const canRead = true;
|
|
61
50
|
setCanLinkEntity(canRead);
|
|
62
51
|
}
|
|
63
52
|
}
|
|
64
53
|
void checkLinkAccess();
|
|
65
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
|
|
66
54
|
}, [
|
|
67
55
|
entityType,
|
|
68
56
|
parameters.instance
|
|
@@ -130,7 +130,6 @@ describe('useEditorPermissions', ()=>{
|
|
|
130
130
|
});
|
|
131
131
|
expect(result.current.canLinkEntity).toBe(true);
|
|
132
132
|
});
|
|
133
|
-
// eslint-disable-next-line -- TODO: describe this disable jest/no-test-prefixes
|
|
134
133
|
it.skip(`denies creation when no content-type can be read`, async ()=>{
|
|
135
134
|
const allContentTypes = [
|
|
136
135
|
makeContentType('one'),
|
|
@@ -4,7 +4,7 @@ const dimensions = {
|
|
|
4
4
|
height: 70
|
|
5
5
|
};
|
|
6
6
|
export function AssetThumbnail(props) {
|
|
7
|
-
return
|
|
7
|
+
return React.createElement("img", {
|
|
8
8
|
alt: props.file.fileName,
|
|
9
9
|
src: `${props.file.url}?w=${dimensions.width}&h=${dimensions.height}&fit=thumb`,
|
|
10
10
|
height: dimensions.height,
|
|
@@ -24,12 +24,10 @@ export const CreateEntryLinkButton = ({ contentTypes, onSelect, customDropdownIt
|
|
|
24
24
|
const suggestedContentType = contentTypes.find((ct)=>ct.sys.id === suggestedContentTypeId);
|
|
25
25
|
const buttonText = text || `Add ${get(suggestedContentType || (contentTypes.length === 1 ? contentTypes[0] : {}), 'name', 'entry')}`;
|
|
26
26
|
const hasDropdown = contentTypes.length > 1 || customDropdownItems;
|
|
27
|
-
|
|
28
|
-
const plusIcon = hasPlusIcon ? /*#__PURE__*/ React.createElement(PlusIcon, null) : undefined;
|
|
29
|
-
// TODO: Always use "New content" here if we fully switch to new layout.
|
|
27
|
+
const plusIcon = hasPlusIcon ? React.createElement(PlusIcon, null) : undefined;
|
|
30
28
|
const contentTypesLabel = useExperimentalStyles ? 'New content' : undefined;
|
|
31
29
|
const styles = useExperimentalStyles ? redesignStyles : standardStyles;
|
|
32
|
-
return
|
|
30
|
+
return React.createElement(CreateEntryMenuTrigger, {
|
|
33
31
|
contentTypes: contentTypes,
|
|
34
32
|
suggestedContentTypeId: suggestedContentTypeId,
|
|
35
33
|
contentTypesLabel: contentTypesLabel,
|
|
@@ -37,8 +35,8 @@ export const CreateEntryLinkButton = ({ contentTypes, onSelect, customDropdownIt
|
|
|
37
35
|
testId: testId,
|
|
38
36
|
dropdownSettings: dropdownSettings,
|
|
39
37
|
customDropdownItems: customDropdownItems
|
|
40
|
-
}, ({ isSelecting })
|
|
41
|
-
endIcon: hasDropdown ?
|
|
38
|
+
}, ({ isSelecting })=>React.createElement(Button, {
|
|
39
|
+
endIcon: hasDropdown ? React.createElement(ChevronDownIcon, null) : undefined,
|
|
42
40
|
variant: "secondary",
|
|
43
41
|
className: styles.action,
|
|
44
42
|
isDisabled: disabled || isSelecting,
|
|
@@ -37,14 +37,14 @@ describe('CreateEntryLinkButton general', ()=>{
|
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
39
|
it('renders with multiple content types as list', ()=>{
|
|
40
|
-
const { getByTestId } = render(
|
|
40
|
+
const { getByTestId } = render(React.createElement(CreateEntryLinkButton, props));
|
|
41
41
|
expect(getByTestId('create-entry-button-menu-trigger')).toBeDefined();
|
|
42
42
|
const link = findButton(getByTestId);
|
|
43
43
|
expect(link).toBeDefined();
|
|
44
44
|
expect(link.textContent).toBe('Add entry');
|
|
45
45
|
});
|
|
46
46
|
it('renders dropdown menu on click when with multiple content types', ()=>{
|
|
47
|
-
const { getByTestId } = render(
|
|
47
|
+
const { getByTestId } = render(React.createElement(CreateEntryLinkButton, props));
|
|
48
48
|
fireEvent.click(findButton(getByTestId));
|
|
49
49
|
const menu = getByTestId('add-entry-menu');
|
|
50
50
|
expect(menu).toBeDefined();
|
|
@@ -54,7 +54,7 @@ describe('CreateEntryLinkButton general', ()=>{
|
|
|
54
54
|
});
|
|
55
55
|
it('renders suggestedContentType as text when given', ()=>{
|
|
56
56
|
const suggestedContentTypeId = 'ID_2';
|
|
57
|
-
const { getByTestId } = render(
|
|
57
|
+
const { getByTestId } = render(React.createElement(CreateEntryLinkButton, {
|
|
58
58
|
...props,
|
|
59
59
|
suggestedContentTypeId: suggestedContentTypeId
|
|
60
60
|
}));
|
|
@@ -64,7 +64,7 @@ describe('CreateEntryLinkButton general', ()=>{
|
|
|
64
64
|
expect(button.textContent).toBe(`Add ${CONTENT_TYPE_2.name}`);
|
|
65
65
|
});
|
|
66
66
|
it('renders the name of the content type as part of the text if only 1 content type is given', ()=>{
|
|
67
|
-
const { getByTestId } = render(
|
|
67
|
+
const { getByTestId } = render(React.createElement(CreateEntryLinkButton, {
|
|
68
68
|
onSelect: props.onSelect,
|
|
69
69
|
contentTypes: [
|
|
70
70
|
CONTENT_TYPE_1
|
|
@@ -80,7 +80,7 @@ describe('CreateEntryLinkButton general', ()=>{
|
|
|
80
80
|
text: 'CUSTOM_TEXT',
|
|
81
81
|
hasPlusIcon: true
|
|
82
82
|
};
|
|
83
|
-
const { getByTestId } = render(
|
|
83
|
+
const { getByTestId } = render(React.createElement(CreateEntryLinkButton, {
|
|
84
84
|
...props,
|
|
85
85
|
...propsOverrides
|
|
86
86
|
}));
|
|
@@ -101,13 +101,13 @@ describe('CreateEntryLinkButton with multiple entries', ()=>{
|
|
|
101
101
|
}
|
|
102
102
|
};
|
|
103
103
|
it('should render dropdown items for each content type', ()=>{
|
|
104
|
-
const { getByTestId, getAllByTestId } = render(
|
|
104
|
+
const { getByTestId, getAllByTestId } = render(React.createElement(CreateEntryLinkButton, props));
|
|
105
105
|
fireEvent.click(findButton(getByTestId));
|
|
106
106
|
expect(getAllByTestId('contentType')).toHaveLength(props.contentTypes.length);
|
|
107
107
|
});
|
|
108
108
|
it('calls onSelect after click on menu item', ()=>{
|
|
109
109
|
const selectSpy = jest.fn();
|
|
110
|
-
const { getByTestId, getAllByTestId } = render(
|
|
110
|
+
const { getByTestId, getAllByTestId } = render(React.createElement(CreateEntryLinkButton, {
|
|
111
111
|
...props,
|
|
112
112
|
onSelect: selectSpy
|
|
113
113
|
}));
|
|
@@ -127,7 +127,7 @@ describe('CreateEntryLinkButton with a single entry', ()=>{
|
|
|
127
127
|
};
|
|
128
128
|
it('should fire the onSelect function when clicked', ()=>{
|
|
129
129
|
const onSelectStub = jest.fn();
|
|
130
|
-
const { getByTestId } = render(
|
|
130
|
+
const { getByTestId } = render(React.createElement(CreateEntryLinkButton, {
|
|
131
131
|
...props,
|
|
132
132
|
onSelect: onSelectStub
|
|
133
133
|
}));
|
|
@@ -139,7 +139,7 @@ describe('CreateEntryLinkButton with a single entry', ()=>{
|
|
|
139
139
|
describe('CreateEntryLinkButton common', ()=>{
|
|
140
140
|
it('should render a spinner if onSelect returns a promise', async ()=>{
|
|
141
141
|
const onSelect = jest.fn(()=>new Promise((resolve)=>setTimeout(resolve, 1000)));
|
|
142
|
-
const { getByTestId, container } = render(
|
|
142
|
+
const { getByTestId, container } = render(React.createElement(CreateEntryLinkButton, {
|
|
143
143
|
contentTypes: [
|
|
144
144
|
CONTENT_TYPE_1
|
|
145
145
|
],
|
|
@@ -155,7 +155,7 @@ describe('CreateEntryLinkButton common', ()=>{
|
|
|
155
155
|
});
|
|
156
156
|
it('should hide a spinner after the promise from onSelect resolves', async ()=>{
|
|
157
157
|
const onSelect = jest.fn(()=>new Promise((resolve)=>setTimeout(resolve, 500)));
|
|
158
|
-
const { getByTestId, container } = render(
|
|
158
|
+
const { getByTestId, container } = render(React.createElement(CreateEntryLinkButton, {
|
|
159
159
|
contentTypes: [
|
|
160
160
|
CONTENT_TYPE_1
|
|
161
161
|
],
|
|
@@ -172,7 +172,7 @@ describe('CreateEntryLinkButton common', ()=>{
|
|
|
172
172
|
});
|
|
173
173
|
it('does not emit onSelect on subsequent click before the promise from onSelect resolves', async ()=>{
|
|
174
174
|
const onSelect = jest.fn(()=>new Promise((resolve)=>setTimeout(()=>resolve(undefined), 200)));
|
|
175
|
-
const { getByTestId } = render(
|
|
175
|
+
const { getByTestId } = render(React.createElement(CreateEntryLinkButton, {
|
|
176
176
|
contentTypes: [
|
|
177
177
|
CONTENT_TYPE_1
|
|
178
178
|
],
|
|
@@ -188,7 +188,7 @@ describe('CreateEntryLinkButton common', ()=>{
|
|
|
188
188
|
});
|
|
189
189
|
it('emits onSelect on subsequent click after the promise from onSelect resolves', async ()=>{
|
|
190
190
|
const onSelect = jest.fn(()=>Promise.resolve());
|
|
191
|
-
const { getByTestId } = render(
|
|
191
|
+
const { getByTestId } = render(React.createElement(CreateEntryLinkButton, {
|
|
192
192
|
contentTypes: [
|
|
193
193
|
CONTENT_TYPE_1
|
|
194
194
|
],
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import React, { useState, useRef, useEffect } from 'react';
|
|
2
2
|
import { TextInput, Menu } from '@contentful/f36-components';
|
|
3
3
|
import { SearchIcon } from '@contentful/f36-icons';
|
|
4
4
|
import tokens from '@contentful/f36-tokens';
|
|
@@ -45,14 +45,7 @@ export const CreateEntryMenuTrigger = ({ contentTypes, suggestedContentTypeId, c
|
|
|
45
45
|
const wrapper = useRef(null);
|
|
46
46
|
const textField = useRef(null);
|
|
47
47
|
const menuListRef = useRef(null);
|
|
48
|
-
|
|
49
|
-
By default, dropdown wraps it's content, so it's width = the width of the widest item
|
|
50
|
-
During search, menu items change, and so the widest menu item can change
|
|
51
|
-
This leads to menu always changing it's width
|
|
52
|
-
To prevent this, we get the width of the menu item after the first mount of a dropdown (when all the content is displayed)
|
|
53
|
-
And hardcode it through the class name. This way we ensure that even during search the menu will keep that max width
|
|
54
|
-
That it had on initial mount and that fits any menu item in has
|
|
55
|
-
*/ const [dropdownWidth, setDropdownWidth] = useState();
|
|
48
|
+
const [dropdownWidth, setDropdownWidth] = useState();
|
|
56
49
|
const hasDropdown = contentTypes.length > 1 || !!customDropdownItems;
|
|
57
50
|
const closeMenu = ()=>setOpen(false);
|
|
58
51
|
useEffect(()=>{
|
|
@@ -77,7 +70,6 @@ export const CreateEntryMenuTrigger = ({ contentTypes, suggestedContentTypeId, c
|
|
|
77
70
|
const handleSelect = (item)=>{
|
|
78
71
|
closeMenu();
|
|
79
72
|
const res = onSelect(item.sys.id);
|
|
80
|
-
// TODO: Convert to controllable component.
|
|
81
73
|
if (res && typeof res.then === 'function') {
|
|
82
74
|
setSelecting(true);
|
|
83
75
|
res.then(()=>setSelecting(false), ()=>setSelecting(false));
|
|
@@ -97,28 +89,28 @@ export const CreateEntryMenuTrigger = ({ contentTypes, suggestedContentTypeId, c
|
|
|
97
89
|
}, [
|
|
98
90
|
isOpen
|
|
99
91
|
]);
|
|
100
|
-
const renderSearchResultsCount = (resultsLength)=>resultsLength ?
|
|
92
|
+
const renderSearchResultsCount = (resultsLength)=>resultsLength ? React.createElement(Menu.SectionTitle, {
|
|
101
93
|
testId: "add-entru-menu-search-results"
|
|
102
94
|
}, resultsLength, " result", resultsLength > 1 ? 's' : '') : null;
|
|
103
95
|
const isSearchable = contentTypes.length > MAX_ITEMS_WITHOUT_SEARCH;
|
|
104
96
|
const maxDropdownHeight = suggestedContentTypeId ? 300 : 250;
|
|
105
97
|
const suggestedContentType = contentTypes.find((ct)=>ct.sys.id === suggestedContentTypeId);
|
|
106
98
|
const filteredContentTypes = contentTypes.filter((ct)=>!searchInput || get(ct, 'name', 'Untitled').toLowerCase().includes(searchInput.toLowerCase()));
|
|
107
|
-
return
|
|
99
|
+
return React.createElement("span", {
|
|
108
100
|
className: styles.wrapper,
|
|
109
101
|
ref: wrapper,
|
|
110
102
|
"data-test-id": testId
|
|
111
|
-
},
|
|
103
|
+
}, React.createElement(Menu, {
|
|
112
104
|
placement: menuPlacementMap[dropdownSettings.position],
|
|
113
105
|
isAutoalignmentEnabled: dropdownSettings.isAutoalignmentEnabled,
|
|
114
106
|
isOpen: isOpen,
|
|
115
107
|
onClose: closeMenu,
|
|
116
108
|
onOpen: handleMenuOpen,
|
|
117
109
|
...menuProps
|
|
118
|
-
},
|
|
110
|
+
}, React.createElement(Menu.Trigger, null, children({
|
|
119
111
|
isOpen,
|
|
120
112
|
isSelecting
|
|
121
|
-
})), isOpen &&
|
|
113
|
+
})), isOpen && React.createElement(Menu.List, {
|
|
122
114
|
className: styles.dropdownList,
|
|
123
115
|
style: {
|
|
124
116
|
width: dropdownWidth != undefined ? `${dropdownWidth}px` : undefined,
|
|
@@ -126,25 +118,25 @@ export const CreateEntryMenuTrigger = ({ contentTypes, suggestedContentTypeId, c
|
|
|
126
118
|
},
|
|
127
119
|
ref: menuListRef,
|
|
128
120
|
testId: "add-entry-menu"
|
|
129
|
-
}, Boolean(customDropdownItems) &&
|
|
121
|
+
}, Boolean(customDropdownItems) && React.createElement(React.Fragment, null, customDropdownItems, React.createElement(Menu.Divider, null)), isSearchable && React.createElement(React.Fragment, null, React.createElement("div", {
|
|
130
122
|
ref: textField,
|
|
131
123
|
className: styles.inputWrapper
|
|
132
|
-
},
|
|
124
|
+
}, React.createElement(TextInput, {
|
|
133
125
|
className: styles.searchInput,
|
|
134
126
|
placeholder: "Search all content types",
|
|
135
127
|
testId: "add-entry-menu-search",
|
|
136
128
|
value: searchInput,
|
|
137
129
|
onChange: (e)=>setSearchInput(e.target.value)
|
|
138
|
-
}),
|
|
130
|
+
}), React.createElement(SearchIcon, {
|
|
139
131
|
className: styles.searchIcon
|
|
140
|
-
})),
|
|
132
|
+
})), React.createElement(Menu.Divider, null)), searchInput && renderSearchResultsCount(filteredContentTypes.length), suggestedContentType && !searchInput && React.createElement(React.Fragment, null, React.createElement(Menu.SectionTitle, null, "Suggested Content Type"), React.createElement(Menu.Item, {
|
|
141
133
|
testId: "suggested",
|
|
142
134
|
onClick: ()=>handleSelect(suggestedContentType)
|
|
143
|
-
}, get(suggestedContentType, 'name')),
|
|
135
|
+
}, get(suggestedContentType, 'name')), React.createElement(Menu.Divider, null)), !searchInput && React.createElement(Menu.SectionTitle, null, contentTypesLabel), filteredContentTypes.length ? filteredContentTypes.map((contentType, i)=>React.createElement(Menu.Item, {
|
|
144
136
|
testId: "contentType",
|
|
145
137
|
key: `${get(contentType, 'name')}-${i}`,
|
|
146
138
|
onClick: ()=>handleSelect(contentType)
|
|
147
|
-
}, get(contentType, 'name', 'Untitled'))) :
|
|
139
|
+
}, get(contentType, 'name', 'Untitled'))) : React.createElement(Menu.Item, {
|
|
148
140
|
testId: "add-entru-menu-search-results"
|
|
149
141
|
}, "No results found"))));
|
|
150
142
|
};
|
|
@@ -3,7 +3,6 @@ import { Button } from '@contentful/f36-components';
|
|
|
3
3
|
import '@testing-library/jest-dom/extend-expect';
|
|
4
4
|
import { act, configure, fireEvent, render } from '@testing-library/react';
|
|
5
5
|
import noop from 'lodash/noop';
|
|
6
|
-
// eslint-disable-next-line -- TODO: describe this disable you-dont-need-lodash-underscore/fill
|
|
7
6
|
import fill from 'lodash/fill';
|
|
8
7
|
import { CreateEntryMenuTrigger } from './CreateEntryMenuTrigger';
|
|
9
8
|
configure({
|
|
@@ -40,7 +39,7 @@ describe('CreateEntryMenuTrigger general', ()=>{
|
|
|
40
39
|
};
|
|
41
40
|
let stub = jest.fn();
|
|
42
41
|
beforeEach(()=>{
|
|
43
|
-
stub = jest.fn().mockImplementation(()
|
|
42
|
+
stub = jest.fn().mockImplementation(()=>React.createElement(Button, {
|
|
44
43
|
testId: "menu-trigger"
|
|
45
44
|
}));
|
|
46
45
|
});
|
|
@@ -48,13 +47,13 @@ describe('CreateEntryMenuTrigger general', ()=>{
|
|
|
48
47
|
const stub = (api)=>{
|
|
49
48
|
expect(api.isOpen).toBe(false);
|
|
50
49
|
expect(api.isSelecting).toBe(false);
|
|
51
|
-
return
|
|
50
|
+
return React.createElement("span", null);
|
|
52
51
|
};
|
|
53
|
-
render(
|
|
52
|
+
render(React.createElement(CreateEntryMenuTrigger, props, stub));
|
|
54
53
|
});
|
|
55
54
|
it('should set isSelecting to true in case onSelect returns a promise', async ()=>{
|
|
56
55
|
const selectStub = jest.fn(()=>new Promise((resolve)=>setTimeout(resolve, 1000)));
|
|
57
|
-
const { getAllByTestId, getByTestId } = render(
|
|
56
|
+
const { getAllByTestId, getByTestId } = render(React.createElement(CreateEntryMenuTrigger, {
|
|
58
57
|
...props,
|
|
59
58
|
onSelect: selectStub
|
|
60
59
|
}, stub));
|
|
@@ -68,7 +67,7 @@ describe('CreateEntryMenuTrigger general', ()=>{
|
|
|
68
67
|
});
|
|
69
68
|
it('should not set isSelecting to true in case onSelect is sync', async ()=>{
|
|
70
69
|
const selectStub = jest.fn();
|
|
71
|
-
const { getAllByTestId, getByTestId } = render(
|
|
70
|
+
const { getAllByTestId, getByTestId } = render(React.createElement(CreateEntryMenuTrigger, {
|
|
72
71
|
...props,
|
|
73
72
|
onSelect: selectStub
|
|
74
73
|
}, stub));
|
|
@@ -85,7 +84,7 @@ describe('CreateEntryMenuTrigger general', ()=>{
|
|
|
85
84
|
expect(selectStub).toHaveBeenCalled();
|
|
86
85
|
});
|
|
87
86
|
it('renders text input if contentTypes.length > 20', ()=>{
|
|
88
|
-
const { getByTestId } = render(
|
|
87
|
+
const { getByTestId } = render(React.createElement(CreateEntryMenuTrigger, {
|
|
89
88
|
...props,
|
|
90
89
|
contentTypes: fill(Array(21), CONTENT_TYPE_3)
|
|
91
90
|
}, stub));
|
|
@@ -96,7 +95,7 @@ describe('CreateEntryMenuTrigger general', ()=>{
|
|
|
96
95
|
});
|
|
97
96
|
it('shows the search results if typed in input', ()=>{
|
|
98
97
|
const contentTypes = fill(fill(fill(Array(21), CONTENT_TYPE_1, 0, 10), CONTENT_TYPE_2, 10, 20), CONTENT_TYPE_3, 20);
|
|
99
|
-
const { getByTestId, getAllByTestId } = render(
|
|
98
|
+
const { getByTestId, getAllByTestId } = render(React.createElement(CreateEntryMenuTrigger, {
|
|
100
99
|
...props,
|
|
101
100
|
contentTypes: contentTypes
|
|
102
101
|
}, stub));
|
|
@@ -129,7 +128,7 @@ describe('CreateEntryMenuTrigger general', ()=>{
|
|
|
129
128
|
expect(getByTestId('add-entru-menu-search-results').textContent).toBe('No results found');
|
|
130
129
|
});
|
|
131
130
|
it('shows suggestedContentType in the list', ()=>{
|
|
132
|
-
const { getByTestId } = render(
|
|
131
|
+
const { getByTestId } = render(React.createElement(CreateEntryMenuTrigger, {
|
|
133
132
|
...props,
|
|
134
133
|
suggestedContentTypeId: props.contentTypes[0].sys.id
|
|
135
134
|
}, stub));
|
|
@@ -9,27 +9,18 @@ const testIds = {
|
|
|
9
9
|
...sharedTextIds,
|
|
10
10
|
actionsWrapper: 'link-actions-menu-trigger'
|
|
11
11
|
};
|
|
12
|
-
|
|
13
|
-
* Alternative, experimental alternative to <LinkActions /> that is planned to
|
|
14
|
-
* replace the current default LinkActions in reference and media editors.
|
|
15
|
-
*
|
|
16
|
-
* Places both actions to create and link new, as well as link existing, behind
|
|
17
|
-
* one action dropdown and introduces new copy for action labels.
|
|
18
|
-
*/ export function CombinedLinkActions(props) {
|
|
12
|
+
export function CombinedLinkActions(props) {
|
|
19
13
|
if (props.isFull) {
|
|
20
|
-
return null;
|
|
14
|
+
return null;
|
|
21
15
|
}
|
|
22
|
-
// We don't want to render a spacious container in case there are are already
|
|
23
|
-
// assets linked (in case of entries, always show it) as the border wouldn't be
|
|
24
|
-
// nicely aligned with asset cards.
|
|
25
16
|
const hideEmptyCard = props.entityType === 'Asset' && !props.isEmpty;
|
|
26
|
-
return
|
|
17
|
+
return React.createElement("div", {
|
|
27
18
|
className: hideEmptyCard ? '' : styles.container
|
|
28
|
-
}, !props.canCreateEntity && !props.canLinkEntity &&
|
|
19
|
+
}, !props.canCreateEntity && !props.canLinkEntity && React.createElement(NoLinkPermissionsInfo, null), props.entityType === 'Entry' && React.createElement(CombinedEntryLinkActions, props), props.entityType === 'Asset' && React.createElement(CombinedAssetLinkActions, props));
|
|
29
20
|
}
|
|
30
21
|
function CombinedEntryLinkActions(props) {
|
|
31
22
|
if (props.canCreateEntity) {
|
|
32
|
-
return
|
|
23
|
+
return React.createElement(CreateEntryLinkButton, {
|
|
33
24
|
testId: testIds.actionsWrapper,
|
|
34
25
|
disabled: props.isDisabled,
|
|
35
26
|
text: props.combinedActionsLabel || 'Add content',
|
|
@@ -42,7 +33,7 @@ function CombinedEntryLinkActions(props) {
|
|
|
42
33
|
onSelect: (contentTypeId)=>{
|
|
43
34
|
return contentTypeId ? props.onCreate(contentTypeId) : Promise.resolve();
|
|
44
35
|
},
|
|
45
|
-
customDropdownItems: props.canLinkEntity ?
|
|
36
|
+
customDropdownItems: props.canLinkEntity ? React.createElement(Menu.Item, {
|
|
46
37
|
testId: testIds.linkExisting,
|
|
47
38
|
onClick: ()=>{
|
|
48
39
|
props.onLinkExisting();
|
|
@@ -50,7 +41,7 @@ function CombinedEntryLinkActions(props) {
|
|
|
50
41
|
}, "Add existing content") : undefined
|
|
51
42
|
});
|
|
52
43
|
} else if (props.canLinkEntity) {
|
|
53
|
-
return
|
|
44
|
+
return React.createElement(Button, {
|
|
54
45
|
isDisabled: props.isDisabled,
|
|
55
46
|
testId: testIds.linkExisting,
|
|
56
47
|
className: styles.action,
|
|
@@ -58,7 +49,7 @@ function CombinedEntryLinkActions(props) {
|
|
|
58
49
|
props.onLinkExisting();
|
|
59
50
|
},
|
|
60
51
|
variant: "secondary",
|
|
61
|
-
startIcon:
|
|
52
|
+
startIcon: React.createElement(LinkIcon, null),
|
|
62
53
|
size: "small"
|
|
63
54
|
}, "Add existing content");
|
|
64
55
|
}
|
|
@@ -68,7 +59,7 @@ function CombinedAssetLinkActions(props) {
|
|
|
68
59
|
const [isOpen, setOpen] = React.useState(false);
|
|
69
60
|
if (!props.canLinkEntity || !props.canCreateEntity) {
|
|
70
61
|
if (props.canLinkEntity) {
|
|
71
|
-
return
|
|
62
|
+
return React.createElement(Button, {
|
|
72
63
|
isDisabled: props.isDisabled,
|
|
73
64
|
testId: testIds.linkExisting,
|
|
74
65
|
className: styles.action,
|
|
@@ -76,12 +67,12 @@ function CombinedAssetLinkActions(props) {
|
|
|
76
67
|
props.onLinkExisting();
|
|
77
68
|
},
|
|
78
69
|
variant: "secondary",
|
|
79
|
-
startIcon:
|
|
70
|
+
startIcon: React.createElement(PlusIcon, null),
|
|
80
71
|
size: "small"
|
|
81
72
|
}, "Add existing media");
|
|
82
73
|
}
|
|
83
74
|
if (props.canCreateEntity) {
|
|
84
|
-
return
|
|
75
|
+
return React.createElement(Button, {
|
|
85
76
|
isDisabled: props.isDisabled,
|
|
86
77
|
testId: testIds.createAndLink,
|
|
87
78
|
className: styles.action,
|
|
@@ -89,15 +80,13 @@ function CombinedAssetLinkActions(props) {
|
|
|
89
80
|
props.onCreate();
|
|
90
81
|
},
|
|
91
82
|
variant: "secondary",
|
|
92
|
-
startIcon:
|
|
83
|
+
startIcon: React.createElement(PlusIcon, null),
|
|
93
84
|
size: "small"
|
|
94
85
|
}, "Add media");
|
|
95
86
|
}
|
|
96
87
|
return null;
|
|
97
88
|
}
|
|
98
|
-
|
|
99
|
-
// that works without content types to cover asset use-case.
|
|
100
|
-
return /*#__PURE__*/ React.createElement(Menu, {
|
|
89
|
+
return React.createElement(Menu, {
|
|
101
90
|
isOpen: isOpen,
|
|
102
91
|
onClose: ()=>{
|
|
103
92
|
setOpen(false);
|
|
@@ -105,22 +94,22 @@ function CombinedAssetLinkActions(props) {
|
|
|
105
94
|
onOpen: ()=>{
|
|
106
95
|
setOpen(true);
|
|
107
96
|
}
|
|
108
|
-
},
|
|
109
|
-
endIcon:
|
|
97
|
+
}, React.createElement(Menu.Trigger, null, React.createElement(Button, {
|
|
98
|
+
endIcon: React.createElement(ChevronDownIcon, null),
|
|
110
99
|
isDisabled: props.isDisabled,
|
|
111
100
|
testId: testIds.actionsWrapper,
|
|
112
101
|
className: styles.action,
|
|
113
102
|
variant: "secondary",
|
|
114
|
-
startIcon:
|
|
103
|
+
startIcon: React.createElement(PlusIcon, null),
|
|
115
104
|
size: "small"
|
|
116
|
-
}, "Add media")), isOpen &&
|
|
105
|
+
}, "Add media")), isOpen && React.createElement(Menu.List, {
|
|
117
106
|
testId: testIds.dropdown
|
|
118
|
-
},
|
|
107
|
+
}, React.createElement(Menu.Item, {
|
|
119
108
|
testId: testIds.linkExisting,
|
|
120
109
|
onClick: ()=>{
|
|
121
110
|
props.onLinkExisting();
|
|
122
111
|
}
|
|
123
|
-
}, "Add existing media"),
|
|
112
|
+
}, "Add existing media"), React.createElement(Menu.Item, {
|
|
124
113
|
testId: testIds.createAndLink,
|
|
125
114
|
onClick: ()=>{
|
|
126
115
|
props.onCreate();
|
|
@@ -20,16 +20,16 @@ export const testIds = {
|
|
|
20
20
|
};
|
|
21
21
|
export function LinkActions(props) {
|
|
22
22
|
if (props.isFull) {
|
|
23
|
-
return null;
|
|
23
|
+
return null;
|
|
24
24
|
}
|
|
25
25
|
const defaultLabels = props.entityType === 'Entry' ? defaultEntryLabels : defaultAssetLabels;
|
|
26
26
|
const labels = {
|
|
27
27
|
...defaultLabels,
|
|
28
28
|
...props.actionLabels
|
|
29
29
|
};
|
|
30
|
-
return
|
|
30
|
+
return React.createElement("div", {
|
|
31
31
|
className: styles.container
|
|
32
|
-
}, props.canCreateEntity &&
|
|
32
|
+
}, props.canCreateEntity && React.createElement(React.Fragment, null, props.entityType === 'Entry' && React.createElement(CreateEntryLinkButton, {
|
|
33
33
|
testId: testIds.createAndLink,
|
|
34
34
|
disabled: props.isDisabled,
|
|
35
35
|
text: labels.createNew({
|
|
@@ -40,27 +40,27 @@ export function LinkActions(props) {
|
|
|
40
40
|
onSelect: (contentTypeId)=>{
|
|
41
41
|
return contentTypeId ? props.onCreate(contentTypeId, props.itemsLength) : Promise.resolve();
|
|
42
42
|
}
|
|
43
|
-
}), props.entityType === 'Asset' &&
|
|
43
|
+
}), props.entityType === 'Asset' && React.createElement(Button, {
|
|
44
44
|
isDisabled: props.isDisabled,
|
|
45
45
|
testId: testIds.createAndLink,
|
|
46
46
|
onClick: ()=>{
|
|
47
47
|
props.onCreate(undefined, props.itemsLength);
|
|
48
48
|
},
|
|
49
49
|
variant: "secondary",
|
|
50
|
-
startIcon:
|
|
50
|
+
startIcon: React.createElement(PlusIcon, null),
|
|
51
51
|
size: "small"
|
|
52
|
-
}, labels.createNew()),
|
|
52
|
+
}, labels.createNew()), React.createElement("span", {
|
|
53
53
|
className: styles.separator
|
|
54
|
-
})), props.canLinkEntity &&
|
|
54
|
+
})), props.canLinkEntity && React.createElement(Button, {
|
|
55
55
|
isDisabled: props.isDisabled,
|
|
56
56
|
testId: testIds.linkExisting,
|
|
57
57
|
onClick: ()=>{
|
|
58
58
|
props.onLinkExisting();
|
|
59
59
|
},
|
|
60
60
|
variant: "secondary",
|
|
61
|
-
startIcon:
|
|
61
|
+
startIcon: React.createElement(LinkIcon, null),
|
|
62
62
|
size: "small"
|
|
63
63
|
}, labels.linkExisting({
|
|
64
64
|
canLinkMultiple: props.canLinkMultiple
|
|
65
|
-
})), !props.canCreateEntity && !props.canLinkEntity &&
|
|
65
|
+
})), !props.canCreateEntity && !props.canLinkEntity && React.createElement(NoLinkPermissionsInfo, null));
|
|
66
66
|
}
|
|
@@ -19,8 +19,7 @@ export function useLinkActionsProps(props) {
|
|
|
19
19
|
slide,
|
|
20
20
|
index
|
|
21
21
|
});
|
|
22
|
-
},
|
|
23
|
-
[
|
|
22
|
+
}, [
|
|
24
23
|
entityType,
|
|
25
24
|
props.onCreate,
|
|
26
25
|
props.onAction
|
|
@@ -35,8 +34,7 @@ export function useLinkActionsProps(props) {
|
|
|
35
34
|
index: index === undefined ? undefined : index + i
|
|
36
35
|
});
|
|
37
36
|
});
|
|
38
|
-
},
|
|
39
|
-
[
|
|
37
|
+
}, [
|
|
40
38
|
entityType,
|
|
41
39
|
props.onLink,
|
|
42
40
|
props.onAction
|
|
@@ -68,8 +66,7 @@ export function useLinkActionsProps(props) {
|
|
|
68
66
|
onLinkedExisting([
|
|
69
67
|
entity
|
|
70
68
|
], index);
|
|
71
|
-
},
|
|
72
|
-
[
|
|
69
|
+
}, [
|
|
73
70
|
sdk,
|
|
74
71
|
entityType,
|
|
75
72
|
onLinkedExisting
|
|
@@ -84,13 +81,11 @@ export function useLinkActionsProps(props) {
|
|
|
84
81
|
return;
|
|
85
82
|
}
|
|
86
83
|
onLinkedExisting(entities, index);
|
|
87
|
-
},
|
|
88
|
-
[
|
|
84
|
+
}, [
|
|
89
85
|
sdk,
|
|
90
86
|
entityType,
|
|
91
87
|
onLinkedExisting
|
|
92
88
|
]);
|
|
93
|
-
// FIXME: The memoization might rerun every time due to the always changing callback identities above
|
|
94
89
|
return useMemo(()=>({
|
|
95
90
|
entityType,
|
|
96
91
|
canLinkMultiple,
|
|
@@ -106,8 +101,7 @@ export function useLinkActionsProps(props) {
|
|
|
106
101
|
onCreated,
|
|
107
102
|
onLinkedExisting,
|
|
108
103
|
itemsLength
|
|
109
|
-
}),
|
|
110
|
-
[
|
|
104
|
+
}), [
|
|
111
105
|
entityType,
|
|
112
106
|
canLinkMultiple,
|
|
113
107
|
isDisabled,
|
|
@@ -116,7 +110,6 @@ export function useLinkActionsProps(props) {
|
|
|
116
110
|
editorPermissions.canCreateEntity,
|
|
117
111
|
editorPermissions.canLinkEntity,
|
|
118
112
|
actionLabels,
|
|
119
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
|
|
120
113
|
editorPermissions.creatableContentTypes.map((ct)=>ct.sys.id).join(':'),
|
|
121
114
|
onCreate,
|
|
122
115
|
onLinkExisting,
|
|
@@ -127,8 +120,8 @@ export function useLinkActionsProps(props) {
|
|
|
127
120
|
]);
|
|
128
121
|
}
|
|
129
122
|
export function LinkEntityActions({ renderCustomActions, ...props }) {
|
|
130
|
-
return renderCustomActions ? renderCustomActions(props) :
|
|
123
|
+
return renderCustomActions ? renderCustomActions(props) : React.createElement(LinkActions, props);
|
|
131
124
|
}
|
|
132
125
|
export function CombinedLinkEntityActions({ renderCustomActions, ...props }) {
|
|
133
|
-
return renderCustomActions ? renderCustomActions(props) :
|
|
126
|
+
return renderCustomActions ? renderCustomActions(props) : React.createElement(CombinedLinkActions, props);
|
|
134
127
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { Paragraph } from '@contentful/f36-components';
|
|
3
3
|
export function NoLinkPermissionsInfo() {
|
|
4
|
-
return
|
|
4
|
+
return React.createElement(Paragraph, null, "You don't have permission to view this content or this field is not correctly configured. Contact your administrator for help.");
|
|
5
5
|
}
|