mirror of
https://github.com/shankar0123/certctl.git
synced 2026-06-14 11:38:53 +00:00
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:
@@ -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>
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user