Phones: a bar under the thumb, and one-tap and swipe acknowledge and snooze

Below tablet width a bottom bar holds Dashboard, Alerts (with its count),
Servers and Menu. On the Alerts page an operator can acknowledge with one tap
or snooze for an hour, or swipe a row right to acknowledge and left to snooze;
each has an Undo, a scroll never triggers a swipe, and every swipe is also a
button.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-11-13 19:50:51 +01:00
1 parent a69d0a611d
commit 939ebf8d83
8 files changed
+425 -4

No files matched your search

+73
View File
@@ -0,0 +1,73 @@
import { useRef, useState, type HTMLAttributes, type ReactNode } from "react";
import { swipeCommits, swipeDirection, swipeOffset, SWIPE_COMMIT } from "../utils/swipe";
/**
* A table row that can be swiped sideways with a finger: to the right does one thing, to the left another (an alert: acknowledge, snooze). The row follows the finger, says what letting go
* will do, and does it only once it has been dragged far enough; a vertical drag is left alone, so scrolling the list never triggers it. Touch only — a mouse never swipes — and every
* swipe is also a button, so nothing can be done only by swiping.
*/
export default function SwipeRow({
onRight,
onLeft,
rightHint,
leftHint,
children,
className = "",
style,
...rest
}: {
onRight?: () => void;
onLeft?: () => void;
/** What letting go will do, said while the row is held that way ("Acknowledge"). */
rightHint?: string;
leftHint?: string;
children: ReactNode;
} & Omit<HTMLAttributes<HTMLTableRowElement>, "onTouchStart" | "onTouchMove" | "onTouchEnd" | "onTouchCancel">) {
const allowed = { right: !!onRight, left: !!onLeft };
const start = useRef<{ x: number; y: number } | null>(null);
const [drag, setDrag] = useState(0);
const [held, setHeld] = useState(false);
const dir = swipeDirection(drag, 0);
const ready = Math.abs(drag) >= SWIPE_COMMIT;
const reset = () => {
start.current = null;
setDrag(0);
setHeld(false);
};
return (
<tr
{...rest}
className={`${className} swipe-row${held ? " swipe-held" : ""}${dir && held ? ` swipe-${dir}${ready ? " swipe-ready" : ""}` : ""}`}
style={{ ...style, transform: held && drag !== 0 ? `translateX(${drag}px)` : undefined }}
data-hint={dir === "right" ? rightHint : dir === "left" ? leftHint : undefined}
onTouchStart={(e) => {
if (e.touches.length !== 1) return;
start.current = { x: e.touches[0].clientX, y: e.touches[0].clientY };
}}
onTouchMove={(e) => {
if (!start.current || e.touches.length !== 1) return;
const dx = e.touches[0].clientX - start.current.x;
const dy = e.touches[0].clientY - start.current.y;
if (!held) {
// undecided until it is clearly sideways; a scroll never becomes a swipe
if (!swipeDirection(dx, dy)) return;
setHeld(true);
}
setDrag(swipeOffset(dx, allowed));
}}
onTouchEnd={(e) => {
const s = start.current;
const t = e.changedTouches[0];
const commit = s && t ? swipeCommits(t.clientX - s.x, t.clientY - s.y, allowed) : null;
reset();
if (commit === "right") onRight?.();
else if (commit === "left") onLeft?.();
}}
onTouchCancel={reset}
>
{children}
</tr>
);
}
+7
View File
@@ -72,6 +72,7 @@ export const sv: Record<string, string> = {
"Acknowledge…": "Kvittera…",
"Acknowledged": "Kvitterad",
"Acknowledged or not": "Kvitterad eller inte",
"Acknowledged.": "Kvitterat.",
"Actions": "Åtgärder",
"Active": "Aktiv",
"Add {name} to favourites": "Lägg till {name} i favoriter",
@@ -312,6 +313,7 @@ export const sv: Record<string, string> = {
"How this server is": "Hur servern mår",
"How tightly pages are packed": "Hur tätt sidorna packas",
"How to show the integrations": "Hur integrationerna visas",
"I'm on it": "Jag tar det",
"If the server then says a restart is due, the restart playbook runs, and the server is checked to have started again.": "Om servern sedan säger att en omstart behövs körs omstarts-playbooken, och servern kontrolleras så att den har startat om.",
"Image": "Avbild",
"Import from Uptime Kuma": "Importera från Uptime Kuma",
@@ -381,6 +383,7 @@ export const sv: Record<string, string> = {
"Media managers": "Mediahanterare",
"Mem": "Minne",
"Memory": "Minne",
"Menu": "Meny",
"Monitoring": "Övervakning",
"Most in an hour": "Flest på en timme",
"most recent first": "senaste först",
@@ -524,6 +527,7 @@ export const sv: Record<string, string> = {
"Proxy hosts": "Proxyvärdar",
"Put back.": "Återlagd.",
"Queries, 24 h": "Frågor, 24 tim",
"Quick links": "Snabblänkar",
"Raised and cleared again and again within an hour — its messages are held back until it has been calm for an hour": "Larmat och släckts om och om igen inom en timme — dess meddelanden hålls tillbaka tills det har varit lugnt i en timme",
"Raised and cleared often enough within an hour to count as flapping": "Larmat och släckts tillräckligt ofta inom en timme för att räknas som fladdrande",
"Reachable": "Nåbar",
@@ -629,7 +633,9 @@ export const sv: Record<string, string> = {
"Since you last looked": "Sedan du senast tittade",
"size goes up and down": "storleken går upp och ned",
"Skip to content": "Hoppa till innehållet",
"Snooze 1 h": "Påminn om 1 tim",
"Snooze…": "Påminn senare…",
"Snoozed for an hour.": "Snoozat i en timme.",
"Somebody is watching.": "Någon tittar.",
"someone": "någon",
"Source": "Källa",
@@ -696,6 +702,7 @@ export const sv: Record<string, string> = {
"Turn on": "Slå på",
"Type a tag and press Enter — e.g. prod, media, rack-1": "Skriv en tagg och tryck Enter — till exempel prod, media, rack-1",
"Under a maintenance window — notifications for this are held back": "Under ett underhållsfönster — notiser för den här hålls tillbaka",
"Undo": "Ångra",
"Uninstall": "Avinstallera",
"Uninstall agent from": "Avinstallera agenten från",
"Unlink": "Koppla bort",
+33 -2
View File
@@ -1,9 +1,9 @@
import { useEffect, useRef, useState, type ReactNode } from "react";
import { Link, NavLink, useLocation } from "react-router-dom";
import { IconPlaneDeparture, IconKey, IconMenu2, IconSun, IconMoon, IconShieldLock, IconTool, IconChevronUp, IconLogout, IconDeviceDesktop, IconChevronsLeft, IconChevronsRight } from "@tabler/icons-react";
import { IconLayoutDashboard, IconAlertTriangle, IconServer2, 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 { isCurrent, isGroup, visibleNav, type NavEntry, type NavGroup } from "./nav";
import SidebarNav, { type NavBadge } from "./SidebarNav";
import { initFavorites } from "../utils/favorites";
import { initDashboardLayout } from "../utils/dashboardLayout";
@@ -450,6 +450,37 @@ export default function AppShell({ user, children }: { user: CurrentUser; childr
</div>
</main>
</div>
{/* On a phone: the three places used most, and the menu, under the thumb (hidden from tablet width up, where the sidebar is always there). */}
<nav className="thumb-bar" aria-label={t("Quick links")}>
{([
{ to: "/", label: t("Dashboard"), icon: <IconLayoutDashboard size={22} />, end: true, badge: null as string | null, level: "" },
{ to: "/alerts", label: t("Alerts"), icon: <IconAlertTriangle size={22} />, end: false, badge: alerts ? String(alerts.count) : null, level: alerts?.level ?? "" },
{ to: "/servers", label: t("Servers"), icon: <IconServer2 size={22} />, end: false, badge: null as string | null, level: "" },
] as const)
.filter((item) => item.to === "/" || item.to === "/alerts" || navHas(nav, item.to))
.map((item) => (
<NavLink key={item.to} to={item.to} end={item.end} className="thumb-item" onClick={() => setSidebarOpen(false)}>
<span className="thumb-icon" aria-hidden="true">
{item.icon}
{item.badge && <span className={`thumb-badge ${item.level === "critical" ? "thumb-badge-critical" : ""}`}>{item.badge}</span>}
</span>
<span className="thumb-label">{item.label}</span>
{item.badge && <span className="visually-hidden">{tn(Number(item.badge), "{n} active alert", "{n} active alerts")}</span>}
</NavLink>
))}
<button type="button" className="thumb-item" aria-expanded={sidebarOpen} onClick={() => setSidebarOpen((open) => !open)}>
<span className="thumb-icon" aria-hidden="true">
<IconMenu2 size={22} />
</span>
<span className="thumb-label">{t("Menu")}</span>
</button>
</nav>
</div>
);
}
/** Whether the menu has this page for this person (a page they hid, or whose role they lack, is not there). */
function navHas(nav: NavEntry[], path: string): boolean {
return nav.some((entry) => (isGroup(entry) ? entry.items.some((i) => i.to === path) : entry.to === path));
}
+69 -2
View File
@@ -28,6 +28,7 @@ import IncidentHistory, { incidentPath } from "../components/IncidentHistory";
import ViewTabs from "../components/ViewTabs";
import AlertNoise from "../components/AlertNoise";
import BulkBar from "../components/BulkBar";
import SwipeRow from "../components/SwipeRow";
import { AckBulkDrawer, SilenceBulkDrawer } from "../components/BulkDrawers";
import { doBulk, plural } from "../utils/bulk";
import { t, tn } from "../i18n";
@@ -281,6 +282,54 @@ function AlertsNow({ user, tabs }: { user: CurrentUser; tabs: React.ReactNode })
toast.error(readableError(err));
}
}
/** One tap: "I'm on it" — acknowledged until the alert is gone, with no note, and an Undo for a tap that was a slip. */
async function quickAck(a: AlertItem) {
try {
await api.alerts.ack({ alertId: a.id, note: "", assigneeId: null, hours: null });
toast.success(t("Acknowledged."), {
label: t("Undo"),
onClick: async () => {
try {
await api.alerts.unack(a.id);
} catch (err) {
toast.error(readableError(err));
} finally {
await load(true);
reloadBadge();
}
},
});
await load(true);
reloadBadge();
} catch (err) {
toast.error(readableError(err));
}
}
/** One tap: snooze for an hour — hidden for now and announced again then if it is still there — with an Undo. */
async function quickSnooze(a: AlertItem) {
try {
await api.alerts.snooze(a.id, new Date(Date.now() + 3600_000).toISOString());
toast.success(t("Snoozed for an hour."), {
label: t("Undo"),
onClick: async () => {
try {
await api.alerts.unsnooze(a.id);
} catch (err) {
toast.error(readableError(err));
} finally {
await load(true);
reloadBadge();
}
},
});
await load(true);
reloadBadge();
} catch (err) {
toast.error(readableError(err));
}
}
async function wake(a: AlertItem) {
try {
await api.alerts.unsnooze(a.id);
@@ -550,7 +599,15 @@ function AlertsNow({ user, tabs }: { user: CurrentUser; tabs: React.ReactNode })
<AlertGroupRow key={a.id} group={a} colSpan={canSilence ? 5 : 4} canPick={canSilence} allPicked={a.pickable.length > 0 && a.pickable.every((id) => picked.has(id))} onToggle={() => toggleGroup(a.id)} onPick={() => pickGroup(a.pickable)} />
) : (
<Fragment key={a.id}>
<tr className={`alert-row alert-row-${a.severity}${a.silenced ? " text-secondary" : ""}`} style={a.silenced ? { opacity: 0.65 } : undefined}>
<SwipeRow
className={`alert-row alert-row-${a.severity}${a.silenced ? " text-secondary" : ""}`}
style={a.silenced ? { opacity: 0.65 } : undefined}
// On a phone: a finger swiped right acknowledges, left snoozes for an hour (both are buttons below as well). Only an alert that is live and not yet taken.
onRight={canSilence && !a.silenced && !a.closed && !a.snoozed && !a.ack?.active ? () => void quickAck(a) : undefined}
onLeft={canSilence && !a.silenced && !a.closed && !a.snoozed ? () => void quickSnooze(a) : undefined}
rightHint={`✓ ${t("I'm on it")}`}
leftHint={`💤 ${t("Snooze 1 h")}`}
>
<td>
{canSilence && (
<input type="checkbox" className="form-check-input me-2 align-middle" aria-label={`Pick: ${a.message}`} checked={picked.has(a.id)} onChange={() => togglePicked(a.id)} />
@@ -647,6 +704,16 @@ function AlertsNow({ user, tabs }: { user: CurrentUser; tabs: React.ReactNode })
{canSilence && (
<td className="text-nowrap stack-wide">
<div className="btn-list flex-nowrap">
{!a.silenced && !a.closed && !a.snoozed && !a.ack?.active && (
<button type="button" className="btn btn-sm btn-primary d-md-none" onClick={() => void quickAck(a)}>
✓ {t("I'm on it")}
</button>
)}
{!a.silenced && !a.closed && !a.snoozed && (
<button type="button" className="btn btn-sm btn-outline-secondary d-md-none" onClick={() => void quickSnooze(a)}>
{t("Snooze 1 h")}
</button>
)}
{!a.silenced && (
<button type="button" className={`btn btn-sm ${a.ack?.active ? "btn-outline-primary" : "btn-outline-secondary"}`} onClick={() => setAcking(a)}>
{a.ack?.active ? t("Acknowledged") : t("Acknowledge…")}
@@ -677,7 +744,7 @@ function AlertsNow({ user, tabs }: { user: CurrentUser; tabs: React.ReactNode })
</div>
</td>
)}
</tr>
</SwipeRow>
{open.has(a.id) &&
(childrenOf.get(a.id) ?? []).map((c) => (
<tr key={c.id} className="alert-row alert-row-child text-secondary">
+130
View File
@@ -2377,3 +2377,133 @@ select,
color: #e6edf7;
opacity: 0.18;
}
/* ── The phone's bar under the thumb (layout/AppShell) and swiped alert rows ── */
.thumb-bar {
display: none;
}
@media (max-width: 767.98px) {
.thumb-bar {
position: fixed;
inset: auto 0 0 0;
z-index: 1025;
display: flex;
padding-bottom: env(safe-area-inset-bottom);
padding-left: env(safe-area-inset-left);
padding-right: env(safe-area-inset-right);
background: var(--tblr-bg-surface, #fff);
border-top: 1px solid var(--tblr-border-color);
}
.thumb-item {
position: relative;
display: flex;
flex: 1 1 0;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 0.1rem;
min-height: 3.5rem;
padding: 0.35rem 0.25rem;
font-size: 0.72rem;
color: var(--tblr-secondary);
text-decoration: none;
background: none;
border: 0;
}
.thumb-item.active,
.thumb-item[aria-expanded="true"] {
color: var(--tblr-primary);
font-weight: 600;
}
.thumb-icon {
position: relative;
display: inline-grid;
place-items: center;
}
.thumb-badge {
position: absolute;
top: -0.35rem;
left: 55%;
min-width: 1.05rem;
padding: 0 0.28rem;
font-size: 0.65rem;
font-weight: 700;
line-height: 1.05rem;
color: #fff;
text-align: center;
background: var(--tblr-yellow, #f59f00);
border-radius: 1rem;
}
.thumb-badge-critical {
background: var(--tblr-red, #d63939);
}
/* room under the page and the toasts for the bar */
.page-body {
padding-bottom: calc(4.5rem + env(safe-area-inset-bottom));
}
.toast-stack {
bottom: calc(4.75rem + env(safe-area-inset-bottom));
}
.detail-drawer,
.modal {
z-index: 1060;
}
}
/* a row being swiped: it follows the finger and says what letting go will do */
tr.swipe-row {
position: relative;
touch-action: pan-y;
}
tr.swipe-row.swipe-held {
transition: none;
}
tr.swipe-row:not(.swipe-held) {
transition: transform 0.18s ease-out;
}
tr.swipe-row.swipe-right {
background: color-mix(in srgb, var(--tblr-green, #2fb344) 16%, var(--tblr-bg-surface, transparent));
}
tr.swipe-row.swipe-left {
background: color-mix(in srgb, var(--tblr-azure, #4299e1) 16%, var(--tblr-bg-surface, transparent));
}
tr.swipe-row.swipe-held::after {
position: absolute;
top: 50%;
z-index: 1;
padding: 0.2rem 0.6rem;
font-size: 0.85rem;
font-weight: 600;
white-space: nowrap;
content: attr(data-hint);
background: var(--tblr-bg-surface, #fff);
border-radius: 1rem;
opacity: 0.7;
transform: translateY(-50%);
}
tr.swipe-row.swipe-right.swipe-held::after {
left: 0.5rem;
}
tr.swipe-row.swipe-left.swipe-held::after {
right: 0.5rem;
}
tr.swipe-row.swipe-ready::after {
opacity: 1;
}
+34
View File
@@ -0,0 +1,34 @@
/** What a finger dragged across a row means. Pure, so it can be tested without a touch screen. */
/** How far a row must be dragged sideways before letting go does something, in pixels. */
export const SWIPE_COMMIT = 90;
/** How far it may follow the finger (a little more than it takes to commit, so it feels held). */
export const SWIPE_MAX = 130;
/** Below this the finger is just resting or scrolling: nothing moves yet. */
export const SWIPE_START = 12;
export type SwipeDirection = "right" | "left";
/**
* Whether a drag is a sideways swipe at all: far enough, and clearly more sideways than up or down (so scrolling the list with a finger is never taken for it). Null while it is still
* undecided or is a scroll.
*/
export function swipeDirection(dx: number, dy: number): SwipeDirection | null {
if (Math.abs(dx) < SWIPE_START) return null;
if (Math.abs(dx) < Math.abs(dy) * 1.5) return null;
return dx > 0 ? "right" : "left";
}
/** Where the row sits while dragged: it follows the finger but no further than SWIPE_MAX, and not at all in a direction nothing is bound to. */
export function swipeOffset(dx: number, allowed: { right: boolean; left: boolean }): number {
if (dx > 0 && !allowed.right) return 0;
if (dx < 0 && !allowed.left) return 0;
return Math.max(-SWIPE_MAX, Math.min(SWIPE_MAX, dx));
}
/** Whether letting go here does the thing: dragged far enough, in a direction something is bound to. */
export function swipeCommits(dx: number, dy: number, allowed: { right: boolean; left: boolean }): SwipeDirection | null {
const dir = swipeDirection(dx, dy);
if (!dir || !allowed[dir]) return null;
return Math.abs(dx) >= SWIPE_COMMIT ? dir : null;
}