v0.128.1: suppress the class hint on USB drives (ruling F5)

Only Observe-sourced drives ever carried class, so legacy PVE dir:-backed USB
drives showed 'lassú' while registry-sourced ones never did. The card already
carries the USB type tag. Hub-report ClassHint UNCHANGED (UI-only). Pinned by
TestStorageTemplate_USBClassBadgeSuppressed (red-proof run).
This commit is contained in:
2026-07-13 21:40:37 +02:00
parent 61c1391ff6
commit d752f159b9
3 changed files with 54 additions and 0 deletions
@@ -0,0 +1,36 @@
package web
import (
"bytes"
"strings"
"testing"
)
// F5 (2026-07-13): USB drives never show the rotational class hint — the card already carries
// the USB tag, and only Observe-sourced drives ever had class set, so USB cards flapped between
// "lassú" and nothing depending on the data source. The guard is client-side (classTag runs on
// /api/disks JSON), so the pin asserts the rendered page ships the guard FIRST in classTag.
// Companion red-proof: remove the `d.type==='usb'` guard line → FAIL.
func TestStorageTemplate_USBClassBadgeSuppressed(t *testing.T) {
s := testServer(t)
s.loadTemplates()
var buf bytes.Buffer
if err := s.tmpl.ExecuteTemplate(&buf, "storage", map[string]interface{}{
"Page": "storage", "Title": "Tárolók",
}); err != nil {
t.Fatalf("render storage: %v", err)
}
html := buf.String()
guard := strings.Index(html, `if(d.type==='usb') return '';`)
slow := strings.Index(html, `tag-off">lassú`)
if guard < 0 {
t.Fatal("classTag USB guard missing from the storage page")
}
if slow < 0 {
t.Fatal("classTag slow-branch missing — the guard has nothing to suppress (test needs updating)")
}
if guard > slow {
t.Fatalf("USB guard (at %d) must run BEFORE the class branches (at %d)", guard, slow)
}
}
@@ -250,6 +250,10 @@ window.__registeredPaths=[{{range .StoragePaths}}{{if .Path}}"{{.Path}}",{{end}}
function usageColorClass(p){ if(p>=85) return 'crit'; if(p>=70) return 'warn'; return 'nominal'; }
var LOCK_ICO='<svg class="ico ico-sm"><use href="#i-lock"/></svg>';
function classTag(d){
// F5 2026-07-13: USB drives never show the class hint — the card already carries the USB
// tag, and Observe-sourced USB drives showing "lassú" while registry-sourced ones never do
// was a misleading inconsistency. Hub-report ClassHint is UNCHANGED (UI-only suppression).
if(d.type==='usb') return '';
if(d.class==='fast') return '<span class="tag">gyors</span>';
if(d.class==='slow') return '<span class="tag tag-off">lassú</span>';
return '';