@actuate-media/cms-admin 0.37.0 → 0.37.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__tests__/layout/sidebar-brand.render.test.d.ts +2 -0
- package/dist/__tests__/layout/sidebar-brand.render.test.d.ts.map +1 -0
- package/dist/__tests__/layout/sidebar-brand.render.test.js +44 -0
- package/dist/__tests__/layout/sidebar-brand.render.test.js.map +1 -0
- package/dist/__tests__/views/login-branding.render.test.d.ts +2 -0
- package/dist/__tests__/views/login-branding.render.test.d.ts.map +1 -0
- package/dist/__tests__/views/login-branding.render.test.js +80 -0
- package/dist/__tests__/views/login-branding.render.test.js.map +1 -0
- package/dist/__tests__/views/login-mfa.render.test.js +6 -0
- package/dist/__tests__/views/login-mfa.render.test.js.map +1 -1
- package/dist/actuate-admin.css +1 -1
- package/dist/components/LogoPlaceholder.d.ts +17 -0
- package/dist/components/LogoPlaceholder.d.ts.map +1 -0
- package/dist/components/LogoPlaceholder.js +13 -0
- package/dist/components/LogoPlaceholder.js.map +1 -0
- package/dist/components/ui/Badge.d.ts +1 -1
- package/dist/components/ui/Button.d.ts +1 -1
- package/dist/components/ui/Card.d.ts +2 -2
- package/dist/components/ui/Input.d.ts +1 -1
- package/dist/components/ui/Select.d.ts +1 -1
- package/dist/layout/Sidebar.d.ts.map +1 -1
- package/dist/layout/Sidebar.js +13 -10
- package/dist/layout/Sidebar.js.map +1 -1
- package/dist/views/Login.d.ts.map +1 -1
- package/dist/views/Login.js +66 -8
- package/dist/views/Login.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/layout/sidebar-brand.render.test.tsx +58 -0
- package/src/__tests__/views/login-branding.render.test.tsx +96 -0
- package/src/__tests__/views/login-mfa.render.test.tsx +7 -0
- package/src/components/LogoPlaceholder.tsx +55 -0
- package/src/layout/Sidebar.tsx +14 -24
- package/src/views/Login.tsx +70 -9
package/src/layout/Sidebar.tsx
CHANGED
|
@@ -34,6 +34,7 @@ import {
|
|
|
34
34
|
} from 'lucide-react'
|
|
35
35
|
import type { LucideIcon } from 'lucide-react'
|
|
36
36
|
import { ActuateBrandLogo } from '../assets/actuate-logo.js'
|
|
37
|
+
import { LogoPlaceholder } from '../components/LogoPlaceholder.js'
|
|
37
38
|
|
|
38
39
|
/**
|
|
39
40
|
* Compact mark used in the collapsed sidebar — just the "C" symbol from the
|
|
@@ -76,28 +77,17 @@ const ICON_MAP: Record<string, LucideIcon> = {
|
|
|
76
77
|
Layers: Layers,
|
|
77
78
|
}
|
|
78
79
|
|
|
79
|
-
/** Square site-initials badge — the final fallback before the Actuate mark. */
|
|
80
|
-
function InitialsBadge({ initials, size }: { initials: string; size: 'sm' | 'lg' }) {
|
|
81
|
-
return (
|
|
82
|
-
<span
|
|
83
|
-
className={`bg-sidebar-primary text-sidebar-primary-foreground inline-flex shrink-0 items-center justify-center rounded-md font-medium ${
|
|
84
|
-
size === 'lg' ? 'h-8 w-8 text-sm' : 'h-8 w-8 text-sm'
|
|
85
|
-
}`}
|
|
86
|
-
aria-hidden="true"
|
|
87
|
-
>
|
|
88
|
-
{initials}
|
|
89
|
-
</span>
|
|
90
|
-
)
|
|
91
|
-
}
|
|
92
|
-
|
|
93
80
|
/**
|
|
94
81
|
* Sidebar brand lockup.
|
|
95
82
|
*
|
|
96
83
|
* Resolution order follows the Appearance spec, sourcing from the live
|
|
97
84
|
* appearance context (DB-backed brand, cached in localStorage) and falling
|
|
98
|
-
* back to legacy `config.admin.branding`, then
|
|
99
|
-
*
|
|
100
|
-
*
|
|
85
|
+
* back to legacy `config.admin.branding`, then a neutral logo placeholder for
|
|
86
|
+
* branded-but-logo-less installs, then the bundled Actuate mark/wordmark for
|
|
87
|
+
* un-branded installs. The placeholder replaces the old initials badge, which
|
|
88
|
+
* read as a user avatar (the real account avatar already sits top-right).
|
|
89
|
+
* Dark-mode uses the dark logo when one is configured. Logos are never
|
|
90
|
+
* stretched/cropped (object-contain).
|
|
101
91
|
*/
|
|
102
92
|
function BrandLogo({ config, collapsed }: { config?: any; collapsed: boolean }) {
|
|
103
93
|
const { adminBrand, resolvedTheme } = useTheme()
|
|
@@ -117,7 +107,7 @@ function BrandLogo({ config, collapsed }: { config?: any; collapsed: boolean })
|
|
|
117
107
|
if (mark) return <img src={mark} alt={alt} className="h-8 w-8 object-contain" />
|
|
118
108
|
if (primary) return <img src={primary} alt={alt} className="h-8 w-8 object-contain" />
|
|
119
109
|
if (configLogo) return <img src={configLogo} alt={alt} className="h-8 w-8 object-contain" />
|
|
120
|
-
if (hasInitials) return <
|
|
110
|
+
if (hasInitials) return <LogoPlaceholder tone="sidebar" />
|
|
121
111
|
return <ActuateMark className="h-8 w-8" />
|
|
122
112
|
}
|
|
123
113
|
|
|
@@ -143,14 +133,10 @@ function BrandLogo({ config, collapsed }: { config?: any; collapsed: boolean })
|
|
|
143
133
|
)
|
|
144
134
|
}
|
|
145
135
|
|
|
146
|
-
if (mark
|
|
136
|
+
if (mark) {
|
|
147
137
|
return (
|
|
148
138
|
<div className="flex min-w-0 items-center gap-2.5">
|
|
149
|
-
{mark
|
|
150
|
-
<img src={mark} alt={alt} className="h-8 w-8 shrink-0 object-contain" />
|
|
151
|
-
) : (
|
|
152
|
-
<InitialsBadge initials={initials} size="lg" />
|
|
153
|
-
)}
|
|
139
|
+
<img src={mark} alt={alt} className="h-8 w-8 shrink-0 object-contain" />
|
|
154
140
|
<span className="text-sidebar-foreground truncate text-sm font-medium">
|
|
155
141
|
{brandName ?? alt}
|
|
156
142
|
</span>
|
|
@@ -158,6 +144,10 @@ function BrandLogo({ config, collapsed }: { config?: any; collapsed: boolean })
|
|
|
158
144
|
)
|
|
159
145
|
}
|
|
160
146
|
|
|
147
|
+
if (hasInitials) {
|
|
148
|
+
return <LogoPlaceholder tone="sidebar" label={brandName ?? alt} />
|
|
149
|
+
}
|
|
150
|
+
|
|
161
151
|
if (brandName) {
|
|
162
152
|
return (
|
|
163
153
|
<div className="flex min-w-0 items-center gap-2.5">
|
package/src/views/Login.tsx
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import { useState, type FormEvent } from 'react'
|
|
3
|
+
import { useState, useEffect, useRef, type FormEvent } from 'react'
|
|
4
4
|
import { Eye, EyeOff, AlertTriangle, Loader2 } from 'lucide-react'
|
|
5
5
|
import { ActuateBrandLogo } from '../assets/actuate-logo.js'
|
|
6
|
+
import { LogoPlaceholder } from '../components/LogoPlaceholder.js'
|
|
7
|
+
import { useTheme } from '../components/ThemeProvider.js'
|
|
8
|
+
import { cmsApi } from '../lib/api.js'
|
|
6
9
|
|
|
7
10
|
export interface CaptchaConfig {
|
|
8
11
|
provider: 'recaptcha' | 'turnstile' | 'none'
|
|
@@ -227,8 +230,45 @@ export function Login({
|
|
|
227
230
|
const [totpError, setTotpError] = useState('')
|
|
228
231
|
const [verifying, setVerifying] = useState(false)
|
|
229
232
|
|
|
233
|
+
// Brand logo, sourced to match the admin sidebar (see resolution note below).
|
|
234
|
+
// `adminBrand` is the ThemeProvider cache the sidebar paints from (hydrated
|
|
235
|
+
// from localStorage on mount); `publicLogo` is fetched only when that cache
|
|
236
|
+
// is empty (a fresh browser that hasn't loaded the admin yet).
|
|
237
|
+
const { adminBrand } = useTheme()
|
|
238
|
+
const [publicLogo, setPublicLogo] = useState<string | null>(null)
|
|
239
|
+
// Site initials resolved from `/public/brand`. Used only to detect whether
|
|
240
|
+
// the install is "branded" on a fresh browser (no cache, no config name), so
|
|
241
|
+
// the logo-less fallback can pick the placeholder over the Actuate wordmark.
|
|
242
|
+
const [publicInitials, setPublicInitials] = useState<string | null>(null)
|
|
243
|
+
const publicBrandFetched = useRef(false)
|
|
244
|
+
|
|
230
245
|
useCaptchaScript(captchaConfig?.provider, captchaConfig?.siteKey)
|
|
231
246
|
|
|
247
|
+
useEffect(() => {
|
|
248
|
+
// The cached admin brand (exactly what the sidebar last rendered) wins and
|
|
249
|
+
// needs no network. Only reach for the unauthenticated `/public/brand`
|
|
250
|
+
// endpoint on a fresh browser with no cache, and never when the integrator
|
|
251
|
+
// opted out of a logo entirely (`branding.logo === null`).
|
|
252
|
+
if (adminBrand.primaryUrl || branding?.logo === null) return
|
|
253
|
+
if (publicBrandFetched.current) return
|
|
254
|
+
publicBrandFetched.current = true
|
|
255
|
+
|
|
256
|
+
let cancelled = false
|
|
257
|
+
void (async () => {
|
|
258
|
+
const res = await cmsApi<{
|
|
259
|
+
public?: { primary?: { url?: string } | null; initials?: string } | null
|
|
260
|
+
}>('/public/brand')
|
|
261
|
+
if (cancelled) return
|
|
262
|
+
const url = res.data?.public?.primary?.url
|
|
263
|
+
if (url) setPublicLogo(url)
|
|
264
|
+
const initials = res.data?.public?.initials
|
|
265
|
+
if (initials) setPublicInitials(initials)
|
|
266
|
+
})()
|
|
267
|
+
return () => {
|
|
268
|
+
cancelled = true
|
|
269
|
+
}
|
|
270
|
+
}, [adminBrand.primaryUrl, branding?.logo])
|
|
271
|
+
|
|
232
272
|
const canSubmit = email.trim() && password && !submitting
|
|
233
273
|
|
|
234
274
|
const handleSubmit = async (e: FormEvent) => {
|
|
@@ -308,27 +348,48 @@ export function Login({
|
|
|
308
348
|
const enabledProviders =
|
|
309
349
|
oauthProviders?.filter((p) => ['google', 'github', 'microsoft'].includes(p)) ?? []
|
|
310
350
|
|
|
311
|
-
//
|
|
312
|
-
//
|
|
313
|
-
//
|
|
314
|
-
//
|
|
315
|
-
|
|
351
|
+
// Logo resolution mirrors the admin sidebar so the login screen shows the
|
|
352
|
+
// same brand mark a user sees once signed in. Precedence (best available
|
|
353
|
+
// pre-auth):
|
|
354
|
+
// 1. the logo uploaded in Settings → Appearance — read from the
|
|
355
|
+
// ThemeProvider cache the sidebar paints from, then (fresh browsers with
|
|
356
|
+
// no cache) the unauthenticated `/public/brand` endpoint;
|
|
357
|
+
// 2. the static `config.admin.branding.logo` URL;
|
|
358
|
+
// 3. a neutral logo placeholder when the install is branded (a site/brand
|
|
359
|
+
// name is set) but no logo has been uploaded yet — matching the sidebar;
|
|
360
|
+
// 4. the bundled Actuate wordmark for a fully un-branded install.
|
|
361
|
+
// `branding.logo === null` still hides the logo entirely (whitelabel opt-out).
|
|
362
|
+
const configLogo = branding?.logo
|
|
363
|
+
const hideLogo = configLogo === null
|
|
364
|
+
const appearanceLogo = adminBrand.primaryUrl ?? publicLogo
|
|
365
|
+
const effectiveLogo = appearanceLogo ?? (typeof configLogo === 'string' ? configLogo : null)
|
|
316
366
|
const brandName = branding?.name ?? 'Actuate CMS'
|
|
317
367
|
const brandTagline = branding?.tagline ?? 'Sign in to your account'
|
|
318
|
-
const showLogo =
|
|
368
|
+
const showLogo = !hideLogo
|
|
369
|
+
// "Branded" = the operator has set a brand identity. Mirrors the sidebar's
|
|
370
|
+
// `hasInitials` signal (initials are derived from the site title) plus an
|
|
371
|
+
// explicit `branding.name` and, for fresh browsers, the initials returned by
|
|
372
|
+
// `/public/brand`. Drives the placeholder vs. Actuate-wordmark fallback so a
|
|
373
|
+
// configured client install never shows Actuate branding. `'A'` is the
|
|
374
|
+
// unset-title default, so it counts as un-branded.
|
|
375
|
+
const hasInitials = (value: string | null | undefined) => Boolean(value) && value !== 'A'
|
|
376
|
+
const isBranded =
|
|
377
|
+
Boolean(branding?.name) || hasInitials(adminBrand.initials) || hasInitials(publicInitials)
|
|
319
378
|
|
|
320
379
|
return (
|
|
321
380
|
<div className="flex min-h-screen items-center justify-center bg-gray-50 px-4">
|
|
322
381
|
<div className="w-full max-w-md">
|
|
323
382
|
<div className="mb-8 text-center">
|
|
324
383
|
{showLogo &&
|
|
325
|
-
(
|
|
384
|
+
(effectiveLogo ? (
|
|
326
385
|
<img
|
|
327
|
-
src={
|
|
386
|
+
src={effectiveLogo}
|
|
328
387
|
alt={brandName}
|
|
329
388
|
className="mx-auto mb-4 max-h-16 w-auto object-contain"
|
|
330
389
|
draggable={false}
|
|
331
390
|
/>
|
|
391
|
+
) : isBranded ? (
|
|
392
|
+
<LogoPlaceholder tone="login" />
|
|
332
393
|
) : (
|
|
333
394
|
<ActuateBrandLogo className="mx-auto mb-4 h-14 w-auto" />
|
|
334
395
|
))}
|