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:
co-authored by
Claude Opus 5.5
parent
eeac33ed2f
commit
6b46bc0c14
@@ -1,12 +1,16 @@
|
||||
import type { Payload, PayloadRequest } from 'payload'
|
||||
|
||||
import type { StatsI18n } from './statsI18n.js'
|
||||
|
||||
import { canReadStats } from './canReadStats.js'
|
||||
import { loadStats } from './loadStats.js'
|
||||
import { num, statsI18n, tr } from './statsI18n.js'
|
||||
import { STATS_CSS, VisitsChart } from './VisitsChart.js'
|
||||
|
||||
type Props = {
|
||||
adminRoute?: string
|
||||
/** Injected by Payload into admin server components. */
|
||||
i18n?: StatsI18n
|
||||
payload?: Payload
|
||||
req?: PayloadRequest
|
||||
timeZone?: string
|
||||
@@ -19,8 +23,9 @@ type Props = {
|
||||
* collection lets read (admins by default); renders nothing on
|
||||
* any error (DB not ready, collection missing).
|
||||
*/
|
||||
export async function StatsWidget({ adminRoute = '/admin', payload, req, timeZone = 'Europe/Warsaw', user }: Props) {
|
||||
export async function StatsWidget({ adminRoute = '/admin', i18n: i18nProp, payload, req, timeZone = 'Europe/Warsaw', user }: Props) {
|
||||
if (!payload || !(await canReadStats(payload, req, user))) {return null}
|
||||
const i18n = statsI18n(i18nProp ?? (req?.i18n as StatsI18n | undefined))
|
||||
let stats
|
||||
try {
|
||||
stats = await loadStats(payload, { timeZone })
|
||||
@@ -30,12 +35,12 @@ export async function StatsWidget({ adminRoute = '/admin', payload, req, timeZon
|
||||
return (
|
||||
<section className="ipal-stats" style={{ marginBottom: '2rem' }}>
|
||||
<style>{STATS_CSS}</style>
|
||||
<h2 style={{ marginBottom: '0.25rem' }}>Visits per day</h2>
|
||||
<h2 style={{ marginBottom: '0.25rem' }}>{tr(i18n, 'statsVisitsPerDay')}</h2>
|
||||
<p style={{ color: 'var(--theme-elevation-500)', margin: '0 0 0.75rem' }}>
|
||||
Last 30 days: {stats.totals.visits.toLocaleString('en-US')} visits, {stats.totals.views.toLocaleString('en-US')} page views ·{' '}
|
||||
<a href={`${adminRoute.replace(/\/$/, '')}/stats`}>All statistics →</a>
|
||||
{tr(i18n, 'statsWidgetSummary', { views: num(i18n, stats.totals.views), visits: num(i18n, stats.totals.visits) })} ·{' '}
|
||||
<a href={`${adminRoute.replace(/\/$/, '')}/stats`}>{tr(i18n, 'statsWidgetLink')}</a>
|
||||
</p>
|
||||
<VisitsChart days={stats.days} />
|
||||
<VisitsChart days={stats.days} i18n={i18n} />
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user