Adds a Leases tab that walks sys/leases/lookup under the mount, shows a lease's timings on demand, renews renewable leases, and revokes one lease or everything under a prefix after confirmation. Covered by unit tests and an ssh OTP integration test. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
40 lines
1.6 KiB
TypeScript
40 lines
1.6 KiB
TypeScript
import { useState } from 'react'
|
|
import type { BaoClient } from '../../api/bao'
|
|
import { engineFor } from '../../api/engines/registry'
|
|
import type { Mount } from '../../api/secrets'
|
|
import { ConfigPanel } from './ConfigPanel'
|
|
import { LeasesPanel } from './LeasesPanel'
|
|
import { RolesPanel } from './RolesPanel'
|
|
|
|
type Tab = 'roles' | 'config' | 'leases'
|
|
|
|
/** Roles, Config and Leases for a dynamic secrets engine. */
|
|
export function EngineView({ client, mount }: { client: BaoClient; mount: Mount }) {
|
|
const engine = engineFor(mount.type)
|
|
const [tab, setTab] = useState<Tab>('roles')
|
|
const tabs: { id: Tab; label: string }[] = [{ id: 'roles', label: 'Roles' }]
|
|
if (engine.configs.length > 0) tabs.push({ id: 'config', label: 'Config' })
|
|
tabs.push({ id: 'leases', label: 'Leases' })
|
|
const current = tabs.some((t) => t.id === tab) ? tab : 'roles'
|
|
|
|
return (
|
|
<div className="engine-view">
|
|
<h2>
|
|
{engine.label} · {mount.path}
|
|
</h2>
|
|
{tabs.length > 1 && (
|
|
<div role="tablist" aria-label="Engine" className="tabs">
|
|
{tabs.map((t) => (
|
|
<button key={t.id} type="button" role="tab" aria-selected={t.id === current} onClick={() => setTab(t.id)}>
|
|
{t.label}
|
|
</button>
|
|
))}
|
|
</div>
|
|
)}
|
|
{current === 'roles' && <RolesPanel key={mount.path} client={client} mount={mount.path} engine={engine} />}
|
|
{current === 'leases' && <LeasesPanel key={mount.path} client={client} mount={mount.path} />}
|
|
{current === 'config' && <ConfigPanel key={mount.path} client={client} mount={mount.path} engine={engine} />}
|
|
</div>
|
|
)
|
|
}
|