- buildRevalidateHook skips outside Next (no NEXT_RUNTIME) and with context.disableRevalidate - BuilderForm focuses only on a real step change (no scroll to the form on remount) - mediaImageProps: placeholder colour only for JPEG (placeholderColor); hook stores no colour for transparent images - buildLinkField: interface name per shape (CmsLink, CmsLinkPlain, CmsLinkNoLabel) + interfaceName option - Cookie Settings: buttons.save -> buttons.savePreferences (Mongoose reserved name) - ThemeScript, ThemeSwitcher, useTheme; Site Settings defaultTheme 'system' + themeToggleLabel; Turnstile follows page theme - extractHeadings, RenderRichText headingIds, TableOfContents, buildTableOfContentsField - createPageRoute onMissing: 'redirectHome' - Form builder: localized placeholder on text/email/textarea/number, new time field - ipal-audit: no false positive for object keys between JSX elements; /md route not reported as dynamic Co-Authored-By: Claude Opus 5.5 <[email protected]>
150 lines
4.3 KiB
TypeScript
150 lines
4.3 KiB
TypeScript
import type { Field } from 'payload'
|
|
|
|
import { CONSENT_CATEGORIES } from '../../modules/consent/categories.js'
|
|
|
|
/**
|
|
* Fields for the CookieSettings global — GDPR consent banner copy, editable
|
|
* per locale. The privacy-policy link TARGET is NOT stored here: it comes from
|
|
* the pages module (system page role 'privacyPolicy'), keeping one source of
|
|
* truth. Only the link's visible text lives here (privacyLinkLabel).
|
|
*/
|
|
export const cookieSettingsFields: Field[] = [
|
|
{
|
|
name: 'policyVersion',
|
|
type: 'number',
|
|
admin: {
|
|
description:
|
|
'Raise by 1 when you add a tool or change the cookie policy — every visitor is asked for consent again.',
|
|
position: 'sidebar',
|
|
step: 1,
|
|
},
|
|
defaultValue: 1,
|
|
min: 1,
|
|
required: true,
|
|
},
|
|
{
|
|
name: 'eyebrow',
|
|
type: 'text',
|
|
admin: {
|
|
description: 'Small label above the banner title, e.g. "Privacy & cookies". Empty → not shown.',
|
|
},
|
|
localized: true,
|
|
},
|
|
{
|
|
name: 'title',
|
|
type: 'text',
|
|
admin: {
|
|
description: 'Banner heading, e.g. "We respect your privacy". Empty → not shown.',
|
|
},
|
|
localized: true,
|
|
},
|
|
{
|
|
name: 'message',
|
|
type: 'textarea',
|
|
admin: {
|
|
description: 'Main consent message shown in the banner.',
|
|
},
|
|
localized: true,
|
|
},
|
|
{
|
|
name: 'settingsTitle',
|
|
type: 'text',
|
|
admin: {
|
|
description: 'Heading for the detailed settings panel.',
|
|
},
|
|
localized: true,
|
|
},
|
|
{
|
|
name: 'settingsDescription',
|
|
type: 'textarea',
|
|
admin: {
|
|
description: 'Intro under the settings heading — what cookies are for and that the choice can be changed later.',
|
|
},
|
|
localized: true,
|
|
},
|
|
{
|
|
name: 'alwaysActiveLabel',
|
|
type: 'text',
|
|
admin: {
|
|
description: 'Badge next to the Necessary category, e.g. "Always active". Empty → a disabled switch/checkbox is shown instead.',
|
|
},
|
|
localized: true,
|
|
},
|
|
{
|
|
name: 'privacyLinkLabel',
|
|
type: 'text',
|
|
admin: {
|
|
description:
|
|
'Text of the privacy-policy link in the banner, e.g. "Privacy policy". The link target is the page assigned as Privacy Policy in Site Settings → System Pages. Empty → the page title is used.',
|
|
},
|
|
localized: true,
|
|
},
|
|
{
|
|
name: 'buttons',
|
|
type: 'group',
|
|
admin: {
|
|
description: 'Button labels.',
|
|
},
|
|
fields: [
|
|
{ name: 'acceptAll', type: 'text', localized: true },
|
|
{ name: 'reject', type: 'text', localized: true },
|
|
{ name: 'settings', type: 'text', localized: true },
|
|
// Not `save`: Mongoose reserves that path name and warns on every start/build.
|
|
{ name: 'savePreferences', type: 'text', label: 'Save', localized: true },
|
|
{ name: 'back', type: 'text', localized: true },
|
|
{
|
|
name: 'close',
|
|
type: 'text',
|
|
admin: { description: 'Screen-reader label of the ✕ button in the settings dialog.' },
|
|
localized: true,
|
|
},
|
|
],
|
|
},
|
|
{
|
|
name: 'categories',
|
|
type: 'array',
|
|
admin: {
|
|
description: 'Per-category titles and descriptions.',
|
|
},
|
|
fields: [
|
|
{
|
|
name: 'key',
|
|
type: 'select',
|
|
options: CONSENT_CATEGORIES.map((c) => ({ label: c, value: c })),
|
|
required: true,
|
|
},
|
|
{ name: 'title', type: 'text', localized: true },
|
|
{ name: 'description', type: 'textarea', localized: true },
|
|
],
|
|
},
|
|
{
|
|
name: 'cookies',
|
|
type: 'array',
|
|
admin: {
|
|
description:
|
|
'Cookies the site uses — shown on the cookie policy page (<CookieTable>). Fill it from a scan: ipal-consent-check → cookie-scan.',
|
|
initCollapsed: true,
|
|
},
|
|
fields: [
|
|
{
|
|
type: 'row',
|
|
fields: [
|
|
{ name: 'name', type: 'text', admin: { width: '40%' }, required: true },
|
|
{ name: 'provider', type: 'text', admin: { description: 'e.g. Google, this site', width: '30%' } },
|
|
{
|
|
name: 'category',
|
|
type: 'select',
|
|
admin: { width: '30%' },
|
|
defaultValue: 'necessary',
|
|
options: CONSENT_CATEGORIES.map((c) => ({ label: c, value: c })),
|
|
required: true,
|
|
},
|
|
],
|
|
},
|
|
{ name: 'purpose', type: 'textarea', localized: true },
|
|
{ name: 'duration', type: 'text', admin: { description: 'e.g. "2 years", "session"' }, localized: true },
|
|
],
|
|
labels: { plural: 'Cookies', singular: 'Cookie' },
|
|
},
|
|
]
|