From b76bd413e84767248dd3b352c3f81f35389ae19a Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Fri, 25 Aug 2023 14:37:41 +0200 Subject: dashboard: display labels in groups Display subsystems and bug presence labels separately from other labels as these are most important. Also, displaying subsystems together with other labels confuses users over our #syz set interface. --- dashboard/app/bug.html | 13 +++++++----- dashboard/app/main.go | 55 ++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 59 insertions(+), 9 deletions(-) diff --git a/dashboard/app/bug.html b/dashboard/app/bug.html index d21af6548..de7957cf5 100644 --- a/dashboard/app/bug.html +++ b/dashboard/app/bug.html @@ -16,11 +16,14 @@ Page with details about a single bug. {{.Bug.Title}}

Status: {{if .Bug.ExternalLink}}{{.Bug.Status}}{{else}}{{.Bug.Status}}{{end}}
- {{if .Labels}} - Labels: {{range .Labels}} - {{link .Link .Name}} - {{- end}} - (incorrect?)
+ {{if .LabelGroups}} + {{range $group := .LabelGroups}} + {{$group.Name}}: {{range $group.Labels}} + {{link .Link .Name}} + {{- end}} +
+ {{end}} + [Documentation on labels]
{{- end}} {{if .DebugSubsystems}} {{link .DebugSubsystems "[Debug subsystem assignment]"}}
diff --git a/dashboard/app/main.go b/dashboard/app/main.go index e6a3acd98..2bab7c66e 100644 --- a/dashboard/app/main.go +++ b/dashboard/app/main.go @@ -254,10 +254,15 @@ type uiBugPage struct { SampleReport template.HTML Crashes *uiCrashTable TestPatchJobs *uiJobList - Labels []*uiBugLabel + LabelGroups []*uiBugLabelGroup DebugSubsystems string } +type uiBugLabelGroup struct { + Name string + Labels []*uiBugLabel +} + const ( sectionBugList = "bug_list" sectionJobList = "job_list" @@ -1075,9 +1080,7 @@ func handleBug(c context.Context, w http.ResponseWriter, r *http.Request) error Sections: sections, SampleReport: sampleReport, Crashes: crashesTable, - } - for _, entry := range bug.Labels { - data.Labels = append(data.Labels, makeBugLabelUI(c, bug, entry)) + LabelGroups: getLabelGroups(c, bug), } if accessLevel == AccessAdmin && !bug.hasUserSubsystems() { data.DebugSubsystems = html.AmendURL(data.Bug.Link, "debug_subsystems", "1") @@ -1115,6 +1118,50 @@ func handleBug(c context.Context, w http.ResponseWriter, r *http.Request) error return serveTemplate(w, "bug.html", data) } +type labelGroupInfo struct { + Label BugLabelType + Name string +} + +var labelGroupOrder = []labelGroupInfo{ + { + Label: OriginLabel, + Name: "Bug presence", + }, + { + Label: SubsystemLabel, + Name: "Subsystems", + }, + { + Label: EmptyLabel, // all the rest + Name: "Labels", + }, +} + +func getLabelGroups(c context.Context, bug *Bug) []*uiBugLabelGroup { + var ret []*uiBugLabelGroup + seenLabel := map[string]bool{} + for _, info := range labelGroupOrder { + obj := &uiBugLabelGroup{ + Name: info.Name, + } + for _, entry := range bug.Labels { + if seenLabel[entry.String()] { + continue + } + if entry.Label == info.Label || info.Label == EmptyLabel { + seenLabel[entry.String()] = true + obj.Labels = append(obj.Labels, makeBugLabelUI(c, bug, entry)) + } + } + if len(obj.Labels) == 0 { + continue + } + ret = append(ret, obj) + } + return ret +} + func debugBugSubsystems(c context.Context, w http.ResponseWriter, bug *Bug) error { service := getSubsystemService(c, bug.Namespace) if service == nil { -- cgit mrf-deployment