Admin follow-ups: localised stats tab title, scanner names, close label, favicon hint

- Statistics view: the browser-tab title follows the admin language.
  Payload's custom-view meta.title is one plain string and its custom-view
  metadata ignores i18n, so the view renders <DocumentTitle> (/admin) with the
  translated title; it re-applies the title while the view is open because
  Next streams the English metadata in after hydration. adminDocumentTitle()
  adds admin.meta.titleSuffix the way Payload does.
- Cookie scanner: CookieIntegration.label may be { en, pl, ... }. The built-in
  names without a product name come from the shared admin texts
  (cookieIntegration*, cookieSourceProject); the scan endpoint answers in the
  request's admin language and stored source names use the scanning editor's.
- Maintenance notice: getConstructionMode(locale) returns `locale`; the "x"
  close button gets a screen-reader name "Close" / "Zamknij" (locale and
  closeLabel props; constructionCloseLabel exported).
- Favicon: FaviconCheck (/admin, afterInput on Site settings -> Site icon)
  warns in the admin language when the image is under 48x48 or not square,
  without blocking the save; validateFaviconField shares faviconProblems().
- Docs, AGENT.md and skills: the above, plus Next.js 16.4.1 or later as the
  minimum safe version (AGENT.md 4.11, ipal-setup, ipal-upgrade).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-10-27 16:31:46 +01:00
co-authored by Claude Opus 5.5
parent 6f32ea4cdb
commit 546806fe39
35 changed files with 428 additions and 70 deletions
+17 -4
View File
@@ -1,9 +1,12 @@
import type { AdminTextKey } from '../../admin-i18n/texts/index.js'
import type { CookieDeclaration, CookieIntegration, CookieScanContext } from './types.js'
import { adminTexts } from '../../admin-i18n/texts/index.js'
import { validAnalyticsId } from '../../analytics/idFormats.js'
import { LOCALE_COOKIE_NAME } from '../../i18n/negotiateLocale.js'
import { getTurnstileConfig } from '../../turnstile/config.js'
import { CONSENT_COOKIE } from '../storage.js'
import { textFor } from './merge.js'
/** A tag ID from Site Integrations is filled in and valid. */
const hasId = (field: string) => (ctx: CookieScanContext) =>
@@ -16,6 +19,11 @@ const months = (n: number) => T(`${n} months`, `${n} mies.`)
const YEAR = T('1 year', '1 rok')
const TWO_YEARS = T('2 years', '2 lata')
const SITE = 'This site'
/** A name from the shared admin texts, in every admin language the plugin ships. */
const A = (key: AdminTextKey) => ({ en: adminTexts.en[key], pl: adminTexts.pl[key] })
/** Source name of the project's own `cookieScanner.declarations`. */
export const PROJECT_SOURCE = A('cookieSourceProject')
/**
* Cookies of everything the plugin itself injects — one place per integration.
@@ -37,7 +45,7 @@ export const DEFAULT_COOKIE_INTEGRATIONS: CookieIntegration[] = [
],
isEnabled: () => true,
key: 'consent',
label: 'Cookie banner',
label: A('cookieIntegrationConsent'),
},
{
declarations: (ctx) => [
@@ -52,7 +60,7 @@ export const DEFAULT_COOKIE_INTEGRATIONS: CookieIntegration[] = [
],
isEnabled: () => true,
key: 'admin',
label: 'Admin panel login',
label: A('cookieIntegrationAdmin'),
},
{
declarations: [
@@ -67,7 +75,7 @@ export const DEFAULT_COOKIE_INTEGRATIONS: CookieIntegration[] = [
],
isEnabled: (ctx) => ctx.plugin.localeCount > 1,
key: 'locale',
label: 'Language choice',
label: A('cookieIntegrationLocale'),
},
{
declarations: [
@@ -85,7 +93,7 @@ export const DEFAULT_COOKIE_INTEGRATIONS: CookieIntegration[] = [
],
isEnabled: (ctx) => ctx.plugin.stats,
key: 'stats',
label: 'Built-in statistics',
label: A('cookieIntegrationStats'),
},
{
declarations: [
@@ -281,6 +289,11 @@ export const DEFAULT_COOKIE_INTEGRATIONS: CookieIntegration[] = [
},
]
/** An integration's name in one admin language (English when that language is missing). */
export function integrationLabel(integration: Pick<CookieIntegration, 'label'>, language = 'en'): string {
return textFor(integration.label, language) ?? ''
}
/** An integration's declarations for this project. */
export function declarationsOf(integration: CookieIntegration, ctx: CookieScanContext): CookieDeclaration[] {
return typeof integration.declarations === 'function' ? integration.declarations(ctx) : integration.declarations