diff --git a/test/admin/collections/CustomViews1.ts b/test/admin/collections/CustomViews1.ts new file mode 100644 index 0000000000..5b230088aa --- /dev/null +++ b/test/admin/collections/CustomViews1.ts @@ -0,0 +1,23 @@ +import type { CollectionConfig } from '../../../packages/payload/src/collections/config/types' + +import CustomEditView from '../components/views/CustomEdit' + +export const CustomViews1: CollectionConfig = { + slug: 'custom-views-one', + versions: true, + admin: { + components: { + views: { + // This will override the entire Edit view including all nested views, i.e. `/edit/:id/*` + // To override one specific nested view, use the nested view's slug as the key + Edit: CustomEditView, + }, + }, + }, + fields: [ + { + name: 'title', + type: 'text', + }, + ], +} diff --git a/test/admin/collections/CustomViews2.ts b/test/admin/collections/CustomViews2.ts new file mode 100644 index 0000000000..7d6d7863d3 --- /dev/null +++ b/test/admin/collections/CustomViews2.ts @@ -0,0 +1,41 @@ +import type { CollectionConfig } from '../../../packages/payload/src/collections/config/types' + +import CustomTabComponent from '../components/CustomTabComponent' +import CustomDefaultEditView from '../components/views/CustomDefaultEdit' +import CustomVersionsView from '../components/views/CustomVersions' +import CustomView from '../components/views/CustomView' + +export const CustomViews2: CollectionConfig = { + slug: 'custom-views-two', + versions: true, + admin: { + components: { + views: { + Edit: { + // This will override one specific nested view within the `/edit/:id` route, i.e. `/edit/:id/versions` + Default: CustomDefaultEditView, + Versions: CustomVersionsView, + MyCustomView: { + path: '/custom-tab-view', + Component: CustomView, + Tab: { + label: 'Custom', + href: '/custom-tab-view', + }, + }, + MyCustomViewWithCustomTab: { + path: '/custom-tab-component', + Component: CustomView, + Tab: CustomTabComponent, + }, + }, + }, + }, + }, + fields: [ + { + name: 'title', + type: 'text', + }, + ], +} diff --git a/test/admin/collections/Geo.ts b/test/admin/collections/Geo.ts new file mode 100644 index 0000000000..14029e6a35 --- /dev/null +++ b/test/admin/collections/Geo.ts @@ -0,0 +1,11 @@ +import type { CollectionConfig } from '../../../packages/payload/src/collections/config/types' + +export const Geo: CollectionConfig = { + slug: 'geo', + fields: [ + { + name: 'point', + type: 'point', + }, + ], +} diff --git a/test/admin/collections/Group1A.ts b/test/admin/collections/Group1A.ts new file mode 100644 index 0000000000..0cd55d9a34 --- /dev/null +++ b/test/admin/collections/Group1A.ts @@ -0,0 +1,16 @@ +import type { CollectionConfig } from '../../../packages/payload/src/collections/config/types' + +import { group1Collection1Slug } from '../shared' + +export const CollectionGroup1A: CollectionConfig = { + slug: group1Collection1Slug, + admin: { + group: 'One', + }, + fields: [ + { + name: 'title', + type: 'text', + }, + ], +} diff --git a/test/admin/collections/Group1B.ts b/test/admin/collections/Group1B.ts new file mode 100644 index 0000000000..7334d60145 --- /dev/null +++ b/test/admin/collections/Group1B.ts @@ -0,0 +1,16 @@ +import type { CollectionConfig } from '../../../packages/payload/src/collections/config/types' + +import { group1Collection2Slug } from '../shared' + +export const CollectionGroup1B: CollectionConfig = { + slug: group1Collection2Slug, + admin: { + group: 'One', + }, + fields: [ + { + name: 'title', + type: 'text', + }, + ], +} diff --git a/test/admin/collections/Group2A.ts b/test/admin/collections/Group2A.ts new file mode 100644 index 0000000000..4444807614 --- /dev/null +++ b/test/admin/collections/Group2A.ts @@ -0,0 +1,14 @@ +import type { CollectionConfig } from '../../../packages/payload/src/collections/config/types' + +export const CollectionGroup2A: CollectionConfig = { + slug: 'group-two-collection-ones', + admin: { + group: 'One', + }, + fields: [ + { + name: 'title', + type: 'text', + }, + ], +} diff --git a/test/admin/collections/Group2B.ts b/test/admin/collections/Group2B.ts new file mode 100644 index 0000000000..bcb9928fb2 --- /dev/null +++ b/test/admin/collections/Group2B.ts @@ -0,0 +1,14 @@ +import type { CollectionConfig } from '../../../packages/payload/src/collections/config/types' + +export const CollectionGroup2B: CollectionConfig = { + slug: 'group-two-collection-twos', + admin: { + group: 'One', + }, + fields: [ + { + name: 'title', + type: 'text', + }, + ], +} diff --git a/test/admin/collections/Hidden.ts b/test/admin/collections/Hidden.ts new file mode 100644 index 0000000000..0da1f7c947 --- /dev/null +++ b/test/admin/collections/Hidden.ts @@ -0,0 +1,14 @@ +import type { CollectionConfig } from '../../../packages/payload/src/collections/config/types' + +export const CollectionHidden: CollectionConfig = { + slug: 'hidden-collection', + admin: { + hidden: () => true, + }, + fields: [ + { + name: 'title', + type: 'text', + }, + ], +} diff --git a/test/admin/collections/Posts.ts b/test/admin/collections/Posts.ts new file mode 100644 index 0000000000..8dff31d846 --- /dev/null +++ b/test/admin/collections/Posts.ts @@ -0,0 +1,78 @@ +import type { CollectionConfig } from '../../../packages/payload/src/collections/config/types' + +import { slateEditor } from '../../../packages/richtext-slate/src' +import DemoUIFieldCell from '../components/DemoUIField/Cell' +import DemoUIFieldField from '../components/DemoUIField/Field' +import { postsSlug, slugPluralLabel, slugSingularLabel } from '../shared' + +export const Posts: CollectionConfig = { + slug: postsSlug, + labels: { + singular: slugSingularLabel, + plural: slugPluralLabel, + }, + admin: { + description: 'Description', + listSearchableFields: ['title', 'description', 'number'], + group: 'One', + useAsTitle: 'title', + defaultColumns: ['id', 'number', 'title', 'description', 'demoUIField'], + preview: () => 'https://payloadcms.com', + }, + versions: { + drafts: true, + }, + fields: [ + { + type: 'tabs', + tabs: [ + { + label: 'Tab 1', + fields: [ + { + name: 'title', + type: 'text', + }, + { + name: 'description', + type: 'text', + }, + { + name: 'number', + type: 'number', + }, + { + name: 'richText', + type: 'richText', + editor: slateEditor({ + admin: { + elements: ['relationship'], + }, + }), + }, + { + type: 'ui', + name: 'demoUIField', + label: 'Demo UI Field', + admin: { + components: { + Field: DemoUIFieldField, + Cell: DemoUIFieldCell, + }, + }, + }, + ], + }, + ], + }, + { + name: 'sidebarField', + type: 'text', + admin: { + position: 'sidebar', + 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.', + }, + }, + ], +} diff --git a/test/admin/collections/Users.ts b/test/admin/collections/Users.ts new file mode 100644 index 0000000000..9469fdbda8 --- /dev/null +++ b/test/admin/collections/Users.ts @@ -0,0 +1,10 @@ +import type { CollectionConfig } from '../../../packages/payload/src/collections/config/types' + +export const Users: CollectionConfig = { + slug: 'users', + auth: true, + admin: { + useAsTitle: 'email', + }, + fields: [], +} diff --git a/test/admin/components/views/CustomDefaultEdit/index.tsx b/test/admin/components/views/CustomDefaultEdit/index.tsx index 05d0548baa..3d94bf93f3 100644 --- a/test/admin/components/views/CustomDefaultEdit/index.tsx +++ b/test/admin/components/views/CustomDefaultEdit/index.tsx @@ -6,7 +6,7 @@ import type { AdminViewComponent } from '../../../../../packages/payload/src/con import { useStepNav } from '../../../../../packages/payload/src/admin/components/elements/StepNav' import { useConfig } from '../../../../../packages/payload/src/admin/components/utilities/Config' -const CustomDefaultView: AdminViewComponent = ({ +const CustomDefaultEditView: AdminViewComponent = ({ canAccessAdmin, // collection, // global, @@ -72,4 +72,4 @@ const CustomDefaultView: AdminViewComponent = ({ ) } -export default CustomDefaultView +export default CustomDefaultEditView diff --git a/test/admin/config.ts b/test/admin/config.ts index 81e4355205..6fdc7ca9d1 100644 --- a/test/admin/config.ts +++ b/test/admin/config.ts @@ -1,31 +1,31 @@ import path from 'path' import { mapAsync } from '../../packages/payload/src/utilities/mapAsync' -import { slateEditor } from '../../packages/richtext-slate/src' import { buildConfigWithDefaults } from '../buildConfigWithDefaults' import { devUser } from '../credentials' +import { CustomViews1 } from './collections/CustomViews1' +import { CustomViews2 } from './collections/CustomViews2' +import { Geo } from './collections/Geo' +import { CollectionGroup1A } from './collections/Group1A' +import { CollectionGroup1B } from './collections/Group1B' +import { CollectionGroup2A } from './collections/Group2A' +import { CollectionGroup2B } from './collections/Group2B' +import { CollectionHidden } from './collections/Hidden' +import { Posts } from './collections/Posts' +import { Users } from './collections/Users' import AfterDashboard from './components/AfterDashboard' import AfterNavLinks from './components/AfterNavLinks' import BeforeLogin from './components/BeforeLogin' -import CustomTabComponent from './components/CustomTabComponent' -import DemoUIFieldCell from './components/DemoUIField/Cell' -import DemoUIFieldField from './components/DemoUIField/Field' import Logout from './components/Logout' import CustomDefaultView from './components/views/CustomDefault' -import CustomDefaultEditView from './components/views/CustomDefaultEdit' -import CustomEditView from './components/views/CustomEdit' import CustomMinimalRoute from './components/views/CustomMinimal' -import CustomVersionsView from './components/views/CustomVersions' -import CustomView from './components/views/CustomView' -import { - globalSlug, - group1Collection1Slug, - group1Collection2Slug, - group1GlobalSlug, - postsSlug, - slugPluralLabel, - slugSingularLabel, -} from './shared' +import { CustomGlobalViews1 } from './globals/CustomViews1' +import { CustomGlobalViews2 } from './globals/CustomViews2' +import { Global } from './globals/Global' +import { GlobalGroup1A } from './globals/Group1A' +import { GlobalGroup1B } from './globals/Group1B' +import { GlobalHidden } from './globals/Hidden' +import { postsSlug } from './shared' export interface Post { createdAt: Date @@ -74,322 +74,24 @@ export default buildConfigWithDefaults({ locales: ['en', 'es'], }, collections: [ - { - slug: 'users', - auth: true, - admin: { - useAsTitle: 'email', - }, - fields: [], - }, - { - slug: 'hidden-collection', - admin: { - hidden: () => true, - }, - fields: [ - { - name: 'title', - type: 'text', - }, - ], - }, - { - slug: postsSlug, - labels: { - singular: slugSingularLabel, - plural: slugPluralLabel, - }, - admin: { - description: 'Description', - listSearchableFields: ['title', 'description', 'number'], - group: 'One', - useAsTitle: 'title', - defaultColumns: ['id', 'number', 'title', 'description', 'demoUIField'], - preview: () => 'https://payloadcms.com', - }, - versions: { - drafts: true, - }, - fields: [ - { - type: 'tabs', - tabs: [ - { - label: 'Tab 1', - fields: [ - { - name: 'title', - type: 'text', - }, - { - name: 'description', - type: 'text', - }, - { - name: 'number', - type: 'number', - }, - { - name: 'richText', - type: 'richText', - editor: slateEditor({ - admin: { - elements: ['relationship'], - }, - }), - }, - { - type: 'ui', - name: 'demoUIField', - label: 'Demo UI Field', - admin: { - components: { - Field: DemoUIFieldField, - Cell: DemoUIFieldCell, - }, - }, - }, - ], - }, - ], - }, - { - name: 'sidebarField', - type: 'text', - admin: { - position: 'sidebar', - 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.', - }, - }, - ], - }, - { - slug: 'custom-views-one', - versions: true, - admin: { - components: { - views: { - // This will override the entire Edit view including all nested views, i.e. `/edit/:id/*` - // To override one specific nested view, use the nested view's slug as the key - Edit: CustomEditView, - }, - }, - }, - fields: [ - { - name: 'title', - type: 'text', - }, - ], - }, - { - slug: 'custom-views-two', - versions: true, - admin: { - components: { - views: { - Edit: { - // This will override one specific nested view within the `/edit/:id` route, i.e. `/edit/:id/versions` - Default: CustomDefaultEditView, - Versions: CustomVersionsView, - MyCustomView: { - path: '/custom-tab-view', - Component: CustomView, - Tab: { - label: 'Custom', - href: '/custom-tab-view', - }, - }, - MyCustomViewWithCustomTab: { - path: '/custom-tab-component', - Component: CustomView, - Tab: CustomTabComponent, - }, - }, - }, - }, - }, - fields: [ - { - name: 'title', - type: 'text', - }, - ], - }, - { - slug: group1Collection1Slug, - admin: { - group: 'One', - }, - fields: [ - { - name: 'title', - type: 'text', - }, - ], - }, - { - slug: group1Collection2Slug, - admin: { - group: 'One', - }, - fields: [ - { - name: 'title', - type: 'text', - }, - ], - }, - { - slug: 'group-two-collection-ones', - admin: { - group: 'Two', - }, - fields: [ - { - name: 'title', - type: 'text', - }, - ], - }, - { - slug: 'group-two-collection-twos', - admin: { - group: 'Two', - }, - fields: [ - { - name: 'title', - type: 'text', - }, - ], - }, - { - slug: 'geo', - fields: [ - { - name: 'point', - type: 'point', - }, - ], - }, + Posts, + Users, + CollectionHidden, + CustomViews1, + CustomViews2, + CollectionGroup1A, + CollectionGroup1B, + CollectionGroup2A, + CollectionGroup2B, + Geo, ], globals: [ - { - slug: 'hidden-global', - admin: { - hidden: () => true, - }, - fields: [ - { - name: 'title', - type: 'text', - }, - ], - }, - { - slug: globalSlug, - label: { - en: 'My Global Label', - }, - admin: { - group: 'Group', - preview: () => 'https://payloadcms.com', - }, - versions: { - drafts: true, - }, - fields: [ - { - name: 'title', - type: 'text', - }, - { - name: 'sidebarField', - type: 'text', - admin: { - position: 'sidebar', - }, - }, - ], - }, - { - slug: 'custom-global-views-one', - versions: true, - admin: { - components: { - views: { - Edit: CustomEditView, - }, - }, - }, - fields: [ - { - name: 'title', - type: 'text', - }, - ], - }, - { - slug: 'custom-global-views-two', - versions: true, - admin: { - components: { - views: { - Edit: { - Default: CustomDefaultEditView, - Versions: CustomVersionsView, - MyCustomView: { - path: '/custom-tab-view', - Component: CustomView, - Tab: { - label: 'Custom', - href: '/custom-tab-view', - }, - }, - MyCustomViewWithCustomTab: { - path: '/custom-tab-component', - Component: CustomView, - Tab: CustomTabComponent, - }, - }, - }, - }, - }, - fields: [ - { - name: 'title', - type: 'text', - }, - ], - }, - { - slug: group1GlobalSlug, - label: 'Group Globals 1', - admin: { - group: 'Group', - }, - fields: [ - { - name: 'title', - type: 'text', - }, - ], - }, - { - slug: 'group-globals-two', - admin: { - group: 'Group', - }, - fields: [ - { - name: 'title', - type: 'text', - }, - ], - }, + GlobalHidden, + Global, + CustomGlobalViews1, + CustomGlobalViews2, + GlobalGroup1A, + GlobalGroup1B, ], onInit: async (payload) => { await payload.create({ diff --git a/test/admin/globals/CustomViews1.ts b/test/admin/globals/CustomViews1.ts new file mode 100644 index 0000000000..ddfcc9a73c --- /dev/null +++ b/test/admin/globals/CustomViews1.ts @@ -0,0 +1,21 @@ +import type { GlobalConfig } from '../../../packages/payload/src/globals/config/types' + +import CustomEditView from '../components/views/CustomEdit' + +export const CustomGlobalViews1: GlobalConfig = { + slug: 'custom-global-views-one', + versions: true, + admin: { + components: { + views: { + Edit: CustomEditView, + }, + }, + }, + fields: [ + { + name: 'title', + type: 'text', + }, + ], +} diff --git a/test/admin/globals/CustomViews2.ts b/test/admin/globals/CustomViews2.ts new file mode 100644 index 0000000000..dcb95d2642 --- /dev/null +++ b/test/admin/globals/CustomViews2.ts @@ -0,0 +1,40 @@ +import type { GlobalConfig } from '../../../packages/payload/src/globals/config/types' + +import CustomTabComponent from '../components/CustomTabComponent' +import CustomDefaultEditView from '../components/views/CustomDefaultEdit' +import CustomVersionsView from '../components/views/CustomVersions' +import CustomView from '../components/views/CustomView' + +export const CustomGlobalViews2: GlobalConfig = { + slug: 'custom-global-views-two', + versions: true, + admin: { + components: { + views: { + Edit: { + Default: CustomDefaultEditView, + Versions: CustomVersionsView, + MyCustomView: { + path: '/custom-tab-view', + Component: CustomView, + Tab: { + label: 'Custom', + href: '/custom-tab-view', + }, + }, + MyCustomViewWithCustomTab: { + path: '/custom-tab-component', + Component: CustomView, + Tab: CustomTabComponent, + }, + }, + }, + }, + }, + fields: [ + { + name: 'title', + type: 'text', + }, + ], +} diff --git a/test/admin/globals/Global.ts b/test/admin/globals/Global.ts new file mode 100644 index 0000000000..20f984b3b6 --- /dev/null +++ b/test/admin/globals/Global.ts @@ -0,0 +1,30 @@ +import type { GlobalConfig } from '../../../packages/payload/src/globals/config/types' + +import { globalSlug } from '../shared' + +export const Global: GlobalConfig = { + slug: globalSlug, + label: { + en: 'My Global Label', + }, + admin: { + group: 'Group', + preview: () => 'https://payloadcms.com', + }, + versions: { + drafts: true, + }, + fields: [ + { + name: 'title', + type: 'text', + }, + { + name: 'sidebarField', + type: 'text', + admin: { + position: 'sidebar', + }, + }, + ], +} diff --git a/test/admin/globals/Group1A.ts b/test/admin/globals/Group1A.ts new file mode 100644 index 0000000000..0681ac156d --- /dev/null +++ b/test/admin/globals/Group1A.ts @@ -0,0 +1,17 @@ +import type { GlobalConfig } from '../../../packages/payload/src/globals/config/types' + +import { group1GlobalSlug } from '../shared' + +export const GlobalGroup1A: GlobalConfig = { + slug: group1GlobalSlug, + label: 'Group Globals 1', + admin: { + group: 'Group', + }, + fields: [ + { + name: 'title', + type: 'text', + }, + ], +} diff --git a/test/admin/globals/Group1B.ts b/test/admin/globals/Group1B.ts new file mode 100644 index 0000000000..861091ee85 --- /dev/null +++ b/test/admin/globals/Group1B.ts @@ -0,0 +1,14 @@ +import type { GlobalConfig } from '../../../packages/payload/src/globals/config/types' + +export const GlobalGroup1B: GlobalConfig = { + slug: 'group-globals-two', + admin: { + group: 'Group', + }, + fields: [ + { + name: 'title', + type: 'text', + }, + ], +} diff --git a/test/admin/globals/Hidden.ts b/test/admin/globals/Hidden.ts new file mode 100644 index 0000000000..fed2d8caa8 --- /dev/null +++ b/test/admin/globals/Hidden.ts @@ -0,0 +1,14 @@ +import type { GlobalConfig } from '../../../packages/payload/src/globals/config/types' + +export const GlobalHidden: GlobalConfig = { + slug: 'hidden-global', + admin: { + hidden: () => true, + }, + fields: [ + { + name: 'title', + type: 'text', + }, + ], +}