Skip to content

fix(next): supports root document view overrides as separate from default edit view - #7673

Merged
jacobsfletch merged 6 commits into
betafrom
fix/root-doc-view-overide
Aug 14, 2024
Merged

jacobsfletch merged 6 commits into
betafrom
fix/root-doc-view-overide

Conversation

@jacobsfletch

@jacobsfletch jacobsfletch commented Aug 14, 2024 •

Copy link
Copy Markdown
Member

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:

import { MyComponent } from './MyComponent.js'

export const MyCollection = {
  // ...
  admin: {
    views: {
      Edit: MyComponent
    }
  }
}

This is now done like this:

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.

  • I have read and understand the CONTRIBUTING.md document in this repository.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • This change requires a documentation update

Checklist:

  • Existing test suite passes locally with my changes
  • I have made corresponding changes to the documentation

@jacobsfletch
jacobsfletch marked this pull request as ready for review August 14, 2024 16:59
@jacobsfletch

Copy link
Copy Markdown
Member Author

An alternative to this would be to make this type a union of Payload Component and the views config. That way we could infer the types based on the presence of the Component key, and TS would flag all the other views.

@jacobsfletch
jacobsfletch merged commit a212cde into beta Aug 14, 2024
@jacobsfletch
jacobsfletch deleted the fix/root-doc-view-overide branch August 14, 2024 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant