feat(ui): toggle sortable arrays and blocks (#6008)
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -130,6 +130,14 @@ const BlockFields: CollectionConfig = {
|
||||
},
|
||||
localized: true,
|
||||
},
|
||||
{
|
||||
...getBlocksField('localized'),
|
||||
name: 'disableSort',
|
||||
admin: {
|
||||
isSortable: false,
|
||||
},
|
||||
localized: true,
|
||||
},
|
||||
{
|
||||
...getBlocksField('localized'),
|
||||
name: 'localizedBlocks',
|
||||
|
||||
@@ -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(() => {
|
||||
|
||||
Reference in New Issue
Block a user