UI: signed-out menu and landing, form checkbox layout, Secrets header

The menu shows only Connect while signed out and the section links
once signed in; / goes to Connect or Identities accordingly. Yes/no
settings in the engine forms put the box beside its text. The Secrets
page now has New secrets engine on its own line, then a labelled engine
picker with Settings and Delete beside it, then the breadcrumbs, and
dynamic engines use the full width.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
mattandClaude Sonnet 5.5 committed 2026-11-09 14:47:31 +00:00
1 parent 58b6230f9b
commit d488bb42cc
11 files changed
+235 -88

No files matched your search

+2 -1
View File
@@ -13,7 +13,8 @@ function Field({ field, value, onChange }: { field: FieldDef; value: string | bo
if (field.type === 'bool') {
return (
<label>
// "check" lays the box beside its text; a plain label in a form stacks them.
<label className="check">
<input type="checkbox" checked={value === true} onChange={(e) => onChange(e.target.checked)} aria-describedby={describedBy} />{' '}
{field.label}
</label>
+8
View File
@@ -121,3 +121,11 @@ test('shows an empty state and the load error', async () => {
renderPanel('ssh')
expect(await screen.findByText('No roles yet.')).toBeInTheDocument()
})
test('yes/no settings lay the box beside its text (the "check" label), not stacked above it', async () => {
renderPanel('ssh')
const user = userEvent.setup()
await user.click(await screen.findByRole('button', { name: 'New role' }))
const box = screen.getByLabelText('Allow user certificates')
expect(box.closest('label')).toHaveClass('check')
})
+36 -4
View File
@@ -148,7 +148,7 @@ test('groups mounts by engine and shows the engine view for a dynamic mount', as
)
const user = userEvent.setup()
await user.click(screen.getByRole('button', { name: 'go' }))
const select = await screen.findByLabelText('Mount')
const select = await screen.findByLabelText('Secrets engine')
expect(within(select).getByRole('group', { name: 'KV' })).toBeInTheDocument()
expect(within(select).getByRole('group', { name: 'Database' })).toBeInTheDocument()
expect(within(select).queryByText('cubbyhole/')).not.toBeInTheDocument()
@@ -202,7 +202,7 @@ test('creating an engine selects it', async () => {
vi.spyOn(BaoClient.prototype, 'list').mockResolvedValue([])
await user.click(screen.getByRole('button', { name: 'Create' }))
expect(await screen.findByRole('heading', { name: /SSH · hosts\// })).toBeInTheDocument()
expect(screen.getByLabelText('Mount')).toHaveValue('hosts/')
expect(screen.getByLabelText('Secrets engine')).toHaveValue('hosts/')
})
test('Settings opens the selected mount\'s settings, and toggles closed', async () => {
@@ -223,7 +223,7 @@ test('deleting the selected engine falls back to another', async () => {
vi.mocked(mountsApi.deleteMount).mockResolvedValue()
vi.spyOn(BaoClient.prototype, 'list').mockResolvedValue([])
const user = await openPage()
await user.selectOptions(await screen.findByLabelText('Mount'), 'hosts/')
await user.selectOptions(await screen.findByLabelText('Secrets engine'), 'hosts/')
await user.click(screen.getByRole('button', { name: 'Delete' }))
expect(await screen.findByRole('alertdialog', { name: 'Delete hosts/' })).toBeInTheDocument()
vi.mocked(api.listMounts).mockResolvedValue([{ path: 'secret/', type: 'kv', version: '2' }])
@@ -244,10 +244,42 @@ test('switching mounts closes an open delete panel', async () => {
const user = await openPage()
await user.click(await screen.findByRole('button', { name: 'Delete' }))
expect(await screen.findByRole('alertdialog', { name: 'Delete secret/' })).toBeInTheDocument()
await user.selectOptions(screen.getByLabelText('Mount'), 'hosts/')
await user.selectOptions(screen.getByLabelText('Secrets engine'), 'hosts/')
expect(screen.queryByRole('alertdialog')).not.toBeInTheDocument()
})
test('lays out New, then the labelled engine picker with Settings and Delete, then the breadcrumbs', async () => {
await openPage()
const newButton = await screen.findByRole('button', { name: 'New secrets engine' })
const select = screen.getByLabelText('Secrets engine') // a single engine still gets its picker, so the bar looks the same
const settings = screen.getByRole('button', { name: 'Settings' })
const del = screen.getByRole('button', { name: 'Delete' })
const crumbs = screen.getByRole('navigation', { name: 'Path' })
// Settings and Delete share the picker's line
const bar = select.closest('.mount-bar')!
expect(bar).toContainElement(settings)
expect(bar).toContainElement(del)
expect(bar).not.toContainElement(newButton)
expect(bar).not.toContainElement(crumbs)
// top to bottom: New, the bar, then the breadcrumbs
const before = (a: Element, b: Element) => Boolean(a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING)
expect(before(newButton, select)).toBe(true)
expect(before(bar, crumbs)).toBe(true)
expect(screen.getByRole('button', { name: 'secret/' }).closest('nav')).toBe(crumbs)
})
test('a dynamic engine uses the full width, with the same header', async () => {
vi.mocked(api.listMounts).mockResolvedValue([{ path: 'hosts/', type: 'ssh' }])
vi.spyOn(BaoClient.prototype, 'list').mockResolvedValue([])
await openPage()
expect(await screen.findByLabelText('Secrets engine')).toHaveValue('hosts/')
expect(screen.getByRole('button', { name: 'Settings' })).toBeInTheDocument()
expect(screen.queryByRole('navigation', { name: 'Path' })).not.toBeInTheDocument()
expect(document.querySelector('.secrets-layout')).toBeNull()
})
test('asks to connect first', () => {
render(
<QueryClientProvider client={new QueryClient()}>
+66 -64
View File
@@ -1,5 +1,5 @@
import { useQuery } from '@tanstack/react-query'
import { useState } from 'react'
import { useId, useState } from 'react'
import type { BaoClient } from '../../api/bao'
import { engineFor, mountKind, mountTypeFor } from '../../api/engines/registry'
import { listSecrets } from '../../api/secrets'
@@ -12,6 +12,7 @@ import { MountDialog } from './MountDialog'
function Browser({ client }: { client: BaoClient }) {
const mounts = useMounts(client)
const selectId = useId()
const [mountChoice, setMount] = useState<string | null>(null)
const [prefix, setPrefix] = useState('')
const [selected, setSelected] = useState<string | null>(null)
@@ -37,21 +38,11 @@ function Browser({ client }: { client: BaoClient }) {
const existing = mounts.data.map((m) => m.path)
const closeDialog = () => setDialog(null)
const manage = (
<div className="mount-actions">
const newButton = (
<div className="mount-new">
<button type="button" onClick={() => setDialog(dialog === 'create' ? null : 'create')} aria-expanded={dialog === 'create'}>
New secrets engine
</button>
{current && mountTypeFor(current) && (
<button type="button" onClick={() => setDialog(dialog === 'edit' ? null : 'edit')} aria-expanded={dialog === 'edit'}>
Settings
</button>
)}
{current && (
<button type="button" onClick={() => setDialog(dialog === 'delete' ? null : 'delete')} aria-expanded={dialog === 'delete'}>
Delete
</button>
)}
</div>
)
const dialogs = dialog === 'delete' && current ? (
@@ -90,7 +81,7 @@ function Browser({ client }: { client: BaoClient }) {
return (
<>
<p>No secrets engines are mounted.</p>
{manage}
{newButton}
{dialogs}
</>
)
@@ -99,70 +90,81 @@ function Browser({ client }: { client: BaoClient }) {
const where = prefix ? `${mount}${prefix}` : mount
const kv = mounts.data.filter((m) => mountKind(m) === 'kv')
const dynamic = mounts.data.filter((m) => mountKind(m) === 'dynamic')
const mountSelect = mounts.data.length > 1 && (
<select
aria-label="Mount"
value={mount}
onChange={(e) => {
setMount(e.target.value)
go('')
// A settings or delete panel belongs to the mount it was opened for.
setDialog(null)
}}
>
{kv.length > 0 && (
<optgroup label="KV">
{kv.map((m) => (
<option key={m.path}>{m.path}</option>
))}
</optgroup>
)}
{[...new Set(dynamic.map((m) => m.type))].map((type) => (
<optgroup key={type} label={engineFor(type).label}>
{dynamic
.filter((m) => m.type === type)
.map((m) => (
<option key={m.path}>{m.path}</option>
// New engine on its own line; then the engine picker with what you can do to it; then (for KV) where you are in it.
const header = (
<>
{newButton}
<div className="mount-bar">
<div className="mount-pick">
<label htmlFor={selectId}>Secrets engine</label>
<select
id={selectId}
value={mount}
onChange={(e) => {
setMount(e.target.value)
go('')
// A settings or delete panel belongs to the mount it was opened for.
setDialog(null)
}}
>
{kv.length > 0 && (
<optgroup label="KV">
{kv.map((m) => (
<option key={m.path}>{m.path}</option>
))}
</optgroup>
)}
{[...new Set(dynamic.map((m) => m.type))].map((type) => (
<optgroup key={type} label={engineFor(type).label}>
{dynamic
.filter((m) => m.type === type)
.map((m) => (
<option key={m.path}>{m.path}</option>
))}
</optgroup>
))}
</optgroup>
))}
</select>
</select>
</div>
<div className="mount-actions">
{mountTypeFor(current) && (
<button type="button" onClick={() => setDialog(dialog === 'edit' ? null : 'edit')} aria-expanded={dialog === 'edit'}>
Settings
</button>
)}
<button type="button" onClick={() => setDialog(dialog === 'delete' ? null : 'delete')} aria-expanded={dialog === 'delete'}>
Delete
</button>
</div>
</div>
{dialogs}
</>
)
if (!isKv) {
return (
<>
{manage}
{dialogs}
<div className="secrets-layout">
<div className="secrets-browser">
<nav aria-label="Path" className="crumbs">
{mountSelect}
</nav>
</div>
<EngineView client={client} mount={current} />
</div>
{header}
<EngineView client={client} mount={current} />
</>
)
}
return (
<>
{manage}
{dialogs}
{header}
<nav aria-label="Path" className="crumbs">
<button type="button" onClick={() => go('')}>
{mount}
</button>
{crumbs.map((c, i) => (
<button key={i} type="button" onClick={() => go(crumbs.slice(0, i + 1).join('/') + '/')}>
{c}/
</button>
))}
</nav>
<div className="secrets-layout">
<div className="secrets-browser">
<nav aria-label="Path" className="crumbs">
{mountSelect}
<button type="button" onClick={() => go('')}>
{mount}
</button>
{crumbs.map((c, i) => (
<button key={i} type="button" onClick={() => go(crumbs.slice(0, i + 1).join('/') + '/')}>
{c}/
</button>
))}
</nav>
{entries.isPending && <p className="hint">Loading…</p>}
{entries.error && <p role="alert">{entries.error.message}</p>}
{entries.data?.length === 0 && <p className="hint">No secrets in {where} yet.</p>}