### What
This PR introduces a new `beforeDocumentControls` slot to the edit view
of both collections and globals.
It allows injecting one or more custom components next to the document
control buttons (e.g., Save, Publish, Save Draft) in the admin UI —
useful for adding context, additional buttons, or custom UI elements.
#### Usage
##### For collections:
```
admin: {
components: {
edit: {
beforeDocumentControls: ['/path/to/CustomComponent'],
},
},
},
```
##### For globals:
```
admin: {
components: {
elements: {
beforeDocumentControls: ['/path/to/CustomComponent'],
},
},
},
```
48 lines
974 B
TypeScript
48 lines
974 B
TypeScript
import type { GlobalConfig } from 'payload'
|
|
|
|
import { globalSlug } from '../slugs.js'
|
|
|
|
export const Global: GlobalConfig = {
|
|
slug: globalSlug,
|
|
admin: {
|
|
components: {
|
|
elements: {
|
|
beforeDocumentControls: [
|
|
'/components/BeforeDocumentControls/CustomDraftButton/index.js#CustomDraftButton',
|
|
],
|
|
},
|
|
views: {
|
|
edit: {
|
|
api: {
|
|
actions: ['/components/actions/GlobalAPIButton/index.js#GlobalAPIButton'],
|
|
},
|
|
default: {
|
|
actions: ['/components/actions/GlobalEditButton/index.js#GlobalEditButton'],
|
|
},
|
|
},
|
|
},
|
|
},
|
|
group: 'Group',
|
|
preview: () => 'https://payloadcms.com',
|
|
},
|
|
fields: [
|
|
{
|
|
name: 'title',
|
|
type: 'text',
|
|
},
|
|
{
|
|
name: 'sidebarField',
|
|
type: 'text',
|
|
admin: {
|
|
position: 'sidebar',
|
|
},
|
|
},
|
|
],
|
|
label: {
|
|
en: 'My Global Label',
|
|
},
|
|
versions: {
|
|
drafts: true,
|
|
},
|
|
}
|