Toasts, logo icons, shared table toolbar with search, and a density toggle

Feedback: toasts confirm common actions, and a page's error or success message
that appears out of view is also shown as a toast. Icons: the tab, app and
home-screen icons are the house from the logo; a dev instance gets a coloured dot
on its tab icon. Tables: Secrets, Admin Links, IP Addresses and Alerts share one
toolbar (search, filters, row count, actions, Export CSV); twelve more tables get
a multi-word search box; long tables keep their column headings in view on wide
screens. Density: Compact / Normal / Roomy in the user menu, remembered per
browser.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-10-14 23:39:19 +02:00
1 parent 7d56ad18b7
commit 617dc1ea2f
56 files changed
+757 -158

No files matched your search

+43
View File
@@ -0,0 +1,43 @@
import { useMemo, useState } from "react";
const haystacks = new WeakMap<object, string>();
/** Every readable value in a row — text and numbers, however deep — as one lowercase string to search in. */
function haystackOf(row: unknown): string {
if (row !== null && typeof row === "object") {
const cached = haystacks.get(row);
if (cached !== undefined) return cached;
}
const parts: string[] = [];
const walk = (value: unknown, depth: number) => {
if (typeof value === "string") parts.push(value);
else if (typeof value === "number") parts.push(String(value));
else if (depth < 3 && Array.isArray(value)) for (const v of value) walk(v, depth + 1);
else if (depth < 3 && value !== null && typeof value === "object") for (const v of Object.values(value)) walk(v, depth + 1);
};
walk(row, 0);
const text = parts.join(" \n").toLowerCase();
if (row !== null && typeof row === "object") haystacks.set(row, text);
return text;
}
/**
* Text search over a table's rows. Several words must all appear (in any column, in any order), so "elsa running" finds a running
* container on elsa. Returns the rows unchanged while the box is empty, and `null`/`undefined` as they came while loading.
*/
export function useTableSearch<T>(items: T[] | null | undefined) {
const [query, setQuery] = useState("");
const terms = query.trim().toLowerCase().split(/\s+/).filter(Boolean);
const key = terms.join(" ");
const filtered = useMemo(() => {
if (!items || key === "") return items;
const wanted = key.split(" ");
return items.filter((row) => {
const hay = haystackOf(row);
return wanted.every((t) => hay.includes(t));
});
}, [items, key]);
return { query, setQuery, filtered, active: key !== "" };
}