MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / StoreHealthCard

Function StoreHealthCard

dashboard/lcm/src/StoreHealth.tsx:94–309  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

92}
93
94export 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({

Callers

nothing calls this directly

Calls 8

fetchJSONFunction · 0.90
friendlyErrorFunction · 0.90
fmtIntFunction · 0.90
useStateFunction · 0.85
useEffectFunction · 0.85
healthPillClassFunction · 0.85
fmtBytesFunction · 0.85
gcPhaseSummaryFunction · 0.85

Tested by

no test coverage detected