feat: add isSortable to arrays and blocks (#5962)

This commit is contained in:
Kendell Joseph
2024-05-03 10:38:02 -04:00
committed by GitHub
parent 23f3eb1cf0
commit 5c58bd322d
16 changed files with 82 additions and 10 deletions

View File

@@ -155,6 +155,21 @@ const ArrayFields: CollectionConfig = {
minRows: 2,
type: 'array',
},
{
name: 'disableSortItems',
defaultValue: arrayDefaultValue,
admin: {
isSortable: false,
},
fields: [
{
name: 'text',
required: true,
type: 'text',
},
],
type: 'array',
},
],
slug: arrayFieldsSlug,
versions: true,

View File

@@ -63,4 +63,15 @@ export const anotherArrayDoc: Partial<ArrayField> = {
text: 'second row',
},
],
disableSortItems: [
{
text: 'un-sortable item 1',
},
{
text: 'un-sortable item 2',
},
{
text: 'un-sortable item 3',
},
],
}

View File

@@ -124,6 +124,7 @@ const BlockFields: CollectionConfig = {
name: 'collapsedByDefaultBlocks',
admin: {
initCollapsed: true,
isSortable: false,
},
localized: true,
},

View File

@@ -696,6 +696,12 @@ describe('fields', () => {
})
})
})
test('should have disabled admin sorting', async () => {
await page.goto(url.create)
const field = page.locator('#field-collapsedByDefaultBlocks .array-actions__action-chevron')
expect(await field.count()).toEqual(0)
})
})
describe('array', () => {
@@ -716,6 +722,12 @@ describe('fields', () => {
await expect(field).toHaveValue('defaultValue')
})
test('should have disabled admin sorting', async () => {
await page.goto(url.create)
const field = page.locator('#field-disableSortItems .array-actions__action-chevron')
expect(await field.count()).toEqual(0)
})
test('should render RowLabel using a function', async () => {
const label = 'custom row label as function'
await page.goto(url.create)

View File

@@ -265,6 +265,10 @@ export interface ArrayField {
id?: string | null
}[]
| null
disableSortItems?: {
text: string
id?: string | null
}[]
updatedAt: string
createdAt: string
}