2FA screens: plain en/pl texts and tab title; CookieButton moves up above the footer
- TOTP_TEXTS (admin-ux.md wording) merged over @clocklimited/payload-2fa's long, informal texts; the project's i18n.translations still win; twoFactor.texts: false keeps the package's. Setup/verify screens titled "Two-step verification" / "Weryfikacja dwuetapowa" instead of "Payload". - CookieButton: position via --ipal-cookie-button-offset / -inset and --ipal-z-header; lifts above the footer (avoid, default COOKIE_BUTTON_AVOID) while it is on screen; side prop; className still replaces the look. - dev: a footer in the frontend layout to check the button against. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
d992d131a2
commit
2886c89d8a
@@ -1,5 +1,7 @@
|
||||
import type { Config, Plugin } from 'payload'
|
||||
|
||||
import { deepMergeSimple } from 'payload/shared'
|
||||
|
||||
import type { ResolvedAdminMeta } from './modules/branding/adminMeta.js'
|
||||
import type { IpalOptions, TotpPluginFactory } from './types.js'
|
||||
|
||||
@@ -30,6 +32,7 @@ import { buildGlobalRevalidateHook } from './modules/hooks/buildRevalidateHook.j
|
||||
import { withFillLocales } from './modules/hooks/fillEmptyLocales.js'
|
||||
import { buildLocalizationConfig, validateI18nConfig } from './modules/i18n/index.js'
|
||||
import { buildSystemPagesFields } from './modules/pages/index.js'
|
||||
import { TOTP_TEXTS, TOTP_VIEW_TITLE } from './modules/security/totp/totpTexts.js'
|
||||
import { buildSeoPlugin, injectAutoFillMeta, injectSeoTabs } from './modules/seo/index.js'
|
||||
import { buildIndexNowHook } from './modules/seo/indexNow.js'
|
||||
import { searchSettingsFields } from './modules/seo/searchSettings.js'
|
||||
@@ -199,6 +202,34 @@ export const ipalKit = (options: IpalOptions): Plugin => {
|
||||
totp: { issuer: tf.issuer },
|
||||
})(config)
|
||||
|
||||
// The package's texts are long and informal: ipal-kit's (admin-ux.md) go over
|
||||
// them, the project's own i18n.translations over both. The 2FA screens get a
|
||||
// tab title instead of "Payload" (view meta is a plain string: the site's language).
|
||||
if (tf.texts !== false) {
|
||||
config.i18n = {
|
||||
...config.i18n,
|
||||
translations: deepMergeSimple(
|
||||
deepMergeSimple((config.i18n?.translations ?? {}) as Record<string, unknown>, TOTP_TEXTS),
|
||||
(incomingConfig.i18n?.translations ?? {}) as Record<string, unknown>,
|
||||
),
|
||||
}
|
||||
const title = TOTP_VIEW_TITLE[options.i18n.defaultLocale.toLowerCase().startsWith('pl') ? 'pl' : 'en']
|
||||
const views = config.admin?.components?.views ?? {}
|
||||
config.admin = {
|
||||
...config.admin,
|
||||
components: {
|
||||
...config.admin?.components,
|
||||
views: Object.fromEntries(
|
||||
Object.entries(views).map(([key, view]) =>
|
||||
/^(?:Setup|Verify)TOTP/.test(key) && view && !view.meta?.title
|
||||
? [key, { ...view, meta: { ...view.meta, title } }]
|
||||
: [key, view],
|
||||
),
|
||||
),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// The package's TOTPProvider reads the path from an `x-pathname` header
|
||||
// no proxy sets on /admin, so it redirected the setup screen to itself
|
||||
// (`setup-totp?back=null`). Swap in ipal-kit's client-side provider, or
|
||||
|
||||
Reference in New Issue
Block a user