feat: M11b — ownership tracking, agent groups, interactive renewal approval

Ownership: owners/teams GUI pages, notification email resolution via
resolveRecipient (owner_id → owner.email lookup). Agent groups: dynamic
device grouping by OS/arch/IP CIDR/version with manual include/exclude
membership, migration 000004, full CRUD stack (domain → repo → service →
handler → frontend). Interactive approval: AwaitingApproval job state,
approve/reject API endpoints with reason tracking. Tests: 12 agent group
handler tests, 8 approve/reject job handler tests, integration tests
updated for 13-param RegisterHandlers. Docs updated across architecture,
concepts, and seed data.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Shankar
2026-03-20 21:02:35 -04:00
parent 1ef16984eb
commit e445cbef22
27 changed files with 1774 additions and 21 deletions
+94
View File
@@ -0,0 +1,94 @@
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
import { getAgentGroups, deleteAgentGroup } from '../api/client';
import PageHeader from '../components/PageHeader';
import DataTable from '../components/DataTable';
import type { Column } from '../components/DataTable';
import StatusBadge from '../components/StatusBadge';
import ErrorState from '../components/ErrorState';
import { formatDateTime } from '../api/utils';
import type { AgentGroup } from '../api/types';
export default function AgentGroupsPage() {
const queryClient = useQueryClient();
const { data, isLoading, error, refetch } = useQuery({
queryKey: ['agent-groups'],
queryFn: () => getAgentGroups(),
});
const deleteMutation = useMutation({
mutationFn: deleteAgentGroup,
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['agent-groups'] }),
});
const columns: Column<AgentGroup>[] = [
{
key: 'name',
label: 'Group',
render: (g) => (
<div>
<div className="font-medium text-slate-200">{g.name}</div>
<div className="text-xs text-slate-500 font-mono">{g.id}</div>
{g.description && (
<div className="text-xs text-slate-400 mt-0.5 max-w-xs truncate">{g.description}</div>
)}
</div>
),
},
{
key: 'criteria',
label: 'Match Criteria',
render: (g) => {
const criteria: string[] = [];
if (g.match_os) criteria.push(`OS: ${g.match_os}`);
if (g.match_architecture) criteria.push(`Arch: ${g.match_architecture}`);
if (g.match_ip_cidr) criteria.push(`IP: ${g.match_ip_cidr}`);
if (g.match_version) criteria.push(`Ver: ${g.match_version}`);
return criteria.length > 0 ? (
<div className="flex flex-wrap gap-1">
{criteria.map((c, i) => (
<span key={i} className="badge badge-neutral text-xs">{c}</span>
))}
</div>
) : (
<span className="text-slate-500 text-xs">Manual only</span>
);
},
},
{
key: 'enabled',
label: 'Status',
render: (g) => <StatusBadge status={g.enabled ? 'active' : 'disabled'} />,
},
{
key: 'created',
label: 'Created',
render: (g) => <span className="text-xs text-slate-400">{formatDateTime(g.created_at)}</span>,
},
{
key: 'actions',
label: '',
render: (g) => (
<button
onClick={(e) => { e.stopPropagation(); if (confirm(`Delete group ${g.name}?`)) deleteMutation.mutate(g.id); }}
className="text-xs text-red-400 hover:text-red-300 transition-colors"
>
Delete
</button>
),
},
];
return (
<>
<PageHeader title="Agent Groups" subtitle={data ? `${data.total} groups` : undefined} />
<div className="flex-1 overflow-y-auto">
{error ? (
<ErrorState error={error as Error} onRetry={() => refetch()} />
) : (
<DataTable columns={columns} data={data?.data || []} isLoading={isLoading} emptyMessage="No agent groups configured" />
)}
</div>
</>
);
}
+88
View File
@@ -0,0 +1,88 @@
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
import { getOwners, getTeams, deleteOwner } from '../api/client';
import PageHeader from '../components/PageHeader';
import DataTable from '../components/DataTable';
import type { Column } from '../components/DataTable';
import ErrorState from '../components/ErrorState';
import { formatDateTime } from '../api/utils';
import type { Owner, Team } from '../api/types';
export default function OwnersPage() {
const queryClient = useQueryClient();
const { data, isLoading, error, refetch } = useQuery({
queryKey: ['owners'],
queryFn: () => getOwners(),
});
const { data: teamsData } = useQuery({
queryKey: ['teams'],
queryFn: () => getTeams(),
});
const deleteMutation = useMutation({
mutationFn: deleteOwner,
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['owners'] }),
});
const teamMap = new Map<string, Team>();
(teamsData?.data || []).forEach((t) => teamMap.set(t.id, t));
const columns: Column<Owner>[] = [
{
key: 'name',
label: 'Owner',
render: (o) => (
<div>
<div className="font-medium text-slate-200">{o.name}</div>
<div className="text-xs text-slate-500 font-mono">{o.id}</div>
</div>
),
},
{
key: 'email',
label: 'Email',
render: (o) => <span className="text-slate-300">{o.email || '\u2014'}</span>,
},
{
key: 'team',
label: 'Team',
render: (o) => {
const team = teamMap.get(o.team_id);
return team
? <span className="text-blue-400">{team.name}</span>
: <span className="text-slate-500 font-mono text-xs">{o.team_id || '\u2014'}</span>;
},
},
{
key: 'created',
label: 'Created',
render: (o) => <span className="text-xs text-slate-400">{formatDateTime(o.created_at)}</span>,
},
{
key: 'actions',
label: '',
render: (o) => (
<button
onClick={(e) => { e.stopPropagation(); if (confirm(`Delete owner ${o.name}?`)) deleteMutation.mutate(o.id); }}
className="text-xs text-red-400 hover:text-red-300 transition-colors"
>
Delete
</button>
),
},
];
return (
<>
<PageHeader title="Owners" subtitle={data ? `${data.total} owners` : undefined} />
<div className="flex-1 overflow-y-auto">
{error ? (
<ErrorState error={error as Error} onRetry={() => refetch()} />
) : (
<DataTable columns={columns} data={data?.data || []} isLoading={isLoading} emptyMessage="No owners configured" />
)}
</div>
</>
);
}
+72
View File
@@ -0,0 +1,72 @@
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
import { getTeams, deleteTeam } from '../api/client';
import PageHeader from '../components/PageHeader';
import DataTable from '../components/DataTable';
import type { Column } from '../components/DataTable';
import ErrorState from '../components/ErrorState';
import { formatDateTime } from '../api/utils';
import type { Team } from '../api/types';
export default function TeamsPage() {
const queryClient = useQueryClient();
const { data, isLoading, error, refetch } = useQuery({
queryKey: ['teams'],
queryFn: () => getTeams(),
});
const deleteMutation = useMutation({
mutationFn: deleteTeam,
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['teams'] }),
});
const columns: Column<Team>[] = [
{
key: 'name',
label: 'Team',
render: (t) => (
<div>
<div className="font-medium text-slate-200">{t.name}</div>
<div className="text-xs text-slate-500 font-mono">{t.id}</div>
</div>
),
},
{
key: 'description',
label: 'Description',
render: (t) => (
<span className="text-slate-300 text-sm max-w-sm truncate block">{t.description || '\u2014'}</span>
),
},
{
key: 'created',
label: 'Created',
render: (t) => <span className="text-xs text-slate-400">{formatDateTime(t.created_at)}</span>,
},
{
key: 'actions',
label: '',
render: (t) => (
<button
onClick={(e) => { e.stopPropagation(); if (confirm(`Delete team ${t.name}?`)) deleteMutation.mutate(t.id); }}
className="text-xs text-red-400 hover:text-red-300 transition-colors"
>
Delete
</button>
),
},
];
return (
<>
<PageHeader title="Teams" subtitle={data ? `${data.total} teams` : undefined} />
<div className="flex-1 overflow-y-auto">
{error ? (
<ErrorState error={error as Error} onRetry={() => refetch()} />
) : (
<DataTable columns={columns} data={data?.data || []} isLoading={isLoading} emptyMessage="No teams configured" />
)}
</div>
</>
);
}