Admin panel in English and Polish, reworded per docs/dev/admin-ux.md

- 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]>
This commit is contained in:
Radosław Smoliński
2026-10-27 15:46:25 +01:00
co-authored by Claude Opus 5.5
parent eeac33ed2f
commit 6b46bc0c14
108 changed files with 2806 additions and 981 deletions
+9 -12
View File
@@ -1,7 +1,9 @@
'use client'
import { useConfig, useDocumentInfo, useFormFields, useLocale } from '@payloadcms/ui'
import { useConfig, useDocumentInfo, useFormFields, useLocale, useTranslation } from '@payloadcms/ui'
import { useEffect, useState } from 'react'
import { ipalT } from '../admin-i18n/t.js'
export type MetaDescriptionCheckProps = {
/** An empty description is filled from the page content on save (autoFill). */
autoFill?: boolean
@@ -39,14 +41,15 @@ export function MetaDescriptionCheck({
serverURL,
},
} = useConfig()
const { t } = useTranslation()
const [warning, setWarning] = useState<null | Warning>(null)
useEffect(() => {
if (!description) {
setWarning(
autoFill
? { text: 'Empty — on save it is filled from this page’s content. Writing your own is better.', tone: 'info' }
: { text: 'Empty — the page gets the site-wide description, the same as every other page.', tone: 'warn' },
? { text: ipalT(t, 'seoDescEmptyAutoFill'), tone: 'info' }
: { text: ipalT(t, 'seoDescEmpty'), tone: 'warn' },
)
return
}
@@ -64,10 +67,7 @@ export function MetaDescriptionCheck({
try {
const settings = await get(`${base}/globals/${settingsSlug}?depth=0&locale=${locale}`)
if (settings && norm(settings[siteDescriptionField]) === description) {
setWarning({
text: 'Same as the site-wide description. Google ignores a description repeated across pages — write one about this page.',
tone: 'warn',
})
setWarning({ text: ipalT(t, 'seoDescSameAsSite'), tone: 'warn' })
return
}
@@ -82,10 +82,7 @@ export function MetaDescriptionCheck({
const twin = (found?.docs as Record<string, unknown>[] | undefined)?.[0]
if (twin) {
const name = norm(twin[titleField]) || String(twin.id)
setWarning({
text: `Same description as “${name}”. Google ignores a description repeated across pages — make each one unique.`,
tone: 'warn',
})
setWarning({ text: ipalT(t, 'seoDescSameAs', { name }), tone: 'warn' })
return
}
setWarning(null)
@@ -99,7 +96,7 @@ export function MetaDescriptionCheck({
clearTimeout(timer)
controller.abort()
}
}, [api, autoFill, collectionSlug, description, id, locale, serverURL, settingsSlug, siteDescriptionField, titleField])
}, [api, autoFill, collectionSlug, description, id, locale, serverURL, settingsSlug, siteDescriptionField, t, titleField])
if (!warning) {return null}
+18 -8
View File
@@ -1,10 +1,12 @@
import type { CheckboxField, Field } from 'payload'
import type { AdminText } from '../admin-i18n/define.js'
type BuildNoindexFieldArgs = {
/** Help text under the checkbox. */
description?: string
/** Sidebar label. Default 'Exclude from indexing (noindex)'. */
label?: string
/** Help text under the checkbox: a string or `{ en, pl }`. */
description?: AdminText | string
/** Sidebar label: a string or `{ en, pl }`. Default "Hide from search engines". */
label?: AdminText | string
/** Field name for the editor-facing checkbox. Default 'noindex'. */
name?: string
/** Extend/override the generated checkbox (position, access, etc.). */
@@ -41,8 +43,11 @@ const idOf = (rel: unknown): unknown => (rel && typeof rel === 'object' ? (rel a
export function buildNoindexField(args: BuildNoindexFieldArgs = {}): Field {
const {
name = 'noindex',
description = 'Check to exclude this page from indexing (robots: noindex, follow), the sitemap, llms.txt and site search.',
label = 'Exclude from indexing (noindex)',
description = {
en: 'Leaves the page out of search results, the sitemap and site search.',
pl: 'Strona nie pojawi się w wynikach wyszukiwania, mapie witryny ani wyszukiwarce witryny.',
},
label = { en: 'Hide from search engines', pl: 'Ukryj przed wyszukiwarkami' },
overrides = {},
protectSystemPages = true,
settingsSlug = 'site-settings',
@@ -52,12 +57,17 @@ export function buildNoindexField(args: BuildNoindexFieldArgs = {}): Field {
if (!protectSystemPages || value !== true || id === undefined) {return true}
try {
const settings = (await req.payload.findGlobal({ slug: settingsSlug as never, depth: 0, req })) as Record<string, unknown>
const pl = req.i18n?.language === 'pl'
if (idOf(settings.homepage) === id) {
return 'This page is the homepage (Site Settings → System Pages). noindex would remove the whole site from Google.'
return pl
? 'To strona główna. Ukrycie jej usunęłoby całą witrynę z wyników wyszukiwania.'
: 'This is the homepage. Hiding it would remove the whole site from search results.'
}
for (const [key, rel] of Object.entries(settings)) {
if (key.endsWith('Archive') && idOf(rel) === id) {
return 'This page is an archive (Site Settings → System Pages). noindex would hide the page that lists all its entries.'
return pl
? 'Ta strona zawiera listę wpisów sekcji. Ukrycie jej usunęłoby tę listę z wyników wyszukiwania.'
: 'This page lists the entries of a section. Hiding it would remove that list from search results.'
}
}
} catch {
+11 -6
View File
@@ -1,5 +1,7 @@
import type { Field, FieldHook, TextareaField } from 'payload'
import type { AdminText } from '../admin-i18n/define.js'
import { blocksToMarkdown } from '../content/blocksToMarkdown.js'
import { mdToPlain, truncate } from './plainText.js'
import { isAutoFillSkipped } from './skipAutoFill.js'
@@ -7,10 +9,10 @@ import { isAutoFillSkipped } from './skipAutoFill.js'
type BuildSummaryFieldArgs = {
/** Auto-fill from page content when the editor leaves it empty. Default true. */
autoFill?: boolean
/** Help text under the field. */
description?: string
/** Sidebar/admin label. */
label?: string
/** Help text under the field: a string or `{ en, pl }`. */
description?: AdminText | string
/** Sidebar label: a string or `{ en, pl }`. Default "AI summary". */
label?: AdminText | string
/** Block layout field to derive the summary from. Default 'layout'. */
layoutField?: string
/** Target length for the auto-generated summary. Default 300. */
@@ -44,8 +46,11 @@ export function buildSummaryField(args: BuildSummaryFieldArgs = {}): Field {
const {
name = 'aiSummary',
autoFill = true,
description = 'Concise page description for AI agents and llms.txt (richer than the meta description). Leave empty to auto-generate from the content.',
label = 'AI summary',
description = {
en: 'Short summary for AI assistants; leave empty to create it from the page content.',
pl: 'Krótkie podsumowanie dla asystentów AI; zostaw puste, aby utworzyć je z treści strony.',
},
label = { en: 'AI summary', pl: 'Podsumowanie dla AI' },
layoutField = 'layout',
maxLength = 300,
overrides = {},
+5 -2
View File
@@ -31,14 +31,17 @@ export const indexNowFields: Field[] = [
name: KEY_FIELD,
type: 'text',
admin: {
description:
'Key that proves this site owns its URLs to IndexNow (Bing, ChatGPT Search). Generated automatically — change only to rotate it.',
description: {
en: 'Created automatically; lets Bing and AI assistants learn about new pages right away.',
pl: 'Tworzony automatycznie; pozwala Bing i asystentom AI od razu poznać nowe strony.',
},
},
hooks: {
beforeChange: [
({ value }) => (typeof value === 'string' && value.trim() ? value.trim() : randomKey()),
],
},
label: { en: 'IndexNow key', pl: 'Klucz IndexNow' },
},
]
+13 -5
View File
@@ -2,6 +2,12 @@ import type { Config, Field, TabsField } from 'payload'
import type { SeoOption } from './types.js'
const CONTENT_TAB = { en: 'Content', pl: 'Treść' }
const SEO_TAB = { en: 'SEO', pl: 'SEO' }
/** The `meta` group sits alone in the SEO tab, so its own "SEO" heading would repeat the tab name. */
const withoutHeading = (meta: Field): Field => ({ ...meta, label: false }) as Field
/**
* Wraps each SEO-enabled collection's fields into a tabbed UI: a "Content" tab
* holding the collection's own fields, and an "SEO" tab holding the `meta`
@@ -43,7 +49,7 @@ export function injectSeoTabs(config: Config, seo: SeoOption): Config {
const existingTabs = firstField
const withSeoTab: TabsField = {
...existingTabs,
tabs: [...existingTabs.tabs, { fields: [metaField], label: 'SEO' }],
tabs: [...existingTabs.tabs, { fields: [withoutHeading(metaField)], label: SEO_TAB }],
}
return {
...collection,
@@ -51,18 +57,20 @@ export function injectSeoTabs(config: Config, seo: SeoOption): Config {
}
}
// Otherwise wrap everything: Content tab + SEO tab.
// Otherwise wrap everything: Content tab + SEO tab. Sidebar fields (address,
// noindex…) stay outside the tabs, so they still show in the sidebar.
const inSidebar = (f: Field) => (f as { admin?: { position?: string } }).admin?.position === 'sidebar'
const tabs: TabsField = {
type: 'tabs',
tabs: [
{ fields: otherFields, label: collection.labels?.singular || 'Content' },
{ fields: [metaField], label: 'SEO' },
{ fields: otherFields.filter((f) => !inSidebar(f)), label: CONTENT_TAB },
{ fields: [withoutHeading(metaField)], label: SEO_TAB },
],
}
return {
...collection,
fields: [tabs],
fields: [tabs, ...otherFields.filter(inSidebar)],
}
}),
}
+77 -41
View File
@@ -1,9 +1,10 @@
import type { Field } from 'payload'
import type { AdminText } from '../admin-i18n/index.js'
import type { AiBotRule, AiBotsPolicy, RobotsOptions } from './buildRobots.js'
/**
* Site Settings → Search & AI: what editors set for search engines and AI
* Site settings → Search engines: what editors set for search engines and AI
* assistants without a deploy — Search Console / Bing verification codes, the
* AI crawler policy for robots.txt, and a note for llms.txt. Empty fields
* change nothing: verification tags appear only once a code is pasted, and the
@@ -36,87 +37,122 @@ export function normalizeVerificationToken(raw: unknown): string {
return /^[\w\-.:+/=]{1,200}$/.test(value) ? value : ''
}
const tokenField = (name: string, label: string, description: string): Field => ({
const tokenField = (name: string, product: string, description: AdminText): Field => ({
name,
type: 'text',
admin: { description },
hooks: { beforeChange: [({ value }) => normalizeVerificationToken(value) || null] },
label,
// A product name reads the same in every language.
label: { en: product, pl: product },
})
const AI_POLICY_OPTIONS = [
{ label: 'As set by the developer (default)', value: 'default' },
{ label: 'Allow all AI assistants and AI training', value: 'allow' },
{ label: 'Allow AI assistants and AI search, block AI training', value: 'block-training' },
{ label: 'Block all known AI bots', value: 'disallow' },
] as const
const AI_POLICY_OPTIONS: { label: AdminText; value: string }[] = [
{ label: { en: 'Default setting', pl: 'Ustawienie domyślne' }, value: 'default' },
{ label: { en: 'Allow all, including AI training', pl: 'Zezwól na wszystko, także trening AI' }, value: 'allow' },
{ label: { en: 'Allow assistants, block training', pl: 'Zezwól asystentom, blokuj trening' }, value: 'block-training' },
{ label: { en: 'Block all AI services', pl: 'Blokuj wszystkie usługi AI' }, value: 'disallow' },
]
/** The "Search & AI" tab fields. Not localized, except the llms.txt note. */
/**
* The "Search engines" tab fields. Not localized, except the llms.txt note.
* Order (admin-ux §7): the note (content) first, then verification codes and
* the AI access policy with its per-bot rules.
*/
export const searchSettingsFields: Field[] = [
{
name: LLMS_INTRO_FIELD,
type: 'textarea',
admin: {
description: {
en: 'Key facts AI assistants may quote: what you do, where, for whom and since when.',
pl: 'Najważniejsze fakty, które asystenci AI mogą cytować: czym zajmuje się firma, gdzie, dla kogo i od kiedy.',
},
},
label: { en: 'Site summary (llms.txt)', pl: 'Opis witryny (llms.txt)' },
localized: true,
},
{
name: SEARCH_VERIFICATION_FIELD,
type: 'group',
admin: {
description:
'Proves to search engines that you own this site. Paste the code (or the whole <meta> tag) from the search engine; it is added to every page. Leave empty if you verify another way (DNS, file).',
description: {
en: 'Paste the code or the whole meta tag from each tool; leave empty if you verify by DNS.',
pl: 'Wklej kod lub cały znacznik meta z narzędzia; zostaw puste przy weryfikacji przez DNS.',
},
},
fields: [
tokenField('google', 'Google Search Console', 'Search Console → Settings → Ownership verification → HTML tag.'),
tokenField('bing', 'Bing Webmaster Tools', 'Bing Webmaster Tools → Add site → HTML Meta Tag (msvalidate.01). Bing also powers ChatGPT Search and Copilot.'),
tokenField('yandex', 'Yandex Webmaster', 'Yandex Webmaster → Site verification → Meta tag.'),
tokenField('google', 'Google Search Console', {
en: 'Find it under Settings, Ownership verification, HTML tag.',
pl: 'Kod znajduje się w: Ustawienia, Weryfikacja własności, Tag HTML.',
}),
tokenField('bing', 'Bing Webmaster Tools', {
en: 'Find it under Add site, HTML Meta Tag; Bing also feeds ChatGPT Search and Copilot.',
pl: 'Kod znajduje się w: Dodaj witrynę, Tag meta HTML; z Bing korzystają też ChatGPT Search i Copilot.',
}),
tokenField('yandex', 'Yandex Webmaster', {
en: 'Find it under Site verification, Meta tag.',
pl: 'Kod znajduje się w: Weryfikacja witryny, Tag meta.',
}),
],
label: 'Search engine verification',
label: { en: 'Site verification', pl: 'Weryfikacja witryny' },
},
{
name: AI_CRAWLERS_FIELD,
type: 'group',
admin: {
description:
'Which AI bots may read the site (robots.txt). Assistants (ClaudeBot, ChatGPT-User, PerplexityBot…) fetch pages to answer questions and cite you; training crawlers (GPTBot, Google-Extended, CCBot…) collect pages to train models. Blocking assistants removes the site from AI answers.',
description: {
en: 'Which AI services may read the site; blocking assistants removes it from AI answers.',
pl: 'Które usługi AI mogą czytać witrynę; zablokowanie asystentów usuwa ją z odpowiedzi AI.',
},
},
fields: [
{
name: 'policy',
type: 'select',
defaultValue: 'default',
label: 'AI bots',
label: { en: 'Access', pl: 'Dostęp' },
options: AI_POLICY_OPTIONS.map((o) => ({ ...o })),
},
{
name: 'rules',
type: 'array',
admin: {
description:
'Exceptions for single bots, by user agent exactly as the bot announces itself (e.g. GPTBot, Bytespider). Wins over the setting above.',
description: {
en: 'Exceptions for single bots by name, e.g. GPTBot; they override the setting above.',
pl: 'Wyjątki dla pojedynczych botów według nazwy, np. GPTBot; mają pierwszeństwo przed ustawieniem powyżej.',
},
initCollapsed: true,
},
fields: [
{ name: 'userAgent', type: 'text', label: 'User agent', required: true },
{
name: 'access',
type: 'select',
defaultValue: 'disallow',
options: [
{ label: 'Allow', value: 'allow' },
{ label: 'Block', value: 'disallow' },
type: 'row',
fields: [
{
name: 'userAgent',
type: 'text',
admin: { placeholder: 'GPTBot' },
label: { en: 'Bot name', pl: 'Nazwa bota' },
required: true,
},
{
name: 'access',
type: 'select',
defaultValue: 'disallow',
label: { en: 'Access', pl: 'Dostęp' },
options: [
{ label: { en: 'Allow', pl: 'Zezwól' }, value: 'allow' },
{ label: { en: 'Block', pl: 'Blokuj' }, value: 'disallow' },
],
required: true,
},
],
required: true,
},
],
label: 'Per-bot exceptions',
label: { en: 'Bot rules', pl: 'Reguły dla botów' },
labels: { plural: { en: 'Rules', pl: 'Reguły' }, singular: { en: 'Rule', pl: 'Reguła' } },
},
],
label: 'AI crawlers',
},
{
name: LLMS_INTRO_FIELD,
type: 'textarea',
admin: {
description:
'Shown at the top of /llms.txt, under the site description: key facts an AI assistant should know and may quote — what you do, where, for whom, since when. Plain sentences, no marketing slogans.',
},
label: 'About the site for AI assistants (llms.txt)',
localized: true,
label: { en: 'AI assistants', pl: 'Asystenci AI' },
},
]
+35 -3
View File
@@ -2,6 +2,7 @@ import type { Field, Plugin } from 'payload'
import { seoPlugin } from '@payloadcms/plugin-seo'
import type { AdminText } from '../admin-i18n/define.js'
import type { SeoOption } from './types.js'
type BuildSeoPluginArgs = {
@@ -19,12 +20,43 @@ const titleOverrideField: Field = {
name: 'titleOverride',
type: 'text',
admin: {
description:
'Use this exact text as the browser-tab title — no site name, no separator. Leave empty to compose the title automatically.',
description: {
en: 'Replaces the whole title, site name included; leave empty to build it automatically.',
pl: 'Zastępuje cały tytuł razem z nazwą witryny; zostaw puste, aby utworzyć go automatycznie.',
},
},
label: { en: 'Exact page title', pl: 'Dokładny tytuł strony' },
localized: true,
}
/** Panel wording for plugin-seo's own fields (labels only; names and data unchanged). */
const SEO_FIELD_TEXTS: Record<string, { description?: AdminText; label: AdminText }> = {
description: { label: { en: 'Description', pl: 'Opis' } },
image: {
description: {
en: 'Shown when the page is shared; best under 500 KB.',
pl: 'Widoczny przy udostępnianiu strony; najlepiej poniżej 500 KB.',
},
label: { en: 'Share image', pl: 'Obraz udostępniania' },
},
overview: { label: { en: 'Overview', pl: 'Przegląd' } },
preview: { label: { en: 'Preview', pl: 'Podgląd' } },
title: { label: { en: 'Page title', pl: 'Tytuł strony' } },
}
function withSeoLabels(fields: Field[]): Field[] {
return fields.map((field) => {
const texts = 'name' in field ? SEO_FIELD_TEXTS[field.name] : undefined
if (!texts) {return field}
const admin = (field as { admin?: Record<string, unknown> }).admin
return {
...field,
...(texts.description ? { admin: { ...admin, description: texts.description } } : {}),
label: texts.label,
} as Field
})
}
/**
* Admin hint right under meta.description (MetaDescriptionCheck): empty,
* same as the site-wide description, or same as another document's.
@@ -71,7 +103,7 @@ export function buildSeoPlugin({ seo, uploadsCollection = seo.uploadsCollection
return seoPlugin({
collections: seo.collections,
fields: ({ defaultFields }) => [
...afterDescription(defaultFields, descriptionCheckField(seo)),
...afterDescription(withSeoLabels(defaultFields), descriptionCheckField(seo)),
titleOverrideField,
...(seo.fields ?? []),
],