Files
payloadcms/test/admin/collections/Posts.ts
Alessio Gravili cfeac79b99 feat!: fix non-functional custom RSC component handling, separate label and description props, fix non-functional label function handling (#6264)
Breaking Changes:

- Globals config: `admin.description` no longer accepts a custom component. You will have to move it to `admin.components.elements.Description`
- Collections config: `admin.description` no longer accepts a custom component. You will have to move it to `admin.components.edit.Description`
- All Fields: `field.admin.description` no longer accepts a custom component. You will have to move it to `field.admin.components.Description`
- Collapsible Field: `field.label` no longer accepts a custom component. You will have to move it to `field.admin.components.RowLabel`
- Array Field: `field.admin.components.RowLabel` no longer accepts strings or records
- If you are using our exported field components in your own app, their `labelProps` property has been stripped down and no longer contains the `label` and `required` prop. Those can now only be configured at the top-level
2024-05-09 17:12:01 -04:00

136 lines
3.2 KiB
TypeScript

import type { CollectionConfig } from 'payload/types'
import { slateEditor } from '@payloadcms/richtext-slate'
import { CustomCell } from '../components/CustomCell/index.js'
import { DemoUIFieldCell } from '../components/DemoUIField/Cell.js'
import { DemoUIField } from '../components/DemoUIField/Field.js'
import { FieldDescriptionComponent } from '../components/FieldDescription/index.js'
import { slugPluralLabel, slugSingularLabel } from '../shared.js'
import { postsCollectionSlug } from '../slugs.js'
export const Posts: CollectionConfig = {
slug: postsCollectionSlug,
admin: {
defaultColumns: ['id', 'number', 'title', 'description', 'demoUIField'],
description: 'Description',
group: 'One',
listSearchableFields: ['id', 'title', 'description', 'number'],
preview: () => 'https://payloadcms.com',
useAsTitle: 'title',
},
fields: [
{
type: 'tabs',
tabs: [
{
fields: [
{
name: 'title',
type: 'text',
},
{
name: 'description',
type: 'text',
},
{
name: 'number',
type: 'number',
},
{
name: 'richText',
type: 'richText',
editor: slateEditor({
admin: {
elements: ['relationship'],
},
}),
},
{
name: 'demoUIField',
type: 'ui',
admin: {
components: {
Cell: DemoUIFieldCell,
Field: DemoUIField,
},
},
label: 'Demo UI Field',
},
],
label: 'Tab 1',
},
],
},
{
name: 'group',
type: 'group',
fields: [
{
name: 'title',
type: 'text',
},
],
},
{
name: 'relationship',
type: 'relationship',
admin: {
position: 'sidebar',
},
relationTo: 'posts',
},
{
name: 'customCell',
type: 'text',
admin: {
components: {
Cell: CustomCell,
},
},
},
{
name: 'sidebarField',
type: 'text',
access: {
update: () => false,
},
admin: {
description:
'This is a very long description that takes many characters to complete and hopefully will wrap instead of push the sidebar open, lorem ipsum dolor sit amet consectetur adipisicing elit. Quisquam, voluptatum voluptates. Quisquam, voluptatum voluptates.',
position: 'sidebar',
},
},
{
name: 'descriptionAsString',
type: 'text',
admin: {
description: 'Static field description.',
},
},
{
name: 'descriptionAsFunction',
type: 'text',
admin: {
description: () => 'Function description',
},
},
{
name: 'descriptionAsComponent',
type: 'text',
admin: {
components: {
Description: FieldDescriptionComponent,
},
},
},
],
labels: {
plural: slugPluralLabel,
singular: slugSingularLabel,
},
versions: {
drafts: true,
},
}