@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
|
@@ -46,18 +46,16 @@ const fieldDefinition = {
|
|
|
46
46
|
describe('Multiple resource editor', ()=>{
|
|
47
47
|
it('renders the action button when no value is set', async ()=>{
|
|
48
48
|
const sdk = mockSdkForField(fieldDefinition);
|
|
49
|
-
render(
|
|
49
|
+
render(React.createElement(MultipleResourceReferenceEditor, {
|
|
50
50
|
isInitiallyDisabled: false,
|
|
51
51
|
sdk: sdk,
|
|
52
52
|
hasCardEditActions: true,
|
|
53
53
|
viewType: "card",
|
|
54
|
-
// @ts-expect-error unused...
|
|
55
54
|
parameters: {}
|
|
56
55
|
}));
|
|
57
56
|
const button = await screen.findByText('Add existing content');
|
|
58
57
|
expect(button).toBeDefined();
|
|
59
58
|
fireEvent.click(button);
|
|
60
|
-
// @ts-expect-error wait app-sdk version update
|
|
61
59
|
const dialogFn = sdk.dialogs.selectMultipleResourceEntries;
|
|
62
60
|
expect(dialogFn).toHaveBeenCalledTimes(1);
|
|
63
61
|
const options = dialogFn.mock.calls[0][0];
|
|
@@ -67,14 +65,13 @@ describe('Multiple resource editor', ()=>{
|
|
|
67
65
|
});
|
|
68
66
|
it('renders custom actions when passed', async ()=>{
|
|
69
67
|
const sdk = mockSdkForField(fieldDefinition);
|
|
70
|
-
render(
|
|
68
|
+
render(React.createElement(MultipleResourceReferenceEditor, {
|
|
71
69
|
isInitiallyDisabled: false,
|
|
72
70
|
sdk: sdk,
|
|
73
71
|
hasCardEditActions: true,
|
|
74
72
|
viewType: "card",
|
|
75
|
-
// @ts-expect-error unused...
|
|
76
73
|
parameters: {},
|
|
77
|
-
renderCustomActions: ()
|
|
74
|
+
renderCustomActions: ()=>React.createElement("div", {
|
|
78
75
|
"data-testid": "custom-actions"
|
|
79
76
|
})
|
|
80
77
|
}));
|
|
@@ -89,18 +86,16 @@ describe('Multiple resource editor', ()=>{
|
|
|
89
86
|
mockedResources[`${link.sys.linkType}.${link.sys.urn}`] = entryInfos[spaceId];
|
|
90
87
|
}
|
|
91
88
|
const sdk = mockSdkForField(fieldDefinition, Object.values(entryLinks));
|
|
92
|
-
render(
|
|
89
|
+
render(React.createElement(MultipleResourceReferenceEditor, {
|
|
93
90
|
isInitiallyDisabled: false,
|
|
94
91
|
sdk: sdk,
|
|
95
92
|
hasCardEditActions: true,
|
|
96
93
|
viewType: "card",
|
|
97
94
|
apiUrl: "test-contentful",
|
|
98
95
|
getEntryRouteHref: ()=>'',
|
|
99
|
-
// @ts-expect-error unused...
|
|
100
96
|
parameters: {}
|
|
101
97
|
}));
|
|
102
98
|
expect(useResource).toHaveBeenCalledTimes(Object.values(entryInfos).length);
|
|
103
|
-
// ensure the card is rendered for every value
|
|
104
99
|
const cards = [];
|
|
105
100
|
const entriesArray = Object.values(entryInfos);
|
|
106
101
|
for (const info of Array.from(entriesArray.values())){
|
|
@@ -118,26 +113,21 @@ describe('Multiple resource editor', ()=>{
|
|
|
118
113
|
mockedResources[`${link.sys.linkType}.${link.sys.urn}`] = entryInfos[spaceId];
|
|
119
114
|
}
|
|
120
115
|
const sdk = mockSdkForField(fieldDefinition, Object.values(entryLinks));
|
|
121
|
-
render(
|
|
116
|
+
render(React.createElement(MultipleResourceReferenceEditor, {
|
|
122
117
|
isInitiallyDisabled: false,
|
|
123
118
|
sdk: sdk,
|
|
124
119
|
hasCardEditActions: true,
|
|
125
120
|
viewType: "card",
|
|
126
121
|
apiUrl: "test-contentful",
|
|
127
122
|
getEntryRouteHref: ()=>'',
|
|
128
|
-
// @ts-expect-error unused...
|
|
129
123
|
parameters: {}
|
|
130
124
|
}));
|
|
131
|
-
// expect(useResource).toHaveBeenCalledTimes(Object.values(entryInfos).length);
|
|
132
|
-
// linking more is available
|
|
133
125
|
const linkExistingBtn = screen.queryByText('Add existing content');
|
|
134
126
|
expect(linkExistingBtn).toBeInTheDocument();
|
|
135
|
-
// ensure the card is rendered for every value
|
|
136
127
|
const entriesArray = Object.values(entryInfos);
|
|
137
128
|
const firstItem = entriesArray[0];
|
|
138
129
|
await expectToNotHaveMoveButton(firstItem, 'Move to top');
|
|
139
130
|
const allButFirst = entriesArray.slice(1);
|
|
140
|
-
// move actions are available
|
|
141
131
|
for (const info of allButFirst){
|
|
142
132
|
await expectToHaveMoveButton(info, 'Move to top');
|
|
143
133
|
}
|
|
@@ -149,21 +139,17 @@ describe('Multiple resource editor', ()=>{
|
|
|
149
139
|
mockedResources[`${link.sys.linkType}.${link.sys.urn}`] = entryInfos[spaceId];
|
|
150
140
|
}
|
|
151
141
|
const sdk = mockSdkForField(fieldDefinition, Object.values(entryLinks));
|
|
152
|
-
render(
|
|
142
|
+
render(React.createElement(MultipleResourceReferenceEditor, {
|
|
153
143
|
isInitiallyDisabled: false,
|
|
154
144
|
sdk: sdk,
|
|
155
145
|
hasCardEditActions: true,
|
|
156
146
|
viewType: "card",
|
|
157
147
|
apiUrl: "test-contentful",
|
|
158
148
|
getEntryRouteHref: ()=>'',
|
|
159
|
-
// @ts-expect-error unused...
|
|
160
149
|
parameters: {}
|
|
161
150
|
}));
|
|
162
|
-
// expect(useResource).toHaveBeenCalledTimes(Object.values(entryInfos).length);
|
|
163
|
-
// linking more is available
|
|
164
151
|
const linkExistingBtn = screen.queryByText('Add existing content');
|
|
165
152
|
expect(linkExistingBtn).toBeInTheDocument();
|
|
166
|
-
// ensure the card is rendered for every value
|
|
167
153
|
const entriesArray = Object.values(entryInfos);
|
|
168
154
|
const lastItem = entriesArray[entriesArray.length - 1];
|
|
169
155
|
await expectToNotHaveMoveButton(lastItem, 'Move to bottom');
|
|
@@ -179,21 +165,17 @@ describe('Multiple resource editor', ()=>{
|
|
|
179
165
|
mockedResources[`${link.sys.linkType}.${link.sys.urn}`] = entryInfos[spaceId];
|
|
180
166
|
}
|
|
181
167
|
const sdk = mockSdkForField(fieldDefinition, Object.values(entryLinks));
|
|
182
|
-
render(
|
|
168
|
+
render(React.createElement(MultipleResourceReferenceEditor, {
|
|
183
169
|
isInitiallyDisabled: false,
|
|
184
170
|
sdk: sdk,
|
|
185
171
|
hasCardEditActions: true,
|
|
186
172
|
viewType: "card",
|
|
187
173
|
apiUrl: "test-contentful",
|
|
188
174
|
getEntryRouteHref: ()=>'',
|
|
189
|
-
// @ts-expect-error unused...
|
|
190
175
|
parameters: {}
|
|
191
176
|
}));
|
|
192
|
-
// expect(useResource).toHaveBeenCalledTimes(Object.values(entryInfos).length);
|
|
193
|
-
// linking more is available
|
|
194
177
|
const linkExistingBtn = screen.queryByText('Add existing content');
|
|
195
178
|
expect(linkExistingBtn).toBeInTheDocument();
|
|
196
|
-
// ensure the card is rendered for every value
|
|
197
179
|
const entriesArray = Object.values(entryInfos);
|
|
198
180
|
for (const info of entriesArray){
|
|
199
181
|
await clickCardActionsButton(info);
|
|
@@ -202,7 +184,6 @@ describe('Multiple resource editor', ()=>{
|
|
|
202
184
|
});
|
|
203
185
|
fireEvent.click(removeBtn);
|
|
204
186
|
}
|
|
205
|
-
// all cards were deleted
|
|
206
187
|
expect(sdk.field.setValue).toHaveBeenCalledTimes(3);
|
|
207
188
|
expect(sdk.field.setValue).toHaveBeenCalledWith([]);
|
|
208
189
|
});
|
|
@@ -12,20 +12,20 @@ export function SingleResourceReferenceEditor(props) {
|
|
|
12
12
|
field,
|
|
13
13
|
apiUrl: props.apiUrl
|
|
14
14
|
});
|
|
15
|
-
return
|
|
15
|
+
return React.createElement(EntityProvider, {
|
|
16
16
|
sdk: props.sdk
|
|
17
|
-
},
|
|
17
|
+
}, React.createElement(FieldConnector, {
|
|
18
18
|
debounce: 0,
|
|
19
19
|
field: props.sdk.field,
|
|
20
20
|
isInitiallyDisabled: props.isInitiallyDisabled,
|
|
21
21
|
isEqualValues: deepEqual
|
|
22
22
|
}, ({ value, disabled })=>{
|
|
23
|
-
return value ?
|
|
23
|
+
return value ? React.createElement(ResourceCard, {
|
|
24
24
|
onRemove: ()=>props.sdk.field.removeValue(),
|
|
25
25
|
resourceLink: value,
|
|
26
26
|
isDisabled: disabled,
|
|
27
27
|
getEntryRouteHref: props.getEntryRouteHref
|
|
28
|
-
}) :
|
|
28
|
+
}) : React.createElement(CombinedLinkEntityActions, {
|
|
29
29
|
...linkActionsProps,
|
|
30
30
|
renderCustomActions: props.renderCustomActions
|
|
31
31
|
});
|
|
@@ -42,18 +42,16 @@ const fieldDefinition = {
|
|
|
42
42
|
describe('Single resource editor', ()=>{
|
|
43
43
|
it('renders the action button when no value is set', async ()=>{
|
|
44
44
|
const sdk = mockSdkForField(fieldDefinition);
|
|
45
|
-
render(
|
|
45
|
+
render(React.createElement(SingleResourceReferenceEditor, {
|
|
46
46
|
isInitiallyDisabled: false,
|
|
47
47
|
sdk: sdk,
|
|
48
48
|
hasCardEditActions: true,
|
|
49
49
|
viewType: "card",
|
|
50
|
-
// @ts-expect-error unused...
|
|
51
50
|
parameters: {}
|
|
52
51
|
}));
|
|
53
52
|
const button = await screen.findByText('Add existing content');
|
|
54
53
|
expect(button).toBeDefined();
|
|
55
54
|
fireEvent.click(button);
|
|
56
|
-
// @ts-expect-error wait app-sdk version update
|
|
57
55
|
const dialogFn = sdk.dialogs.selectSingleResourceEntry;
|
|
58
56
|
expect(dialogFn).toHaveBeenCalledTimes(1);
|
|
59
57
|
const options = dialogFn.mock.calls[0][0];
|
|
@@ -63,14 +61,13 @@ describe('Single resource editor', ()=>{
|
|
|
63
61
|
});
|
|
64
62
|
it('renders custom actions when passed', async ()=>{
|
|
65
63
|
const sdk = mockSdkForField(fieldDefinition);
|
|
66
|
-
render(
|
|
64
|
+
render(React.createElement(SingleResourceReferenceEditor, {
|
|
67
65
|
isInitiallyDisabled: false,
|
|
68
66
|
sdk: sdk,
|
|
69
67
|
hasCardEditActions: true,
|
|
70
68
|
viewType: "card",
|
|
71
|
-
// @ts-expect-error unused...
|
|
72
69
|
parameters: {},
|
|
73
|
-
renderCustomActions: ()
|
|
70
|
+
renderCustomActions: ()=>React.createElement("div", {
|
|
74
71
|
"data-testid": "custom-actions"
|
|
75
72
|
})
|
|
76
73
|
}));
|
|
@@ -94,18 +91,16 @@ describe('Single resource editor', ()=>{
|
|
|
94
91
|
}
|
|
95
92
|
});
|
|
96
93
|
mockedResources[`Contentful:Entry.crn:test:::content:spaces/x-space/entries/linkedEntryId`] = info;
|
|
97
|
-
render(
|
|
94
|
+
render(React.createElement(SingleResourceReferenceEditor, {
|
|
98
95
|
isInitiallyDisabled: false,
|
|
99
96
|
sdk: sdk,
|
|
100
97
|
hasCardEditActions: true,
|
|
101
98
|
viewType: "card",
|
|
102
99
|
apiUrl: "test-contentful",
|
|
103
100
|
getEntryRouteHref: jest.fn(),
|
|
104
|
-
// @ts-expect-error unused...
|
|
105
101
|
parameters: {}
|
|
106
102
|
}));
|
|
107
103
|
expect(useResource).toHaveBeenCalled();
|
|
108
|
-
// ensure the card is rendered
|
|
109
104
|
const title = await screen.findByText('Title of linked entry');
|
|
110
105
|
await screen.findByText('X Space');
|
|
111
106
|
const theCard = title.closest('[data-test-id="cf-ui-entry-card"]');
|
|
@@ -4,17 +4,13 @@ export function mockSdkForField(fieldDefinition, fieldValue) {
|
|
|
4
4
|
getValue: jest.fn(()=>fieldValue),
|
|
5
5
|
setValue: jest.fn(()=>Promise.resolve(undefined)),
|
|
6
6
|
removeValue: jest.fn(),
|
|
7
|
-
// eslint-disable-next-line -- test helper
|
|
8
7
|
onSchemaErrorsChanged: ()=>{},
|
|
9
|
-
// eslint-disable-next-line -- test helper
|
|
10
8
|
onIsDisabledChanged: ()=>{},
|
|
11
|
-
// eslint-disable-next-line -- test helper
|
|
12
9
|
onValueChanged: ()=>{},
|
|
13
10
|
...fieldDefinition,
|
|
14
11
|
locale: 'en'
|
|
15
12
|
},
|
|
16
13
|
dialogs: {
|
|
17
|
-
// @ts-expect-error wait app-sdk version update
|
|
18
14
|
selectSingleResourceEntry: jest.fn().mockResolvedValue({
|
|
19
15
|
sys: {
|
|
20
16
|
type: 'Entry',
|
|
@@ -54,11 +50,8 @@ export function mockSdkForField(fieldDefinition, fieldValue) {
|
|
|
54
50
|
contentType: 'testCT'
|
|
55
51
|
},
|
|
56
52
|
space: {
|
|
57
|
-
// @ts-expect-error wait app-sdk version update
|
|
58
|
-
// eslint-disable-next-line -- test helper
|
|
59
53
|
onEntityChanged: ()=>{}
|
|
60
54
|
},
|
|
61
|
-
// @ts-expect-error
|
|
62
55
|
navigator: {
|
|
63
56
|
onSlideInNavigation: ()=>()=>({})
|
|
64
57
|
}
|
|
@@ -41,14 +41,10 @@ export function useResourceLinkActions({ dialogs, field, onAfterLink, apiUrl })
|
|
|
41
41
|
]);
|
|
42
42
|
const multiple = field.type === 'Array';
|
|
43
43
|
const onLinkExisting = useMemo(()=>{
|
|
44
|
-
const promptSelection = multiple ? async ()
|
|
45
|
-
await dialogs.selectMultipleResourceEntries({
|
|
46
|
-
// @ts-expect-error wait for update of app-sdk version
|
|
44
|
+
const promptSelection = multiple ? async ()=>await dialogs.selectMultipleResourceEntries({
|
|
47
45
|
allowedResources: field.allowedResources
|
|
48
46
|
}) : async ()=>[
|
|
49
|
-
// @ts-expect-error wait for update of app-sdk version
|
|
50
47
|
await dialogs.selectSingleResourceEntry({
|
|
51
|
-
// @ts-expect-error wait for update of app-sdk version
|
|
52
48
|
allowedResources: field.allowedResources
|
|
53
49
|
})
|
|
54
50
|
];
|
|
@@ -59,7 +55,6 @@ export function useResourceLinkActions({ dialogs, field, onAfterLink, apiUrl })
|
|
|
59
55
|
}
|
|
60
56
|
onLinkedExisting(res);
|
|
61
57
|
};
|
|
62
|
-
// @ts-expect-error wait for update of app-sdk version
|
|
63
58
|
}, [
|
|
64
59
|
dialogs,
|
|
65
60
|
field.allowedResources,
|
|
@@ -68,9 +63,7 @@ export function useResourceLinkActions({ dialogs, field, onAfterLink, apiUrl })
|
|
|
68
63
|
]);
|
|
69
64
|
return {
|
|
70
65
|
onLinkExisting,
|
|
71
|
-
// @ts-expect-error
|
|
72
66
|
onLinkedExisting,
|
|
73
|
-
// hardcoded values to match interface for standard reference field actions
|
|
74
67
|
entityType: 'Entry',
|
|
75
68
|
contentTypes: [],
|
|
76
69
|
canCreateEntity: false,
|
|
@@ -79,9 +72,7 @@ export function useResourceLinkActions({ dialogs, field, onAfterLink, apiUrl })
|
|
|
79
72
|
isDisabled: false,
|
|
80
73
|
isEmpty: false,
|
|
81
74
|
isFull: false,
|
|
82
|
-
// eslint-disable-next-line -- hardcoded values to match interface for standard reference field actions
|
|
83
75
|
onCreate: async ()=>{},
|
|
84
|
-
// eslint-disable-next-line -- hardcoded values to match interface for standard reference field actions
|
|
85
76
|
onCreated: ()=>{}
|
|
86
77
|
};
|
|
87
78
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import isNumber from 'lodash/isNumber';
|
|
2
2
|
export function fromFieldValidations(field) {
|
|
3
|
-
// eslint-disable-next-line -- TODO: describe this disable @typescript-eslint/no-explicit-any
|
|
4
3
|
const validations = [
|
|
5
4
|
...field.validations,
|
|
6
5
|
...field.type === 'Array' ? field.items?.validations ?? [] : []
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { ReferenceEditorProps } from '../common/ReferenceEditor';
|
|
3
3
|
type EditorProps = Pick<ReferenceEditorProps, Exclude<keyof ReferenceEditorProps, 'hasCardEditActions'>>;
|
|
4
|
-
export declare function MultipleMediaEditor(props: EditorProps):
|
|
4
|
+
export declare function MultipleMediaEditor(props: EditorProps): JSX.Element;
|
|
5
5
|
export declare namespace MultipleMediaEditor {
|
|
6
6
|
var defaultProps: {
|
|
7
7
|
isInitiallyDisabled: boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { ReferenceEditorProps } from '../common/ReferenceEditor';
|
|
3
3
|
type EditorProps = Pick<ReferenceEditorProps, Exclude<keyof ReferenceEditorProps, 'hasCardEditActions'>>;
|
|
4
|
-
export declare function SingleMediaEditor(props: EditorProps):
|
|
4
|
+
export declare function SingleMediaEditor(props: EditorProps): JSX.Element;
|
|
5
5
|
export declare namespace SingleMediaEditor {
|
|
6
6
|
var defaultProps: {
|
|
7
7
|
isInitiallyDisabled: boolean;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { File } from '../../types';
|
|
3
3
|
export declare function renderAssetInfo(props: {
|
|
4
4
|
entityFile: File;
|
|
5
|
-
}):
|
|
5
|
+
}): JSX.Element[];
|
|
6
6
|
export declare function renderActions(props: {
|
|
7
7
|
onEdit?: () => void;
|
|
8
8
|
onRemove?: () => void;
|
|
9
9
|
isDisabled: boolean;
|
|
10
10
|
entityFile?: File;
|
|
11
|
-
}): (
|
|
11
|
+
}): (JSX.Element | null)[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { CustomCardRenderer, RenderCustomMissingEntityCard } from '../../common/customCardTypes';
|
|
3
3
|
import { Action, FieldAppSDK, ViewType, RenderDragFn } from '../../types';
|
|
4
4
|
type FetchingWrappedAssetCardProps = {
|
|
@@ -13,5 +13,5 @@ type FetchingWrappedAssetCardProps = {
|
|
|
13
13
|
renderCustomCard?: CustomCardRenderer;
|
|
14
14
|
renderCustomMissingEntityCard?: RenderCustomMissingEntityCard;
|
|
15
15
|
};
|
|
16
|
-
export declare function FetchingWrappedAssetCard(props: FetchingWrappedAssetCardProps):
|
|
16
|
+
export declare function FetchingWrappedAssetCard(props: FetchingWrappedAssetCardProps): JSX.Element;
|
|
17
17
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { SpaceAPI } from '@contentful/app-sdk';
|
|
3
3
|
import { Asset, RenderDragFn } from '../../types';
|
|
4
4
|
export interface WrappedAssetCardProps {
|
|
@@ -17,7 +17,7 @@ export interface WrappedAssetCardProps {
|
|
|
17
17
|
isClickable: boolean;
|
|
18
18
|
}
|
|
19
19
|
export declare const WrappedAssetCard: {
|
|
20
|
-
(props: WrappedAssetCardProps):
|
|
20
|
+
(props: WrappedAssetCardProps): JSX.Element;
|
|
21
21
|
defaultProps: {
|
|
22
22
|
isClickable: boolean;
|
|
23
23
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { SpaceAPI } from '@contentful/field-editor-shared';
|
|
3
3
|
import { Asset, RenderDragFn } from '../../types';
|
|
4
4
|
export interface WrappedAssetLinkProps {
|
|
@@ -13,4 +13,4 @@ export interface WrappedAssetLinkProps {
|
|
|
13
13
|
onRemove: () => void;
|
|
14
14
|
renderDragHandle?: RenderDragFn;
|
|
15
15
|
}
|
|
16
|
-
export declare const WrappedAssetLink: (props: WrappedAssetLinkProps) =>
|
|
16
|
+
export declare const WrappedAssetLink: (props: WrappedAssetLinkProps) => JSX.Element;
|
|
@@ -58,5 +58,5 @@ export declare function useResource(resourceType: ResourceType, urn: string, opt
|
|
|
58
58
|
data: ResourceInfo<Resource> | undefined;
|
|
59
59
|
error: unknown;
|
|
60
60
|
};
|
|
61
|
-
declare function EntityProvider({ children, ...props }: React.PropsWithChildren<EntityStoreProps>):
|
|
61
|
+
declare function EntityProvider({ children, ...props }: React.PropsWithChildren<EntityStoreProps>): JSX.Element;
|
|
62
62
|
export { EntityProvider, useEntityLoader };
|
|
@@ -19,7 +19,7 @@ export declare function MultipleReferenceEditor(props: ReferenceEditorProps & {
|
|
|
19
19
|
entityType: ContentEntityType;
|
|
20
20
|
children: (props: ReferenceEditorProps & ChildProps) => React.ReactElement;
|
|
21
21
|
setIndexToUpdate?: React.Dispatch<React.SetStateAction<number | undefined>>;
|
|
22
|
-
}):
|
|
22
|
+
}): JSX.Element;
|
|
23
23
|
export declare namespace MultipleReferenceEditor {
|
|
24
24
|
var defaultProps: {
|
|
25
25
|
hasCardEditActions: boolean;
|
|
@@ -37,7 +37,7 @@ export interface ReferenceEditorProps {
|
|
|
37
37
|
export type CustomActionProps = LinkActionsProps;
|
|
38
38
|
export declare function ReferenceEditor<T>(props: ReferenceEditorProps & {
|
|
39
39
|
children: FieldConnector<T>['props']['children'];
|
|
40
|
-
}):
|
|
40
|
+
}): JSX.Element;
|
|
41
41
|
export declare namespace ReferenceEditor {
|
|
42
42
|
var defaultProps: {
|
|
43
43
|
isInitiallyDisabled: boolean;
|
|
@@ -14,7 +14,7 @@ type ChildProps = {
|
|
|
14
14
|
export declare function SingleReferenceEditor(props: ReferenceEditorProps & {
|
|
15
15
|
entityType: ContentEntityType;
|
|
16
16
|
children: (props: ChildProps) => React.ReactElement;
|
|
17
|
-
}):
|
|
17
|
+
}): JSX.Element;
|
|
18
18
|
export declare namespace SingleReferenceEditor {
|
|
19
19
|
var defaultProps: {
|
|
20
20
|
hasCardEditActions: boolean;
|
|
@@ -23,5 +23,5 @@ type SortableLinkListProps<T> = ReferenceEditorProps & {
|
|
|
23
23
|
};
|
|
24
24
|
export declare const SortableLinkList: <T extends {
|
|
25
25
|
sys: any;
|
|
26
|
-
}>({ items, isDisabled, className, children, onSortStart, onSortEnd, updateBeforeSortStart, sortingStrategy, }: SortableLinkListProps<T>) =>
|
|
26
|
+
}>({ items, isDisabled, className, children, onSortStart, onSortEnd, updateBeforeSortStart, sortingStrategy, }: SortableLinkListProps<T>) => JSX.Element;
|
|
27
27
|
export {};
|
|
@@ -6,4 +6,4 @@ export declare const useQuery: typeof useRQ;
|
|
|
6
6
|
* Provides access to a query client either by sharing an existing client or
|
|
7
7
|
* creating a new one.
|
|
8
8
|
*/
|
|
9
|
-
export declare function SharedQueryClientProvider({ children }: React.PropsWithChildren<{}>):
|
|
9
|
+
export declare function SharedQueryClientProvider({ children }: React.PropsWithChildren<{}>): JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { File } from '../../types';
|
|
3
3
|
interface AssetThumbnailProps {
|
|
4
4
|
file: File;
|
|
5
5
|
}
|
|
6
|
-
export declare function AssetThumbnail(props: AssetThumbnailProps):
|
|
6
|
+
export declare function AssetThumbnail(props: AssetThumbnailProps): JSX.Element;
|
|
7
7
|
export {};
|
|
@@ -15,5 +15,5 @@ interface CreateEntryLinkButtonProps {
|
|
|
15
15
|
position: 'bottom-left' | 'bottom-right';
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
-
export declare const CreateEntryLinkButton: ({ contentTypes, onSelect, customDropdownItems, text, testId, hasPlusIcon, useExperimentalStyles, suggestedContentTypeId, dropdownSettings, disabled, }: CreateEntryLinkButtonProps) =>
|
|
18
|
+
export declare const CreateEntryLinkButton: ({ contentTypes, onSelect, customDropdownItems, text, testId, hasPlusIcon, useExperimentalStyles, suggestedContentTypeId, dropdownSettings, disabled, }: CreateEntryLinkButtonProps) => JSX.Element;
|
|
19
19
|
export {};
|
|
@@ -24,7 +24,7 @@ interface CreateEntryMenuTrigger {
|
|
|
24
24
|
menuProps?: Omit<MenuProps, 'children'>;
|
|
25
25
|
}
|
|
26
26
|
export declare const CreateEntryMenuTrigger: {
|
|
27
|
-
({ contentTypes, suggestedContentTypeId, contentTypesLabel, onSelect, testId, dropdownSettings, customDropdownItems, children, menuProps, }: CreateEntryMenuTrigger):
|
|
27
|
+
({ contentTypes, suggestedContentTypeId, contentTypesLabel, onSelect, testId, dropdownSettings, customDropdownItems, children, menuProps, }: CreateEntryMenuTrigger): JSX.Element;
|
|
28
28
|
defaultProps: {
|
|
29
29
|
testId: string;
|
|
30
30
|
contentTypesLabel: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { LinkActionsProps } from './LinkActions';
|
|
3
3
|
/**
|
|
4
4
|
* Alternative, experimental alternative to <LinkActions /> that is planned to
|
|
@@ -7,4 +7,4 @@ import { LinkActionsProps } from './LinkActions';
|
|
|
7
7
|
* Places both actions to create and link new, as well as link existing, behind
|
|
8
8
|
* one action dropdown and introduces new copy for action labels.
|
|
9
9
|
*/
|
|
10
|
-
export declare function CombinedLinkActions(props: LinkActionsProps):
|
|
10
|
+
export declare function CombinedLinkActions(props: LinkActionsProps): JSX.Element | null;
|
|
@@ -23,4 +23,4 @@ export declare const testIds: {
|
|
|
23
23
|
createAndLinkWrapper: string;
|
|
24
24
|
linkExisting: string;
|
|
25
25
|
};
|
|
26
|
-
export declare function LinkActions(props: LinkActionsProps):
|
|
26
|
+
export declare function LinkActions(props: LinkActionsProps): JSX.Element | null;
|
|
@@ -17,8 +17,8 @@ type LinkEntityActionsProps = {
|
|
|
17
17
|
export declare function useLinkActionsProps(props: LinkEntityActionsProps): LinkActionsProps;
|
|
18
18
|
export declare function LinkEntityActions({ renderCustomActions, ...props }: LinkActionsProps & {
|
|
19
19
|
renderCustomActions?: (props: LinkActionsProps) => React.ReactElement;
|
|
20
|
-
}):
|
|
20
|
+
}): JSX.Element;
|
|
21
21
|
export declare function CombinedLinkEntityActions({ renderCustomActions, ...props }: LinkActionsProps & {
|
|
22
22
|
renderCustomActions?: (props: LinkActionsProps) => React.ReactElement;
|
|
23
|
-
}):
|
|
23
|
+
}): JSX.Element;
|
|
24
24
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function NoLinkPermissionsInfo():
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare function NoLinkPermissionsInfo(): JSX.Element;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { ContentEntityType } from '../../types';
|
|
3
3
|
export declare function MissingEntityCard(props: {
|
|
4
4
|
entityType: ContentEntityType;
|
|
@@ -6,4 +6,4 @@ export declare function MissingEntityCard(props: {
|
|
|
6
6
|
isSelected?: boolean;
|
|
7
7
|
isDisabled: boolean;
|
|
8
8
|
onRemove?: Function;
|
|
9
|
-
}):
|
|
9
|
+
}): JSX.Element;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
export declare function ResourceEntityErrorCard(props: {
|
|
3
3
|
linkType: string;
|
|
4
4
|
error: unknown;
|
|
5
5
|
isSelected?: boolean;
|
|
6
6
|
isDisabled: boolean;
|
|
7
7
|
onRemove?: Function;
|
|
8
|
-
}):
|
|
8
|
+
}): JSX.Element;
|
|
@@ -6,5 +6,5 @@ type ScheduledIconWithTooltipProps = {
|
|
|
6
6
|
entityId: string;
|
|
7
7
|
children: React.ReactElement;
|
|
8
8
|
};
|
|
9
|
-
export declare const ScheduledIconWithTooltip: ({ entityType, entityId, getEntityScheduledActions, children, }: ScheduledIconWithTooltipProps) =>
|
|
9
|
+
export declare const ScheduledIconWithTooltip: ({ entityType, entityId, getEntityScheduledActions, children, }: ScheduledIconWithTooltipProps) => JSX.Element | null;
|
|
10
10
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
interface SourceProps {
|
|
3
3
|
spaceName: string;
|
|
4
4
|
environmentName?: string;
|
|
5
5
|
}
|
|
6
|
-
export declare function SpaceName(props: SourceProps):
|
|
6
|
+
export declare function SpaceName(props: SourceProps): JSX.Element;
|
|
7
7
|
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { ReferenceEditorProps } from '../common/ReferenceEditor';
|
|
3
|
-
export declare function MultipleEntryReferenceEditor(props: ReferenceEditorProps):
|
|
3
|
+
export declare function MultipleEntryReferenceEditor(props: ReferenceEditorProps): JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { ReferenceEditorProps } from '../common/ReferenceEditor';
|
|
3
|
-
export declare function SingleEntryReferenceEditor(props: ReferenceEditorProps):
|
|
3
|
+
export declare function SingleEntryReferenceEditor(props: ReferenceEditorProps): JSX.Element;
|
|
4
4
|
export declare namespace SingleEntryReferenceEditor {
|
|
5
5
|
var defaultProps: {
|
|
6
6
|
isInitiallyDisabled: boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { RenderCustomMissingEntityCard } from '../../common/customCardTypes';
|
|
3
3
|
import { ReferenceEditorProps } from '../../common/ReferenceEditor';
|
|
4
4
|
import { ContentType, RenderDragFn } from '../../types';
|
|
@@ -15,4 +15,4 @@ export type EntryCardReferenceEditorProps = ReferenceEditorProps & {
|
|
|
15
15
|
renderCustomMissingEntityCard?: RenderCustomMissingEntityCard;
|
|
16
16
|
isBeingDragged?: boolean;
|
|
17
17
|
};
|
|
18
|
-
export declare function FetchingWrappedEntryCard(props: EntryCardReferenceEditorProps):
|
|
18
|
+
export declare function FetchingWrappedEntryCard(props: EntryCardReferenceEditorProps): JSX.Element;
|
|
@@ -24,7 +24,7 @@ export interface WrappedEntryCardProps {
|
|
|
24
24
|
hasCardMoveActions?: boolean;
|
|
25
25
|
hasCardRemoveActions?: boolean;
|
|
26
26
|
}
|
|
27
|
-
export declare function WrappedEntryCard(props: WrappedEntryCardProps):
|
|
27
|
+
export declare function WrappedEntryCard(props: WrappedEntryCardProps): JSX.Element;
|
|
28
28
|
export declare namespace WrappedEntryCard {
|
|
29
29
|
var defaultProps: {
|
|
30
30
|
isClickable: boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { Entry } from '@contentful/field-editor-shared';
|
|
3
3
|
import { RenderDragFn, ResourceInfo } from '../../types';
|
|
4
4
|
export type CardActionsHandlers = {
|
|
@@ -17,5 +17,5 @@ type ContentfulEntryCardProps = {
|
|
|
17
17
|
renderDragHandle?: RenderDragFn;
|
|
18
18
|
getEntryRouteHref: (entryRoute: EntryRoute) => string;
|
|
19
19
|
} & CardActionsHandlers;
|
|
20
|
-
export declare function ContentfulEntryCard({ info, isDisabled, renderDragHandle, onRemove, onMoveTop, onMoveBottom, getEntryRouteHref, }: ContentfulEntryCardProps):
|
|
20
|
+
export declare function ContentfulEntryCard({ info, isDisabled, renderDragHandle, onRemove, onMoveTop, onMoveBottom, getEntryRouteHref, }: ContentfulEntryCardProps): JSX.Element;
|
|
21
21
|
export {};
|