diff --git a/src/features/graph/Details.tsx b/src/features/graph/Details.tsx index 1482add..bf6ccd3 100644 --- a/src/features/graph/Details.tsx +++ b/src/features/graph/Details.tsx @@ -3,6 +3,7 @@ import type { BaoClient } from '../../api/bao' import { revokeAccess } from '../../api/grants' import type { AccessGraph, GraphEdge, GraphNode, PolicyInput } from '../../model/graph' import { parseManagedPolicy, type GrantTarget } from '../../model/managed' +import { CapabilityChips } from '../shared/CapabilityChips' export type Selection = { kind: 'node'; id: string } | { kind: 'edge'; id: string } @@ -17,65 +18,125 @@ interface Props { const nodeById = (g: AccessGraph, id: string) => g.nodes.find((n) => n.id === id) const label = (n: GraphNode | undefined) => n?.label ?? '?' +/** An identity's name with its kind, so "alice" the user and "alice" the entity read differently. */ +function Who({ node }: { node: GraphNode | undefined }) { + return ( + <> + {label(node)} + {node?.type === 'identity' && {node.kind}} + > + ) +} + +function Warnings({ items }: { items: string[] | undefined }) { + return items?.map((w) => ( +
+ {w} +
+ )) +} + function NodeDetails({ node, full, policies }: { node: GraphNode; full: AccessGraph; policies: PolicyInput[] }) { const out = full.edges.filter((e) => e.source === node.id) const into = full.edges.filter((e) => e.target === node.id) - const caps = (e: GraphEdge) => (e.capabilities?.length ? ` (${e.capabilities.join(', ')})` : '') if (node.type === 'identity') { return ( <> -{node.kind}
+- {node.missing ? 'Attached but does not exist.' : node.managed ? 'Managed by EnvBao.' : 'Not managed by EnvBao (read-only).'} -
- {node.warnings.length > 0 && ( -{label(nodeById(full, e.target))}
+ No policies attached.
)} -{label(nodeById(full, e.target))}
- {caps(e)}
- {hcl}}
>
)
}
+
+ if (node.type === 'policy') {
+ const hcl = policies.find((p) => p.name === node.label)?.hcl
+ const status = node.missing ? 'Attached but does not exist' : node.managed ? 'Managed by EnvBao' : 'Not managed by EnvBao (read-only)'
+ return (
+ <>
+ {status}.
+Not attached to anything.
+ )} +{label(nodeById(full, e.target))}
+ {e.capabilities && No grants.
+ )} + {hcl && ( +{hcl}
+ {node.label}
- {node.label}
+ {label(nodeById(full, e.source))}
+ {e.capabilities && No identity uses this policy.
+ )}Capabilities: {edge.capabilities.join(', ')}
} - {edge.warnings?.map((w) =>⚠ {w}
)} +
+ {label(to)}
+