Files
ipal-kit/src/globals/SiteIntegrations/fields/smtp.ts
T
radoslaw.smolinskiandClaude Opus 5.5 2bd9d60822 Cookie banner layout options; keep admin UI out of /client
CookieBanner: order, settings="modal", controls="switch",
settingsActions, icon and a class slot for every element. Cookie
Settings gains eyebrow, title, settingsDescription, alwaysActiveLabel
and buttons.close.

MaskedField, TestEmailButton and IntegrationStatusBanner import
@payloadcms/ui and moved from /client to /admin; with sideEffects in
package.json the site bundle no longer ships ~235 KB gz of admin code.
A test walks the /client import graph to keep it that way.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-17 03:20:11 +02:00

96 lines
2.7 KiB
TypeScript

import type { Field } from 'payload'
import { buildIntegrationStatusBanner, buildIntegrationStatusField } from '../../../modules/integrations/status.js'
/**
* SMTP transport settings for outbound email.
*
* 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.
*/
export const smtpFields: Field[] = [
// Status written by mailAdapter on every send (throttled) — banner on this tab.
buildIntegrationStatusBanner('emailStatus', 'Email'),
{
name: 'emailTransport',
type: 'select',
admin: {
description:
'How outbound email is sent. "Microsoft Graph" is only available when configured by the administrator (Intecion).',
// 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',
options: [
{ label: 'SMTP', value: 'smtp' },
{ label: 'Microsoft Graph (Exchange)', value: 'graph' },
],
},
{
type: 'row',
admin: {
// Hide SMTP fields when Graph is selected — they're not used then.
condition: (_, siblingData) => siblingData?.emailTransport !== 'graph',
},
fields: [
{
name: 'smtpHost',
type: 'text',
admin: { placeholder: 'smtp.example.com', width: '70%' },
},
{
name: 'smtpPort',
type: 'number',
admin: { width: '30%' },
defaultValue: 587,
},
],
},
{
name: 'smtpUser',
type: 'text',
admin: {
description: 'SMTP account username.',
},
},
{
name: 'smtpPassword',
type: 'text',
admin: {
description: 'SMTP account password.',
// Masked in the UI (••••) — stored plaintext, readable for SMTP auth.
components: {
Field: '@intecion/ipal-kit/admin#MaskedField',
},
},
},
{
name: 'smtpFromAddress',
type: 'email',
admin: {
description: 'Default "from" address for outgoing mail.',
},
},
{
name: 'smtpFromName',
type: 'text',
admin: {
description: 'Default "from" display name.',
},
},
{
name: 'emailTest',
type: 'ui',
admin: {
components: {
Field: '@intecion/ipal-kit/admin#TestEmailButton',
},
},
},
buildIntegrationStatusField('emailStatus'),
]