Files
payload/test/versions/collections/Diff/index.ts
Alessio Gravili 393b4a0929 fix(next): no client field found error when accessing version view in some configurations (#13339)
This PR fixes some incorrect field paths handling (=> should not pass
path and schema paths that contain index paths down to sub-fields
outside of the indexPath property) when building the version fields.

Fixes https://github.com/payloadcms/payload/issues/12376

---
- To see the specific tasks where the Asana app for GitHub is being
used, see below:
  - https://app.asana.com/0/0/1210932060696925
2025-08-21 10:04:55 -04:00

285 lines
5.6 KiB
TypeScript

import type { CollectionConfig } from 'payload'
import { diffCollectionSlug, draftCollectionSlug } from '../../slugs.js'
export const Diff: CollectionConfig = {
slug: diffCollectionSlug,
fields: [
{
name: 'array',
type: 'array',
fields: [
{
name: 'textInArray',
type: 'text',
},
],
},
{
name: 'arrayLocalized',
type: 'array',
localized: true,
fields: [
{
name: 'textInArrayLocalized',
type: 'text',
},
],
},
{
name: 'blocks',
type: 'blocks',
blocks: [
{
slug: 'TextBlock',
fields: [
{
name: 'textInBlock',
type: 'text',
},
],
},
{
slug: 'CollapsibleBlock',
fields: [
{
type: 'collapsible',
label: 'Collapsible',
fields: [
{
type: 'collapsible',
label: 'Nested Collapsible',
fields: [
{
name: 'textInCollapsibleInCollapsibleBlock',
type: 'text',
},
],
},
{
type: 'row',
fields: [
{
name: 'textInRowInCollapsibleBlock',
type: 'text',
},
],
},
],
},
],
},
{
slug: 'TabsBlock',
fields: [
{
type: 'tabs',
tabs: [
{
name: 'namedTab1InBlock',
fields: [
{
name: 'textInNamedTab1InBlock',
type: 'text',
},
],
},
{
label: 'Unnamed Tab 2 In Block',
fields: [
{
name: 'textInUnnamedTab2InBlock',
type: 'text',
},
{
type: 'row',
fields: [
{
name: 'textInRowInUnnamedTab2InBlock',
type: 'text',
},
],
},
],
},
],
},
],
},
],
},
{
type: 'checkbox',
name: 'checkbox',
},
{
type: 'code',
name: 'code',
},
{
type: 'collapsible',
label: 'Collapsible',
fields: [
{
name: 'textInCollapsible',
type: 'text',
},
],
},
{
type: 'date',
name: 'date',
},
{
type: 'email',
name: 'email',
},
{
type: 'group',
name: 'group',
fields: [
{
name: 'textInGroup',
type: 'text',
},
],
},
{
type: 'number',
name: 'number',
},
{
type: 'point',
name: 'point',
},
{
type: 'json',
name: 'json',
},
{
type: 'radio',
name: 'radio',
options: [
{
label: 'Option 1',
value: 'option1',
},
{
label: 'Option 2',
value: 'option2',
},
],
},
{
type: 'relationship',
name: 'relationship',
relationTo: draftCollectionSlug,
},
{
type: 'relationship',
name: 'relationshipHasMany',
hasMany: true,
relationTo: draftCollectionSlug,
},
{
type: 'relationship',
name: 'relationshipPolymorphic',
relationTo: [draftCollectionSlug, 'text'],
},
{
type: 'relationship',
name: 'relationshipHasManyPolymorphic',
hasMany: true,
relationTo: [draftCollectionSlug, 'text'],
},
{
type: 'relationship',
name: 'relationshipHasManyPolymorphic2',
hasMany: true,
relationTo: [draftCollectionSlug, 'text'],
},
{
name: 'richtext',
type: 'richText',
},
{
name: 'richtextWithCustomDiff',
type: 'richText',
admin: {
components: {
Diff: './elements/RichTextDiffComponent/index.js#RichTextDiffComponent',
},
},
},
{
fields: [
{
name: 'textInRow',
type: 'text',
},
],
type: 'row',
},
{
name: 'select',
type: 'select',
options: [
{
label: 'Option 1',
value: 'option1',
},
{
label: 'Option 2',
value: 'option2',
},
],
},
{
type: 'tabs',
tabs: [
{
name: 'namedTab1',
fields: [
{
name: 'textInNamedTab1',
type: 'text',
},
],
},
{
label: 'Unnamed Tab 2',
fields: [
{
name: 'textInUnnamedTab2',
type: 'text',
},
],
},
],
},
{
name: 'text',
type: 'text',
},
{
name: 'textArea',
type: 'textarea',
},
{
name: 'upload',
relationTo: 'media',
type: 'upload',
},
{
name: 'uploadHasMany',
hasMany: true,
relationTo: 'media',
type: 'upload',
},
],
versions: {
drafts: true,
maxPerDoc: 35,
},
}