- admin-i18n module: AdminText { en, pl }, component texts under the ipal
namespace (project translations win), en + pl admin languages when the
project sets none (project's supportedLanguages wins)
- every plugin label, description, option, tab and group as { en, pl };
explicit labels instead of auto-labels; sentence case; glossary terms
- visible renames (slugs, names, data unchanged): Cookie banner, Form
messages, Privacy group, Search engines, Maintenance, Spam protection,
E-mail sending, stats nav link Overview (hidden without access)
- Polish visitor defaults by page locale: cookie banner, form messages,
validators, lightbox, accessibility widget; {field} uses the label
- fixes: e-mail status banner used Turnstile wording; developer words and
env var names out of editor messages; stats numbers/dates in the admin
language; test e-mail no longer says ipal-kit
- test/adminUx.test.ts: length limits, en + pl present, no developer words
Co-Authored-By: Claude Opus 5.5 <[email protected]>
83 lines
3.1 KiB
TypeScript
83 lines
3.1 KiB
TypeScript
import type { Field, GlobalConfig } from 'payload'
|
|
|
|
import { userMeetsRole } from '../../modules/access/index.js'
|
|
import { generalFields } from './fields/general.js'
|
|
import { themeFields } from './fields/theme.js'
|
|
|
|
type BuildSiteSettingsArgs = {
|
|
/** Extra fields injected by the client project */
|
|
additionalFields?: Field[]
|
|
/** "Maintenance" tab (maintenance mode) — given when the pages module is on. */
|
|
constructionFields?: Field[]
|
|
/** "E-mails" tab — given with `forms: { emailLayout: true }`. */
|
|
emailFields?: Field[]
|
|
/** "Search engines" tab — search-engine verification, AI assistants, llms.txt note (seo module). */
|
|
searchFields?: Field[]
|
|
/**
|
|
* Fields for the "System pages" tab — page assignments by role (homepage,
|
|
* privacy policy, collection archives). Assembled by the caller, which is the
|
|
* only place that knows which modules are enabled. The tab is omitted when
|
|
* this is empty.
|
|
*/
|
|
systemPageFields?: Field[]
|
|
}
|
|
|
|
/**
|
|
* Builds the SiteSettings global.
|
|
*
|
|
* Composes tabs out of field groups; it deliberately doesn't know where those
|
|
* groups come from. Earlier it imported the pages and content modules directly,
|
|
* which meant a global — a presentation-layer concern — had an opinion about
|
|
* blogs. Now the plugin's composition root passes fields in, and adding a new
|
|
* kind of page assignment needs no change here.
|
|
*
|
|
* Uses unnamed tabs — data stays flat (siteSettings.siteName, not
|
|
* siteSettings.general.siteName). Client-provided fields land in their own
|
|
* "More" tab so core data paths never shift. Tab labels are presentation only.
|
|
*/
|
|
export function buildSiteSettings({
|
|
additionalFields,
|
|
constructionFields,
|
|
emailFields,
|
|
searchFields,
|
|
systemPageFields,
|
|
}: BuildSiteSettingsArgs = {}): GlobalConfig {
|
|
return {
|
|
slug: 'site-settings',
|
|
access: {
|
|
read: () => true,
|
|
// Editors and admins only — a plain 'user' account (open sign-up) must
|
|
// not rewrite the brand, homepage or construction mode.
|
|
update: ({ req }) => userMeetsRole(req, 'editor'),
|
|
},
|
|
admin: {
|
|
group: { en: 'Settings', pl: 'Ustawienia' },
|
|
},
|
|
fields: [
|
|
{
|
|
type: 'tabs',
|
|
tabs: [
|
|
{
|
|
fields: generalFields,
|
|
label: { en: 'General', pl: 'Ogólne' },
|
|
},
|
|
{
|
|
fields: themeFields,
|
|
label: { en: 'Theme', pl: 'Motyw' },
|
|
},
|
|
...(systemPageFields?.length
|
|
? [{ fields: systemPageFields, label: { en: 'System pages', pl: 'Strony systemowe' } }]
|
|
: []),
|
|
...(searchFields?.length ? [{ fields: searchFields, label: { en: 'Search engines', pl: 'Wyszukiwarki' } }] : []),
|
|
...(emailFields?.length ? [{ fields: emailFields, label: { en: 'E-mails', pl: 'E-maile' } }] : []),
|
|
...(constructionFields?.length
|
|
? [{ fields: constructionFields, label: { en: 'Maintenance', pl: 'Prace techniczne' } }]
|
|
: []),
|
|
...(additionalFields?.length ? [{ fields: additionalFields, label: { en: 'More', pl: 'Więcej' } }] : []),
|
|
],
|
|
},
|
|
],
|
|
label: { en: 'Site settings', pl: 'Ustawienia witryny' },
|
|
}
|
|
}
|