Files
website-enchun-mgr/apps/backend/src/Header/config.ts
pkupuk d0e8c3bcff Add role-based access control with admin/editor roles
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.
2026-01-31 13:03:16 +08:00

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],
},
}