Added white-label support
This commit is contained in:
Vendored
+72
-2
@@ -67,8 +67,8 @@ import { buildSeoPlugin, injectAutoFillMeta, injectSeoTabs } from './modules/seo
|
||||
// optional peer dependency at build time (it isn't in the plugin's own
|
||||
// node_modules). Avoids TS2307 without @ts-expect-error; the module
|
||||
// exists at runtime in projects that installed it.
|
||||
// @ts-ignore
|
||||
const mod = await import('@clocklimited/payload-2fa');
|
||||
const pkg = '@clocklimited/payload-2fa';
|
||||
const mod = await import(pkg);
|
||||
// The package exports `payloadTotp`; older/other builds may use
|
||||
// `totpPlugin`. Accept either so a rename doesn't break us.
|
||||
const totp = mod.payloadTotp ?? mod.totpPlugin;
|
||||
@@ -86,6 +86,76 @@ import { buildSeoPlugin, injectAutoFillMeta, injectSeoTabs } from './modules/seo
|
||||
throw new Error('[ipal] 2FA is enforced but @clocklimited/payload-2fa is not installed. ' + 'Run: pnpm add @clocklimited/payload-2fa — or set twoFactor: false to ' + `opt out (discouraged). Original error: ${String(err)}`);
|
||||
}
|
||||
}
|
||||
// --- white-label admin branding ---
|
||||
// Inject admin.components.graphics.Logo/Icon pointing at the plugin's
|
||||
// /admin export. The components read SiteSettings at render, so each client
|
||||
// sees their own brand from the panel (no brand in code). Project must run
|
||||
// `pnpm generate:importmap` so Payload resolves the component paths.
|
||||
if (options.whiteLabel) {
|
||||
const wl = options.whiteLabel === true ? {} : options.whiteLabel;
|
||||
const serverProps = {};
|
||||
if (wl.settingsSlug) {
|
||||
serverProps.settingsSlug = wl.settingsSlug;
|
||||
}
|
||||
if (wl.nameField) {
|
||||
serverProps.nameField = wl.nameField;
|
||||
}
|
||||
const logoProps = {
|
||||
...serverProps,
|
||||
...wl.logoField ? {
|
||||
imageField: wl.logoField
|
||||
} : {}
|
||||
};
|
||||
const iconProps = {
|
||||
...serverProps,
|
||||
...wl.iconField ? {
|
||||
imageField: wl.iconField
|
||||
} : {}
|
||||
};
|
||||
// Vendor credit ("Technology by Intecion.com") under the nav — on by
|
||||
// default, hidden with credit:false, text/url overridable.
|
||||
const creditOn = wl.credit !== false;
|
||||
const creditProps = wl.credit && typeof wl.credit === 'object' ? {
|
||||
...wl.credit.text ? {
|
||||
text: wl.credit.text
|
||||
} : {},
|
||||
...wl.credit.url ? {
|
||||
url: wl.credit.url
|
||||
} : {}
|
||||
} : {};
|
||||
config.admin = {
|
||||
...config.admin ?? {},
|
||||
components: {
|
||||
...config.admin?.components ?? {},
|
||||
graphics: {
|
||||
...config.admin?.components?.graphics ?? {},
|
||||
Icon: {
|
||||
path: '@intecion/ipal-kit/admin#AdminIcon',
|
||||
serverProps: iconProps
|
||||
},
|
||||
Logo: {
|
||||
path: '@intecion/ipal-kit/admin#AdminLogo',
|
||||
serverProps: logoProps
|
||||
}
|
||||
},
|
||||
...creditOn ? {
|
||||
afterNavLinks: [
|
||||
...config.admin?.components?.afterNavLinks ?? [],
|
||||
{
|
||||
path: '@intecion/ipal-kit/admin#IntecionCredit',
|
||||
serverProps: creditProps
|
||||
}
|
||||
]
|
||||
} : {}
|
||||
},
|
||||
...wl.titleSuffix ? {
|
||||
meta: {
|
||||
...config.admin?.meta ?? {},
|
||||
titleSuffix: wl.titleSuffix
|
||||
}
|
||||
} : {}
|
||||
};
|
||||
}
|
||||
// --- i18n ---
|
||||
config.localization = buildLocalizationConfig(options.i18n);
|
||||
// --- access: inject roles into the client's auth collection ---
|
||||
|
||||
Reference in New Issue
Block a user