Files
archie/ui/src/settings/history.ts
T
sam 43d2acf300 feat(webui): Settings > History, and a resizable Settings sidebar
History replaces the Audit card on every settings page: one change log for
all settings, filterable by section, actor and time window, with the
filters in the query so each page's History link opens it filtered to that
page. Rows show the old and new value as a diff and expand to the full
value; Restore still puts a resource back to the version before a change.

The sidebar's edge drags (or takes arrow keys) between 180 and 420px,
resets on double-click and remembers its width per browser.
2026-09-25 15:10:07 +10:00

31 lines
873 B
TypeScript

interface HistoryEntry {
record_key: string;
actor: string;
at?: string;
}
export interface HistoryFilter {
/** Resource kinds to keep; empty or absent keeps every kind. */
kinds?: string[];
actor?: string;
/** Keep entries newer than this many milliseconds before now. */
sinceMs?: number;
}
/** filterHistory keeps the audit entries that match every filter set. */
export function filterHistory<T extends HistoryEntry>(
entries: T[],
filter: HistoryFilter,
now: number,
): T[] {
return entries.filter((entry) => {
if (filter.kinds?.length && !filter.kinds.includes(entry.record_key)) return false;
if (filter.actor && entry.actor !== filter.actor) return false;
if (filter.sinceMs !== undefined) {
if (!entry.at) return false;
if (now - Date.parse(entry.at) > filter.sinceMs) return false;
}
return true;
});
}