feat(ui): toggle sortable arrays and blocks (#6008)

This commit is contained in:
Kendell Joseph
2024-05-08 13:28:26 -04:00
committed by GitHub
parent dc8c099d9e
commit 4c6aaafe88
14 changed files with 129 additions and 18 deletions

View File

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

View File

@@ -130,6 +130,14 @@ const BlockFields: CollectionConfig = {
},
localized: true,
},
{
...getBlocksField('localized'),
name: 'disableSort',
admin: {
isSortable: false,
},
localized: true,
},
{
...getBlocksField('localized'),
name: 'localizedBlocks',

View File

@@ -24,7 +24,14 @@ import { POLL_TOPASS_TIMEOUT, TEST_TIMEOUT_LONG } from '../playwright.config.js'
import { jsonDoc } from './collections/JSON/shared.js'
import { numberDoc } from './collections/Number/shared.js'
import { textDoc } from './collections/Text/shared.js'
import { collapsibleFieldsSlug, pointFieldsSlug, tabsFieldsSlug, textFieldsSlug } from './slugs.js'
import {
arrayFieldsSlug,
blockFieldsSlug,
collapsibleFieldsSlug,
pointFieldsSlug,
tabsFieldsSlug,
textFieldsSlug,
} from './slugs.js'
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
@@ -536,6 +543,44 @@ describe('fields', () => {
})
})
describe('sortable arrays', () => {
let url: AdminUrlUtil
beforeAll(() => {
url = new AdminUrlUtil(serverURL, arrayFieldsSlug)
})
test('should have disabled admin sorting', async () => {
await page.goto(url.create)
const field = page.locator('#field-disableSort .array-actions__action-chevron')
expect(await field.count()).toEqual(0)
})
test('the drag handle should be hidden', async () => {
await page.goto(url.create)
const field = page.locator('#field-disableSort .collapsible__drag')
expect(await field.count()).toEqual(0)
})
})
describe('sortable blocks', () => {
let url: AdminUrlUtil
beforeAll(() => {
url = new AdminUrlUtil(serverURL, blockFieldsSlug)
})
test('should have disabled admin sorting', async () => {
await page.goto(url.create)
const field = page.locator('#field-disableSort .array-actions__action-chevron')
expect(await field.count()).toEqual(0)
})
test('the drag handle should be hidden', async () => {
await page.goto(url.create)
const field = page.locator('#field-disableSort .collapsible__drag')
expect(await field.count()).toEqual(0)
})
})
describe('tabs', () => {
let url: AdminUrlUtil
beforeAll(() => {