Skip to content

Commit 120ae92

Browse files
author
Faxbot Agent
committed
Admin UI: local-only 'Use Local Admin Key' button; add DOM event navigation; add 'settings/keys' route; show actionable 401/403 banner on Inbox with link to Keys + docs
1 parent a5e0170 commit 120ae92

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

api/admin_ui/src/App.tsx

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,10 @@ function AppContent() {
259259
setTabValue(4);
260260
setSettingsTab(3);
261261
break;
262+
case 'settings/keys':
263+
setTabValue(4);
264+
setSettingsTab(3);
265+
break;
262266
case 'jobs':
263267
setTabValue(2);
264268
break;
@@ -277,6 +281,17 @@ function AppContent() {
277281
if (isMobile) setMobileOpen(false);
278282
};
279283

284+
// Listen for simple navigation events from child components
285+
useEffect(() => {
286+
const handler = (e: any) => { if (e?.detail) handleNavigate(e.detail); };
287+
window.addEventListener('navigate-to', handler as any);
288+
window.addEventListener('faxbot:navigate', handler as any);
289+
return () => {
290+
window.removeEventListener('navigate-to', handler as any);
291+
window.removeEventListener('faxbot:navigate', handler as any);
292+
};
293+
}, []);
294+
280295
// Auto-login if key exists
281296
useEffect(() => {
282297
if (apiKey && !authenticated) {
@@ -485,7 +500,19 @@ function AppContent() {
485500
sx={{ mt: 3 }}
486501
autoFocus
487502
/>
488-
503+
504+
{/* Local-only helper: prefill known bootstrap key for dev */}
505+
{['localhost', '127.0.0.1'].includes(window.location.hostname) && (
506+
<Button
507+
fullWidth
508+
variant="outlined"
509+
onClick={() => { const k = 'fbk_live_local_admin'; setApiKey(k); handleLogin(k); }}
510+
sx={{ mt: 2, borderRadius: 2 }}
511+
>
512+
Use Local Admin Key
513+
</Button>
514+
)}
515+
489516
<Button
490517
fullWidth
491518
variant="contained"

api/admin_ui/src/components/Inbound.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ function Inbound({ client, docsBase }: InboundProps) {
8080
const data = await client.listInbound();
8181
setFaxes(data);
8282
} catch (err) {
83-
setError(err instanceof Error ? err.message : 'Failed to fetch inbound faxes');
83+
const msg = err instanceof Error ? err.message : 'Failed to fetch inbound faxes';
84+
setError(msg);
8485
} finally {
8586
setLoading(false);
8687
}
@@ -264,6 +265,16 @@ function Inbound({ client, docsBase }: InboundProps) {
264265

265266
return (
266267
<Box>
268+
{/* Guidance banner when auth/scopes block inbox */}
269+
{error && /401|403|insufficient|scope/i.test(error) && (
270+
<Alert severity="warning" sx={{ mb: 2, borderRadius: 2 }}>
271+
You are not authorized to view inbound faxes. Use an API key with inbound:list and inbound:read.
272+
<Box sx={{ mt: 1, display: 'flex', gap: 1, flexWrap: 'wrap' }}>
273+
<Button size="small" variant="outlined" onClick={() => window.dispatchEvent(new CustomEvent('faxbot:navigate', { detail: 'settings/keys' }))}>Open API Keys</Button>
274+
<Button size="small" href={(docsBase || 'https://dmontgomery40.github.io/Faxbot') + '/admin-console/api-keys/'} target="_blank" rel="noreferrer">Learn more</Button>
275+
</Box>
276+
</Alert>
277+
)}
267278
<Box
268279
display="flex"
269280
justifyContent="space-between"

0 commit comments

Comments
 (0)