@actuate-media/cms-admin 0.26.0 → 0.28.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 (105) hide show
  1. package/dist/__tests__/views/appearance-settings.render.test.d.ts +2 -0
  2. package/dist/__tests__/views/appearance-settings.render.test.d.ts.map +1 -0
  3. package/dist/__tests__/views/appearance-settings.render.test.js +95 -0
  4. package/dist/__tests__/views/appearance-settings.render.test.js.map +1 -0
  5. package/dist/__tests__/views/security-settings.render.test.d.ts +2 -0
  6. package/dist/__tests__/views/security-settings.render.test.d.ts.map +1 -0
  7. package/dist/__tests__/views/security-settings.render.test.js +175 -0
  8. package/dist/__tests__/views/security-settings.render.test.js.map +1 -0
  9. package/dist/actuate-admin.css +1 -1
  10. package/dist/components/ThemeProvider.d.ts +47 -4
  11. package/dist/components/ThemeProvider.d.ts.map +1 -1
  12. package/dist/components/ThemeProvider.js +173 -27
  13. package/dist/components/ThemeProvider.js.map +1 -1
  14. package/dist/components/ui/Badge.d.ts +1 -1
  15. package/dist/components/ui/Button.d.ts +1 -1
  16. package/dist/components/ui/Card.d.ts +2 -2
  17. package/dist/components/ui/Input.d.ts +1 -1
  18. package/dist/components/ui/Select.d.ts +1 -1
  19. package/dist/layout/Sidebar.d.ts.map +1 -1
  20. package/dist/layout/Sidebar.js +47 -8
  21. package/dist/layout/Sidebar.js.map +1 -1
  22. package/dist/views/Settings.d.ts.map +1 -1
  23. package/dist/views/Settings.js +5 -17
  24. package/dist/views/Settings.js.map +1 -1
  25. package/dist/views/settings/AccessProtectionCard.d.ts +10 -0
  26. package/dist/views/settings/AccessProtectionCard.d.ts.map +1 -0
  27. package/dist/views/settings/AccessProtectionCard.js +20 -0
  28. package/dist/views/settings/AccessProtectionCard.js.map +1 -0
  29. package/dist/views/settings/AdminThemeCard.d.ts +6 -0
  30. package/dist/views/settings/AdminThemeCard.d.ts.map +1 -0
  31. package/dist/views/settings/AdminThemeCard.js +31 -0
  32. package/dist/views/settings/AdminThemeCard.js.map +1 -0
  33. package/dist/views/settings/AppearanceTab.d.ts +7 -0
  34. package/dist/views/settings/AppearanceTab.d.ts.map +1 -0
  35. package/dist/views/settings/AppearanceTab.js +24 -0
  36. package/dist/views/settings/AppearanceTab.js.map +1 -0
  37. package/dist/views/settings/AuthMfaCard.d.ts +10 -0
  38. package/dist/views/settings/AuthMfaCard.d.ts.map +1 -0
  39. package/dist/views/settings/AuthMfaCard.js +33 -0
  40. package/dist/views/settings/AuthMfaCard.js.map +1 -0
  41. package/dist/views/settings/BrandPreviewCard.d.ts +5 -0
  42. package/dist/views/settings/BrandPreviewCard.d.ts.map +1 -0
  43. package/dist/views/settings/BrandPreviewCard.js +18 -0
  44. package/dist/views/settings/BrandPreviewCard.js.map +1 -0
  45. package/dist/views/settings/BrandingCard.d.ts +6 -0
  46. package/dist/views/settings/BrandingCard.d.ts.map +1 -0
  47. package/dist/views/settings/BrandingCard.js +38 -0
  48. package/dist/views/settings/BrandingCard.js.map +1 -0
  49. package/dist/views/settings/SecretsAuditCard.d.ts +11 -0
  50. package/dist/views/settings/SecretsAuditCard.d.ts.map +1 -0
  51. package/dist/views/settings/SecretsAuditCard.js +22 -0
  52. package/dist/views/settings/SecretsAuditCard.js.map +1 -0
  53. package/dist/views/settings/SecurityStatusCard.d.ts +6 -0
  54. package/dist/views/settings/SecurityStatusCard.d.ts.map +1 -0
  55. package/dist/views/settings/SecurityStatusCard.js +35 -0
  56. package/dist/views/settings/SecurityStatusCard.js.map +1 -0
  57. package/dist/views/settings/SecurityTab.d.ts +5 -0
  58. package/dist/views/settings/SecurityTab.d.ts.map +1 -0
  59. package/dist/views/settings/SecurityTab.js +41 -0
  60. package/dist/views/settings/SecurityTab.js.map +1 -0
  61. package/dist/views/settings/SessionPolicyCard.d.ts +11 -0
  62. package/dist/views/settings/SessionPolicyCard.d.ts.map +1 -0
  63. package/dist/views/settings/SessionPolicyCard.js +21 -0
  64. package/dist/views/settings/SessionPolicyCard.js.map +1 -0
  65. package/dist/views/settings/TypographyMotionCard.d.ts +6 -0
  66. package/dist/views/settings/TypographyMotionCard.d.ts.map +1 -0
  67. package/dist/views/settings/TypographyMotionCard.js +8 -0
  68. package/dist/views/settings/TypographyMotionCard.js.map +1 -0
  69. package/dist/views/settings/securityPrimitives.d.ts +21 -0
  70. package/dist/views/settings/securityPrimitives.d.ts.map +1 -0
  71. package/dist/views/settings/securityPrimitives.js +31 -0
  72. package/dist/views/settings/securityPrimitives.js.map +1 -0
  73. package/dist/views/settings/useAppearanceSettings.d.ts +69 -0
  74. package/dist/views/settings/useAppearanceSettings.d.ts.map +1 -0
  75. package/dist/views/settings/useAppearanceSettings.js +344 -0
  76. package/dist/views/settings/useAppearanceSettings.js.map +1 -0
  77. package/dist/views/settings/useGeneralSettings.d.ts +4 -1
  78. package/dist/views/settings/useGeneralSettings.d.ts.map +1 -1
  79. package/dist/views/settings/useGeneralSettings.js.map +1 -1
  80. package/dist/views/settings/useSecuritySettings.d.ts +37 -0
  81. package/dist/views/settings/useSecuritySettings.d.ts.map +1 -0
  82. package/dist/views/settings/useSecuritySettings.js +154 -0
  83. package/dist/views/settings/useSecuritySettings.js.map +1 -0
  84. package/package.json +2 -2
  85. package/src/__tests__/views/appearance-settings.render.test.tsx +132 -0
  86. package/src/__tests__/views/security-settings.render.test.tsx +212 -0
  87. package/src/components/ThemeProvider.tsx +249 -36
  88. package/src/layout/Sidebar.tsx +81 -13
  89. package/src/styles/theme.css +32 -2
  90. package/src/views/Settings.tsx +5 -68
  91. package/src/views/settings/AccessProtectionCard.tsx +143 -0
  92. package/src/views/settings/AdminThemeCard.tsx +145 -0
  93. package/src/views/settings/AppearanceTab.tsx +81 -0
  94. package/src/views/settings/AuthMfaCard.tsx +118 -0
  95. package/src/views/settings/BrandPreviewCard.tsx +125 -0
  96. package/src/views/settings/BrandingCard.tsx +332 -0
  97. package/src/views/settings/SecretsAuditCard.tsx +129 -0
  98. package/src/views/settings/SecurityStatusCard.tsx +110 -0
  99. package/src/views/settings/SecurityTab.tsx +162 -0
  100. package/src/views/settings/SessionPolicyCard.tsx +123 -0
  101. package/src/views/settings/TypographyMotionCard.tsx +65 -0
  102. package/src/views/settings/securityPrimitives.tsx +75 -0
  103. package/src/views/settings/useAppearanceSettings.ts +513 -0
  104. package/src/views/settings/useGeneralSettings.ts +4 -1
  105. package/src/views/settings/useSecuritySettings.ts +197 -0
@@ -0,0 +1,332 @@
1
+ 'use client'
2
+
3
+ import {
4
+ AlertTriangle,
5
+ ChevronDown,
6
+ ChevronRight,
7
+ ImageIcon,
8
+ Loader2,
9
+ Trash2,
10
+ Upload,
11
+ } from 'lucide-react'
12
+ import { useRef } from 'react'
13
+
14
+ import type { BrandAssetField, UseAppearanceSettings } from './useAppearanceSettings.js'
15
+
16
+ const LOGO_ACCEPT = 'image/svg+xml,image/png'
17
+
18
+ function previewSurface(dark: boolean): string {
19
+ return dark ? 'bg-foreground border-border' : 'bg-muted border-border'
20
+ }
21
+
22
+ function LogoField({
23
+ label,
24
+ helper,
25
+ field,
26
+ accept,
27
+ square,
28
+ darkSurface,
29
+ brand,
30
+ assets,
31
+ uploadingField,
32
+ canEdit,
33
+ warning,
34
+ onUpload,
35
+ onRemove,
36
+ }: {
37
+ label: string
38
+ helper: string
39
+ field: BrandAssetField
40
+ accept: string
41
+ square?: boolean
42
+ darkSurface?: boolean
43
+ brand: UseAppearanceSettings['brand']
44
+ assets: UseAppearanceSettings['assets']
45
+ uploadingField: BrandAssetField | null
46
+ canEdit: boolean
47
+ warning?: string
48
+ onUpload: (field: BrandAssetField, file: File) => void
49
+ onRemove: (field: BrandAssetField) => void
50
+ }) {
51
+ const inputRef = useRef<HTMLInputElement>(null)
52
+ const assetId = brand[field]
53
+ const asset = assetId ? assets[assetId] : undefined
54
+ const uploading = uploadingField === field
55
+ const inputId = `brand-${field}`
56
+
57
+ return (
58
+ <div className="flex items-start gap-4">
59
+ <div
60
+ className={`flex shrink-0 items-center justify-center overflow-hidden rounded-md border p-2 ${previewSurface(
61
+ Boolean(darkSurface),
62
+ )} ${square ? 'h-12 w-12' : 'h-12 w-20'}`}
63
+ aria-hidden={!asset}
64
+ >
65
+ {asset?.url ? (
66
+ // Never stretch/crop — contain preserves aspect ratio + transparency.
67
+ <img
68
+ src={asset.url}
69
+ alt={`${label} preview`}
70
+ className="max-h-full max-w-full object-contain"
71
+ />
72
+ ) : (
73
+ <ImageIcon size={18} className="text-muted-foreground" aria-hidden="true" />
74
+ )}
75
+ </div>
76
+
77
+ <div className="min-w-0 flex-1">
78
+ <label htmlFor={inputId} className="text-foreground block text-base font-medium">
79
+ {label}
80
+ </label>
81
+ <p className="text-muted-foreground mt-0.5 text-sm">{helper}</p>
82
+
83
+ <div className="mt-2 flex items-center gap-2">
84
+ <input
85
+ ref={inputRef}
86
+ id={inputId}
87
+ type="file"
88
+ accept={accept}
89
+ className="sr-only"
90
+ disabled={!canEdit || uploading}
91
+ onChange={(e) => {
92
+ const file = e.target.files?.[0]
93
+ if (file) onUpload(field, file)
94
+ if (inputRef.current) inputRef.current.value = ''
95
+ }}
96
+ />
97
+ <button
98
+ type="button"
99
+ onClick={() => inputRef.current?.click()}
100
+ disabled={!canEdit || uploading}
101
+ className="border-border text-foreground hover:bg-accent inline-flex items-center gap-2 rounded-md border px-3 py-1.5 text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50"
102
+ >
103
+ {uploading ? (
104
+ <Loader2 size={14} className="animate-spin" aria-hidden="true" />
105
+ ) : (
106
+ <Upload size={14} aria-hidden="true" />
107
+ )}
108
+ {asset ? 'Replace' : `Upload ${label.toLowerCase()}`}
109
+ </button>
110
+ {asset && (
111
+ <button
112
+ type="button"
113
+ onClick={() => onRemove(field)}
114
+ disabled={!canEdit}
115
+ className="text-muted-foreground hover:text-destructive inline-flex items-center gap-1.5 rounded-md px-2 py-1.5 text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50"
116
+ aria-label={`Remove ${label}`}
117
+ >
118
+ <Trash2 size={14} aria-hidden="true" /> Remove
119
+ </button>
120
+ )}
121
+ </div>
122
+
123
+ {warning && (
124
+ <p
125
+ className="text-warning mt-2 flex items-start gap-1.5 text-sm"
126
+ role="status"
127
+ aria-live="polite"
128
+ >
129
+ <AlertTriangle size={14} className="mt-0.5 shrink-0" aria-hidden="true" /> {warning}
130
+ </p>
131
+ )}
132
+ </div>
133
+ </div>
134
+ )
135
+ }
136
+
137
+ export function BrandingCard({ s, canEdit }: { s: UseAppearanceSettings; canEdit: boolean }) {
138
+ const warningFor = (field: BrandAssetField): string | undefined =>
139
+ s.issues.find((i) => i.field === field && i.severity === 'warning')?.message
140
+
141
+ const custom = s.brand.mode === 'customAdminBrand'
142
+
143
+ return (
144
+ <section className="border-border bg-card rounded-lg border p-6">
145
+ <header className="mb-4">
146
+ <h3 className="text-foreground text-lg font-medium">Branding</h3>
147
+ <p className="text-muted-foreground mt-0.5 text-sm">
148
+ Logos shown in the admin sidebar and on the public site.
149
+ </p>
150
+ </header>
151
+
152
+ <div className="space-y-5">
153
+ <LogoField
154
+ label="Primary Logo"
155
+ helper="SVG or PNG, up to 1MB. Best for the public header and full admin sidebar."
156
+ field="publicPrimaryLogoAssetId"
157
+ accept={LOGO_ACCEPT}
158
+ brand={s.brand}
159
+ assets={s.assets}
160
+ uploadingField={s.uploadingField}
161
+ canEdit={canEdit}
162
+ warning={warningFor('publicPrimaryLogoAssetId')}
163
+ onUpload={s.uploadAsset}
164
+ onRemove={s.removeAsset}
165
+ />
166
+
167
+ <LogoField
168
+ label="Favicon / App Icon Source"
169
+ helper="32×32 PNG or SVG. A larger square image is fine — it scales down cleanly."
170
+ field="faviconSourceAssetId"
171
+ accept={LOGO_ACCEPT}
172
+ square
173
+ brand={s.brand}
174
+ assets={s.assets}
175
+ uploadingField={s.uploadingField}
176
+ canEdit={canEdit}
177
+ warning={warningFor('faviconSourceAssetId')}
178
+ onUpload={s.uploadAsset}
179
+ onRemove={s.removeAsset}
180
+ />
181
+
182
+ {/* Advanced logo variants disclosure (Logo Mark + Dark Mode Logo). */}
183
+ <div className="border-border border-t pt-4">
184
+ <button
185
+ type="button"
186
+ onClick={() => s.setShowAdvanced(!s.showAdvanced)}
187
+ aria-expanded={s.showAdvanced}
188
+ className="text-foreground hover:text-brand inline-flex items-center gap-1.5 text-sm font-medium transition-colors"
189
+ >
190
+ {s.showAdvanced ? (
191
+ <ChevronDown size={16} aria-hidden="true" />
192
+ ) : (
193
+ <ChevronRight size={16} aria-hidden="true" />
194
+ )}
195
+ Advanced logo variants
196
+ </button>
197
+
198
+ {s.showAdvanced && (
199
+ <div className="mt-4 space-y-5">
200
+ <LogoField
201
+ label="Logo Mark"
202
+ helper="Square icon or mark. Used for the collapsed sidebar, compact UI, and app icons."
203
+ field="publicLogoMarkAssetId"
204
+ accept={LOGO_ACCEPT}
205
+ square
206
+ brand={s.brand}
207
+ assets={s.assets}
208
+ uploadingField={s.uploadingField}
209
+ canEdit={canEdit}
210
+ warning={warningFor('publicLogoMarkAssetId')}
211
+ onUpload={s.uploadAsset}
212
+ onRemove={s.removeAsset}
213
+ />
214
+ <LogoField
215
+ label="Dark Mode Logo"
216
+ helper="Optional. Used on dark backgrounds or the dark admin theme."
217
+ field="publicDarkLogoAssetId"
218
+ accept={LOGO_ACCEPT}
219
+ darkSurface
220
+ brand={s.brand}
221
+ assets={s.assets}
222
+ uploadingField={s.uploadingField}
223
+ canEdit={canEdit}
224
+ warning={warningFor('publicDarkLogoAssetId')}
225
+ onUpload={s.uploadAsset}
226
+ onRemove={s.removeAsset}
227
+ />
228
+ </div>
229
+ )}
230
+ </div>
231
+
232
+ {/* Admin branding mode — admin inherits the public brand by default. */}
233
+ <div className="border-border border-t pt-4">
234
+ <div className="flex items-center gap-2">
235
+ <span className="text-foreground text-base font-medium">Admin branding</span>
236
+ </div>
237
+ <p className="text-muted-foreground mt-0.5 text-sm">
238
+ Admin uses the public brand by default.
239
+ </p>
240
+ <div
241
+ role="radiogroup"
242
+ aria-label="Admin branding mode"
243
+ className="border-border bg-muted mt-2 inline-flex rounded-md border p-0.5"
244
+ >
245
+ {(
246
+ [
247
+ ['inheritPublicBrand', 'Inherit public brand'],
248
+ ['customAdminBrand', 'Custom admin logo'],
249
+ ] as const
250
+ ).map(([value, text]) => {
251
+ const active = s.brand.mode === value
252
+ return (
253
+ <button
254
+ key={value}
255
+ type="button"
256
+ role="radio"
257
+ aria-checked={active}
258
+ disabled={!canEdit}
259
+ onClick={() => s.setBrandingMode(value)}
260
+ className={`rounded px-3 py-1.5 text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50 ${
261
+ active
262
+ ? 'bg-card text-foreground shadow-sm'
263
+ : 'text-muted-foreground hover:text-foreground'
264
+ }`}
265
+ >
266
+ {text}
267
+ </button>
268
+ )
269
+ })}
270
+ </div>
271
+
272
+ {custom && (
273
+ <div className="mt-4 space-y-5">
274
+ <LogoField
275
+ label="Admin Primary Logo"
276
+ helper="Shown in the admin sidebar instead of the public logo."
277
+ field="adminPrimaryLogoAssetId"
278
+ accept={LOGO_ACCEPT}
279
+ brand={s.brand}
280
+ assets={s.assets}
281
+ uploadingField={s.uploadingField}
282
+ canEdit={canEdit}
283
+ warning={warningFor('adminPrimaryLogoAssetId')}
284
+ onUpload={s.uploadAsset}
285
+ onRemove={s.removeAsset}
286
+ />
287
+ <LogoField
288
+ label="Admin Logo Mark"
289
+ helper="Square mark for the collapsed admin sidebar."
290
+ field="adminLogoMarkAssetId"
291
+ accept={LOGO_ACCEPT}
292
+ square
293
+ brand={s.brand}
294
+ assets={s.assets}
295
+ uploadingField={s.uploadingField}
296
+ canEdit={canEdit}
297
+ warning={warningFor('adminLogoMarkAssetId')}
298
+ onUpload={s.uploadAsset}
299
+ onRemove={s.removeAsset}
300
+ />
301
+ </div>
302
+ )}
303
+ </div>
304
+
305
+ {/* Default alt text */}
306
+ <div className="border-border border-t pt-4">
307
+ <label htmlFor="brand-alt" className="text-foreground block text-base font-medium">
308
+ Logo alt text
309
+ </label>
310
+ <p className="text-muted-foreground mt-0.5 mb-2 text-sm">
311
+ Used by screen readers on the public site. Defaults to the Site Title when empty.
312
+ </p>
313
+ <input
314
+ id="brand-alt"
315
+ type="text"
316
+ value={s.brand.defaultLogoAltText ?? ''}
317
+ disabled={!canEdit}
318
+ onChange={(e) => s.setAltText(e.target.value)}
319
+ placeholder="Site Title"
320
+ className="border-border bg-input-background text-foreground focus-visible:ring-ring w-full max-w-md rounded-md border px-3 py-2 text-base focus-visible:ring-2 focus-visible:outline-none disabled:opacity-50"
321
+ />
322
+ </div>
323
+ </div>
324
+
325
+ {s.saveError && (
326
+ <p className="text-destructive mt-4 text-sm" role="alert">
327
+ {s.saveError}
328
+ </p>
329
+ )}
330
+ </section>
331
+ )
332
+ }
@@ -0,0 +1,129 @@
1
+ 'use client'
2
+
3
+ import { useId } from 'react'
4
+ import type {
5
+ ApiKeysSecuritySummary,
6
+ CheckStatus,
7
+ SecretsStatus,
8
+ SecuritySourceMetadata,
9
+ UsersSecuritySummary,
10
+ } from '@actuate-media/cms-core/security-center'
11
+ import { SettingsSourceBadge } from './components.js'
12
+ import { SecurityCard, StatusRow } from './securityPrimitives.js'
13
+
14
+ function secretValue(status: CheckStatus): string {
15
+ switch (status) {
16
+ case 'pass':
17
+ return 'Configured'
18
+ case 'warning':
19
+ return 'Not configured'
20
+ case 'fail':
21
+ return 'Missing / invalid'
22
+ default:
23
+ return 'Unknown'
24
+ }
25
+ }
26
+
27
+ export function SecretsAuditCard({
28
+ secrets,
29
+ auditEnabled,
30
+ failedLogins24h,
31
+ users,
32
+ apiKeys,
33
+ sources,
34
+ onNavigate,
35
+ }: {
36
+ secrets: SecretsStatus
37
+ auditEnabled: boolean
38
+ failedLogins24h: number
39
+ users: UsersSecuritySummary
40
+ apiKeys: ApiKeysSecuritySummary
41
+ sources: Record<string, SecuritySourceMetadata>
42
+ onNavigate?: (path: string) => void
43
+ }) {
44
+ const headingId = useId()
45
+
46
+ return (
47
+ <SecurityCard
48
+ headingId={headingId}
49
+ title="Secrets, Encryption & Audit"
50
+ description="Platform secret status (values are never shown), audit logging, and cross-module risk."
51
+ >
52
+ <div className="space-y-2">
53
+ <StatusRow
54
+ status={secrets.cmsSecret}
55
+ label="CMS signing secret"
56
+ value={secretValue(secrets.cmsSecret)}
57
+ badge={<SettingsSourceBadge meta={sources.cmsSecret} />}
58
+ />
59
+ <StatusRow
60
+ status={secrets.encryptionKey}
61
+ label="Encryption key"
62
+ value={secretValue(secrets.encryptionKey)}
63
+ badge={<SettingsSourceBadge meta={sources.encryptionKey} />}
64
+ />
65
+ <StatusRow status="pass" label="API keys hashed at rest" value="Yes" />
66
+ <StatusRow
67
+ status={secrets.webhookSecretsEncrypted ? 'pass' : 'warning'}
68
+ label="Webhook secrets encrypted"
69
+ value={secrets.webhookSecretsEncrypted ? 'Yes' : 'Plaintext fallback'}
70
+ />
71
+ </div>
72
+
73
+ <div className="border-border mt-4 space-y-2 border-t pt-4">
74
+ <StatusRow
75
+ status={auditEnabled ? 'pass' : 'warning'}
76
+ label="Audit logging"
77
+ value={auditEnabled ? 'Enabled' : 'Disabled'}
78
+ badge={<SettingsSourceBadge meta={sources.audit} />}
79
+ />
80
+ <StatusRow
81
+ status={failedLogins24h >= 20 ? 'warning' : 'pass'}
82
+ label="Failed logins (24h)"
83
+ value={String(failedLogins24h)}
84
+ />
85
+ </div>
86
+
87
+ {/* Cross-module summaries — link out, never duplicate management here. */}
88
+ <div className="border-border mt-4 space-y-3 border-t pt-4">
89
+ <div className="flex items-start justify-between gap-3">
90
+ <div className="text-sm">
91
+ <p className="text-foreground font-medium">Users</p>
92
+ <p className="text-muted-foreground">
93
+ {users.totalAdmins} admin{users.totalAdmins === 1 ? '' : 's'},{' '}
94
+ {users.adminsWithoutMfa} without MFA
95
+ {users.inactive > 0 ? `, ${users.inactive} inactive` : ''}
96
+ </p>
97
+ </div>
98
+ {onNavigate && (
99
+ <button
100
+ type="button"
101
+ onClick={() => onNavigate('/settings?tab=users')}
102
+ className="text-brand shrink-0 text-sm hover:underline"
103
+ >
104
+ Review users →
105
+ </button>
106
+ )}
107
+ </div>
108
+ <div className="flex items-start justify-between gap-3">
109
+ <div className="text-sm">
110
+ <p className="text-foreground font-medium">API keys</p>
111
+ <p className="text-muted-foreground">
112
+ {apiKeys.active} active, {apiKeys.broadScope} broad-scope, {apiKeys.withoutExpiration}{' '}
113
+ without expiry
114
+ </p>
115
+ </div>
116
+ {onNavigate && (
117
+ <button
118
+ type="button"
119
+ onClick={() => onNavigate('/settings?tab=api-keys')}
120
+ className="text-brand shrink-0 text-sm hover:underline"
121
+ >
122
+ Review API keys →
123
+ </button>
124
+ )}
125
+ </div>
126
+ </div>
127
+ </SecurityCard>
128
+ )
129
+ }
@@ -0,0 +1,110 @@
1
+ 'use client'
2
+
3
+ import { useId } from 'react'
4
+ import { Shield, ShieldAlert, ShieldCheck, ShieldX } from 'lucide-react'
5
+ import type { SecurityStatus, SecurityWarning } from '@actuate-media/cms-core/security-center'
6
+ import { CheckIcon } from './securityPrimitives.js'
7
+
8
+ const LEVEL_STYLES: Record<
9
+ SecurityStatus['status'],
10
+ { pill: string; Icon: typeof Shield; word: string }
11
+ > = {
12
+ secure: {
13
+ pill: 'bg-success/15 text-success border-success/30',
14
+ Icon: ShieldCheck,
15
+ word: 'Secure',
16
+ },
17
+ needs_attention: {
18
+ pill: 'bg-warning/15 text-warning border-warning/30',
19
+ Icon: ShieldAlert,
20
+ word: 'Needs attention',
21
+ },
22
+ at_risk: {
23
+ pill: 'bg-destructive/15 text-destructive border-destructive/30',
24
+ Icon: ShieldX,
25
+ word: 'At risk',
26
+ },
27
+ unknown: { pill: 'bg-muted text-muted-foreground border-border', Icon: Shield, word: 'Unknown' },
28
+ }
29
+
30
+ const SEVERITY_STYLES: Record<SecurityWarning['severity'], string> = {
31
+ critical: 'border-destructive/30 bg-destructive/10 text-destructive',
32
+ warning: 'border-warning/30 bg-warning/10 text-warning',
33
+ info: 'border-border bg-muted text-muted-foreground',
34
+ }
35
+
36
+ export function SecurityStatusCard({
37
+ status,
38
+ onNavigate,
39
+ }: {
40
+ status: SecurityStatus
41
+ onNavigate?: (path: string) => void
42
+ }) {
43
+ const headingId = useId()
44
+ const style = LEVEL_STYLES[status.status]
45
+ const { Icon } = style
46
+
47
+ return (
48
+ <section aria-labelledby={headingId} className="border-border bg-card rounded-lg border p-4">
49
+ <div className="mb-1 flex items-start justify-between gap-3">
50
+ <h3 id={headingId} className="text-foreground text-base font-medium">
51
+ Security Status
52
+ </h3>
53
+ <span
54
+ className={`inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-sm font-medium ${style.pill}`}
55
+ >
56
+ <Icon size={15} aria-hidden="true" />
57
+ {/* Visible text label means the status never relies on color alone. */}
58
+ {style.word}
59
+ </span>
60
+ </div>
61
+ <p className="text-muted-foreground mb-4 text-sm">{status.description}</p>
62
+
63
+ <div className="grid grid-cols-1 gap-x-6 gap-y-1 sm:grid-cols-2">
64
+ {status.checks.map((check) => (
65
+ <button
66
+ key={check.key}
67
+ type="button"
68
+ disabled={!check.actionHref || !onNavigate}
69
+ onClick={() => check.actionHref && onNavigate?.(check.actionHref)}
70
+ className="enabled:hover:bg-accent/50 flex items-center justify-between gap-3 rounded-md py-1.5 text-left text-sm disabled:cursor-default"
71
+ >
72
+ <span className="flex items-center gap-2">
73
+ <CheckIcon status={check.status} />
74
+ <span className="text-foreground">{check.label}</span>
75
+ </span>
76
+ {check.value !== undefined && (
77
+ <span className="text-muted-foreground text-right">{check.value}</span>
78
+ )}
79
+ </button>
80
+ ))}
81
+ </div>
82
+
83
+ {status.warnings.length > 0 && (
84
+ <div className="mt-4 space-y-2" aria-live="polite">
85
+ {status.warnings.map((w) => (
86
+ <div
87
+ key={w.id}
88
+ role="note"
89
+ className={`flex items-start justify-between gap-3 rounded-lg border p-3 text-sm ${SEVERITY_STYLES[w.severity]}`}
90
+ >
91
+ <div>
92
+ <p className="font-medium">{w.title}</p>
93
+ <p className="mt-0.5 opacity-90">{w.description}</p>
94
+ </div>
95
+ {w.actionHref && w.actionLabel && onNavigate && (
96
+ <button
97
+ type="button"
98
+ onClick={() => onNavigate(w.actionHref!)}
99
+ className="shrink-0 self-center rounded-md border border-current/30 px-2.5 py-1 text-xs font-medium hover:opacity-80"
100
+ >
101
+ {w.actionLabel}
102
+ </button>
103
+ )}
104
+ </div>
105
+ ))}
106
+ </div>
107
+ )}
108
+ </section>
109
+ )
110
+ }