From 7cc499d57c26a22a281dc5aea7531927319302aa Mon Sep 17 00:00:00 2001 From: Mikhail Yenuchenko Date: Tue, 11 Aug 2026 01:23:52 +0300 Subject: [PATCH] panel: show the send log's status as a badge MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The send log was the one place in the panel where a status was bare text, next to a delivery's own page where the same value is a badge, and a domain list where the DNS verdict is one too — so a message's outcome looked like a different kind of fact depending on which page you read it from. The level travels on the row rather than being worked out in the template: deliveryLevel is the one place that decides what a status means, the delivery page already reads it, and a second mapping written into the template or the stylesheet would have been free to drift from it. sent is ok, deferred a warning, bounced and rejected errors, and queued unknown — nothing has gone wrong, nothing has been reported yet. Co-Authored-By: Claude Opus 5 --- CHANGELOG.md | 8 +++++++- internal/web/handlers/handlers_monitor.go | 15 ++++++++++++++- internal/web/view/templates/deliveries_rows.html | 2 +- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d31e0b1..f344c51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,7 +28,13 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); version whose only card is the narrow one now takes its heading and footer down to the card's width instead of splitting them across the wider measure, and the send log stops breaking `Details` and `deferred` across two lines when a row is - tight. The three + tight. +- panel: the send log's **status is a badge**, in the same ok/warn/error/unknown + colours the status page and the DNS checks use, instead of the one place in + the panel where a status was bare text. The mapping is the one the delivery + page already applied — `sent` is ok, `deferred` a warning, `bounced` and + `rejected` errors, `queued` unknown because nothing has gone wrong yet. + The three WOFF2 files add ~76 KB to the image and are served from the panel's own origin, so the Content-Security-Policy is unchanged (`default-src 'self'`). diff --git a/internal/web/handlers/handlers_monitor.go b/internal/web/handlers/handlers_monitor.go index 60fffd9..57a0b4c 100644 --- a/internal/web/handlers/handlers_monitor.go +++ b/internal/web/handlers/handlers_monitor.go @@ -145,6 +145,17 @@ func deliveryLevel(status string) string { } } +// sendLogRow is a row of the send log as the table draws it: the stored row +// plus the badge level its status maps onto. The level is carried rather than +// derived in the template because deliveryLevel is the one place that decides +// what a status means — the delivery page already reads it, and a second +// mapping written in the template or the stylesheet would be free to drift +// from it. +type sendLogRow struct { + store.SendLogRow + Level string // ok / warn / error / unknown, as deliveryLevel returns +} + // deliveryEvent is one step of a message's history, as the timeline on the // delivery page draws it. At is zero for the step that has not happened yet — // the delivery report a queued message is still waiting for. @@ -324,8 +335,10 @@ func (h *Handlers) sendLogData(r *http.Request) (map[string]any, error) { if err != nil { return nil, err } + view := make([]sendLogRow, len(rows)) for i := range rows { rows[i].Subject = mailhdr.DecodeSubject(rows[i].Subject) + view[i] = sendLogRow{SendLogRow: rows[i], Level: deliveryLevel(rows[i].Status)} } domainNames := make([]string, 0, len(assigned)) @@ -358,7 +371,7 @@ func (h *Handlers) sendLogData(r *http.Request) (map[string]any, error) { lastPage = int((total + sendLogPageSize - 1) / sendLogPageSize) } return map[string]any{ - "Rows": rows, + "Rows": view, "FilterDomains": domainNames, "FilterApps": logins, "FilterDomain": filter.Domain, diff --git a/internal/web/view/templates/deliveries_rows.html b/internal/web/view/templates/deliveries_rows.html index f0275d4..b14610f 100644 --- a/internal/web/view/templates/deliveries_rows.html +++ b/internal/web/view/templates/deliveries_rows.html @@ -13,7 +13,7 @@ {{.From}} {{.To}} {{.Subject}} - {{.Status}} + {{.Status}} Details {{end}}