Search and paging on lists, Settings in tabs, pinned sidebar (1.3.0)
- Installs, Customers, Alerts and the audit log get a search box and 25-per-page paging (Installs also a health filter); install History pages too. - Settings is split into Releases and alerts / Email / Login and security / Audit log tabs, remembered in the URL hash. - The side navigation is sticky at window height, so Sign out no longer scrolls off long pages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,29 +1,35 @@
|
||||
"use client";
|
||||
|
||||
import React, { useEffect, useState } from "react";
|
||||
import React, { useEffect, useMemo, useState } from "react";
|
||||
import Link from "next/link";
|
||||
import { api, errorText } from "@/lib/api";
|
||||
import { ago, fmtDate } from "@/lib/format";
|
||||
import { matches, usePaged } from "@/lib/paging";
|
||||
import type { InstallEvent } from "@/lib/types";
|
||||
import { Badge, Loading, PageTitle } from "@/components/ui";
|
||||
import { Badge, Loading, PageTitle, Pager, SearchInput } from "@/components/ui";
|
||||
|
||||
/** Open alerts, and the history of everything that happened to installs. */
|
||||
export default function AlertsPage() {
|
||||
const [openOnly, setOpenOnly] = useState(true);
|
||||
const [events, setEvents] = useState<InstallEvent[] | null>(null);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [query, setQuery] = useState("");
|
||||
|
||||
useEffect(() => {
|
||||
setEvents(null);
|
||||
api<InstallEvent[]>(`/api/admin/events${openOnly ? "?open=true" : ""}`).then(setEvents).catch(e => setError(errorText(e)));
|
||||
}, [openOnly]);
|
||||
|
||||
const shown = useMemo(() => (events || []).filter(e => matches(query, e.message, e.level, e.install?.name, e.install?.url)), [events, query]);
|
||||
const paged = usePaged(shown, `${query}|${openOnly}`);
|
||||
|
||||
return (
|
||||
<>
|
||||
<PageTitle title="Alerts" subtitle="Checked every 5 minutes. New warnings and critical alerts are emailed once (Settings → Alert email)." />
|
||||
<div className="mb-4 flex gap-2">
|
||||
<PageTitle title="Alerts" subtitle="Checked every 5 minutes. New warnings and critical alerts are emailed once (Settings → Releases and alerts → Alert email)." />
|
||||
<div className="mb-4 flex flex-wrap gap-2">
|
||||
<button className={openOnly ? "btn-primary" : "btn-secondary"} onClick={() => setOpenOnly(true)}>Open</button>
|
||||
<button className={!openOnly ? "btn-primary" : "btn-secondary"} onClick={() => setOpenOnly(false)}>Everything</button>
|
||||
<SearchInput className="w-full sm:ml-auto sm:w-72" value={query} onChange={setQuery} placeholder="Search alerts or install" />
|
||||
</div>
|
||||
{error && <p className="text-sm text-red-700">{error}</p>}
|
||||
{!events ? <Loading /> : events.length === 0 ? <p className="text-sm text-slate-500">{openOnly ? "No open alerts. 🎉" : "Nothing yet."}</p> : (
|
||||
@@ -31,7 +37,8 @@ export default function AlertsPage() {
|
||||
<table className="w-full text-sm">
|
||||
<thead className="bg-slate-50 text-left text-xs text-slate-500"><tr><th className="p-3">When</th><th className="p-3">Install</th><th className="p-3">What</th><th className="p-3">State</th></tr></thead>
|
||||
<tbody>
|
||||
{events.map(e => (
|
||||
{paged.rows.length === 0 && <tr><td colSpan={4} className="p-3 text-slate-500">No alerts match.</td></tr>}
|
||||
{paged.rows.map(e => (
|
||||
<tr key={e.id} className="border-t align-top">
|
||||
<td className="p-3 whitespace-nowrap text-xs text-slate-500">{fmtDate(e.createdAt)}</td>
|
||||
<td className="p-3">{e.install ? <Link href={`/installs/${e.install.id}`} className="text-indigo-700 hover:underline">{e.install.name}</Link> : "—"}</td>
|
||||
@@ -41,6 +48,7 @@ export default function AlertsPage() {
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
<Pager {...paged} />
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
|
||||
Reference in New Issue
Block a user