Away mode, and critical alerts through quiet hours

For a one-person homelab, "on call" is when you can be reached. Settings ->
Notifications -> When -> Away holds notifications while you are away (a banner on
every page says so) and sends one digest when it ends, at its time or when you say
you are back. Critical alerts can still come through. Quiet hours get the same
"still send critical alerts" option. Escalation steps marked to send in quiet hours
are sent while away too. What is held for one reason is not released while the
other still holds it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-10-22 19:14:29 +02:00
1 parent 3b31b16796
commit 16b24f5436
21 files changed
+737 -50

No files matched your search

+35 -2
View File
@@ -1,7 +1,8 @@
import { useEffect, useRef, useState, type ReactNode } from "react";
import { Link, NavLink, useLocation } from "react-router-dom";
import { IconKey, IconMenu2, IconSun, IconMoon, IconShieldLock, IconTool, IconChevronUp, IconLogout, IconDeviceDesktop, IconChevronsLeft, IconChevronsRight } from "@tabler/icons-react";
import { api, type CurrentUser, type MaintenanceWindow } from "../api/client";
import { IconPlaneDeparture, IconKey, IconMenu2, IconSun, IconMoon, IconShieldLock, IconTool, IconChevronUp, IconLogout, IconDeviceDesktop, IconChevronsLeft, IconChevronsRight } from "@tabler/icons-react";
import { api, type AwayView, type CurrentUser, type MaintenanceWindow } from "../api/client";
import { formatDateTime } from "../utils/date";
import { isCurrent, isGroup, visibleNav, type NavGroup } from "./nav";
import SidebarNav, { type NavBadge } from "./SidebarNav";
import { initFavorites } from "../utils/favorites";
@@ -79,6 +80,7 @@ export default function AppShell({ user, children }: { user: CurrentUser; childr
return () => window.removeEventListener("toggle-sidebar", toggle);
}, []);
const [maintenance, setMaintenance] = useState<MaintenanceWindow[]>([]);
const [away, setAway] = useState<AwayView | null>(null);
const environment = useEnvironment();
useStackedTables();
useShortcuts(user);
@@ -128,6 +130,26 @@ export default function AppShell({ user, children }: { user: CurrentUser; childr
};
}, []);
// Everyone sees when notifications are being held because somebody is away, for the same reason.
useEffect(() => {
let cancelled = false;
const load = () =>
api.away
.get()
.then((res) => {
if (!cancelled) setAway(res);
})
.catch(() => {});
load();
const poll = setInterval(load, 60_000);
window.addEventListener("away-changed", load);
return () => {
cancelled = true;
clearInterval(poll);
window.removeEventListener("away-changed", load);
};
}, []);
const nav = visibleNav(user.role);
const { pathname } = useLocation();
@@ -358,6 +380,17 @@ export default function AppShell({ user, children }: { user: CurrentUser; childr
<div className="page-wrapper">
<main className="page-body" id="main" tabIndex={-1} ref={mainRef}>
<div className="container-xl">
{away && away.away.state !== "none" && away.away.until && (
<div className="alert alert-info d-flex align-items-center gap-2">
<IconPlaneDeparture size={18} />
<div>
{away.away.state === "planned" ? `Away from ${formatDateTime(new Date(away.away.from!))} until ${formatDateTime(new Date(away.away.until))}` : `Away until ${formatDateTime(new Date(away.away.until))}`}
{away.away.note ? ` — ${away.away.note}` : ""}.{" "}
{away.away.state === "active" ? `Notifications are held${away.away.criticalThrough ? " (critical alerts still come through)" : ""}${away.held > 0 ? ` — ${away.held} so far` : ""}. ` : ""}
<Link to="/settings/notifications?tab=when">{user.role === "admin" ? "Manage" : "Details"}</Link>
</div>
</div>
)}
{maintenance.length > 0 && (
<div className="alert alert-warning d-flex align-items-center gap-2">
<IconTool size={18} />