This adds a new `showSaveDraftButton` option to the `versions.drafts.autosave` config for collections and globals. By default, the "Save as draft" button is hidden when autosave is enabled. This new option allows the button to remain visible for manual saves while autosave is active. Also updates the admin UI logic to conditionally render the button when this flag is set, and updates the documentation with an example usage.
33 lines
690 B
TypeScript
33 lines
690 B
TypeScript
import type { CollectionConfig } from 'payload'
|
|
|
|
import { autosaveWithDraftButtonSlug } from '../slugs.js'
|
|
|
|
const AutosaveWithDraftButtonPosts: CollectionConfig = {
|
|
slug: autosaveWithDraftButtonSlug,
|
|
labels: {
|
|
singular: 'Autosave with Draft Button Post',
|
|
plural: 'Autosave with Draft Button Posts',
|
|
},
|
|
admin: {
|
|
useAsTitle: 'title',
|
|
defaultColumns: ['title', 'subtitle', 'createdAt', '_status'],
|
|
},
|
|
versions: {
|
|
drafts: {
|
|
autosave: {
|
|
showSaveDraftButton: true,
|
|
interval: 1000,
|
|
},
|
|
},
|
|
},
|
|
fields: [
|
|
{
|
|
name: 'title',
|
|
type: 'text',
|
|
required: true,
|
|
},
|
|
],
|
|
}
|
|
|
|
export default AutosaveWithDraftButtonPosts
|