Phone-width layout fixes (ENB-23)
CI / integration (push) Successful in 12s
CI / check (push) Successful in 16s

Checked at 390px and 360px in a headless mobile Chrome; no horizontal overflow
on any page.

- Tables become stacked cards on phones, with column names from data-label and
  row actions underneath instead of off the edge.
- Nav fits on one line; chips no longer wrap mid-name; less nested padding.
- Graph opens at a fixed readable zoom on phones with a pan/zoom hint, and
  scrolls to the details card when a node or label is tapped.
- Add the missing headings and wide layout to the user, entity and group forms
  (previously only the token form had them).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
mattandClaude Sonnet 5.5 committed 2026-10-20 13:34:21 +01:00
1 parent 0882d35123
commit 61bb6d912a
11 files changed
+154 -23

No files matched your search

+1 -1
View File
@@ -114,7 +114,7 @@ export function AccessEditor({ client, target, onClose }: Props) {
<code>{row.display}</code> <code>{row.display}</code>
{row.wildcard && <span className="tag">everything inside</span>} {row.wildcard && <span className="tag">everything inside</span>}
</td> </td>
<td> <td data-label="Can">
<CapabilityChips capabilities={row.capabilities} /> <CapabilityChips capabilities={row.capabilities} />
</td> </td>
<td> <td>
+4 -2
View File
@@ -1,4 +1,5 @@
import { useMutation, useQueryClient } from '@tanstack/react-query' import { useMutation, useQueryClient } from '@tanstack/react-query'
import type { Ref } from 'react'
import type { BaoClient } from '../../api/bao' import type { BaoClient } from '../../api/bao'
import { revokeAccess } from '../../api/grants' import { revokeAccess } from '../../api/grants'
import type { AccessGraph, GraphEdge, GraphNode, PolicyInput } from '../../model/graph' import type { AccessGraph, GraphEdge, GraphNode, PolicyInput } from '../../model/graph'
@@ -14,6 +15,7 @@ interface Props {
policies: PolicyInput[] policies: PolicyInput[]
selection: Selection | null selection: Selection | null
onRevoked: () => void onRevoked: () => void
ref?: Ref<HTMLElement>
} }
const nodeById = (g: AccessGraph, id: string) => g.nodes.find((n) => n.id === id) const nodeById = (g: AccessGraph, id: string) => g.nodes.find((n) => n.id === id)
@@ -210,7 +212,7 @@ function EdgeDetails({ client, edge, full, policies, onRevoked }: { client: BaoC
) )
} }
export function Details({ client, full, policies, selection, onRevoked }: Props) { export function Details({ client, full, policies, selection, onRevoked, ref }: Props) {
let body = <p className="detail-empty">Select a node or a line to see what it grants.</p> let body = <p className="detail-empty">Select a node or a line to see what it grants.</p>
if (selection?.kind === 'node') { if (selection?.kind === 'node') {
const node = nodeById(full, selection.id) const node = nodeById(full, selection.id)
@@ -220,7 +222,7 @@ export function Details({ client, full, policies, selection, onRevoked }: Props)
if (edge) body = <EdgeDetails client={client} edge={edge} full={full} policies={policies} onRevoked={onRevoked} /> if (edge) body = <EdgeDetails client={client} edge={edge} full={full} policies={policies} onRevoked={onRevoked} />
} }
return ( return (
<aside className="graph-details" aria-label="Details"> <aside ref={ref} className="graph-details" aria-label="Details">
{body} {body}
</aside> </aside>
) )
+16 -3
View File
@@ -9,13 +9,14 @@ import {
} from '@xyflow/react' } from '@xyflow/react'
import '@xyflow/react/dist/style.css' import '@xyflow/react/dist/style.css'
import { useQueryClient } from '@tanstack/react-query' import { useQueryClient } from '@tanstack/react-query'
import { useMemo, useState } from 'react' import { useEffect, useMemo, useRef, useState } from 'react'
import type { BaoClient } from '../../api/bao' import type { BaoClient } from '../../api/bao'
import { buildAccessGraph, type AccessGraph } from '../../model/graph' import { buildAccessGraph, type AccessGraph } from '../../model/graph'
import { filterGraph } from '../../model/graphFilter' import { filterGraph } from '../../model/graphFilter'
import { layoutColumns } from '../../model/layout' import { layoutColumns } from '../../model/layout'
import { RequireConnection } from '../shared/RequireConnection' import { RequireConnection } from '../shared/RequireConnection'
import { useAccessInputs } from '../shared/useAccessInputs' import { useAccessInputs } from '../shared/useAccessInputs'
import { useNarrow } from '../shared/useNarrow'
import { Details, type Selection } from './Details' import { Details, type Selection } from './Details'
import { GrantEdge, type GrantEdgeData } from './GraphEdge' import { GrantEdge, type GrantEdgeData } from './GraphEdge'
import { GraphNodeCard } from './GraphNode' import { GraphNodeCard } from './GraphNode'
@@ -79,6 +80,13 @@ function GraphView({ client }: { client: BaoClient }) {
const [path, setPath] = useState('') const [path, setPath] = useState('')
const [hideDefault, setHideDefault] = useState(true) const [hideDefault, setHideDefault] = useState(true)
const [selected, setSelected] = useState<Selection | null>(null) const [selected, setSelected] = useState<Selection | null>(null)
const narrow = useNarrow()
const detailsRef = useRef<HTMLElement>(null)
// On a phone the details sit below the canvas, so bring them into view when something is picked.
useEffect(() => {
if (narrow && selected) detailsRef.current?.scrollIntoView({ block: 'start', behavior: 'smooth' })
}, [narrow, selected])
const full = useMemo( const full = useMemo(
() => (inputs.data ? buildAccessGraph(inputs.data.identities, inputs.data.policies) : null), () => (inputs.data ? buildAccessGraph(inputs.data.identities, inputs.data.policies) : null),
@@ -131,6 +139,7 @@ function GraphView({ client }: { client: BaoClient }) {
</li> </li>
<li>Dashed: policy is attached but missing</li> <li>Dashed: policy is attached but missing</li>
<li className="grow">Identities include policies inherited through entities and groups.</li> <li className="grow">Identities include policies inherited through entities and groups.</li>
<li className="graph-hint">Drag to pan, pinch to zoom, tap a node or label for details.</li>
</ul> </ul>
</div> </div>
{inputs.data.notes.map((n) => ( {inputs.data.notes.map((n) => (
@@ -144,11 +153,15 @@ function GraphView({ client }: { client: BaoClient }) {
<div className="graph-layout"> <div className="graph-layout">
<div className="graph-canvas" data-testid="graph-canvas"> <div className="graph-canvas" data-testid="graph-canvas">
<ReactFlow <ReactFlow
// A phone can't fit the whole graph at a readable size: open at a fixed zoom and let people pan.
key={narrow ? 'narrow' : 'wide'}
nodes={flow.nodes} nodes={flow.nodes}
edges={flow.edges} edges={flow.edges}
nodeTypes={nodeTypes} nodeTypes={nodeTypes}
edgeTypes={edgeTypes} edgeTypes={edgeTypes}
fitView fitView={!narrow}
defaultViewport={narrow ? { x: 16, y: 16, zoom: 0.8 } : undefined}
minZoom={narrow ? 0.3 : undefined}
nodesDraggable={false} nodesDraggable={false}
nodesConnectable={false} nodesConnectable={false}
elementsSelectable elementsSelectable
@@ -161,7 +174,7 @@ function GraphView({ client }: { client: BaoClient }) {
<Controls showInteractive={false} /> <Controls showInteractive={false} />
</ReactFlow> </ReactFlow>
</div> </div>
<Details client={client} full={full} policies={inputs.data.policies} selection={selected} onRevoked={() => setSelected(null)} /> <Details ref={detailsRef} client={client} full={full} policies={inputs.data.policies} selection={selected} onRevoked={() => setSelected(null)} />
</div> </div>
)} )}
</> </>
+4 -3
View File
@@ -74,10 +74,10 @@ export function EntitiesTab({ client }: { client: BaoClient }) {
{entities.data?.map((e) => ( {entities.data?.map((e) => (
<tr key={e.id}> <tr key={e.id}>
<td>{e.name}</td> <td>{e.name}</td>
<td> <td data-label="Aliases">
<NameChips names={e.aliases.map((a) => a.name)} /> <NameChips names={e.aliases.map((a) => a.name)} />
</td> </td>
<td> <td data-label="Policies">
<PolicyChips policies={e.policies} /> <PolicyChips policies={e.policies} />
</td> </td>
<td> <td>
@@ -110,7 +110,8 @@ export function EntitiesTab({ client }: { client: BaoClient }) {
</button> </button>
)} )}
{draft && ( {draft && (
<form onSubmit={submit} aria-label={draft.isNew ? 'New entity' : `Edit ${draft.name}`}> <form onSubmit={submit} aria-label={draft.isNew ? 'New entity' : `Edit ${draft.name}`} className="wide">
<h3>{draft.isNew ? 'New entity' : `Edit ${draft.name}`}</h3>
<label> <label>
Name Name
<input value={draft.name} disabled={!draft.isNew} onChange={(e) => setDraft({ ...draft, name: e.target.value })} required /> <input value={draft.name} disabled={!draft.isNew} onChange={(e) => setDraft({ ...draft, name: e.target.value })} required />
+4 -3
View File
@@ -57,10 +57,10 @@ export function GroupsTab({ client }: { client: BaoClient }) {
{groups.data?.map((g) => ( {groups.data?.map((g) => (
<tr key={g.id}> <tr key={g.id}>
<td>{g.name}</td> <td>{g.name}</td>
<td> <td data-label="Members">
<NameChips names={g.member_entity_ids.map(nameOf)} /> <NameChips names={g.member_entity_ids.map(nameOf)} />
</td> </td>
<td> <td data-label="Policies">
<PolicyChips policies={g.policies} /> <PolicyChips policies={g.policies} />
</td> </td>
<td> <td>
@@ -92,7 +92,8 @@ export function GroupsTab({ client }: { client: BaoClient }) {
</button> </button>
)} )}
{draft && ( {draft && (
<form onSubmit={submit} aria-label={draft.isNew ? 'New group' : `Edit ${draft.name}`}> <form onSubmit={submit} aria-label={draft.isNew ? 'New group' : `Edit ${draft.name}`} className="wide">
<h3>{draft.isNew ? 'New group' : `Edit ${draft.name}`}</h3>
<label> <label>
Name Name
<input value={draft.name} disabled={!draft.isNew} onChange={(e) => setDraft({ ...draft, name: e.target.value })} required /> <input value={draft.name} disabled={!draft.isNew} onChange={(e) => setDraft({ ...draft, name: e.target.value })} required />
+3 -3
View File
@@ -104,11 +104,11 @@ export function TokensTab({ client }: { client: BaoClient }) {
{t.display_name || '—'} {t.display_name || '—'}
{isSelf ? ' (you)' : ''} {isSelf ? ' (you)' : ''}
</td> </td>
<td> <td data-label="Policies">
<PolicyChips policies={t.policies} /> <PolicyChips policies={t.policies} />
</td> </td>
<td>{formatTtl(t.ttl)}</td> <td data-label="Expires">{formatTtl(t.ttl)}</td>
<td> <td data-label="Accessor">
<code>{t.accessor.slice(0, 8)}…</code> <code>{t.accessor.slice(0, 8)}…</code>
</td> </td>
<td> <td>
@@ -33,6 +33,15 @@ test('lists users', async () => {
expect(within(row).getByText('dev')).toBeInTheDocument() expect(within(row).getByText('dev')).toBeInTheDocument()
}) })
test('the user form has a heading that says what it is for', async () => {
const user = setup()
await user.click(await screen.findByRole('button', { name: 'New user' }))
expect(screen.getByRole('heading', { name: 'New user' })).toBeInTheDocument()
await user.click(screen.getByRole('button', { name: 'Cancel' }))
await user.click(await screen.findByRole('button', { name: 'Edit alice' }))
expect(screen.getByRole('heading', { name: 'Edit alice' })).toBeInTheDocument()
})
test('creates a user with selected policies', async () => { test('creates a user with selected policies', async () => {
const user = setup() const user = setup()
await user.click(await screen.findByRole('button', { name: 'New user' })) await user.click(await screen.findByRole('button', { name: 'New user' }))
+3 -2
View File
@@ -58,7 +58,7 @@ export function UsersTab({ client }: { client: BaoClient }) {
{users.data?.map((u) => ( {users.data?.map((u) => (
<tr key={u.name}> <tr key={u.name}>
<td>{u.name}</td> <td>{u.name}</td>
<td> <td data-label="Policies">
<PolicyChips policies={u.policies} /> <PolicyChips policies={u.policies} />
</td> </td>
<td> <td>
@@ -90,7 +90,8 @@ export function UsersTab({ client }: { client: BaoClient }) {
</button> </button>
)} )}
{draft && ( {draft && (
<form onSubmit={submit} aria-label={draft.isNew ? 'New user' : `Edit ${draft.name}`}> <form onSubmit={submit} aria-label={draft.isNew ? 'New user' : `Edit ${draft.name}`} className="wide">
<h3>{draft.isNew ? 'New user' : `Edit ${draft.name}`}</h3>
<label> <label>
Username Username
<input value={draft.name} disabled={!draft.isNew} onChange={(e) => setDraft({ ...draft, name: e.target.value })} required /> <input value={draft.name} disabled={!draft.isNew} onChange={(e) => setDraft({ ...draft, name: e.target.value })} required />
+2 -2
View File
@@ -54,10 +54,10 @@ function Entries({ data, path }: { data: NonNullable<ReturnType<typeof useAccess
<td> <td>
<span>{e.identity.name}</span> <span className="tag">{e.identity.kind}</span> <span>{e.identity.name}</span> <span className="tag">{e.identity.kind}</span>
</td> </td>
<td> <td data-label="Via policy">
<code>{e.policy}</code> <code>{e.policy}</code>
</td> </td>
<td> <td data-label="Can">
<CapabilityChips capabilities={e.capabilities} /> <CapabilityChips capabilities={e.capabilities} />
</td> </td>
</tr> </tr>
+18
View File
@@ -0,0 +1,18 @@
import { useSyncExternalStore } from 'react'
const QUERY = '(max-width: 40rem)'
const supported = () => typeof window !== 'undefined' && typeof window.matchMedia === 'function'
/** True on phone-width screens (matches the 40rem breakpoint in index.css). */
export function useNarrow(): boolean {
return useSyncExternalStore(
(onChange) => {
if (!supported()) return () => {}
const m = window.matchMedia(QUERY)
m.addEventListener('change', onChange)
return () => m.removeEventListener('change', onChange)
},
() => supported() && window.matchMedia(QUERY).matches,
() => false,
)
}
+90 -4
View File
@@ -998,6 +998,7 @@ dd {
} }
.chips li { .chips li {
white-space: nowrap;
padding: 0 var(--s2); padding: 0 var(--s2);
background: var(--accent-soft); background: var(--accent-soft);
color: var(--accent); color: var(--accent);
@@ -1230,17 +1231,101 @@ button.primary:hover:not(:disabled) {
} }
} }
.graph-hint {
display: none;
}
@media (max-width: 40rem) { @media (max-width: 40rem) {
/* Wide tables scroll sideways inside themselves rather than widening the page. */ /*
table { * Tables become stacked cards: the first cell is the title, other cells show their column name
* (from data-label) above the value, and row actions sit underneath instead of off the edge.
*/
table,
tbody,
tr,
td {
display: block; display: block;
overflow-x: auto; }
table {
overflow: visible;
}
thead {
display: none;
}
tr {
padding: var(--s3) var(--s4);
border-bottom: 1px solid var(--line);
}
tbody tr:last-child {
border-bottom: 0;
}
td {
padding: var(--s1) 0;
border: 0;
}
td[data-label]::before {
content: attr(data-label);
display: block;
color: var(--ink-faint);
font-size: var(--text-sm);
}
td:last-child:has(button) {
display: flex;
flex-wrap: wrap;
gap: var(--s2);
padding-top: var(--s2);
text-align: left;
}
td:last-child button + button {
margin-left: 0;
}
/* Five nav items have to fit on one line. */
.shell > nav {
gap: 0;
padding: 0 var(--s2);
}
.shell > nav strong {
margin-right: var(--s2);
}
.shell > nav a {
padding: var(--s3) var(--s2);
font-size: var(--text-sm);
} }
.shell > nav .whoami { .shell > nav .whoami {
display: none; display: none;
} }
/* Less nested padding so cards inside cards keep their width. */
form,
.secret-detail {
padding: var(--s4);
}
.access-head {
padding: var(--s3) var(--s4);
}
.access-body {
padding: var(--s3);
}
.graph-hint {
display: list-item;
list-style: none;
}
.graph-toolbar label:not(.check), .graph-toolbar label:not(.check),
.graph-toolbar input:not([type='checkbox']) { .graph-toolbar input:not([type='checkbox']) {
width: 100%; width: 100%;
@@ -1250,8 +1335,9 @@ button.primary:hover:not(:disabled) {
margin-left: 0; margin-left: 0;
} }
/* The legend is already most of a screen on a phone; drop the long note. */
.graph-legend .grow { .graph-legend .grow {
margin-left: 0; display: none;
} }
.access-head, .access-head,