diff --git a/src/scenes/Approvals.tsx b/src/scenes/Approvals.tsx index ce6ccf5..de9e10c 100644 --- a/src/scenes/Approvals.tsx +++ b/src/scenes/Approvals.tsx @@ -36,6 +36,8 @@ export default function Approvals() { const [busy, setBusy] = useState(null); const tenantId = useApp((s) => s.tenantId); + const [runtimeHealth, setRuntimeHealth] = useState<"unknown" | "up" | "down">("unknown"); + const loadQueue = async () => { if (!tenantId) { setItems([]); @@ -52,6 +54,21 @@ export default function Approvals() { useEffect(() => { void loadQueue(); }, [tenantId]); + useEffect(() => { + let cancelled = false; + fetch(`${api.config.baseUrl}/api/ea2/runtime-values`, { + method: "GET", + headers: { Authorization: `Bearer ${sessionStorage.getItem("fm.mc.token.v1")}` }, + }) + .then((r) => { + if (cancelled) return; + if (r.status === 422 || r.ok) setRuntimeHealth("up"); + else setRuntimeHealth("down"); + }) + .catch(() => { if (!cancelled) setRuntimeHealth("down"); }); + return () => { cancelled = true; }; + }, []); + useEffect(() => { if (!activeKey) return; let cancelled = false; @@ -163,21 +180,26 @@ export default function Approvals() { )} -
- Acting on a step writes the decision back to EA2. The runtime-values service in this environment is currently offline, so a Submit will be rejected with an error. Use this view to inspect cases; switch to a live environment to act on them. -
+ {runtimeHealth === "down" && ( +
+ Runtime engine is unreachable from this environment. Action buttons are disabled. Use this view to inspect cases; once the runtime comes back, actions will write to EA2. +
+ )}
- {(tx.available_actions || []).map((a: any) => ( - - ))} + {(tx.available_actions || []).map((a: any) => { + const disabled = !a.enabled || busy === a.id || runtimeHealth === "down"; + return ( + + ); + })} {(!tx.available_actions || tx.available_actions.length === 0) && (
No actions available on this step.
)}