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
@@ -2,9 +2,11 @@
|
||||
|
||||
import type { TextFieldClientComponent } from 'payload'
|
||||
|
||||
import { FieldDescription, FieldLabel, useField } from '@payloadcms/ui'
|
||||
import { FieldDescription, FieldLabel, useField, useTranslation } from '@payloadcms/ui'
|
||||
import { useState } from 'react'
|
||||
|
||||
import { ipalT } from '../../../modules/admin-i18n/t.js'
|
||||
|
||||
/**
|
||||
* Masked text input for sensitive values (SMTP password, R2 secret key,
|
||||
* Turnstile secret key, etc.).
|
||||
@@ -23,11 +25,12 @@ import { useState } from 'react'
|
||||
* Assigned via a field's admin.components.Field. Works on any `text` field.
|
||||
*/
|
||||
export const MaskedField: TextFieldClientComponent = ({ field, path }) => {
|
||||
const { t } = useTranslation()
|
||||
const { setValue, value } = useField<string>({ path })
|
||||
const [revealed, setRevealed] = useState(false)
|
||||
|
||||
const label =
|
||||
typeof field?.label === 'string' ? field.label : (field?.name ?? path)
|
||||
// A string or one string per language — FieldLabel / FieldDescription translate it.
|
||||
const label = field?.label || field?.name || path
|
||||
const description = field?.admin?.description
|
||||
|
||||
return (
|
||||
@@ -60,11 +63,11 @@ export const MaskedField: TextFieldClientComponent = ({ field, path }) => {
|
||||
}}
|
||||
type="button"
|
||||
>
|
||||
{revealed ? 'Hide' : 'Reveal'}
|
||||
{ipalT(t as never, revealed ? 'maskedHide' : 'maskedShow')}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{description && typeof description === 'string' ? (
|
||||
{description && typeof description !== 'function' ? (
|
||||
<FieldDescription description={description} path={path} />
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
@@ -1,17 +1,21 @@
|
||||
'use client'
|
||||
|
||||
import { useTranslation } from '@payloadcms/ui'
|
||||
import { useState } from 'react'
|
||||
|
||||
import { ipalT } from '../../../modules/admin-i18n/t.js'
|
||||
|
||||
/**
|
||||
* Admin UI: a small "send test email" tool for the SiteIntegrations email tab.
|
||||
* Admin UI: a small "send test e-mail" tool for the SiteIntegrations e-mail tab.
|
||||
* Enter an address, click Send, and it POSTs to /api/ipal/test-email, which
|
||||
* sends through the currently-selected transport (SMTP or Graph). Shows the
|
||||
* result inline so you can confirm delivery — or read the exact error — without
|
||||
* leaving the panel.
|
||||
* result inline so you can confirm delivery without leaving the panel.
|
||||
*
|
||||
* Assigned via a `ui` field's admin.components.Field.
|
||||
* Assigned via a `ui` field's admin.components.Field. Texts: `testEmail*` keys.
|
||||
*/
|
||||
export const TestEmailButton = () => {
|
||||
const { t } = useTranslation()
|
||||
const text = (key: Parameters<typeof ipalT>[1], vars?: Record<string, unknown>) => ipalT(t as never, key, vars)
|
||||
const [to, setTo] = useState('')
|
||||
const [status, setStatus] = useState<
|
||||
{ kind: 'error'; msg: string } | { kind: 'idle' } | { kind: 'ok'; msg: string } | { kind: 'sending' }
|
||||
@@ -19,7 +23,7 @@ export const TestEmailButton = () => {
|
||||
|
||||
const send = async () => {
|
||||
if (!to.trim()) {
|
||||
setStatus({ kind: 'error', msg: 'Enter a recipient address.' })
|
||||
setStatus({ kind: 'error', msg: text('testEmailInvalidRecipient') })
|
||||
return
|
||||
}
|
||||
setStatus({ kind: 'sending' })
|
||||
@@ -32,27 +36,25 @@ export const TestEmailButton = () => {
|
||||
})
|
||||
const data = await res.json()
|
||||
if (data.ok) {
|
||||
setStatus({ kind: 'ok', msg: data.message ?? 'Test email sent.' })
|
||||
setStatus({ kind: 'ok', msg: data.message ?? text('testEmailSent', { to: to.trim() }) })
|
||||
} else {
|
||||
setStatus({ kind: 'error', msg: data.error ?? 'Send failed.' })
|
||||
setStatus({ kind: 'error', msg: data.error ?? text('testEmailFailed') })
|
||||
}
|
||||
} catch {
|
||||
setStatus({ kind: 'error', msg: 'Request failed. Is the server running?' })
|
||||
setStatus({ kind: 'error', msg: text('testEmailNoConnection') })
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="field-type" style={{ marginTop: '1rem' }}>
|
||||
<label className="field-label" htmlFor="ipal-test-email-to">Send a test email</label>
|
||||
<p style={{ fontSize: '.85rem', marginTop: 0, opacity: 0.7 }}>
|
||||
Sends through the transport selected above. Save your changes first.
|
||||
</p>
|
||||
<label className="field-label" htmlFor="ipal-test-email-to">{text('testEmailLabel')}</label>
|
||||
<p style={{ fontSize: '.85rem', marginTop: 0, opacity: 0.7 }}>{text('testEmailHint')}</p>
|
||||
<div style={{ alignItems: 'center', display: 'flex', flexWrap: 'wrap', gap: '.5rem' }}>
|
||||
<input
|
||||
aria-label="Test email recipient"
|
||||
aria-label={text('testEmailRecipient')}
|
||||
id="ipal-test-email-to"
|
||||
onChange={(e) => setTo(e.target.value)}
|
||||
placeholder="you@example.com"
|
||||
placeholder="anna@example.com"
|
||||
style={{ flex: 1, minWidth: '220px' }}
|
||||
type="email"
|
||||
value={to}
|
||||
@@ -64,7 +66,7 @@ export const TestEmailButton = () => {
|
||||
style={{ whiteSpace: 'nowrap' }}
|
||||
type="button"
|
||||
>
|
||||
{status.kind === 'sending' ? 'Sending…' : 'Send test'}
|
||||
{status.kind === 'sending' ? text('testEmailSending') : text('testEmailSend')}
|
||||
</button>
|
||||
</div>
|
||||
{status.kind === 'ok' && (
|
||||
@@ -73,7 +75,7 @@ export const TestEmailButton = () => {
|
||||
</p>
|
||||
)}
|
||||
{status.kind === 'error' && (
|
||||
<p style={{ color: 'var(--theme-error-500, crimson)', marginTop: '.5rem' }}>
|
||||
<p role="alert" style={{ color: 'var(--theme-error-500, crimson)', marginTop: '.5rem' }}>
|
||||
✗ {status.msg}
|
||||
</p>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user