import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query' import { useId, useState, type FormEvent } from 'react' import type { BaoClient } from '../../api/bao' import { engineFor } from '../../api/engines/registry' import { deleteMount, mountImpact, type MountImpact } from '../../api/mounts' import type { Mount } from '../../api/secrets' import { policiesReferencing } from '../../model/mounts' import { useAccessInputs } from '../shared/useAccessInputs' import { NameChips } from '../shared/PolicyChips' const plural = (n: number, one: string, many = `${one}s`) => `${n} ${n === 1 ? one : many}` function Consequences({ mount, impact }: { mount: Mount; impact: MountImpact }) { if (impact.kind === 'kv') { return (
Every secret stored in {mount.path}, with all of its versions, will be permanently deleted
{impact.topLevelEntries !== undefined && <> (at least {plural(impact.topLevelEntries, 'entry', 'entries')} at the top level)>}.
The {engineFor(mount.type).label} engine at {mount.path} will be permanently deleted
{impact.roles !== undefined && <>, with its {plural(impact.roles, 'role')} and its configuration>}.
{impact.hasLeases ? ' Every lease it has issued will be revoked, so credentials already handed out stop working.' : ''}
Checking what is in it…
} {impact.error &&{impact.error.message}
} {impact.data &&Could not count {impact.data.unknown.join(', ')}, so there may be more than shown.
)}This cannot be undone.
{referencing.length > 0 && ( <>{plural(referencing.length, 'policy', 'policies')} grant{referencing.length === 1 ? 's' : ''} access under this mount. They are not changed, and will point at nothing:
Could not check which policies refer to this mount: {access.error.message}
}