Polish pass: identity forms, confirm dialogs, policy chips, merged grants, narrow screens
- Tokens: bigger show-once token with primary Copy; warn when no policies are selected (OpenBao then inherits the creator's policies). - Identity forms get headings, wider cards and two-column policy lists. - Replace window.confirm with an in-app confirm dialog (falls back to window.confirm without a provider). - Show policies, aliases and members as chips in the identity tables. - Access panel: one row per secret instead of separate data/metadata rules. - Stack graph details below 60rem; phone-width rules for tables, nav, toolbar. - New favicon and page title; label the root "*" path as "everything". Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d67a9c9b62
commit
0a2054eb41
19 files changed
+551
-67
No files matched your search
@@ -5,6 +5,8 @@ import { addAlias, deleteAlias, deleteEntity, listEntities, saveEntity, userpass
|
||||
import { AccessEditor } from '../access/AccessEditor'
|
||||
import { ListState } from '../shared/ListState'
|
||||
import { PolicyPicker } from '../shared/PolicyPicker'
|
||||
import { useConfirm } from '../shared/useConfirm'
|
||||
import { NameChips, PolicyChips } from '../shared/PolicyChips'
|
||||
|
||||
interface Draft {
|
||||
name: string
|
||||
@@ -15,6 +17,7 @@ interface Draft {
|
||||
|
||||
export function EntitiesTab({ client }: { client: BaoClient }) {
|
||||
const qc = useQueryClient()
|
||||
const confirm = useConfirm()
|
||||
const entities = useQuery({ queryKey: ['entities'], queryFn: () => listEntities(client) })
|
||||
const [draft, setDraft] = useState<Draft | null>(null)
|
||||
const [accessFor, setAccessFor] = useState<string | null>(null)
|
||||
@@ -71,19 +74,26 @@ export function EntitiesTab({ client }: { client: BaoClient }) {
|
||||
{entities.data?.map((e) => (
|
||||
<tr key={e.id}>
|
||||
<td>{e.name}</td>
|
||||
<td>{e.aliases.map((a) => a.name).join(', ') || '—'}</td>
|
||||
<td>{e.policies.join(', ') || '—'}</td>
|
||||
<td>
|
||||
<NameChips names={e.aliases.map((a) => a.name)} />
|
||||
</td>
|
||||
<td>
|
||||
<PolicyChips policies={e.policies} />
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" aria-label={`Access ${e.name}`} onClick={() => setAccessFor(e.name)}>
|
||||
Access
|
||||
</button>{' '}
|
||||
</button>
|
||||
<button type="button" aria-label={`Edit ${e.name}`} onClick={() => setDraft({ name: e.name, policies: e.policies, isNew: false, entity: e })}>
|
||||
Edit
|
||||
</button>{' '}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
aria-label={`Delete ${e.name}`}
|
||||
onClick={() => window.confirm(`Delete entity "${e.name}" and its aliases?`) && remove.mutate(e.name)}
|
||||
onClick={async () => {
|
||||
if (await confirm({ title: `Delete entity “${e.name}”?`, message: 'Its aliases are deleted too. This cannot be undone.', confirmLabel: 'Delete' }))
|
||||
remove.mutate(e.name)
|
||||
}}
|
||||
>
|
||||
Delete
|
||||
</button>
|
||||
@@ -107,10 +117,10 @@ export function EntitiesTab({ client }: { client: BaoClient }) {
|
||||
</label>
|
||||
<PolicyPicker client={client} value={draft.policies} onChange={(policies) => setDraft({ ...draft, policies })} />
|
||||
{save.error && <p role="alert">{save.error.message}</p>}
|
||||
<div>
|
||||
<div className="form-actions">
|
||||
<button type="submit" disabled={save.isPending}>
|
||||
Save
|
||||
</button>{' '}
|
||||
</button>
|
||||
<button type="button" onClick={() => setDraft(null)}>
|
||||
Cancel
|
||||
</button>
|
||||
@@ -121,7 +131,13 @@ export function EntitiesTab({ client }: { client: BaoClient }) {
|
||||
{draft.entity.aliases.map((a) => (
|
||||
<div key={a.id}>
|
||||
{a.name}{' '}
|
||||
<button type="button" onClick={() => window.confirm(`Remove alias "${a.name}"?`) && detach.mutate(a.id)}>
|
||||
<button
|
||||
type="button"
|
||||
onClick={async () => {
|
||||
if (await confirm({ title: `Remove alias “${a.name}”?`, message: 'The userpass user is no longer linked to this entity.', confirmLabel: 'Remove' }))
|
||||
detach.mutate(a.id)
|
||||
}}
|
||||
>
|
||||
Remove
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -5,6 +5,8 @@ import { deleteGroup, listEntities, listGroups, saveGroup } from '../../api/iden
|
||||
import { AccessEditor } from '../access/AccessEditor'
|
||||
import { ListState } from '../shared/ListState'
|
||||
import { PolicyPicker } from '../shared/PolicyPicker'
|
||||
import { useConfirm } from '../shared/useConfirm'
|
||||
import { NameChips, PolicyChips } from '../shared/PolicyChips'
|
||||
|
||||
interface Draft {
|
||||
name: string
|
||||
@@ -15,6 +17,7 @@ interface Draft {
|
||||
|
||||
export function GroupsTab({ client }: { client: BaoClient }) {
|
||||
const qc = useQueryClient()
|
||||
const confirm = useConfirm()
|
||||
const groups = useQuery({ queryKey: ['groups'], queryFn: () => listGroups(client) })
|
||||
const entities = useQuery({ queryKey: ['entities'], queryFn: () => listEntities(client) })
|
||||
const [draft, setDraft] = useState<Draft | null>(null)
|
||||
@@ -54,20 +57,26 @@ export function GroupsTab({ client }: { client: BaoClient }) {
|
||||
{groups.data?.map((g) => (
|
||||
<tr key={g.id}>
|
||||
<td>{g.name}</td>
|
||||
<td>{g.member_entity_ids.map(nameOf).join(', ') || '—'}</td>
|
||||
<td>{g.policies.join(', ') || '—'}</td>
|
||||
<td>
|
||||
<NameChips names={g.member_entity_ids.map(nameOf)} />
|
||||
</td>
|
||||
<td>
|
||||
<PolicyChips policies={g.policies} />
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" aria-label={`Access ${g.name}`} onClick={() => setAccessFor(g.name)}>
|
||||
Access
|
||||
</button>{' '}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
aria-label={`Edit ${g.name}`}
|
||||
onClick={() => setDraft({ name: g.name, policies: g.policies, members: g.member_entity_ids, isNew: false })}
|
||||
>
|
||||
Edit
|
||||
</button>{' '}
|
||||
<button type="button" aria-label={`Delete ${g.name}`} onClick={() => window.confirm(`Delete group "${g.name}"?`) && remove.mutate(g.name)}>
|
||||
</button>
|
||||
<button type="button" aria-label={`Delete ${g.name}`} onClick={async () => {
|
||||
if (await confirm({ title: `Delete group “${g.name}”?`, message: 'This cannot be undone.', confirmLabel: 'Delete' })) remove.mutate(g.name)
|
||||
}}>
|
||||
Delete
|
||||
</button>
|
||||
</td>
|
||||
@@ -88,7 +97,7 @@ export function GroupsTab({ client }: { client: BaoClient }) {
|
||||
Name
|
||||
<input value={draft.name} disabled={!draft.isNew} onChange={(e) => setDraft({ ...draft, name: e.target.value })} required />
|
||||
</label>
|
||||
<fieldset>
|
||||
<fieldset className="pick-grid">
|
||||
<legend>Member entities</legend>
|
||||
{entities.data?.map((e) => (
|
||||
<label key={e.id} className="check">
|
||||
@@ -106,10 +115,10 @@ export function GroupsTab({ client }: { client: BaoClient }) {
|
||||
</fieldset>
|
||||
<PolicyPicker client={client} value={draft.policies} onChange={(policies) => setDraft({ ...draft, policies })} />
|
||||
{save.error && <p role="alert">{save.error.message}</p>}
|
||||
<div>
|
||||
<div className="form-actions">
|
||||
<button type="submit" disabled={save.isPending}>
|
||||
Save
|
||||
</button>{' '}
|
||||
</button>
|
||||
<button type="button" onClick={() => setDraft(null)}>
|
||||
Cancel
|
||||
</button>
|
||||
|
||||
@@ -5,6 +5,8 @@ import { createToken, listTokens, revokeToken, type CreatedToken } from '../../a
|
||||
import { useSession } from '../../api/useSession'
|
||||
import { ListState } from '../shared/ListState'
|
||||
import { PolicyPicker } from '../shared/PolicyPicker'
|
||||
import { useConfirm } from '../shared/useConfirm'
|
||||
import { PolicyChips } from '../shared/PolicyChips'
|
||||
|
||||
interface Draft {
|
||||
displayName: string
|
||||
@@ -25,6 +27,7 @@ function formatTtl(seconds: number): string {
|
||||
|
||||
export function TokensTab({ client }: { client: BaoClient }) {
|
||||
const qc = useQueryClient()
|
||||
const confirm = useConfirm()
|
||||
const { tokenInfo } = useSession()
|
||||
const tokens = useQuery({ queryKey: ['tokens'], queryFn: () => listTokens(client) })
|
||||
const [draft, setDraft] = useState<Draft | null>(null)
|
||||
@@ -68,13 +71,15 @@ export function TokensTab({ client }: { client: BaoClient }) {
|
||||
<p>
|
||||
<strong>Copy this token now. It will not be shown again.</strong>
|
||||
</p>
|
||||
<code>{created.token}</code>{' '}
|
||||
<button type="button" onClick={copy}>
|
||||
{copied ? 'Copied' : 'Copy'}
|
||||
</button>{' '}
|
||||
<button type="button" onClick={() => setCreated(null)}>
|
||||
Done
|
||||
</button>
|
||||
<code className="token-value">{created.token}</code>
|
||||
<div className="form-actions">
|
||||
<button type="button" className="primary" onClick={copy}>
|
||||
{copied ? 'Copied' : 'Copy'}
|
||||
</button>
|
||||
<button type="button" onClick={() => setCreated(null)}>
|
||||
Done
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
<ListState query={tokens} empty="No tokens." />
|
||||
@@ -98,7 +103,9 @@ export function TokensTab({ client }: { client: BaoClient }) {
|
||||
{t.display_name || '—'}
|
||||
{isSelf ? ' (you)' : ''}
|
||||
</td>
|
||||
<td>{t.policies.join(', ') || '—'}</td>
|
||||
<td>
|
||||
<PolicyChips policies={t.policies} />
|
||||
</td>
|
||||
<td>{formatTtl(t.ttl)}</td>
|
||||
<td>
|
||||
<code>{t.accessor.slice(0, 8)}…</code>
|
||||
@@ -109,10 +116,14 @@ export function TokensTab({ client }: { client: BaoClient }) {
|
||||
aria-label={`Revoke ${t.display_name || t.accessor}`}
|
||||
disabled={isSelf}
|
||||
title={isSelf ? 'This is the token you are signed in with' : undefined}
|
||||
onClick={() =>
|
||||
window.confirm(`Revoke token "${t.display_name || t.accessor}"? Tokens created from it are revoked too.`) &&
|
||||
revoke.mutate(t.accessor)
|
||||
}
|
||||
onClick={async () => {
|
||||
const ok = await confirm({
|
||||
title: `Revoke token “${t.display_name || t.accessor}”?`,
|
||||
message: 'Tokens created from it are revoked too.',
|
||||
confirmLabel: 'Revoke',
|
||||
})
|
||||
if (ok) revoke.mutate(t.accessor)
|
||||
}}
|
||||
>
|
||||
Revoke
|
||||
</button>
|
||||
@@ -130,7 +141,8 @@ export function TokensTab({ client }: { client: BaoClient }) {
|
||||
</button>
|
||||
)}
|
||||
{draft && (
|
||||
<form onSubmit={submit} aria-label="New token">
|
||||
<form onSubmit={submit} aria-label="New token" className="wide">
|
||||
<h3>New token</h3>
|
||||
<label>
|
||||
Display name
|
||||
<input value={draft.displayName} onChange={(e) => setDraft({ ...draft, displayName: e.target.value })} />
|
||||
@@ -143,15 +155,23 @@ export function TokensTab({ client }: { client: BaoClient }) {
|
||||
<input type="checkbox" checked={draft.renewable} onChange={(e) => setDraft({ ...draft, renewable: e.target.checked })} /> Renewable
|
||||
</label>
|
||||
<label className="check">
|
||||
<input type="checkbox" checked={draft.orphan} onChange={(e) => setDraft({ ...draft, orphan: e.target.checked })} /> Orphan
|
||||
(outlives the token you are signed in with; requires sudo)
|
||||
<input type="checkbox" checked={draft.orphan} onChange={(e) => setDraft({ ...draft, orphan: e.target.checked })} />
|
||||
<span>
|
||||
Orphan <span className="hint">(outlives the token you are signed in with; requires sudo)</span>
|
||||
</span>
|
||||
</label>
|
||||
<PolicyPicker client={client} value={draft.policies} onChange={(policies) => setDraft({ ...draft, policies })} />
|
||||
{draft.policies.length === 0 && (
|
||||
<p className="note-warn">
|
||||
No policies selected: OpenBao gives the new token the same policies as yours
|
||||
{tokenInfo?.policies.length ? ` (${tokenInfo.policies.join(', ')})` : ''}.
|
||||
</p>
|
||||
)}
|
||||
{create.error && <p role="alert">{create.error.message}</p>}
|
||||
<div>
|
||||
<div className="form-actions">
|
||||
<button type="submit" disabled={create.isPending}>
|
||||
Create
|
||||
</button>{' '}
|
||||
</button>
|
||||
<button type="button" onClick={() => setDraft(null)}>
|
||||
Cancel
|
||||
</button>
|
||||
|
||||
@@ -5,6 +5,8 @@ import { deleteUser, listUsers, saveUser } from '../../api/identities'
|
||||
import { AccessEditor } from '../access/AccessEditor'
|
||||
import { ListState } from '../shared/ListState'
|
||||
import { PolicyPicker } from '../shared/PolicyPicker'
|
||||
import { useConfirm } from '../shared/useConfirm'
|
||||
import { PolicyChips } from '../shared/PolicyChips'
|
||||
|
||||
interface Draft {
|
||||
name: string
|
||||
@@ -18,6 +20,7 @@ const empty: Draft = { name: '', password: '', policies: [], ttl: '', isNew: tru
|
||||
|
||||
export function UsersTab({ client }: { client: BaoClient }) {
|
||||
const qc = useQueryClient()
|
||||
const confirm = useConfirm()
|
||||
const users = useQuery({ queryKey: ['users'], queryFn: () => listUsers(client) })
|
||||
const [draft, setDraft] = useState<Draft | null>(null)
|
||||
const [accessFor, setAccessFor] = useState<string | null>(null)
|
||||
@@ -55,18 +58,22 @@ export function UsersTab({ client }: { client: BaoClient }) {
|
||||
{users.data?.map((u) => (
|
||||
<tr key={u.name}>
|
||||
<td>{u.name}</td>
|
||||
<td>{u.policies.join(', ') || '—'}</td>
|
||||
<td>
|
||||
<PolicyChips policies={u.policies} />
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" aria-label={`Access ${u.name}`} onClick={() => setAccessFor(u.name)}>
|
||||
Access
|
||||
</button>{' '}
|
||||
</button>
|
||||
<button type="button" aria-label={`Edit ${u.name}`} onClick={() => setDraft({ ...u, password: '', ttl: u.ttl ? `${u.ttl}s` : '', isNew: false })}>
|
||||
Edit
|
||||
</button>{' '}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
aria-label={`Delete ${u.name}`}
|
||||
onClick={() => window.confirm(`Delete user "${u.name}"? This cannot be undone.`) && remove.mutate(u.name)}
|
||||
onClick={async () => {
|
||||
if (await confirm({ title: `Delete user “${u.name}”?`, message: 'This cannot be undone.', confirmLabel: 'Delete' })) remove.mutate(u.name)
|
||||
}}
|
||||
>
|
||||
Delete
|
||||
</button>
|
||||
@@ -105,10 +112,10 @@ export function UsersTab({ client }: { client: BaoClient }) {
|
||||
</label>
|
||||
<PolicyPicker client={client} value={draft.policies} onChange={(policies) => setDraft({ ...draft, policies })} />
|
||||
{save.error && <p role="alert">{save.error.message}</p>}
|
||||
<div>
|
||||
<div className="form-actions">
|
||||
<button type="submit" disabled={save.isPending}>
|
||||
Save
|
||||
</button>{' '}
|
||||
</button>
|
||||
<button type="button" onClick={() => setDraft(null)}>
|
||||
Cancel
|
||||
</button>
|
||||
|
||||
Reference in new issue
Block a user