- 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]>
125 lines
3.9 KiB
TypeScript
125 lines
3.9 KiB
TypeScript
import type { Condition, Field } from 'payload'
|
|
|
|
import { buildIntegrationStatusBanner, buildIntegrationStatusField } from '../../../modules/integrations/status.js'
|
|
|
|
/**
|
|
* E-mail sending settings (SMTP, or Microsoft Graph set up on the server).
|
|
*
|
|
* Protected at the global level (SiteIntegrations requires an authenticated
|
|
* user), so all fields — including the password — stay editable in the admin
|
|
* panel while remaining inaccessible to anonymous API requests.
|
|
*/
|
|
|
|
// SMTP fields only matter with the SMTP transport — hidden while Graph is selected.
|
|
const usesSmtp: Condition = (_, siblingData) => siblingData?.emailTransport !== 'graph'
|
|
|
|
export const smtpFields: Field[] = [
|
|
// Status written by mailAdapter on every send (throttled) — banner on this tab.
|
|
buildIntegrationStatusBanner(
|
|
'emailStatus',
|
|
{ en: 'E-mail sending', pl: 'Wysyłka e-mail' },
|
|
{ failing: 'statusEmailFailing', hint: 'statusEmailHint' },
|
|
),
|
|
{
|
|
name: 'emailTransport',
|
|
type: 'select',
|
|
admin: {
|
|
description: {
|
|
en: 'Microsoft Graph works only when your administrator has set it up on the server.',
|
|
pl: 'Microsoft Graph działa tylko wtedy, gdy administrator skonfiguruje go na serwerze.',
|
|
},
|
|
// The Graph option only makes sense when agency credentials exist in env.
|
|
// We can't read process.env in the admin UI directly, so a client project
|
|
// that hasn't set up Graph should filter this option via integrationsFields
|
|
// override, or simply leave it on 'smtp'. The adapter enforces the real
|
|
// availability at send time regardless of what's selected here.
|
|
},
|
|
defaultValue: 'smtp',
|
|
label: { en: 'Sending method', pl: 'Sposób wysyłki' },
|
|
options: [
|
|
{ label: { en: 'SMTP server', pl: 'Serwer SMTP' }, value: 'smtp' },
|
|
{ label: { en: 'Microsoft Graph (Exchange)', pl: 'Microsoft Graph (Exchange)' }, value: 'graph' },
|
|
],
|
|
},
|
|
{
|
|
type: 'row',
|
|
fields: [
|
|
{
|
|
name: 'smtpFromAddress',
|
|
type: 'email',
|
|
admin: {
|
|
description: {
|
|
en: 'E-mails are sent from this address; with Microsoft Graph, replies go to it.',
|
|
pl: 'Z tego adresu wychodzą e-maile; przy Microsoft Graph trafiają na niego odpowiedzi.',
|
|
},
|
|
placeholder: '[email protected]',
|
|
width: '50%',
|
|
},
|
|
label: { en: 'Sender address', pl: 'Adres nadawcy' },
|
|
},
|
|
{
|
|
name: 'smtpFromName',
|
|
type: 'text',
|
|
admin: {
|
|
description: {
|
|
en: 'The name recipients see, e.g. the company name.',
|
|
pl: 'Nazwa widoczna dla odbiorcy, np. nazwa firmy.',
|
|
},
|
|
width: '50%',
|
|
},
|
|
label: { en: 'Sender name', pl: 'Nazwa nadawcy' },
|
|
},
|
|
],
|
|
},
|
|
{
|
|
type: 'row',
|
|
admin: { condition: usesSmtp },
|
|
fields: [
|
|
{
|
|
name: 'smtpHost',
|
|
type: 'text',
|
|
admin: { placeholder: 'smtp.example.com', width: '70%' },
|
|
label: { en: 'Server', pl: 'Serwer' },
|
|
},
|
|
{
|
|
name: 'smtpPort',
|
|
type: 'number',
|
|
admin: {
|
|
description: { en: 'Usually 587, or 465.', pl: 'Zwykle 587 lub 465.' },
|
|
width: '30%',
|
|
},
|
|
defaultValue: 587,
|
|
label: { en: 'Port', pl: 'Port' },
|
|
},
|
|
],
|
|
},
|
|
{
|
|
name: 'smtpUser',
|
|
type: 'text',
|
|
admin: { condition: usesSmtp },
|
|
label: { en: 'User name', pl: 'Nazwa użytkownika' },
|
|
},
|
|
{
|
|
name: 'smtpPassword',
|
|
type: 'text',
|
|
admin: {
|
|
// Masked in the UI (••••) — stored plaintext, readable for SMTP auth.
|
|
components: {
|
|
Field: '@intecion/ipal-kit/admin#MaskedField',
|
|
},
|
|
condition: usesSmtp,
|
|
},
|
|
label: { en: 'Password', pl: 'Hasło' },
|
|
},
|
|
{
|
|
name: 'emailTest',
|
|
type: 'ui',
|
|
admin: {
|
|
components: {
|
|
Field: '@intecion/ipal-kit/admin#TestEmailButton',
|
|
},
|
|
},
|
|
},
|
|
buildIntegrationStatusField('emailStatus'),
|
|
]
|