Add a since-you-last-looked summary, 30-day uptime ribbons, a maintenance timeline and hover timestamps
- Dashboard card on what changed since the user pressed Got it (users.last_looked_at, migration 0021), folding each problem and its recovery into one line. - Uptime ribbons on servers and integrations, built from the audit log; integrations' failing/working-again moments are now recorded. - Timeline of running and scheduled maintenance windows on the Maintenance page. - TimeAgo component: relative times with the exact time in the chosen format on hover. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3945c60681
commit
906220040e
32 files changed
+3380
-15
No files matched your search
@@ -0,0 +1,40 @@
|
||||
import { useEffect, useSyncExternalStore } from "react";
|
||||
import { api, type UptimeReport } from "../api/client";
|
||||
|
||||
// One report for every ribbon on a page: the first to appear fetches it, the rest share it, and it is fetched again after a few minutes.
|
||||
const STALE_MS = 5 * 60_000;
|
||||
let report: UptimeReport | null = null;
|
||||
let fetchedAt = 0;
|
||||
let loading = false;
|
||||
const listeners = new Set<() => void>();
|
||||
|
||||
function load(): void {
|
||||
if (loading || (report && Date.now() - fetchedAt < STALE_MS)) return;
|
||||
loading = true;
|
||||
api.uptime
|
||||
.get()
|
||||
.then((r) => {
|
||||
report = r;
|
||||
fetchedAt = Date.now();
|
||||
listeners.forEach((l) => l());
|
||||
})
|
||||
.catch(() => {
|
||||
// No ribbons rather than an error on every row: this is a nicety on top of the lists.
|
||||
})
|
||||
.finally(() => {
|
||||
loading = false;
|
||||
});
|
||||
}
|
||||
|
||||
function subscribe(listener: () => void): () => void {
|
||||
listeners.add(listener);
|
||||
return () => {
|
||||
listeners.delete(listener);
|
||||
};
|
||||
}
|
||||
|
||||
/** How each server and integration has done over the last 30 days; null until it has loaded (or if it couldn't). */
|
||||
export function useUptime(): UptimeReport | null {
|
||||
useEffect(load, []);
|
||||
return useSyncExternalStore(subscribe, () => report);
|
||||
}
|
||||
Reference in new issue
Block a user