fix: #1184
This commit is contained in:
@@ -3,6 +3,7 @@ import AutosavePosts from './collections/Autosave';
|
||||
import DraftPosts from './collections/Drafts';
|
||||
import AutosaveGlobal from './globals/Autosave';
|
||||
import { devUser } from '../credentials';
|
||||
import DraftGlobal from './globals/Draft';
|
||||
|
||||
export default buildConfig({
|
||||
collections: [
|
||||
@@ -11,6 +12,7 @@ export default buildConfig({
|
||||
],
|
||||
globals: [
|
||||
AutosaveGlobal,
|
||||
DraftGlobal,
|
||||
],
|
||||
localization: {
|
||||
locales: ['en', 'es'],
|
||||
|
||||
30
test/versions/globals/Draft.ts
Normal file
30
test/versions/globals/Draft.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { GlobalConfig } from '../../../src/globals/config/types';
|
||||
|
||||
const DraftGlobal: GlobalConfig = {
|
||||
slug: 'draft-global',
|
||||
label: 'Draft Global',
|
||||
versions: {
|
||||
max: 20,
|
||||
drafts: true,
|
||||
},
|
||||
access: {
|
||||
read: ({ draft, req: { user } }) => {
|
||||
// To read a draft of this global, you need to be authenticated
|
||||
if (draft) {
|
||||
return Boolean(user);
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
},
|
||||
fields: [
|
||||
{
|
||||
name: 'title',
|
||||
type: 'text',
|
||||
required: true,
|
||||
localized: true,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export default DraftGlobal;
|
||||
Reference in New Issue
Block a user