Chore/clean community (#9181)

Cleans up _community test suite
This commit is contained in:
James Mikrut
2024-11-13 14:12:19 -05:00
committed by GitHub
parent 5b9cee67c0
commit ced79be591
7 changed files with 96 additions and 363 deletions

View File

@@ -1,6 +0,0 @@
'use client'
import React from 'react'
export const MyAvatar: React.FC = () => {
return <p>Some custom Avatar</p>
}

View File

@@ -1,9 +0,0 @@
'use client'
import type { TextFieldClientComponent } from 'payload'
import { TextField } from '@payloadcms/ui'
import React from 'react'
export const MyClientFieldComponent: TextFieldClientComponent = (props) => {
return <TextField {...props} />
}

View File

@@ -1,6 +0,0 @@
'use client'
import React from 'react'
export const MyComponent2: React.FC = () => {
return <p>Some custom label2</p>
}

View File

@@ -1,29 +0,0 @@
import type { TextFieldServerComponent } from 'payload'
import { TextField } from '@payloadcms/ui'
import React from 'react'
export const MyServerFieldComponent: TextFieldServerComponent = (props) => {
const {
clientField,
indexPath,
parentPath,
parentSchemaPath,
path,
schemaPath,
// siblingData,
// value,
// data
} = props
return (
<TextField
field={clientField}
indexPath={indexPath}
parentPath={parentPath}
parentSchemaPath={parentSchemaPath}
path={path}
schemaPath={schemaPath}
/>
)
}

View File

@@ -5,99 +5,13 @@ export const postsSlug = 'posts'
export const PostsCollection: CollectionConfig = {
slug: postsSlug,
admin: {
useAsTitle: 'text',
useAsTitle: 'title',
},
fields: [
{
admin: {
components: {
Field: '/collections/Posts/MyClientField.js#MyClientFieldComponent',
},
},
name: 'text',
label: 'Client Text Field',
name: 'title',
type: 'text',
},
{
admin: {
components: {
Field: '/collections/Posts/MyServerField.js#MyServerFieldComponent',
},
},
name: 'serverTextField',
type: 'text',
},
{
name: 'relationToSelf',
type: 'relationship',
relationTo: postsSlug,
},
{
name: 'myArray',
type: 'array',
fields: [
{
admin: {
components: {
Field: '/collections/Posts/MyServerField.js#MyServerFieldComponent',
},
},
name: 'serverTextField',
type: 'text',
},
{
admin: {
components: {
Field: '/collections/Posts/MyClientField.js#MyClientFieldComponent',
},
},
name: 'text',
label: 'Client Text Field',
type: 'text',
},
],
},
// {
// name: 'richText',
// type: 'richText',
// },
// {
// name: 'myBlocks',
// type: 'blocks',
// blocks: [
// {
// slug: 'test',
// fields: [
// {
// name: 'test',
// type: 'text',
// },
// ],
// },
// {
// slug: 'someBlock2',
// fields: [
// {
// name: 'test2',
// type: 'text',
// },
// ],
// },
// ],
// },
// {
// type: 'row',
// fields: [],
// },
// {
// name: 'associatedMedia',
// type: 'upload',
// access: {
// create: () => true,
// update: () => false,
// },
// relationTo: mediaSlug,
// },
],
versions: {
drafts: true,

View File

@@ -1,4 +1,4 @@
// import { BlocksFeature, lexicalEditor } from '@payloadcms/richtext-lexical'
import { lexicalEditor } from '@payloadcms/richtext-lexical'
import { fileURLToPath } from 'node:url'
import path from 'path'
@@ -7,148 +7,22 @@ import { devUser } from '../credentials.js'
import { MediaCollection } from './collections/Media/index.js'
import { PostsCollection, postsSlug } from './collections/Posts/index.js'
import { MenuGlobal } from './globals/Menu/index.js'
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
export default buildConfigWithDefaults({
// ...extend config here
collections: [
PostsCollection,
{
slug: 'simple',
fields: [
{
name: 'text',
type: 'text',
},
],
},
],
collections: [PostsCollection, MediaCollection],
admin: {
importMap: {
baseDir: path.resolve(dirname),
},
avatar: {
Component: '/collections/Posts/MyAvatar.js#MyAvatar',
},
},
editor: null,
// editor: lexicalEditor({
// features: ({ defaultFeatures }) => [
// ...defaultFeatures,
// BlocksFeature({
// blocks: [
// {
// admin: {
// components: {
// Label: '/collections/Posts/MyComponent2.js#MyComponent2',
// },
// },
// slug: 'test',
// fields: [
// {
// name: 'test',
// type: 'text',
// },
// ],
// },
// {
// slug: 'someBlock2',
// fields: [
// {
// name: 'test2',
// type: 'text',
// },
// ],
// },
// ],
// inlineBlocks: [
// {
// admin: {
// components: {
// Label: '/collections/Posts/MyComponent2.js#MyComponent2',
// },
// },
// slug: 'test',
// fields: [
// {
// name: 'test',
// type: 'text',
// },
// ],
// },
// {
// slug: 'someBlock2',
// fields: [
// {
// name: 'test2',
// type: 'text',
// },
// ],
// },
// ],
// }),
// ],
// }),
cors: ['http://localhost:3000', 'http://localhost:3001'],
editor: lexicalEditor({}),
globals: [
MenuGlobal,
{
slug: 'custom-ts',
fields: [
{
name: 'custom',
type: 'text',
typescriptSchema: [
() => ({
enum: ['hello', 'world'],
}),
],
},
{
name: 'withDefinitionsUsage',
type: 'text',
typescriptSchema: [
() => ({
type: 'array',
items: {
$ref: `#/definitions/objectWithNumber`,
},
}),
],
},
{
name: 'json',
type: 'json',
jsonSchema: {
fileMatch: ['a://b/foo.json'],
schema: {
type: 'array',
items: {
type: 'object',
additionalProperties: false,
properties: {
id: {
type: 'string',
},
name: {
type: 'string',
},
age: {
type: 'integer',
},
// Add other properties here
},
required: ['id', 'name'], // Specify which properties are required
},
},
uri: 'a://b/foo.json',
},
required: true,
},
],
},
// ...add more globals here
MenuGlobal,
],
onInit: async (payload) => {
await payload.create({
@@ -162,37 +36,11 @@ export default buildConfigWithDefaults({
await payload.create({
collection: postsSlug,
data: {
text: 'example post',
title: 'example post',
},
})
// // Create image
// const imageFilePath = path.resolve(dirname, '../uploads/image.png')
// const imageFile = await getFileByPath(imageFilePath)
// await payload.create({
// collection: 'media',
// data: {},
// file: imageFile,
// })
},
typescript: {
outputFile: path.resolve(dirname, 'payload-types.ts'),
schema: [
({ jsonSchema }) => {
jsonSchema.definitions.objectWithNumber = {
type: 'object',
additionalProperties: false,
properties: {
id: {
type: 'number',
required: true,
},
},
required: true,
}
return jsonSchema
},
],
},
})

View File

@@ -12,7 +12,7 @@ export interface Config {
};
collections: {
posts: Post;
simple: Simple;
media: Media;
users: User;
'payload-locked-documents': PayloadLockedDocument;
'payload-preferences': PayloadPreference;
@@ -21,7 +21,7 @@ export interface Config {
collectionsJoins: {};
collectionsSelect: {
posts: PostsSelect<false> | PostsSelect<true>;
simple: SimpleSelect<false> | SimpleSelect<true>;
media: MediaSelect<false> | MediaSelect<true>;
users: UsersSelect<false> | UsersSelect<true>;
'payload-locked-documents': PayloadLockedDocumentsSelect<false> | PayloadLockedDocumentsSelect<true>;
'payload-preferences': PayloadPreferencesSelect<false> | PayloadPreferencesSelect<true>;
@@ -32,11 +32,9 @@ export interface Config {
};
globals: {
menu: Menu;
'custom-ts': CustomT;
};
globalsSelect: {
menu: MenuSelect<false> | MenuSelect<true>;
'custom-ts': CustomTsSelect<false> | CustomTsSelect<true>;
};
locale: null;
user: User & {
@@ -71,29 +69,54 @@ export interface UserAuthOperations {
*/
export interface Post {
id: string;
text?: string | null;
serverTextField?: string | null;
relationToSelf?: (string | null) | Post;
myArray?:
| {
serverTextField?: string | null;
text?: string | null;
id?: string | null;
}[]
| null;
title?: string | null;
updatedAt: string;
createdAt: string;
_status?: ('draft' | 'published') | null;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "simple".
* via the `definition` "media".
*/
export interface Simple {
export interface Media {
id: string;
text?: string | null;
updatedAt: string;
createdAt: string;
url?: string | null;
thumbnailURL?: string | null;
filename?: string | null;
mimeType?: string | null;
filesize?: number | null;
width?: number | null;
height?: number | null;
focalX?: number | null;
focalY?: number | null;
sizes?: {
thumbnail?: {
url?: string | null;
width?: number | null;
height?: number | null;
mimeType?: string | null;
filesize?: number | null;
filename?: string | null;
};
medium?: {
url?: string | null;
width?: number | null;
height?: number | null;
mimeType?: string | null;
filesize?: number | null;
filename?: string | null;
};
large?: {
url?: string | null;
width?: number | null;
height?: number | null;
mimeType?: string | null;
filesize?: number | null;
filename?: string | null;
};
};
}
/**
* This interface was referenced by `Config`'s JSON-Schema
@@ -124,8 +147,8 @@ export interface PayloadLockedDocument {
value: string | Post;
} | null)
| ({
relationTo: 'simple';
value: string | Simple;
relationTo: 'media';
value: string | Media;
} | null)
| ({
relationTo: 'users';
@@ -178,28 +201,61 @@ export interface PayloadMigration {
* via the `definition` "posts_select".
*/
export interface PostsSelect<T extends boolean = true> {
text?: T;
serverTextField?: T;
relationToSelf?: T;
myArray?:
| T
| {
serverTextField?: T;
text?: T;
id?: T;
};
title?: T;
updatedAt?: T;
createdAt?: T;
_status?: T;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "simple_select".
* via the `definition` "media_select".
*/
export interface SimpleSelect<T extends boolean = true> {
text?: T;
export interface MediaSelect<T extends boolean = true> {
updatedAt?: T;
createdAt?: T;
url?: T;
thumbnailURL?: T;
filename?: T;
mimeType?: T;
filesize?: T;
width?: T;
height?: T;
focalX?: T;
focalY?: T;
sizes?:
| T
| {
thumbnail?:
| T
| {
url?: T;
width?: T;
height?: T;
mimeType?: T;
filesize?: T;
filename?: T;
};
medium?:
| T
| {
url?: T;
width?: T;
height?: T;
mimeType?: T;
filesize?: T;
filename?: T;
};
large?:
| T
| {
url?: T;
width?: T;
height?: T;
mimeType?: T;
filesize?: T;
filename?: T;
};
};
}
/**
* This interface was referenced by `Config`'s JSON-Schema
@@ -258,29 +314,6 @@ export interface Menu {
updatedAt?: string | null;
createdAt?: string | null;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "custom-ts".
*/
export interface CustomT {
id: string;
custom?: 'hello' | 'world';
withDefinitionsUsage?: ObjectWithNumber[];
json: {
id: string;
name: string;
age?: number;
}[];
updatedAt?: string | null;
createdAt?: string | null;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "objectWithNumber".
*/
export interface ObjectWithNumber {
id?: number;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "menu_select".
@@ -291,18 +324,6 @@ export interface MenuSelect<T extends boolean = true> {
createdAt?: T;
globalType?: T;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "custom-ts_select".
*/
export interface CustomTsSelect<T extends boolean = true> {
custom?: T;
withDefinitionsUsage?: T;
json?: T;
updatedAt?: T;
createdAt?: T;
globalType?: T;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "auth".