Fixes an issue where an autosave being triggered would turn off the ability to schedule a publish. This happened because we check against `modified` on the form but with autosave modified is always true. Now we make an exception for autosave enabled collections when checking the modified state.
66 lines
1.2 KiB
TypeScript
66 lines
1.2 KiB
TypeScript
import type { CollectionConfig } from 'payload'
|
|
|
|
import { autosaveCollectionSlug } from '../slugs.js'
|
|
|
|
const AutosavePosts: CollectionConfig = {
|
|
slug: autosaveCollectionSlug,
|
|
labels: {
|
|
singular: 'Autosave Post',
|
|
plural: 'Autosave Posts',
|
|
},
|
|
admin: {
|
|
useAsTitle: 'title',
|
|
defaultColumns: ['title', 'description', 'createdAt', '_status'],
|
|
},
|
|
versions: {
|
|
maxPerDoc: 35,
|
|
drafts: {
|
|
autosave: {
|
|
interval: 2000,
|
|
},
|
|
schedulePublish: true,
|
|
},
|
|
},
|
|
access: {
|
|
read: ({ req: { user } }) => {
|
|
if (user) {
|
|
return true
|
|
}
|
|
|
|
return {
|
|
or: [
|
|
{
|
|
_status: {
|
|
equals: 'published',
|
|
},
|
|
},
|
|
{
|
|
_status: {
|
|
exists: false,
|
|
},
|
|
},
|
|
],
|
|
}
|
|
},
|
|
readVersions: ({ req: { user } }) => Boolean(user),
|
|
},
|
|
fields: [
|
|
{
|
|
name: 'title',
|
|
label: 'Title',
|
|
type: 'text',
|
|
required: true,
|
|
unique: true,
|
|
localized: true,
|
|
},
|
|
{
|
|
name: 'description',
|
|
label: 'Description',
|
|
type: 'textarea',
|
|
required: true,
|
|
},
|
|
],
|
|
}
|
|
|
|
export default AutosavePosts
|