}>)}
)}
);
}
export function RunCases({ id, waiting }: { id: string; waiting: boolean }) {
const gate = useGate(id, waiting);
const cases = useCases(id);
const approve = useApproveCases(id);
const g = waiting && gate.data?.gate === 'approve_cases' ? (gate.data as ApproveGate) : null;
const [sel, setSel] = useState>(new Set());
const [comments, setComments] = useState>({});
const [preview, setPreview] = useState(null);
const pendingIds = useMemo(() => g?.pending.map((p) => p.id) ?? [], [g]);
useEffect(() => setSel(new Set(pendingIds)), [pendingIds]);
const submit = (approved: string[]) => {
const rejected = pendingIds.filter((i) => !approved.includes(i));
const cm = Object.fromEntries(Object.entries(comments).filter(([, v]) => v.trim()));
approve.mutate({ approved, rejected, comments: cm });
};
return (
{g && (
Approval gate: {g.pending.length} case(s) need a decision
{g.policy === 'L0' ? 'Every new or changed case needs a person to approve it.' : `Approval level ${g.policy}: some cases were approved automatically because this business area has a proven track record.`}
{g.auto_approved.length ? ` Approved automatically: ${g.auto_approved.join(', ')}.` : ''} Untick a case to skip it in this run.
Approving library cases rewrites their YAML approval_status line and commits it to library.git under your user. Unselected cases are rejected and deferred.
0} indeterminate={sel.size > 0 && sel.size < pendingIds.length}
onChange={(e) => setSel(e.currentTarget.checked ? new Set(pendingIds) : new Set())} />CaseBusiness areaPriorityOriginWhyComment
{g.pending.map((p) => (
{ const on = e.currentTarget.checked; setSel((s) => { const n = new Set(s); if (on) n.add(p.id); else n.delete(p.id); return n; }); }} />{p.id}{p.title}{p.module}{p.priority}{p.origin}{[p.new_or_changed && 'new/changed', p.changed_by_patch && 'touched by patch', p.origin === 'generated' && 'generated draft'].filter(Boolean).join(', ')} { const v = e.currentTarget.value; setComments((c) => ({ ...c, [p.id]: v })); }} />
))}
Your role cannot answer this gate (consultant or admin required).}>
{approve.isSuccess && Answer recorded; the run resumes.}
)}
setPreview(null)} />
{cases.data && (
In scope ({cases.data.test_cases.length}) / deferred ({cases.data.deferred.length})