121 lines
6.9 KiB
TypeScript
121 lines
6.9 KiB
TypeScript
import { router } from '@inertiajs/react';
|
|
import { useState } from 'react';
|
|
|
|
interface Proposal {
|
|
id: number;
|
|
scope: string;
|
|
target: string;
|
|
doctor_execution_id: string;
|
|
evidence_hash: string;
|
|
command: string;
|
|
arguments_json: string;
|
|
risk_level: string;
|
|
rollback: string;
|
|
status: string;
|
|
created_by: string;
|
|
created_at: string;
|
|
}
|
|
|
|
export default function ProposalPage({ proposal }: { proposal: Proposal }) {
|
|
const [submitting, setSubmitting] = useState(false);
|
|
const [confirmed, setConfirmed] = useState(false);
|
|
const [executionConfirmed, setExecutionConfirmed] = useState(false);
|
|
|
|
function approve() {
|
|
setSubmitting(true);
|
|
router.post(`/proposals/${proposal.id}/approval`, {}, { onFinish: () => setSubmitting(false) });
|
|
}
|
|
|
|
function execute() {
|
|
setSubmitting(true);
|
|
router.post(`/proposals/${proposal.id}/execution`, {}, { onFinish: () => setSubmitting(false) });
|
|
}
|
|
|
|
return (
|
|
<main className="min-h-screen bg-[#071019] px-5 py-8 text-slate-100">
|
|
<div className="mx-auto max-w-4xl">
|
|
<a href={`/incidents/${proposal.scope}/${proposal.target}`} className="text-xs text-cyan-300">
|
|
← Incident evidence
|
|
</a>
|
|
<section className="mt-6 overflow-hidden rounded-3xl border border-violet-300/20 bg-[#0a141e]">
|
|
<div className="border-b border-white/10 p-7">
|
|
<p className="text-xs uppercase tracking-[0.2em] text-violet-200">Durable proposal #{proposal.id}</p>
|
|
<h1 className="mt-3 text-3xl font-semibold">{proposal.scope} / {proposal.target}</h1>
|
|
<p className="mt-3 font-mono text-xs text-slate-500">Evidence SHA-256 {proposal.evidence_hash}</p>
|
|
</div>
|
|
<div className="grid gap-px bg-white/10 md:grid-cols-2">
|
|
<div className="space-y-5 bg-[#0b1621] p-6">
|
|
<p className="text-xs uppercase tracking-[0.18em] text-slate-600">Exact proposed action</p>
|
|
<code className="block rounded-lg bg-black/20 p-3 text-xs text-violet-100">
|
|
./jeannie {proposal.command} {JSON.parse(proposal.arguments_json).join(' ')}
|
|
</code>
|
|
<p className="text-sm text-slate-400">Created by {proposal.created_by}</p>
|
|
</div>
|
|
<div className="space-y-5 bg-[#0b1621] p-6">
|
|
<p className="text-xs uppercase tracking-[0.18em] text-slate-600">Risk and rollback</p>
|
|
<p className="text-sm uppercase text-rose-200">{proposal.risk_level} risk</p>
|
|
<p className="whitespace-pre-wrap text-sm leading-6 text-slate-400">{proposal.rollback}</p>
|
|
</div>
|
|
</div>
|
|
<div className="p-6">
|
|
<p className="text-sm text-amber-200">
|
|
Approval re-runs Doctor, compares the evidence hash, checks the Jeannie allowlist, and validates the exact arguments. It records the decision but does not execute it.
|
|
</p>
|
|
{proposal.status === 'pending' && (
|
|
<label className="mt-5 flex cursor-pointer items-start gap-3 rounded-xl border border-white/10 bg-white/[0.025] p-4 text-sm text-slate-300">
|
|
<input
|
|
type="checkbox"
|
|
checked={confirmed}
|
|
onChange={(event) => setConfirmed(event.target.checked)}
|
|
className="mt-0.5 size-4 accent-cyan-300"
|
|
/>
|
|
<span>I reviewed the evidence, exact action, risk, and rollback procedure.</span>
|
|
</label>
|
|
)}
|
|
{proposal.status === 'pending' && (
|
|
<button
|
|
type="button"
|
|
onClick={approve}
|
|
disabled={submitting || !confirmed}
|
|
className="mt-5 w-full rounded-lg bg-violet-300 px-4 py-3 font-semibold text-slate-950 disabled:cursor-not-allowed disabled:bg-white/8 disabled:text-slate-500"
|
|
>
|
|
{submitting ? 'Revalidating…' : 'Approve proposal'}
|
|
</button>
|
|
)}
|
|
{proposal.status === 'approved' && (
|
|
<div className="mt-5 rounded-2xl border border-rose-300/20 bg-rose-300/[0.04] p-5">
|
|
<p className="text-xs uppercase tracking-[0.18em] text-rose-200">Execution boundary</p>
|
|
<p className="mt-3 text-sm leading-6 text-slate-400">
|
|
Execution revalidates current evidence, command allowlisting, and exact arguments before one submission to Jeannie.
|
|
</p>
|
|
<label className="mt-4 flex cursor-pointer items-start gap-3 text-sm text-slate-300">
|
|
<input
|
|
type="checkbox"
|
|
checked={executionConfirmed}
|
|
onChange={(event) => setExecutionConfirmed(event.target.checked)}
|
|
className="mt-0.5 size-4 accent-rose-300"
|
|
/>
|
|
<span>Execute this approved action now and monitor its validation report.</span>
|
|
</label>
|
|
<button
|
|
type="button"
|
|
onClick={execute}
|
|
disabled={submitting || !executionConfirmed}
|
|
className="mt-5 w-full rounded-lg bg-rose-300 px-4 py-3 font-semibold text-slate-950 disabled:cursor-not-allowed disabled:bg-white/8 disabled:text-slate-500"
|
|
>
|
|
{submitting ? 'Revalidating and submitting…' : 'Execute approved action'}
|
|
</button>
|
|
</div>
|
|
)}
|
|
{proposal.status !== 'pending' && proposal.status !== 'approved' && (
|
|
<p className="mt-5 rounded-xl border border-white/10 bg-white/[0.025] p-4 text-sm text-slate-400">
|
|
Proposal status: {proposal.status}
|
|
</p>
|
|
)}
|
|
</div>
|
|
</section>
|
|
</div>
|
|
</main>
|
|
);
|
|
}
|