@prenta/admin 2.14.8 → 2.16.0
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/CHANGELOG.md +17 -0
- package/dist/AdminRoot.d.ts.map +1 -1
- package/dist/AdminRoot.js +11 -6
- package/dist/AdminRoot.js.map +1 -1
- package/dist/LoginRoot.js +3 -3
- package/dist/LoginRoot.js.map +1 -1
- package/dist/__tests__/assets/prenta-logo.test.js +26 -10
- package/dist/__tests__/assets/prenta-logo.test.js.map +1 -1
- package/dist/__tests__/layout/sidebar-brand.render.test.js +25 -22
- package/dist/__tests__/layout/sidebar-brand.render.test.js.map +1 -1
- package/dist/__tests__/views/appearance-settings.render.test.js +9 -0
- package/dist/__tests__/views/appearance-settings.render.test.js.map +1 -1
- package/dist/__tests__/views/login-branding.render.test.js +15 -30
- package/dist/__tests__/views/login-branding.render.test.js.map +1 -1
- package/dist/__tests__/views/mcp-connect.render.test.js +54 -4
- package/dist/__tests__/views/mcp-connect.render.test.js.map +1 -1
- package/dist/__tests__/views/mcp-consent.render.test.d.ts +2 -0
- package/dist/__tests__/views/mcp-consent.render.test.d.ts.map +1 -0
- package/dist/__tests__/views/mcp-consent.render.test.js +112 -0
- package/dist/__tests__/views/mcp-consent.render.test.js.map +1 -0
- package/dist/assets/prenta-logo.d.ts +18 -21
- package/dist/assets/prenta-logo.d.ts.map +1 -1
- package/dist/assets/prenta-logo.js +24 -12
- package/dist/assets/prenta-logo.js.map +1 -1
- package/dist/components/AuthBranding.d.ts +40 -0
- package/dist/components/AuthBranding.d.ts.map +1 -0
- package/dist/components/AuthBranding.js +81 -0
- package/dist/components/AuthBranding.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/layout/Sidebar.d.ts.map +1 -1
- package/dist/layout/Sidebar.js +15 -23
- package/dist/layout/Sidebar.js.map +1 -1
- package/dist/prenta-admin.css +1 -1
- package/dist/views/ForgotPassword.d.ts +3 -1
- package/dist/views/ForgotPassword.d.ts.map +1 -1
- package/dist/views/ForgotPassword.js +6 -4
- package/dist/views/ForgotPassword.js.map +1 -1
- package/dist/views/Login.d.ts +2 -5
- package/dist/views/Login.d.ts.map +1 -1
- package/dist/views/Login.js +9 -74
- package/dist/views/Login.js.map +1 -1
- package/dist/views/McpConsent.d.ts.map +1 -1
- package/dist/views/McpConsent.js +21 -3
- package/dist/views/McpConsent.js.map +1 -1
- package/dist/views/ResetPassword.d.ts +3 -1
- package/dist/views/ResetPassword.d.ts.map +1 -1
- package/dist/views/ResetPassword.js +5 -3
- package/dist/views/ResetPassword.js.map +1 -1
- package/dist/views/Settings.js +1 -1
- package/dist/views/Settings.js.map +1 -1
- package/dist/views/SetupWizard.d.ts +3 -1
- package/dist/views/SetupWizard.d.ts.map +1 -1
- package/dist/views/SetupWizard.js +5 -3
- package/dist/views/SetupWizard.js.map +1 -1
- package/dist/views/settings/BrandPreviewCard.d.ts.map +1 -1
- package/dist/views/settings/BrandPreviewCard.js +5 -6
- package/dist/views/settings/BrandPreviewCard.js.map +1 -1
- package/dist/views/settings/BrandingCard.d.ts.map +1 -1
- package/dist/views/settings/BrandingCard.js +4 -3
- package/dist/views/settings/BrandingCard.js.map +1 -1
- package/dist/views/settings/McpConnectTab.d.ts +2 -1
- package/dist/views/settings/McpConnectTab.d.ts.map +1 -1
- package/dist/views/settings/McpConnectTab.js +95 -4
- package/dist/views/settings/McpConnectTab.js.map +1 -1
- package/package.json +4 -4
- package/src/AdminRoot.tsx +15 -5
- package/src/LoginRoot.tsx +9 -2
- package/src/__tests__/assets/prenta-logo.test.tsx +27 -10
- package/src/__tests__/layout/sidebar-brand.render.test.tsx +29 -25
- package/src/__tests__/views/appearance-settings.render.test.tsx +11 -0
- package/src/__tests__/views/login-branding.render.test.tsx +15 -30
- package/src/__tests__/views/mcp-connect.render.test.tsx +79 -5
- package/src/__tests__/views/mcp-consent.render.test.tsx +124 -0
- package/src/assets/prenta-logo.tsx +55 -53
- package/src/components/AuthBranding.tsx +125 -0
- package/src/index.ts +2 -0
- package/src/layout/Sidebar.tsx +51 -49
- package/src/views/ForgotPassword.tsx +12 -5
- package/src/views/Login.tsx +15 -89
- package/src/views/McpConsent.tsx +37 -10
- package/src/views/ResetPassword.tsx +12 -5
- package/src/views/Settings.tsx +1 -1
- package/src/views/SetupWizard.tsx +12 -5
- package/src/views/settings/BrandPreviewCard.tsx +20 -27
- package/src/views/settings/BrandingCard.tsx +18 -1
- package/src/views/settings/McpConnectTab.tsx +232 -16
- package/dist/components/LogoPlaceholder.d.ts +0 -17
- package/dist/components/LogoPlaceholder.d.ts.map +0 -1
- package/dist/components/LogoPlaceholder.js +0 -13
- package/dist/components/LogoPlaceholder.js.map +0 -1
- package/src/components/LogoPlaceholder.tsx +0 -55
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { useEffect, useRef, useState, type ReactElement } from 'react'
|
|
4
|
+
import { PrentaBrandLogo } from '../assets/prenta-logo.js'
|
|
5
|
+
import { useTheme } from './ThemeProvider.js'
|
|
6
|
+
import { cmsApi } from '../lib/api.js'
|
|
7
|
+
|
|
8
|
+
export interface AuthBrandingConfig {
|
|
9
|
+
logo?: string | null
|
|
10
|
+
name?: string
|
|
11
|
+
tagline?: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface ResolvedAuthBrand {
|
|
15
|
+
/** Resolved custom logo URL (uploaded in Appearance or set in config), if any. */
|
|
16
|
+
effectiveLogo: string | null
|
|
17
|
+
/** True when `branding.logo === null` explicitly hides the top hero logo. */
|
|
18
|
+
hideLogo: boolean
|
|
19
|
+
/** True when a custom logo or whitelabel opt-out replaces the default Prenta hero. */
|
|
20
|
+
showPermanentFooter: boolean
|
|
21
|
+
/** Brand display name (falls back to `'Prenta CMS'`). */
|
|
22
|
+
brandName: string
|
|
23
|
+
/** Handler to mark a broken custom logo URL as failed so the Prenta fallback renders. */
|
|
24
|
+
onLogoError: (src: string) => void
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Resolve the brand lockup for pre-authenticated screens (Login, SetupWizard,
|
|
29
|
+
* ForgotPassword, ResetPassword). Uses the cached `adminBrand` when warm, and
|
|
30
|
+
* falls back to `/public/brand` on fresh browsers. Whenever no custom logo has
|
|
31
|
+
* been uploaded or configured, the bundled `Prënta` wordmark serves as the
|
|
32
|
+
* default placeholder.
|
|
33
|
+
*/
|
|
34
|
+
export function useAuthBrand(branding?: AuthBrandingConfig): ResolvedAuthBrand {
|
|
35
|
+
const { adminBrand, resolvedTheme } = useTheme()
|
|
36
|
+
const [publicPrimaryUrl, setPublicPrimaryUrl] = useState<string | null>(null)
|
|
37
|
+
const [publicDarkUrl, setPublicDarkUrl] = useState<string | null>(null)
|
|
38
|
+
const [failedSrcs, setFailedSrcs] = useState<Set<string>>(new Set())
|
|
39
|
+
const fetchedRef = useRef(false)
|
|
40
|
+
|
|
41
|
+
const configLogo = branding?.logo
|
|
42
|
+
const hideLogo = configLogo === null
|
|
43
|
+
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (adminBrand.primaryUrl || hideLogo) return
|
|
46
|
+
if (fetchedRef.current) return
|
|
47
|
+
fetchedRef.current = true
|
|
48
|
+
|
|
49
|
+
let cancelled = false
|
|
50
|
+
void (async () => {
|
|
51
|
+
const res = await cmsApi<{
|
|
52
|
+
public?: {
|
|
53
|
+
primary?: { url?: string } | null
|
|
54
|
+
dark?: { url?: string } | null
|
|
55
|
+
} | null
|
|
56
|
+
}>('/public/brand')
|
|
57
|
+
if (cancelled) return
|
|
58
|
+
const primary = res.data?.public?.primary?.url
|
|
59
|
+
const dark = res.data?.public?.dark?.url
|
|
60
|
+
if (primary) setPublicPrimaryUrl(primary)
|
|
61
|
+
if (dark) setPublicDarkUrl(dark)
|
|
62
|
+
})()
|
|
63
|
+
return () => {
|
|
64
|
+
cancelled = true
|
|
65
|
+
}
|
|
66
|
+
}, [adminBrand.primaryUrl, hideLogo])
|
|
67
|
+
|
|
68
|
+
const usable = (url: string | null | undefined): string | null =>
|
|
69
|
+
url && !failedSrcs.has(url) ? url : null
|
|
70
|
+
|
|
71
|
+
const darkPref = resolvedTheme === 'dark' ? (adminBrand.darkUrl ?? publicDarkUrl) : null
|
|
72
|
+
const appearanceLogo = usable(darkPref) ?? usable(adminBrand.primaryUrl ?? publicPrimaryUrl)
|
|
73
|
+
const staticLogo = typeof configLogo === 'string' ? usable(configLogo) : null
|
|
74
|
+
const effectiveLogo = hideLogo ? null : (appearanceLogo ?? staticLogo)
|
|
75
|
+
const brandName = branding?.name ?? 'Prenta CMS'
|
|
76
|
+
|
|
77
|
+
const onLogoError = (src: string) => {
|
|
78
|
+
setFailedSrcs((prev) => (prev.has(src) ? prev : new Set(prev).add(src)))
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
effectiveLogo,
|
|
83
|
+
hideLogo,
|
|
84
|
+
showPermanentFooter: hideLogo || Boolean(effectiveLogo),
|
|
85
|
+
brandName,
|
|
86
|
+
onLogoError,
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Top-of-card brand hero shared across Login, SetupWizard, ForgotPassword, and
|
|
92
|
+
* ResetPassword. Shows the uploaded/configured logo when present, otherwise the
|
|
93
|
+
* cropped `Prënta` placeholder wordmark.
|
|
94
|
+
*/
|
|
95
|
+
export function AuthBrandHero({ brand }: { brand: ResolvedAuthBrand }): ReactElement | null {
|
|
96
|
+
if (brand.hideLogo) return null
|
|
97
|
+
if (brand.effectiveLogo) {
|
|
98
|
+
return (
|
|
99
|
+
<img
|
|
100
|
+
src={brand.effectiveLogo}
|
|
101
|
+
alt={brand.brandName}
|
|
102
|
+
className="mx-auto mb-4 max-h-16 w-auto object-contain"
|
|
103
|
+
draggable={false}
|
|
104
|
+
onError={() => brand.onLogoError(brand.effectiveLogo!)}
|
|
105
|
+
/>
|
|
106
|
+
)
|
|
107
|
+
}
|
|
108
|
+
return <PrentaBrandLogo className="text-foreground mx-auto mb-4 h-11 w-auto" />
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Subtle permanent CMS attribution rendered beneath auth cards whenever a
|
|
113
|
+
* tenant's custom logo (or whitelabel opt-out) replaces the top Prenta hero.
|
|
114
|
+
*/
|
|
115
|
+
export function AuthPrentaFooter(): ReactElement {
|
|
116
|
+
return (
|
|
117
|
+
<div
|
|
118
|
+
aria-label="Powered by Prenta CMS"
|
|
119
|
+
className="text-muted-foreground mt-6 flex items-center justify-center gap-1.5 text-xs select-none"
|
|
120
|
+
>
|
|
121
|
+
<span>Powered by</span>
|
|
122
|
+
<PrentaBrandLogo decorative className="text-foreground/75 h-3.5 w-auto shrink-0" />
|
|
123
|
+
</div>
|
|
124
|
+
)
|
|
125
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -2,6 +2,8 @@ export { AdminRoot } from './AdminRoot.js'
|
|
|
2
2
|
export type { AdminRootProps } from './AdminRoot.js'
|
|
3
3
|
export { LoginRoot } from './LoginRoot.js'
|
|
4
4
|
export type { LoginRootProps } from './LoginRoot.js'
|
|
5
|
+
export { PrentaBrandLogo, PrentaMark, PRENTA_ACCENT } from './assets/prenta-logo.js'
|
|
6
|
+
export type { BrandLogoProps } from './assets/prenta-logo.js'
|
|
5
7
|
|
|
6
8
|
// Pluggable canvas renderers for custom section types (see `AdminRoot`'s
|
|
7
9
|
// `sectionRenderers` prop). The types structurally mirror
|
package/src/layout/Sidebar.tsx
CHANGED
|
@@ -8,30 +8,25 @@ import { adminPortalContainer } from '../lib/portal-container.js'
|
|
|
8
8
|
import { TIER_MEDIA } from '../lib/tiers.js'
|
|
9
9
|
import { useTheme } from '../components/ThemeProvider.js'
|
|
10
10
|
import { PrentaBrandLogo, PrentaMark } from '../assets/prenta-logo.js'
|
|
11
|
-
import { LogoPlaceholder } from '../components/LogoPlaceholder.js'
|
|
12
11
|
import { activeChildPath, hasActiveDescendant, isPathActive, type NavItem } from './nav-config.js'
|
|
13
12
|
import { useNavItems } from './use-nav-items.js'
|
|
14
13
|
|
|
15
14
|
/**
|
|
16
15
|
* Sidebar brand lockup.
|
|
17
16
|
*
|
|
18
|
-
* Resolution order
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* Dark-mode uses the dark logo when one is configured. Logos are never
|
|
25
|
-
* stretched/cropped (object-contain). Kit sizes (cms-responsive.css): the
|
|
26
|
-
* full logo is 24px tall and at most 150px wide; the rail mark is 26px.
|
|
17
|
+
* Resolution order sources from the live appearance context (DB-backed brand,
|
|
18
|
+
* cached in localStorage) and falls back to legacy `config.admin.branding`,
|
|
19
|
+
* then to the bundled Prenta wordmark / `Prë` mark as the default placeholder
|
|
20
|
+
* until the operator uploads their own logo in Settings → Admin appearance.
|
|
21
|
+
* Dark mode uses the dark logo when one is configured. Logos are never
|
|
22
|
+
* stretched/cropped (`object-contain`).
|
|
27
23
|
*/
|
|
28
24
|
function BrandLogo({ config, collapsed }: { config?: any; collapsed: boolean }) {
|
|
29
25
|
const { adminBrand, resolvedTheme } = useTheme()
|
|
30
26
|
const branding = config?.admin?.branding
|
|
31
27
|
const configLogo = branding?.logo
|
|
28
|
+
const hideLogo = configLogo === null
|
|
32
29
|
const brandName = branding?.name
|
|
33
|
-
const initials = adminBrand.initials
|
|
34
|
-
const hasInitials = Boolean(initials) && initials !== 'A'
|
|
35
30
|
|
|
36
31
|
// Track image URLs that fail to load (broken/expired/deleted asset) so the
|
|
37
32
|
// resolution falls through to the next option instead of showing the browser's
|
|
@@ -50,7 +45,7 @@ function BrandLogo({ config, collapsed }: { config?: any; collapsed: boolean })
|
|
|
50
45
|
const darkPref = resolvedTheme === 'dark' ? adminBrand.darkUrl : null
|
|
51
46
|
const primary = usable(darkPref) ?? usable(adminBrand.primaryUrl)
|
|
52
47
|
const mark = usable(adminBrand.markUrl)
|
|
53
|
-
const cfg = usable(configLogo)
|
|
48
|
+
const cfg = typeof configLogo === 'string' ? usable(configLogo) : null
|
|
54
49
|
const alt = brandName ?? 'Admin'
|
|
55
50
|
|
|
56
51
|
// Wide horizontal logos scale down to fit the rail / sidebar header instead
|
|
@@ -72,8 +67,8 @@ function BrandLogo({ config, collapsed }: { config?: any; collapsed: boolean })
|
|
|
72
67
|
if (primary)
|
|
73
68
|
return <img src={primary} alt={alt} className={logoClass} onError={onErr(primary)} />
|
|
74
69
|
if (cfg) return <img src={cfg} alt={alt} className={logoClass} onError={onErr(cfg)} />
|
|
75
|
-
if (
|
|
76
|
-
return <PrentaMark className="h-
|
|
70
|
+
if (hideLogo) return null
|
|
71
|
+
return <PrentaMark className="text-txt h-auto w-8 object-contain" />
|
|
77
72
|
}
|
|
78
73
|
|
|
79
74
|
if (primary) {
|
|
@@ -106,20 +101,13 @@ function BrandLogo({ config, collapsed }: { config?: any; collapsed: boolean })
|
|
|
106
101
|
)
|
|
107
102
|
}
|
|
108
103
|
|
|
109
|
-
if (
|
|
110
|
-
return
|
|
104
|
+
if (hideLogo) {
|
|
105
|
+
return brandName ? (
|
|
106
|
+
<span className="text-body text-txt truncate font-medium">{brandName}</span>
|
|
107
|
+
) : null
|
|
111
108
|
}
|
|
112
109
|
|
|
113
|
-
|
|
114
|
-
return (
|
|
115
|
-
<div className="flex min-w-0 items-center gap-2.5">
|
|
116
|
-
<PrentaMark className="h-[26px] w-[26px] shrink-0" />
|
|
117
|
-
<span className="text-body text-txt truncate font-medium">{brandName}</span>
|
|
118
|
-
</div>
|
|
119
|
-
)
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
return <PrentaBrandLogo className="h-6 w-auto" />
|
|
110
|
+
return <PrentaBrandLogo className="text-txt h-6 w-auto" />
|
|
123
111
|
}
|
|
124
112
|
|
|
125
113
|
export interface SidebarProps {
|
|
@@ -177,28 +165,42 @@ export function Sidebar({
|
|
|
177
165
|
<NavTree items={navItems} ctx={{ collapsed, currentPath, onNavigate }} />
|
|
178
166
|
</nav>
|
|
179
167
|
|
|
180
|
-
{/*
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
168
|
+
{/* Permanent CMS brand footer + desktop collapse toggle (>=1025px). */}
|
|
169
|
+
<div className="border-bdr shrink-0 border-t p-2">
|
|
170
|
+
{collapsed ? (
|
|
171
|
+
<div className="flex items-center justify-center py-1.5" title="Powered by Prenta CMS">
|
|
172
|
+
<PrentaMark label="Powered by Prenta CMS" className="text-sub h-auto w-6 opacity-80" />
|
|
173
|
+
</div>
|
|
174
|
+
) : (
|
|
175
|
+
<div
|
|
176
|
+
aria-label="Powered by Prenta CMS"
|
|
177
|
+
className="text-hint text-faint flex items-center gap-1.5 px-2.5 py-1.5 whitespace-nowrap select-none"
|
|
178
|
+
>
|
|
179
|
+
<span>Powered by</span>
|
|
180
|
+
<PrentaBrandLogo decorative className="text-sub h-3.5 w-auto shrink-0" />
|
|
181
|
+
</div>
|
|
182
|
+
)}
|
|
183
|
+
<div className="not-narrow:block hidden">
|
|
184
|
+
<button
|
|
185
|
+
type="button"
|
|
186
|
+
onClick={onToggleCollapse}
|
|
187
|
+
className={`rounded-7 text-meta text-sub hover:bg-acc-l hover:text-acc flex w-full cursor-pointer items-center gap-[9px] overflow-hidden border-0 bg-transparent px-2.5 py-[7px] leading-[normal] font-normal whitespace-nowrap ${
|
|
188
|
+
collapsed ? 'justify-center' : ''
|
|
189
|
+
}`}
|
|
190
|
+
aria-expanded={!collapsed}
|
|
191
|
+
aria-label={collapsed ? 'Expand sidebar' : 'Collapse sidebar'}
|
|
192
|
+
>
|
|
193
|
+
{/* 19px: the kit's inline chevron sits on the 12px text baseline, so the button is 33px. */}
|
|
194
|
+
<span className="flex h-[19px] shrink-0 items-center">
|
|
195
|
+
{collapsed ? (
|
|
196
|
+
<ChevronRight className="h-[15px] w-[15px]" strokeWidth={1.75} aria-hidden />
|
|
197
|
+
) : (
|
|
198
|
+
<ChevronLeft className="h-[15px] w-[15px]" strokeWidth={1.75} aria-hidden />
|
|
199
|
+
)}
|
|
200
|
+
</span>
|
|
201
|
+
<span className={collapsed ? 'sr-only' : ''}>Collapse sidebar</span>
|
|
202
|
+
</button>
|
|
203
|
+
</div>
|
|
202
204
|
</div>
|
|
203
205
|
</aside>
|
|
204
206
|
)
|
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
3
|
import { useState, type FormEvent } from 'react'
|
|
4
|
-
import {
|
|
4
|
+
import { ArrowLeft, Loader2, CheckCircle2, AlertTriangle } from 'lucide-react'
|
|
5
|
+
import {
|
|
6
|
+
AuthBrandHero,
|
|
7
|
+
AuthPrentaFooter,
|
|
8
|
+
useAuthBrand,
|
|
9
|
+
type AuthBrandingConfig,
|
|
10
|
+
} from '../components/AuthBranding.js'
|
|
5
11
|
import { cmsApi } from '../lib/api.js'
|
|
6
12
|
|
|
7
13
|
export interface ForgotPasswordProps {
|
|
8
14
|
onNavigate: (path: string) => void
|
|
15
|
+
branding?: AuthBrandingConfig
|
|
9
16
|
}
|
|
10
17
|
|
|
11
18
|
const fieldClass =
|
|
12
19
|
'w-full rounded-lg border border-border bg-input-background px-3 py-2.5 text-sm text-foreground focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:outline-none'
|
|
13
20
|
|
|
14
|
-
export function ForgotPassword({ onNavigate }: ForgotPasswordProps) {
|
|
21
|
+
export function ForgotPassword({ onNavigate, branding }: ForgotPasswordProps) {
|
|
22
|
+
const brand = useAuthBrand(branding)
|
|
15
23
|
const [email, setEmail] = useState('')
|
|
16
24
|
const [submitting, setSubmitting] = useState(false)
|
|
17
25
|
const [sent, setSent] = useState(false)
|
|
@@ -48,9 +56,7 @@ export function ForgotPassword({ onNavigate }: ForgotPasswordProps) {
|
|
|
48
56
|
<div className="bg-muted flex min-h-screen items-center justify-center px-4">
|
|
49
57
|
<div className="w-full max-w-md">
|
|
50
58
|
<div className="mb-8 text-center">
|
|
51
|
-
<
|
|
52
|
-
<Shield className="text-primary-foreground h-7 w-7" />
|
|
53
|
-
</div>
|
|
59
|
+
<AuthBrandHero brand={brand} />
|
|
54
60
|
<h1 className="text-foreground text-2xl font-medium">Reset Password</h1>
|
|
55
61
|
<p className="text-muted-foreground mt-2">
|
|
56
62
|
{sent
|
|
@@ -137,6 +143,7 @@ export function ForgotPassword({ onNavigate }: ForgotPasswordProps) {
|
|
|
137
143
|
</button>
|
|
138
144
|
)}
|
|
139
145
|
</div>
|
|
146
|
+
{brand.showPermanentFooter && <AuthPrentaFooter />}
|
|
140
147
|
</div>
|
|
141
148
|
</div>
|
|
142
149
|
)
|
package/src/views/Login.tsx
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import { useState, useEffect,
|
|
3
|
+
import { useState, useEffect, type FormEvent } from 'react'
|
|
4
4
|
import { Eye, EyeOff, AlertTriangle, CheckCircle2, Loader2 } from 'lucide-react'
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
import {
|
|
6
|
+
AuthBrandHero,
|
|
7
|
+
AuthPrentaFooter,
|
|
8
|
+
useAuthBrand,
|
|
9
|
+
type AuthBrandingConfig,
|
|
10
|
+
} from '../components/AuthBranding.js'
|
|
9
11
|
import { hasLoggedOutQuery } from '../lib/logout-redirect.js'
|
|
10
12
|
|
|
11
13
|
export interface CaptchaConfig {
|
|
@@ -18,11 +20,7 @@ export interface CaptchaConfig {
|
|
|
18
20
|
* sidebar so integrators only need to set it once. `logo` should be a URL or
|
|
19
21
|
* data URL; pass `null` to opt out of any logo entirely.
|
|
20
22
|
*/
|
|
21
|
-
|
|
22
|
-
logo?: string | null
|
|
23
|
-
name?: string
|
|
24
|
-
tagline?: string
|
|
25
|
-
}
|
|
23
|
+
type LoginBrandingConfig = AuthBrandingConfig
|
|
26
24
|
|
|
27
25
|
export interface LoginProps {
|
|
28
26
|
onLogin: (
|
|
@@ -254,45 +252,10 @@ export function Login({
|
|
|
254
252
|
const [totpError, setTotpError] = useState('')
|
|
255
253
|
const [verifying, setVerifying] = useState(false)
|
|
256
254
|
|
|
257
|
-
|
|
258
|
-
// `adminBrand` is the ThemeProvider cache the sidebar paints from (hydrated
|
|
259
|
-
// from localStorage on mount); `publicLogo` is fetched only when that cache
|
|
260
|
-
// is empty (a fresh browser that hasn't loaded the admin yet).
|
|
261
|
-
const { adminBrand } = useTheme()
|
|
262
|
-
const [publicLogo, setPublicLogo] = useState<string | null>(null)
|
|
263
|
-
// Site initials resolved from `/public/brand`. Used only to detect whether
|
|
264
|
-
// the install is "branded" on a fresh browser (no cache, no config name), so
|
|
265
|
-
// the logo-less fallback can pick the placeholder over the Prenta wordmark.
|
|
266
|
-
const [publicInitials, setPublicInitials] = useState<string | null>(null)
|
|
267
|
-
const publicBrandFetched = useRef(false)
|
|
255
|
+
const brand = useAuthBrand(branding)
|
|
268
256
|
|
|
269
257
|
useCaptchaScript(captchaConfig?.provider, captchaConfig?.siteKey)
|
|
270
258
|
|
|
271
|
-
useEffect(() => {
|
|
272
|
-
// The cached admin brand (exactly what the sidebar last rendered) wins and
|
|
273
|
-
// needs no network. Only reach for the unauthenticated `/public/brand`
|
|
274
|
-
// endpoint on a fresh browser with no cache, and never when the integrator
|
|
275
|
-
// opted out of a logo entirely (`branding.logo === null`).
|
|
276
|
-
if (adminBrand.primaryUrl || branding?.logo === null) return
|
|
277
|
-
if (publicBrandFetched.current) return
|
|
278
|
-
publicBrandFetched.current = true
|
|
279
|
-
|
|
280
|
-
let cancelled = false
|
|
281
|
-
void (async () => {
|
|
282
|
-
const res = await cmsApi<{
|
|
283
|
-
public?: { primary?: { url?: string } | null; initials?: string } | null
|
|
284
|
-
}>('/public/brand')
|
|
285
|
-
if (cancelled) return
|
|
286
|
-
const url = res.data?.public?.primary?.url
|
|
287
|
-
if (url) setPublicLogo(url)
|
|
288
|
-
const initials = res.data?.public?.initials
|
|
289
|
-
if (initials) setPublicInitials(initials)
|
|
290
|
-
})()
|
|
291
|
-
return () => {
|
|
292
|
-
cancelled = true
|
|
293
|
-
}
|
|
294
|
-
}, [adminBrand.primaryUrl, branding?.logo])
|
|
295
|
-
|
|
296
259
|
const loggedOut = hasLoggedOutQuery()
|
|
297
260
|
const canSubmit = email.trim() && password && !submitting
|
|
298
261
|
|
|
@@ -374,55 +337,17 @@ export function Login({
|
|
|
374
337
|
const enabledProviders =
|
|
375
338
|
oauthProviders?.filter((p) => ['google', 'github', 'microsoft'].includes(p)) ?? []
|
|
376
339
|
|
|
377
|
-
|
|
378
|
-
// same brand mark a user sees once signed in. Precedence (best available
|
|
379
|
-
// pre-auth):
|
|
380
|
-
// 1. the logo uploaded in Settings → Appearance — read from the
|
|
381
|
-
// ThemeProvider cache the sidebar paints from, then (fresh browsers with
|
|
382
|
-
// no cache) the unauthenticated `/public/brand` endpoint;
|
|
383
|
-
// 2. the static `config.admin.branding.logo` URL;
|
|
384
|
-
// 3. a neutral logo placeholder when the install is branded (a site/brand
|
|
385
|
-
// name is set) but no logo has been uploaded yet — matching the sidebar;
|
|
386
|
-
// 4. the bundled Prenta wordmark for a fully un-branded install.
|
|
387
|
-
// `branding.logo === null` still hides the logo entirely (whitelabel opt-out).
|
|
388
|
-
const configLogo = branding?.logo
|
|
389
|
-
const hideLogo = configLogo === null
|
|
390
|
-
const appearanceLogo = adminBrand.primaryUrl ?? publicLogo
|
|
391
|
-
const effectiveLogo = appearanceLogo ?? (typeof configLogo === 'string' ? configLogo : null)
|
|
392
|
-
const brandName = branding?.name ?? 'Prenta CMS'
|
|
340
|
+
const brandName = brand.brandName
|
|
393
341
|
const brandTagline = branding?.tagline ?? 'Sign in to your account'
|
|
394
|
-
|
|
395
|
-
//
|
|
396
|
-
|
|
397
|
-
// explicit `branding.name` and, for fresh browsers, the initials returned by
|
|
398
|
-
// `/public/brand`. Drives the placeholder vs. Prenta-wordmark fallback so a
|
|
399
|
-
// configured client install never shows Prenta branding. `'A'` is the
|
|
400
|
-
// unset-title default, so it counts as un-branded.
|
|
401
|
-
const hasInitials = (value: string | null | undefined) => Boolean(value) && value !== 'A'
|
|
402
|
-
const isBranded =
|
|
403
|
-
Boolean(branding?.name) || hasInitials(adminBrand.initials) || hasInitials(publicInitials)
|
|
404
|
-
// A logo image or the bundled wordmark already carries the brand — a
|
|
405
|
-
// separate headline would duplicate it. Keep the name only for the
|
|
406
|
-
// branded-but-logo-less placeholder.
|
|
407
|
-
const showBrandName = !effectiveLogo && isBranded
|
|
342
|
+
// Show the configured brand name as a heading when no custom logo image
|
|
343
|
+
// already displays it.
|
|
344
|
+
const showBrandName = !brand.effectiveLogo && Boolean(branding?.name)
|
|
408
345
|
|
|
409
346
|
return (
|
|
410
347
|
<main className="bg-muted flex min-h-screen items-center justify-center px-4">
|
|
411
348
|
<div className="w-full max-w-md">
|
|
412
349
|
<div className="mb-8 text-center">
|
|
413
|
-
{
|
|
414
|
-
(effectiveLogo ? (
|
|
415
|
-
<img
|
|
416
|
-
src={effectiveLogo}
|
|
417
|
-
alt={brandName}
|
|
418
|
-
className="mx-auto mb-4 max-h-16 w-auto object-contain"
|
|
419
|
-
draggable={false}
|
|
420
|
-
/>
|
|
421
|
-
) : isBranded ? (
|
|
422
|
-
<LogoPlaceholder tone="login" />
|
|
423
|
-
) : (
|
|
424
|
-
<PrentaBrandLogo className="mx-auto mb-4 h-14 w-auto" />
|
|
425
|
-
))}
|
|
350
|
+
<AuthBrandHero brand={brand} />
|
|
426
351
|
{!showBrandName && <h1 className="sr-only">Sign in</h1>}
|
|
427
352
|
{showBrandName && <h1 className="text-foreground text-2xl font-medium">{brandName}</h1>}
|
|
428
353
|
<p className="text-muted-foreground mt-2">{brandTagline}</p>
|
|
@@ -642,6 +567,7 @@ export function Login({
|
|
|
642
567
|
)}
|
|
643
568
|
</form>
|
|
644
569
|
)}
|
|
570
|
+
{brand.showPermanentFooter && <AuthPrentaFooter />}
|
|
645
571
|
</div>
|
|
646
572
|
</main>
|
|
647
573
|
)
|
package/src/views/McpConsent.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import { useEffect, useState } from 'react'
|
|
3
|
+
import { useEffect, useRef, useState } from 'react'
|
|
4
4
|
import { Loader2 } from 'lucide-react'
|
|
5
5
|
import { cmsApi } from '../lib/api.js'
|
|
6
6
|
import { parseRouteQuery } from '../router/index.js'
|
|
@@ -10,13 +10,17 @@ type ConsentDetails = {
|
|
|
10
10
|
clientId: string
|
|
11
11
|
redirectHost: string
|
|
12
12
|
scope: string
|
|
13
|
+
autoApprove?: boolean
|
|
14
|
+
autoApproveReason?: 'trusted_client' | 'existing_grant' | null
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
export function McpConsent({ currentPath }: { currentPath: string }) {
|
|
16
18
|
const txn = parseRouteQuery(currentPath).get('txn') ?? ''
|
|
17
19
|
const [details, setDetails] = useState<ConsentDetails | null>(null)
|
|
20
|
+
const [autoApproving, setAutoApproving] = useState(false)
|
|
18
21
|
const [error, setError] = useState('')
|
|
19
22
|
const [busy, setBusy] = useState(false)
|
|
23
|
+
const autoSubmittedTxnRef = useRef<string | null>(null)
|
|
20
24
|
|
|
21
25
|
useEffect(() => {
|
|
22
26
|
if (!txn) {
|
|
@@ -24,14 +28,31 @@ export function McpConsent({ currentPath }: { currentPath: string }) {
|
|
|
24
28
|
return
|
|
25
29
|
}
|
|
26
30
|
let cancelled = false
|
|
27
|
-
cmsApi<ConsentDetails>(`/mcp/oauth/transactions/${encodeURIComponent(txn)}`).then(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
cmsApi<ConsentDetails>(`/mcp/oauth/transactions/${encodeURIComponent(txn)}`).then(
|
|
32
|
+
async (res) => {
|
|
33
|
+
if (cancelled) return
|
|
34
|
+
if (res.error || !res.data) {
|
|
35
|
+
setError(res.error ?? 'This connection request expired.')
|
|
36
|
+
return
|
|
37
|
+
}
|
|
38
|
+
setDetails(res.data)
|
|
39
|
+
if (res.data.autoApprove && autoSubmittedTxnRef.current !== txn) {
|
|
40
|
+
autoSubmittedTxnRef.current = txn
|
|
41
|
+
setAutoApproving(true)
|
|
42
|
+
const consentRes = await cmsApi<{ redirectUrl: string }>('/mcp/oauth/consent', {
|
|
43
|
+
method: 'POST',
|
|
44
|
+
body: JSON.stringify({ txn, allow: true, auto: true }),
|
|
45
|
+
})
|
|
46
|
+
if (cancelled) return
|
|
47
|
+
if (consentRes.error || !consentRes.data?.redirectUrl) {
|
|
48
|
+
setAutoApproving(false)
|
|
49
|
+
setError(consentRes.error ?? 'Could not auto-approve connection.')
|
|
50
|
+
return
|
|
51
|
+
}
|
|
52
|
+
window.location.assign(consentRes.data.redirectUrl)
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
)
|
|
35
56
|
return () => {
|
|
36
57
|
cancelled = true
|
|
37
58
|
}
|
|
@@ -62,8 +83,14 @@ export function McpConsent({ currentPath }: { currentPath: string }) {
|
|
|
62
83
|
Loading the request
|
|
63
84
|
</p>
|
|
64
85
|
)}
|
|
86
|
+
{details && autoApproving && (
|
|
87
|
+
<p className="text-muted-foreground mt-4 flex items-center gap-2 text-sm">
|
|
88
|
+
<Loader2 className="animate-spin" size={16} aria-hidden="true" />
|
|
89
|
+
Connecting <span className="text-foreground font-medium">{details.clientName}</span>…
|
|
90
|
+
</p>
|
|
91
|
+
)}
|
|
65
92
|
{error && <p className="text-destructive mt-4 text-sm">{error}</p>}
|
|
66
|
-
{details && (
|
|
93
|
+
{details && !autoApproving && (
|
|
67
94
|
<div className="mt-4 space-y-4">
|
|
68
95
|
<p className="text-foreground text-base">
|
|
69
96
|
<span className="font-medium">{details.clientName}</span> wants to edit content on
|
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
3
|
import { useState, type FormEvent } from 'react'
|
|
4
|
-
import {
|
|
4
|
+
import { Eye, EyeOff, Loader2, CheckCircle2, AlertTriangle, XCircle } from 'lucide-react'
|
|
5
|
+
import {
|
|
6
|
+
AuthBrandHero,
|
|
7
|
+
AuthPrentaFooter,
|
|
8
|
+
useAuthBrand,
|
|
9
|
+
type AuthBrandingConfig,
|
|
10
|
+
} from '../components/AuthBranding.js'
|
|
5
11
|
import { cmsApi } from '../lib/api.js'
|
|
6
12
|
|
|
7
13
|
export interface ResetPasswordProps {
|
|
8
14
|
onNavigate: (path: string) => void
|
|
9
15
|
token: string | null
|
|
16
|
+
branding?: AuthBrandingConfig
|
|
10
17
|
}
|
|
11
18
|
|
|
12
19
|
const fieldClass =
|
|
13
20
|
'w-full rounded-lg border border-border bg-input-background px-3 py-2.5 text-sm text-foreground focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:outline-none'
|
|
14
21
|
|
|
15
|
-
export function ResetPassword({ onNavigate, token }: ResetPasswordProps) {
|
|
22
|
+
export function ResetPassword({ onNavigate, token, branding }: ResetPasswordProps) {
|
|
23
|
+
const brand = useAuthBrand(branding)
|
|
16
24
|
const [password, setPassword] = useState('')
|
|
17
25
|
const [confirmPassword, setConfirmPassword] = useState('')
|
|
18
26
|
const [showPassword, setShowPassword] = useState(false)
|
|
@@ -87,9 +95,7 @@ export function ResetPassword({ onNavigate, token }: ResetPasswordProps) {
|
|
|
87
95
|
<div className="bg-muted flex min-h-screen items-center justify-center px-4">
|
|
88
96
|
<div className="w-full max-w-md">
|
|
89
97
|
<div className="mb-8 text-center">
|
|
90
|
-
<
|
|
91
|
-
<Shield className="text-primary-foreground h-7 w-7" />
|
|
92
|
-
</div>
|
|
98
|
+
<AuthBrandHero brand={brand} />
|
|
93
99
|
<h1 className="text-foreground text-2xl font-medium">
|
|
94
100
|
{success ? 'Password Reset' : 'Choose New Password'}
|
|
95
101
|
</h1>
|
|
@@ -200,6 +206,7 @@ export function ResetPassword({ onNavigate, token }: ResetPasswordProps) {
|
|
|
200
206
|
</form>
|
|
201
207
|
)}
|
|
202
208
|
</div>
|
|
209
|
+
{brand.showPermanentFooter && <AuthPrentaFooter />}
|
|
203
210
|
</div>
|
|
204
211
|
</div>
|
|
205
212
|
)
|
package/src/views/Settings.tsx
CHANGED
|
@@ -280,7 +280,7 @@ export function Settings({
|
|
|
280
280
|
className: 'space-y-4',
|
|
281
281
|
},
|
|
282
282
|
users: { body: <UsersView onNavigate={onNavigate} embedded currentPath={currentPath} /> },
|
|
283
|
-
mcp: { body: <McpConnectTab onNavigate={onNavigate} /> },
|
|
283
|
+
mcp: { body: <McpConnectTab onNavigate={onNavigate} role={session?.user?.role} /> },
|
|
284
284
|
'api-keys': { body: <ApiKeysView onNavigate={onNavigate} embedded /> },
|
|
285
285
|
updates: { body: <UpdatesTab role={session?.user?.role} />, className: 'space-y-4' },
|
|
286
286
|
}
|