@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.
Files changed (94) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/AdminRoot.d.ts.map +1 -1
  3. package/dist/AdminRoot.js +11 -6
  4. package/dist/AdminRoot.js.map +1 -1
  5. package/dist/LoginRoot.js +3 -3
  6. package/dist/LoginRoot.js.map +1 -1
  7. package/dist/__tests__/assets/prenta-logo.test.js +26 -10
  8. package/dist/__tests__/assets/prenta-logo.test.js.map +1 -1
  9. package/dist/__tests__/layout/sidebar-brand.render.test.js +25 -22
  10. package/dist/__tests__/layout/sidebar-brand.render.test.js.map +1 -1
  11. package/dist/__tests__/views/appearance-settings.render.test.js +9 -0
  12. package/dist/__tests__/views/appearance-settings.render.test.js.map +1 -1
  13. package/dist/__tests__/views/login-branding.render.test.js +15 -30
  14. package/dist/__tests__/views/login-branding.render.test.js.map +1 -1
  15. package/dist/__tests__/views/mcp-connect.render.test.js +54 -4
  16. package/dist/__tests__/views/mcp-connect.render.test.js.map +1 -1
  17. package/dist/__tests__/views/mcp-consent.render.test.d.ts +2 -0
  18. package/dist/__tests__/views/mcp-consent.render.test.d.ts.map +1 -0
  19. package/dist/__tests__/views/mcp-consent.render.test.js +112 -0
  20. package/dist/__tests__/views/mcp-consent.render.test.js.map +1 -0
  21. package/dist/assets/prenta-logo.d.ts +18 -21
  22. package/dist/assets/prenta-logo.d.ts.map +1 -1
  23. package/dist/assets/prenta-logo.js +24 -12
  24. package/dist/assets/prenta-logo.js.map +1 -1
  25. package/dist/components/AuthBranding.d.ts +40 -0
  26. package/dist/components/AuthBranding.d.ts.map +1 -0
  27. package/dist/components/AuthBranding.js +81 -0
  28. package/dist/components/AuthBranding.js.map +1 -0
  29. package/dist/index.d.ts +2 -0
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +1 -0
  32. package/dist/index.js.map +1 -1
  33. package/dist/layout/Sidebar.d.ts.map +1 -1
  34. package/dist/layout/Sidebar.js +15 -23
  35. package/dist/layout/Sidebar.js.map +1 -1
  36. package/dist/prenta-admin.css +1 -1
  37. package/dist/views/ForgotPassword.d.ts +3 -1
  38. package/dist/views/ForgotPassword.d.ts.map +1 -1
  39. package/dist/views/ForgotPassword.js +6 -4
  40. package/dist/views/ForgotPassword.js.map +1 -1
  41. package/dist/views/Login.d.ts +2 -5
  42. package/dist/views/Login.d.ts.map +1 -1
  43. package/dist/views/Login.js +9 -74
  44. package/dist/views/Login.js.map +1 -1
  45. package/dist/views/McpConsent.d.ts.map +1 -1
  46. package/dist/views/McpConsent.js +21 -3
  47. package/dist/views/McpConsent.js.map +1 -1
  48. package/dist/views/ResetPassword.d.ts +3 -1
  49. package/dist/views/ResetPassword.d.ts.map +1 -1
  50. package/dist/views/ResetPassword.js +5 -3
  51. package/dist/views/ResetPassword.js.map +1 -1
  52. package/dist/views/Settings.js +1 -1
  53. package/dist/views/Settings.js.map +1 -1
  54. package/dist/views/SetupWizard.d.ts +3 -1
  55. package/dist/views/SetupWizard.d.ts.map +1 -1
  56. package/dist/views/SetupWizard.js +5 -3
  57. package/dist/views/SetupWizard.js.map +1 -1
  58. package/dist/views/settings/BrandPreviewCard.d.ts.map +1 -1
  59. package/dist/views/settings/BrandPreviewCard.js +5 -6
  60. package/dist/views/settings/BrandPreviewCard.js.map +1 -1
  61. package/dist/views/settings/BrandingCard.d.ts.map +1 -1
  62. package/dist/views/settings/BrandingCard.js +4 -3
  63. package/dist/views/settings/BrandingCard.js.map +1 -1
  64. package/dist/views/settings/McpConnectTab.d.ts +2 -1
  65. package/dist/views/settings/McpConnectTab.d.ts.map +1 -1
  66. package/dist/views/settings/McpConnectTab.js +95 -4
  67. package/dist/views/settings/McpConnectTab.js.map +1 -1
  68. package/package.json +4 -4
  69. package/src/AdminRoot.tsx +15 -5
  70. package/src/LoginRoot.tsx +9 -2
  71. package/src/__tests__/assets/prenta-logo.test.tsx +27 -10
  72. package/src/__tests__/layout/sidebar-brand.render.test.tsx +29 -25
  73. package/src/__tests__/views/appearance-settings.render.test.tsx +11 -0
  74. package/src/__tests__/views/login-branding.render.test.tsx +15 -30
  75. package/src/__tests__/views/mcp-connect.render.test.tsx +79 -5
  76. package/src/__tests__/views/mcp-consent.render.test.tsx +124 -0
  77. package/src/assets/prenta-logo.tsx +55 -53
  78. package/src/components/AuthBranding.tsx +125 -0
  79. package/src/index.ts +2 -0
  80. package/src/layout/Sidebar.tsx +51 -49
  81. package/src/views/ForgotPassword.tsx +12 -5
  82. package/src/views/Login.tsx +15 -89
  83. package/src/views/McpConsent.tsx +37 -10
  84. package/src/views/ResetPassword.tsx +12 -5
  85. package/src/views/Settings.tsx +1 -1
  86. package/src/views/SetupWizard.tsx +12 -5
  87. package/src/views/settings/BrandPreviewCard.tsx +20 -27
  88. package/src/views/settings/BrandingCard.tsx +18 -1
  89. package/src/views/settings/McpConnectTab.tsx +232 -16
  90. package/dist/components/LogoPlaceholder.d.ts +0 -17
  91. package/dist/components/LogoPlaceholder.d.ts.map +0 -1
  92. package/dist/components/LogoPlaceholder.js +0 -13
  93. package/dist/components/LogoPlaceholder.js.map +0 -1
  94. package/src/components/LogoPlaceholder.tsx +0 -55
@@ -4,23 +4,40 @@ import { render } from '@testing-library/react'
4
4
  import { PRENTA_ACCENT, PrentaBrandLogo, PrentaMark } from '../../assets/prenta-logo.js'
5
5
 
6
6
  describe('bundled Prenta lockup', () => {
7
- it('renders the wordmark as Prenta with the accent ellipsis dot', () => {
7
+ it('renders the bespoke Prënta wordmark vector path with three vermilion dots', () => {
8
8
  const { container } = render(<PrentaBrandLogo />)
9
- expect(container.querySelector('svg')?.getAttribute('aria-label')).toBe('Prenta')
10
- expect(container.textContent).toContain('Prenta')
9
+ const svg = container.querySelector('svg')
10
+ expect(svg?.getAttribute('aria-label')).toBe('Prenta')
11
+ expect(svg?.getAttribute('viewBox')).toBe('0 0 620 162')
12
+ expect(container.querySelector('text')).toBeNull()
13
+ const path = container.querySelector('path')
14
+ expect(path?.getAttribute('fill')).toBe('currentColor')
15
+ expect(path?.getAttribute('d')?.startsWith('M')).toBe(true)
11
16
  const dots = container.querySelectorAll('circle')
12
17
  expect(dots).toHaveLength(3)
13
- expect(dots[2]?.getAttribute('fill')).toBe(PRENTA_ACCENT)
14
- expect(container.innerHTML).not.toContain('#F05E65')
18
+ expect(PRENTA_ACCENT).toBe('#E83D28')
19
+ for (const dot of dots) {
20
+ expect(dot.getAttribute('fill')).toBe('#E83D28')
21
+ }
15
22
  })
16
23
 
17
- it('renders the compact P… mark without the retired Actuate A', () => {
24
+ it('renders the compact Prë mark vector path with three vermilion dots', () => {
18
25
  const { container } = render(<PrentaMark />)
19
- expect(container.querySelector('svg')?.getAttribute('aria-label')).toBe('Prenta')
20
- expect(container.querySelector('polygon')).toBeNull()
21
- expect(container.innerHTML).not.toContain('#F05E65')
26
+ const svg = container.querySelector('svg')
27
+ expect(svg?.getAttribute('aria-label')).toBe('Prenta')
28
+ expect(svg?.getAttribute('viewBox')).toBe('0 0 306 162')
29
+ expect(container.querySelector('path')?.getAttribute('fill')).toBe('currentColor')
22
30
  const dots = container.querySelectorAll('circle')
23
31
  expect(dots).toHaveLength(3)
24
- expect(dots[2]?.getAttribute('fill')).toBe(PRENTA_ACCENT)
32
+ for (const dot of dots) {
33
+ expect(dot.getAttribute('fill')).toBe('#E83D28')
34
+ }
35
+ })
36
+
37
+ it('supports decorative rendering inside labeled attribution wrappers', () => {
38
+ const { container } = render(<PrentaBrandLogo decorative />)
39
+ const svg = container.querySelector('svg')
40
+ expect(svg?.getAttribute('aria-hidden')).toBe('true')
41
+ expect(svg?.getAttribute('role')).toBeNull()
25
42
  })
26
43
  })
@@ -8,9 +8,6 @@ vi.mock('../../lib/forms-service.js', () => ({
8
8
  fetchFormsSidebarCounts: vi.fn(async () => []),
9
9
  }))
10
10
 
11
- // Drive the brand lockup directly via a mutable theme state. happy-dom's
12
- // localStorage stub is unreliable here, so we mock the theme hook rather than
13
- // hydrating it. Tests mutate `themeState` before rendering.
14
11
  interface ThemeState {
15
12
  adminBrand: {
16
13
  primaryUrl: string | null
@@ -58,13 +55,7 @@ afterEach(() => {
58
55
  themeState = { ...DEFAULT_THEME }
59
56
  })
60
57
 
61
- /**
62
- * Brand lockup fallback behaviour. When an install is branded (a site name is
63
- * set, so initials exist) but no logo has been uploaded, the sidebar must show
64
- * the neutral logo placeholder — NOT a filled initials badge, which reads as a
65
- * user avatar (the real account avatar already lives top-right).
66
- */
67
- describe('Sidebar bundled Prenta fallback', () => {
58
+ describe('Sidebar bundled Prenta placeholder logo', () => {
68
59
  it('shows the Prenta wordmark when the install is unbranded — expanded', () => {
69
60
  setTheme({ initials: 'A' })
70
61
  renderSidebar(false)
@@ -77,26 +68,44 @@ describe('Sidebar bundled Prenta fallback', () => {
77
68
  renderSidebar(true)
78
69
  expect(screen.getByRole('img', { name: 'Prenta' })).toBeTruthy()
79
70
  })
80
- })
81
71
 
82
- describe('Sidebar brand placeholder', () => {
83
- it('renders the logo placeholder (not an initials avatar) when branded with no logo — expanded', () => {
72
+ it('uses the Prenta wordmark as the default placeholder even when a Site Title is set — expanded', () => {
84
73
  renderSidebar(false, { admin: { branding: { name: 'Acme Co' } } })
85
74
 
86
- // Placeholder slot is present and the brand name shows beside it.
87
- expect(screen.getByText('Acme Co')).toBeTruthy()
88
- // The old avatar-style initials badge must not render.
75
+ expect(screen.getByRole('img', { name: 'Prenta' })).toBeTruthy()
89
76
  expect(screen.queryByText('AC')).toBeNull()
90
77
  })
91
78
 
92
- it('renders the logo placeholder slot when branded with no logo — collapsed', () => {
79
+ it('uses the Prenta mark as the default placeholder even when initials exist — collapsed', () => {
93
80
  renderSidebar(true)
94
81
 
95
- expect(screen.getByRole('img', { name: 'Logo placeholder' })).toBeTruthy()
82
+ expect(screen.getByRole('img', { name: 'Prenta' })).toBeTruthy()
96
83
  expect(screen.queryByText('AC')).toBeNull()
97
84
  })
98
85
  })
99
86
 
87
+ describe('Sidebar permanent CMS brand footer', () => {
88
+ it('keeps a permanent "Powered by Prenta CMS" attribution in the expanded sidebar even after uploading a tenant logo', () => {
89
+ setTheme({ primaryUrl: 'https://cdn.example.com/acme-logo.svg' })
90
+ renderSidebar(false, { admin: { branding: { name: 'Acme Co' } } })
91
+
92
+ // Top-left header renders the tenant's uploaded logo.
93
+ const tenantImg = screen.getByRole('img', { name: 'Acme Co' }) as HTMLImageElement
94
+ expect(tenantImg.src).toContain('acme-logo.svg')
95
+ // Footer still carries the permanent Prenta CMS attribution.
96
+ expect(screen.getByLabelText('Powered by Prenta CMS')).toBeTruthy()
97
+ expect(screen.getByText('Powered by')).toBeTruthy()
98
+ })
99
+
100
+ it('renders the compact permanent Prenta mark in the collapsed rail footer when a tenant logo is uploaded', () => {
101
+ setTheme({ primaryUrl: 'https://cdn.example.com/acme-logo.svg' })
102
+ renderSidebar(true, { admin: { branding: { name: 'Acme Co' } } })
103
+
104
+ expect(screen.getByRole('img', { name: 'Acme Co' })).toBeTruthy()
105
+ expect(screen.getByRole('img', { name: 'Powered by Prenta CMS' })).toBeTruthy()
106
+ })
107
+ })
108
+
100
109
  describe('Sidebar brand logo rendering', () => {
101
110
  it('shows the primary logo (scaled to fit) when collapsed — never the favicon', () => {
102
111
  setTheme({ primaryUrl: 'https://cdn.example.com/logo.svg' })
@@ -104,7 +113,6 @@ describe('Sidebar brand logo rendering', () => {
104
113
 
105
114
  const img = screen.getByRole('img', { name: 'Admin' }) as HTMLImageElement
106
115
  expect(img.src).toContain('logo.svg')
107
- // Wide logos must be width-capped so they scale down instead of overflowing.
108
116
  expect(img.className).toContain('max-w-full')
109
117
  })
110
118
 
@@ -139,19 +147,15 @@ describe('Sidebar brand logo rendering', () => {
139
147
  expect(img.src).toContain('dark.svg')
140
148
  })
141
149
 
142
- it('falls through to the placeholder when the logo URL is broken (onError)', () => {
150
+ it('falls through to the Prenta placeholder logo when the uploaded logo URL is broken (onError)', () => {
143
151
  setTheme({ primaryUrl: 'https://cdn.example.com/broken.svg' })
144
152
  renderSidebar(false, { admin: { branding: { name: 'Acme Co' } } })
145
153
 
146
- // With a brand name configured, the logo alt is the brand name.
147
154
  const img = screen.getByRole('img', { name: 'Acme Co' }) as HTMLImageElement
148
155
  expect(img.src).toContain('broken.svg')
149
- // Simulate the asset URL failing to load.
150
156
  fireEvent.error(img)
151
157
 
152
- // The broken logo is gone; the neutral placeholder + brand name take over
153
- // (no browser broken-image glyph left behind).
154
158
  expect(screen.queryByRole('img', { name: 'Acme Co' })).toBeNull()
155
- expect(screen.getByText('Acme Co')).toBeTruthy()
159
+ expect(screen.getByRole('img', { name: 'Prenta' })).toBeTruthy()
156
160
  })
157
161
  })
@@ -251,4 +251,15 @@ describe('AppearanceTab', () => {
251
251
  (screen.getByRole('button', { name: /upload primary logo/i }) as HTMLButtonElement).disabled,
252
252
  ).toBe(true)
253
253
  })
254
+
255
+ it('shows Prenta placeholder lockups and default favicon in Brand preview before custom assets are uploaded', async () => {
256
+ render(<AppearanceTab role="ADMIN" />)
257
+ await screen.findByText('Brand preview')
258
+
259
+ // Default favicon tile renders an image (not "None").
260
+ expect(screen.queryByText('None')).toBeNull()
261
+ expect(screen.getByAltText('Favicon preview')).toBeTruthy()
262
+ // Default Prenta lockups appear in the unconfigured preview tiles.
263
+ expect(screen.getAllByRole('img', { name: 'Prenta' }).length).toBeGreaterThanOrEqual(4)
264
+ })
254
265
  })
@@ -2,16 +2,6 @@
2
2
  import { describe, expect, it, vi, beforeEach } from 'vitest'
3
3
  import { render, screen, waitFor } from '@testing-library/react'
4
4
 
5
- /**
6
- * The login screen resolves its logo to match the admin sidebar:
7
- * 1. the brand uploaded in Settings → Appearance (cached admin brand, then
8
- * the unauthenticated `/public/brand` endpoint for fresh browsers),
9
- * 2. the static `config.admin.branding.logo`,
10
- * 3. the bundled Prenta wordmark,
11
- * and `branding.logo === null` hides the logo entirely (whitelabel opt-out).
12
- *
13
- * `cmsApi` is mocked because the component fetches `/public/brand` on mount.
14
- */
15
5
  const cmsApiMock = vi.fn()
16
6
  vi.mock('../../lib/api.js', () => ({
17
7
  cmsApi: (...args: unknown[]) => cmsApiMock(...args),
@@ -23,34 +13,27 @@ const onLogin = vi.fn(async () => ({ success: true }))
23
13
 
24
14
  beforeEach(() => {
25
15
  cmsApiMock.mockReset()
26
- // Default: no public brand configured.
27
16
  cmsApiMock.mockResolvedValue({ data: {}, status: 200 })
28
17
  })
29
18
 
30
- describe('Login — logo resolution', () => {
31
- it('renders the bundled Prenta logo when nothing is branded', async () => {
19
+ describe('Login — logo resolution & permanent attribution', () => {
20
+ it('renders the bundled Prenta logo when nothing is branded without duplicating attribution below', async () => {
32
21
  render(<Login onLogin={onLogin} />)
33
- // Bundled SVG exposes role="img" + aria-label="Prenta".
34
22
  expect(screen.getByRole('img', { name: 'Prenta' })).toBeTruthy()
35
- // No <img> logo element, and the wordmark already says Prenta — no extra headline.
36
23
  expect(screen.queryByRole('img', { name: 'Prenta CMS' })).toBeNull()
37
24
  expect(screen.queryByRole('heading', { name: 'Prenta CMS' })).toBeNull()
25
+ expect(screen.queryByLabelText('Powered by Prenta CMS')).toBeNull()
38
26
  await waitFor(() => expect(cmsApiMock).toHaveBeenCalledWith('/public/brand'))
39
27
  })
40
28
 
41
- it('shows the neutral logo placeholder when branded but no logo is set', async () => {
29
+ it('keeps the Prenta placeholder logo when a brand name is set but no logo image is uploaded yet', async () => {
42
30
  render(<Login onLogin={onLogin} branding={{ name: 'Acme Co' }} />)
43
- // Placeholder slot, not the bundled Prenta wordmark.
44
- expect(screen.getByRole('img', { name: 'Logo placeholder' })).toBeTruthy()
45
- expect(screen.queryByRole('img', { name: 'Prenta' })).toBeNull()
46
- // The brand name still renders as the headline.
31
+ expect(screen.getByRole('img', { name: 'Prenta' })).toBeTruthy()
47
32
  expect(screen.getByRole('heading', { name: 'Acme Co' })).toBeTruthy()
33
+ expect(screen.queryByLabelText('Powered by Prenta CMS')).toBeNull()
48
34
  })
49
35
 
50
- it('shows the placeholder for a fresh browser when /public/brand reports a branded site (initials) but no logo', async () => {
51
- // No config name, no cached admin brand — only the public brand initials
52
- // signal a branded install. The logo-less fallback must be the placeholder,
53
- // not the Prenta wordmark.
36
+ it('keeps the Prenta placeholder logo when /public/brand reports site initials with no uploaded logo', async () => {
54
37
  cmsApiMock.mockResolvedValue({
55
38
  data: { public: { primary: null, initials: 'AC' } },
56
39
  status: 200,
@@ -59,22 +42,22 @@ describe('Login — logo resolution', () => {
59
42
  render(<Login onLogin={onLogin} />)
60
43
 
61
44
  await waitFor(() => {
62
- expect(screen.getByRole('img', { name: 'Logo placeholder' })).toBeTruthy()
45
+ expect(cmsApiMock).toHaveBeenCalledWith('/public/brand')
63
46
  })
64
- expect(screen.queryByRole('img', { name: 'Prenta' })).toBeNull()
47
+ expect(screen.getByRole('img', { name: 'Prenta' })).toBeTruthy()
65
48
  })
66
49
 
67
- it('uses the static config logo when no appearance brand exists', async () => {
50
+ it('replaces the hero with the static config logo and renders "Powered by Prenta CMS" below the card', async () => {
68
51
  render(
69
52
  <Login onLogin={onLogin} branding={{ logo: 'https://cdn.example.com/config-logo.png' }} />,
70
53
  )
71
54
  const img = (await screen.findByAltText('Prenta CMS')) as HTMLImageElement
72
55
  expect(img.getAttribute('src')).toBe('https://cdn.example.com/config-logo.png')
73
- // Logo carries the brand — no duplicate headline.
74
56
  expect(screen.queryByRole('heading', { name: 'Prenta CMS', level: 1 })).toBeNull()
57
+ expect(screen.getByLabelText('Powered by Prenta CMS')).toBeTruthy()
75
58
  })
76
59
 
77
- it('prefers the uploaded appearance logo from /public/brand over the config logo', async () => {
60
+ it('prefers the uploaded appearance logo from /public/brand over the config logo and keeps footer attribution', async () => {
78
61
  cmsApiMock.mockResolvedValue({
79
62
  data: { public: { primary: { url: 'https://cdn.example.com/appearance-logo.svg' } } },
80
63
  status: 200,
@@ -88,12 +71,14 @@ describe('Login — logo resolution', () => {
88
71
  const img = screen.getByAltText('Prenta CMS') as HTMLImageElement
89
72
  expect(img.getAttribute('src')).toBe('https://cdn.example.com/appearance-logo.svg')
90
73
  })
74
+ expect(screen.getByLabelText('Powered by Prenta CMS')).toBeTruthy()
91
75
  })
92
76
 
93
- it('hides the logo entirely when branding.logo is null (whitelabel) and skips the fetch', async () => {
77
+ it('hides the hero logo when branding.logo is null (whitelabel) while keeping subtle footer attribution', async () => {
94
78
  render(<Login onLogin={onLogin} branding={{ logo: null }} />)
95
79
  expect(screen.queryByRole('img', { name: 'Prenta' })).toBeNull()
96
80
  expect(screen.queryByAltText('Prenta CMS')).toBeNull()
81
+ expect(screen.getByLabelText('Powered by Prenta CMS')).toBeTruthy()
97
82
  expect(cmsApiMock).not.toHaveBeenCalled()
98
83
  })
99
84
  })
@@ -1,12 +1,45 @@
1
1
  // @vitest-environment happy-dom
2
2
  import { beforeEach, describe, expect, it, vi } from 'vitest'
3
- import { fireEvent, render, screen } from '@testing-library/react'
3
+ import { fireEvent, render, screen, waitFor } from '@testing-library/react'
4
4
 
5
- const cmsApi = vi.fn(async (endpoint: string, options?: { method?: string }) => {
5
+ let mcpSettingsState: {
6
+ autoApproveReconnect: boolean
7
+ autoApproveReconnectFromConfig: boolean
8
+ trustedClients: Array<{ value: string; source: 'config' | 'settings' }>
9
+ } = {
10
+ autoApproveReconnect: true,
11
+ autoApproveReconnectFromConfig: false,
12
+ trustedClients: [{ value: 'https://config.example', source: 'config' }],
13
+ }
14
+
15
+ const cmsApi = vi.fn(async (endpoint: string, options?: { method?: string; body?: string }) => {
6
16
  if (endpoint === '/mcp/oauth/setup') {
7
17
  return { data: { mcpUrl: 'https://example.com/mcp' }, status: 200 }
8
18
  }
9
- if (endpoint === '/mcp/oauth/grants' && options?.method === 'DELETE') {
19
+ if (endpoint === '/mcp/oauth/settings' && (!options?.method || options.method === 'GET')) {
20
+ return { data: mcpSettingsState, status: 200 }
21
+ }
22
+ if (endpoint === '/mcp/oauth/settings' && options?.method === 'PUT') {
23
+ const parsed = JSON.parse(options.body ?? '{}') as {
24
+ autoApproveReconnect?: boolean
25
+ trustedClients?: string[]
26
+ }
27
+ mcpSettingsState = {
28
+ ...mcpSettingsState,
29
+ ...(typeof parsed.autoApproveReconnect === 'boolean'
30
+ ? { autoApproveReconnect: parsed.autoApproveReconnect }
31
+ : {}),
32
+ trustedClients: [
33
+ { value: 'https://config.example', source: 'config' },
34
+ ...(parsed.trustedClients ?? []).map((value) => ({
35
+ value,
36
+ source: 'settings' as const,
37
+ })),
38
+ ],
39
+ }
40
+ return { data: mcpSettingsState, status: 200 }
41
+ }
42
+ if (endpoint.startsWith('/mcp/oauth/grants/') && options?.method === 'DELETE') {
10
43
  return { data: { note: 'Disconnected' }, status: 200 }
11
44
  }
12
45
  if (endpoint === '/mcp/oauth/grants') {
@@ -32,12 +65,17 @@ const { McpConnectTab } = await import('../../views/settings/McpConnectTab.js')
32
65
 
33
66
  beforeEach(() => {
34
67
  cmsApi.mockClear()
68
+ mcpSettingsState = {
69
+ autoApproveReconnect: true,
70
+ autoApproveReconnectFromConfig: false,
71
+ trustedClients: [{ value: 'https://config.example', source: 'config' }],
72
+ }
35
73
  })
36
74
 
37
75
  describe('McpConnectTab', () => {
38
76
  it('shows a Claude Code prompt and switches to the Cursor config', async () => {
39
77
  const onNavigate = vi.fn()
40
- render(<McpConnectTab onNavigate={onNavigate} />)
78
+ render(<McpConnectTab onNavigate={onNavigate} role="ADMIN" />)
41
79
 
42
80
  expect(
43
81
  await screen.findByRole('heading', { name: 'Connect this site to Claude Code' }),
@@ -57,9 +95,45 @@ describe('McpConnectTab', () => {
57
95
  })
58
96
 
59
97
  it('lists a connected app and revokes it', async () => {
60
- render(<McpConnectTab />)
98
+ render(<McpConnectTab role="ADMIN" />)
61
99
  expect(await screen.findByText('https://claude.ai/oauth/client')).toBeTruthy()
62
100
  fireEvent.click(screen.getByRole('button', { name: 'Revoke' }))
63
101
  expect(cmsApi).toHaveBeenCalledWith('/mcp/oauth/grants/grant-1', { method: 'DELETE' })
64
102
  })
103
+
104
+ it('allows admins to toggle Auto-approve reconnects and add/trust clients', async () => {
105
+ render(<McpConnectTab role="ADMIN" />)
106
+
107
+ expect(await screen.findByText('https://config.example')).toBeTruthy()
108
+ const toggle = screen.getByRole('switch', { name: /auto-approve reconnects/i })
109
+ expect(toggle.getAttribute('aria-checked')).toBe('true')
110
+
111
+ fireEvent.click(toggle)
112
+ await waitFor(() =>
113
+ expect(cmsApi).toHaveBeenCalledWith(
114
+ '/mcp/oauth/settings',
115
+ expect.objectContaining({
116
+ method: 'PUT',
117
+ body: JSON.stringify({ autoApproveReconnect: false, trustedClients: [] }),
118
+ }),
119
+ ),
120
+ )
121
+
122
+ // One-click "Trust" button on a connected app adds its clientId to trustedClients.
123
+ fireEvent.click(
124
+ screen.getByRole('button', { name: /trust https:\/\/claude\.ai\/oauth\/client/i }),
125
+ )
126
+ await waitFor(() =>
127
+ expect(cmsApi).toHaveBeenCalledWith(
128
+ '/mcp/oauth/settings',
129
+ expect.objectContaining({
130
+ method: 'PUT',
131
+ body: JSON.stringify({
132
+ autoApproveReconnect: false,
133
+ trustedClients: ['https://claude.ai/oauth/client'],
134
+ }),
135
+ }),
136
+ ),
137
+ )
138
+ })
65
139
  })
@@ -0,0 +1,124 @@
1
+ // @vitest-environment happy-dom
2
+ import { beforeEach, describe, expect, it, vi } from 'vitest'
3
+ import { fireEvent, render, screen, waitFor } from '@testing-library/react'
4
+
5
+ const cmsApiMock = vi.fn()
6
+ vi.mock('../../lib/api.js', () => ({
7
+ cmsApi: (...args: unknown[]) => cmsApiMock(...args),
8
+ }))
9
+
10
+ import { McpConsent } from '../../views/McpConsent.js'
11
+
12
+ const assignMock = vi.fn()
13
+
14
+ beforeEach(() => {
15
+ cmsApiMock.mockReset()
16
+ assignMock.mockReset()
17
+ Object.defineProperty(window, 'location', {
18
+ value: { ...window.location, assign: assignMock },
19
+ writable: true,
20
+ configurable: true,
21
+ })
22
+ })
23
+
24
+ describe('McpConsent', () => {
25
+ it('auto-submits consent and redirects without a click when autoApprove is true', async () => {
26
+ cmsApiMock.mockImplementation(async (endpoint: string, options?: { method?: string }) => {
27
+ if (endpoint === '/mcp/oauth/transactions/txn-auto' && !options?.method) {
28
+ return {
29
+ data: {
30
+ clientName: 'Claude',
31
+ clientId: 'https://claude.ai/oauth/client.json',
32
+ redirectHost: 'claude.ai',
33
+ scope: 'content',
34
+ autoApprove: true,
35
+ autoApproveReason: 'trusted_client',
36
+ },
37
+ status: 200,
38
+ }
39
+ }
40
+ if (endpoint === '/mcp/oauth/consent' && options?.method === 'POST') {
41
+ return {
42
+ data: { redirectUrl: 'https://claude.ai/api/mcp/auth_callback?code=abc' },
43
+ status: 200,
44
+ }
45
+ }
46
+ return { data: {}, status: 200 }
47
+ })
48
+
49
+ render(<McpConsent currentPath="/mcp/consent?txn=txn-auto" />)
50
+
51
+ await waitFor(() => {
52
+ expect(cmsApiMock).toHaveBeenCalledWith('/mcp/oauth/consent', {
53
+ method: 'POST',
54
+ body: JSON.stringify({ txn: 'txn-auto', allow: true, auto: true }),
55
+ })
56
+ })
57
+ expect(assignMock).toHaveBeenCalledWith('https://claude.ai/api/mcp/auth_callback?code=abc')
58
+ // Manual Allow button is not shown while auto-approving succeeds.
59
+ expect(screen.queryByRole('button', { name: 'Allow' })).toBeNull()
60
+ })
61
+
62
+ it('falls back to manual Allow / Deny buttons if auto-approve POST fails', async () => {
63
+ cmsApiMock.mockImplementation(async (endpoint: string, options?: { method?: string }) => {
64
+ if (endpoint === '/mcp/oauth/transactions/txn-fallback' && !options?.method) {
65
+ return {
66
+ data: {
67
+ clientName: 'Claude',
68
+ clientId: 'https://claude.ai/oauth/client.json',
69
+ redirectHost: 'claude.ai',
70
+ scope: 'content',
71
+ autoApprove: true,
72
+ autoApproveReason: 'existing_grant',
73
+ },
74
+ status: 200,
75
+ }
76
+ }
77
+ if (endpoint === '/mcp/oauth/consent' && options?.method === 'POST') {
78
+ return { error: 'Client is not eligible for auto-approval', status: 403 }
79
+ }
80
+ return { data: {}, status: 200 }
81
+ })
82
+
83
+ render(<McpConsent currentPath="/mcp/consent?txn=txn-fallback" />)
84
+
85
+ expect(await screen.findByRole('button', { name: 'Allow' })).toBeTruthy()
86
+ expect(screen.getByRole('button', { name: 'Deny' })).toBeTruthy()
87
+ })
88
+
89
+ it('requires a manual click when autoApprove is false', async () => {
90
+ cmsApiMock.mockImplementation(async (endpoint: string, options?: { method?: string }) => {
91
+ if (endpoint === '/mcp/oauth/transactions/txn-manual' && !options?.method) {
92
+ return {
93
+ data: {
94
+ clientName: 'Custom Connector',
95
+ clientId: 'https://custom.example/client.json',
96
+ redirectHost: 'custom.example',
97
+ scope: 'content',
98
+ autoApprove: false,
99
+ autoApproveReason: null,
100
+ },
101
+ status: 200,
102
+ }
103
+ }
104
+ if (endpoint === '/mcp/oauth/consent' && options?.method === 'POST') {
105
+ return { data: { redirectUrl: 'https://custom.example/cb?code=xyz' }, status: 200 }
106
+ }
107
+ return { data: {}, status: 200 }
108
+ })
109
+
110
+ render(<McpConsent currentPath="/mcp/consent?txn=txn-manual" />)
111
+
112
+ const allow = await screen.findByRole('button', { name: 'Allow' })
113
+ expect(assignMock).not.toHaveBeenCalled()
114
+
115
+ fireEvent.click(allow)
116
+ await waitFor(() => {
117
+ expect(cmsApiMock).toHaveBeenCalledWith('/mcp/oauth/consent', {
118
+ method: 'POST',
119
+ body: JSON.stringify({ txn: 'txn-manual', allow: true }),
120
+ })
121
+ })
122
+ expect(assignMock).toHaveBeenCalledWith('https://custom.example/cb?code=xyz')
123
+ })
124
+ })
@@ -1,87 +1,89 @@
1
1
  /**
2
- * Default Prenta brand lockup for the admin sidebar (top-left) and the login
3
- * screen: the word "Prenta" plus a three-dot ellipsis (last dot is the brand
4
- * red). The collapsed sidebar uses the matching "P…" mark.
2
+ * Default Prenta brand lockup (`Prënta` wordmark and `Prë` short mark).
5
3
  *
6
- * Letterforms and the first two dots render in `currentColor` so the lockup
7
- * follows the surrounding theme in light and dark mode. The accent dot is the
8
- * one baked-in brand color.
4
+ * Letterforms render in `currentColor` so the lockup adapts automatically across
5
+ * Porcelain, Linen, and Graphite themes in light and dark mode. The three dots
6
+ * above `e` stay locked to the brand vermilion (`#E83D28`).
9
7
  *
10
- * Integrators override this default via:
11
- * defineConfig({
12
- * admin: { branding: { logo: '/my-logo.svg', name: 'Acme' } }
13
- * })
14
- *
15
- * Both the sidebar (top-left) and the login screen read from the same
16
- * `admin.branding` config so swapping logos is a one-line change.
8
+ * Integrators override the placeholder in Settings → Admin appearance →
9
+ * Branding, or via `defineConfig({ admin: { branding: { logo: '/my-logo.svg' } } })`.
17
10
  */
18
11
 
12
+ import {
13
+ PRENTA_ACCENT,
14
+ PRENTA_BRAND_DOTS,
15
+ PRENTA_MARK_INK_PATH,
16
+ PRENTA_MARK_VIEWBOX,
17
+ PRENTA_WORDMARK_INK_PATH,
18
+ PRENTA_WORDMARK_VIEWBOX,
19
+ } from '@prenta/core/appearance'
19
20
  import type { ReactElement } from 'react'
20
21
 
22
+ export { PRENTA_ACCENT }
23
+
21
24
  export interface BrandLogoProps {
22
25
  /** Tailwind / CSS class applied to the root `<svg>` element. */
23
26
  className?: string
27
+ /** Accessible name when rendered as `role="img"` (defaults to `"Prenta"`). */
28
+ label?: string
29
+ /** Marks the SVG `aria-hidden="true"` when nested inside an already-labeled wrapper. */
30
+ decorative?: boolean
24
31
  }
25
32
 
26
- /** Brand-red accent used for the final ellipsis dot. */
27
- export const PRENTA_ACCENT = '#E30613'
28
-
29
- const FONT = "system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif"
33
+ function BrandDots(): ReactElement {
34
+ return (
35
+ <>
36
+ {PRENTA_BRAND_DOTS.map((dot) => (
37
+ <circle key={dot.cx} cx={dot.cx} cy={dot.cy} r={dot.r} fill={PRENTA_ACCENT} />
38
+ ))}
39
+ </>
40
+ )
41
+ }
30
42
 
31
43
  /**
32
- * Compact "P…" mark for the collapsed sidebar rail and other square slots.
44
+ * Compact `Prë` mark for the collapsed sidebar rail, compact attribution, and
45
+ * square/narrow brand slots.
33
46
  */
34
- export function PrentaMark({ className }: BrandLogoProps): ReactElement {
47
+ export function PrentaMark({
48
+ className,
49
+ label = 'Prenta',
50
+ decorative = false,
51
+ }: BrandLogoProps): ReactElement {
35
52
  return (
36
53
  <svg
37
- viewBox="0 0 48 48"
54
+ viewBox={PRENTA_MARK_VIEWBOX}
38
55
  xmlns="http://www.w3.org/2000/svg"
39
56
  className={className}
40
- role="img"
41
- aria-label="Prenta"
57
+ role={decorative ? undefined : 'img'}
58
+ aria-label={decorative ? undefined : label}
59
+ aria-hidden={decorative ? 'true' : undefined}
42
60
  >
43
- <path
44
- fill="currentColor"
45
- fillRule="evenodd"
46
- d="M8 4h10.5c8.2 0 13.5 4.4 13.5 12.2 0 7.7-5.3 12.1-13.5 12.1H16v15.7H8V4zm8 6.4v11.4h2.2c4.7 0 7.4-2.3 7.4-5.7 0-3.5-2.7-5.7-7.4-5.7H16z"
47
- />
48
- <circle cx="26" cy="43.2" r="2.7" fill="currentColor" />
49
- <circle cx="34.2" cy="43.2" r="2.7" fill="currentColor" />
50
- <circle cx="42.4" cy="43.2" r="2.7" fill={PRENTA_ACCENT} />
61
+ <path fill="currentColor" d={PRENTA_MARK_INK_PATH} />
62
+ <BrandDots />
51
63
  </svg>
52
64
  )
53
65
  }
54
66
 
55
67
  /**
56
- * Horizontal "Prenta…" wordmark. Ships as JSX (no bundler asset pipeline —
57
- * works under Next.js, Vite, Webpack, esbuild). `textLength` pins the
58
- * rendered width so the lockup stays proportioned across font fallbacks.
68
+ * Full `Prënta` horizontal wordmark. Ships as pure vector JSX (zero bundler
69
+ * asset pipeline — works under Next.js, Astro, Vite, Webpack, and esbuild).
59
70
  */
60
- export function PrentaBrandLogo({ className }: BrandLogoProps): ReactElement {
71
+ export function PrentaBrandLogo({
72
+ className,
73
+ label = 'Prenta',
74
+ decorative = false,
75
+ }: BrandLogoProps): ReactElement {
61
76
  return (
62
77
  <svg
63
- viewBox="0 0 168 32"
78
+ viewBox={PRENTA_WORDMARK_VIEWBOX}
64
79
  xmlns="http://www.w3.org/2000/svg"
65
80
  className={className}
66
- role="img"
67
- aria-label="Prenta"
81
+ role={decorative ? undefined : 'img'}
82
+ aria-label={decorative ? undefined : label}
83
+ aria-hidden={decorative ? 'true' : undefined}
68
84
  >
69
- <text
70
- x="0"
71
- y="24"
72
- fontFamily={FONT}
73
- fontSize="22"
74
- fontWeight="700"
75
- letterSpacing="-0.6"
76
- fill="currentColor"
77
- textLength="104"
78
- lengthAdjust="spacingAndGlyphs"
79
- >
80
- Prenta
81
- </text>
82
- <circle cx="118" cy="20" r="3.1" fill="currentColor" />
83
- <circle cx="130.5" cy="20" r="3.1" fill="currentColor" />
84
- <circle cx="143" cy="20" r="3.1" fill={PRENTA_ACCENT} />
85
+ <path fill="currentColor" d={PRENTA_WORDMARK_INK_PATH} />
86
+ <BrandDots />
85
87
  </svg>
86
88
  )
87
89
  }