## Description We've since lost the ability to override the document view at the root-level. This was a feature that made it possible to override _the entire document routing/view structure_, including the document header/tabs and all nested routes within, i.e. the API route/view, the Live Preview route/view, etc. This is distinct from the "default" edit view, which _only_ targets the component rendered within the "edit" tab. This regression was introduced when types were simplified down to better support "component paths" here: #7620. The `default` key was incorrectly used as the "root" view override. To continue to support stricter types _and_ root view overrides, a new `root` key has been added to the `views` config. You were previously able to do this: ```tsx import { MyComponent } from './MyComponent.js' export const MyCollection = { // ... admin: { views: { Edit: MyComponent } } } ``` This is now done like this: ```tsx export const MyCollection = { // ... admin: { views: { edit: { root: { Component: './path-to-my-component.js' } } } } } ``` Some of the documentation was also incorrect according to the new component paths API. - [x] I have read and understand the [CONTRIBUTING.md](https://github.com/payloadcms/payload/blob/main/CONTRIBUTING.md) document in this repository. ## Type of change - [x] Bug fix (non-breaking change which fixes an issue) - [x] This change requires a documentation update ## Checklist: - [x] Existing test suite passes locally with my changes - [x] I have made corresponding changes to the documentation
28 lines
669 B
TypeScript
28 lines
669 B
TypeScript
import type { CollectionConfig } from 'payload'
|
|
|
|
import { customViews1CollectionSlug } from '../slugs.js'
|
|
|
|
export const CustomViews1: CollectionConfig = {
|
|
slug: customViews1CollectionSlug,
|
|
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: {
|
|
root: {
|
|
Component: '/components/views/CustomEdit/index.js#CustomEditView',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
fields: [
|
|
{
|
|
name: 'title',
|
|
type: 'text',
|
|
},
|
|
],
|
|
versions: true,
|
|
}
|