fix: properly sets tabs key in fieldSchemaToJSON (#4317)
This commit is contained in:
@@ -74,7 +74,7 @@ export const fieldSchemaToJSON = (fields: Field[]): FieldSchemaJSON => {
|
|||||||
tabFields.push({
|
tabFields.push({
|
||||||
name: tab.name,
|
name: tab.name,
|
||||||
fields: fieldSchemaToJSON(tab.fields),
|
fields: fieldSchemaToJSON(tab.fields),
|
||||||
type: 'tab',
|
type: field.type,
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,6 +121,23 @@ export const Pages: CollectionConfig = {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: 'Named Tabs',
|
||||||
|
type: 'tabs',
|
||||||
|
tabs: [
|
||||||
|
{
|
||||||
|
name: 'tab',
|
||||||
|
label: 'Tab',
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
name: 'relationshipInTab',
|
||||||
|
type: 'relationship',
|
||||||
|
relationTo: 'posts',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -307,6 +307,27 @@ describe('Collections - Live Preview', () => {
|
|||||||
expect(merge2.relationshipPolyHasMany).toEqual([])
|
expect(merge2.relationshipPolyHasMany).toEqual([])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('— relationships - populates within tabs', async () => {
|
||||||
|
const initialData: Partial<Page> = {
|
||||||
|
title: 'Test Page',
|
||||||
|
}
|
||||||
|
|
||||||
|
const merge1 = await mergeData({
|
||||||
|
depth: 1,
|
||||||
|
fieldSchema: schemaJSON,
|
||||||
|
incomingData: {
|
||||||
|
...initialData,
|
||||||
|
tab: {
|
||||||
|
relationshipInTab: testPost.id,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
initialData,
|
||||||
|
serverURL,
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(merge1.tab.relationshipInTab).toMatchObject(testPost)
|
||||||
|
})
|
||||||
|
|
||||||
it('— relationships - populates within arrays', async () => {
|
it('— relationships - populates within arrays', async () => {
|
||||||
const initialData: Partial<Page> = {
|
const initialData: Partial<Page> = {
|
||||||
title: 'Test Page',
|
title: 'Test Page',
|
||||||
|
|||||||
@@ -152,11 +152,6 @@ export interface Page {
|
|||||||
}
|
}
|
||||||
)[]
|
)[]
|
||||||
| null
|
| null
|
||||||
meta?: {
|
|
||||||
title?: string | null
|
|
||||||
description?: string | null
|
|
||||||
image?: string | Media | null
|
|
||||||
}
|
|
||||||
relationshipInRichText?:
|
relationshipInRichText?:
|
||||||
| {
|
| {
|
||||||
[k: string]: unknown
|
[k: string]: unknown
|
||||||
@@ -198,6 +193,14 @@ export interface Page {
|
|||||||
id?: string | null
|
id?: string | null
|
||||||
}[]
|
}[]
|
||||||
| null
|
| null
|
||||||
|
tab: {
|
||||||
|
relationshipInTab?: (string | null) | Post
|
||||||
|
}
|
||||||
|
meta?: {
|
||||||
|
title?: string | null
|
||||||
|
description?: string | null
|
||||||
|
image?: string | Media | null
|
||||||
|
}
|
||||||
updatedAt: string
|
updatedAt: string
|
||||||
createdAt: string
|
createdAt: string
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user