()
| 92 | } |
| 93 | |
| 94 | export function StoreHealthCard(): React.ReactElement { |
| 95 | const [health, setHealth] = useState<PayloadHealthResponse | null>(null); |
| 96 | const [healthLoading, setHealthLoading] = useState(false); |
| 97 | const [healthError, setHealthError] = useState(""); |
| 98 | |
| 99 | const [gcPreview, setGcPreview] = useState<GcResponse | null>(null); |
| 100 | const [gcApplied, setGcApplied] = useState<GcResponse | null>(null); |
| 101 | const [gcBusy, setGcBusy] = useState(false); |
| 102 | const [gcError, setGcError] = useState(""); |
| 103 | |
| 104 | const refresh = useCallback(function () { |
| 105 | setHealthLoading(true); |
| 106 | setHealthError(""); |
| 107 | fetchJSON<PayloadHealthResponse>(`${API}/payloads/health`) |
| 108 | .then(function (json) { |
| 109 | setHealth(json); |
| 110 | }) |
| 111 | .catch(function (err) { |
| 112 | setHealthError(friendlyError(err)); |
| 113 | }) |
| 114 | .finally(function () { |
| 115 | setHealthLoading(false); |
| 116 | }); |
| 117 | }, []); |
| 118 | |
| 119 | useEffect( |
| 120 | function () { |
| 121 | refresh(); |
| 122 | }, |
| 123 | [refresh], |
| 124 | ); |
| 125 | |
| 126 | const runPreview = useCallback(function () { |
| 127 | setGcBusy(true); |
| 128 | setGcError(""); |
| 129 | setGcApplied(null); |
| 130 | fetchJSON<GcResponse>(`${API}/payloads/gc`) |
| 131 | .then(function (json) { |
| 132 | setGcPreview(json); |
| 133 | }) |
| 134 | .catch(function (err) { |
| 135 | setGcPreview(null); |
| 136 | setGcError(friendlyError(err)); |
| 137 | }) |
| 138 | .finally(function () { |
| 139 | setGcBusy(false); |
| 140 | }); |
| 141 | }, []); |
| 142 | |
| 143 | const runApply = useCallback( |
| 144 | function () { |
| 145 | if (!gcPreview || !gcPreview.dry_run_token) return; |
| 146 | setGcBusy(true); |
| 147 | setGcError(""); |
| 148 | fetchJSON<GcResponse>(`${API}/payloads/gc`, { |
| 149 | method: "POST", |
| 150 | headers: { "Content-Type": "application/json" }, |
| 151 | body: JSON.stringify({ |
nothing calls this directly
no test coverage detected