Create adminOnly and adminOrEditor access functions. Add role field to Users collection (admin/editor, default: editor). Update access control across all collections and globals to enforce role-based permissions.
35 lines
675 B
TypeScript
35 lines
675 B
TypeScript
import type { GlobalConfig } from 'payload'
|
|
|
|
import { adminOnly } from '../access/adminOnly'
|
|
import { link } from '@/fields/link'
|
|
import { revalidateHeader } from './hooks/revalidateHeader'
|
|
|
|
export const Header: GlobalConfig = {
|
|
slug: 'header',
|
|
access: {
|
|
read: () => true,
|
|
update: adminOnly,
|
|
},
|
|
fields: [
|
|
{
|
|
name: 'navItems',
|
|
type: 'array',
|
|
fields: [
|
|
link({
|
|
appearances: false,
|
|
}),
|
|
],
|
|
maxRows: 6,
|
|
admin: {
|
|
initCollapsed: true,
|
|
components: {
|
|
RowLabel: '@/Header/RowLabel#RowLabel',
|
|
},
|
|
},
|
|
},
|
|
],
|
|
hooks: {
|
|
afterChange: [revalidateHeader],
|
|
},
|
|
}
|