aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2023-01-26 11:36:00 +0100
committerAleksandr Nogikh <wp32pw@gmail.com>2023-01-27 17:31:25 +0100
commit6b1283d2ce0e5c36029f8e2fb8eeb3c6b7c29209 (patch)
tree94c669cff01ff5d4952fd2fd0815009c55229367
parent9da06344c240d3cd7ce53ee0261722ee2198654a (diff)
dashboard: display subsystems in bug lists
To generate filtering URLs, use the ability of context.Context to carry on variable values.
-rw-r--r--dashboard/app/handler.go11
-rw-r--r--dashboard/app/main.go12
-rw-r--r--dashboard/app/templates.html7
-rw-r--r--pkg/html/html.go15
-rw-r--r--pkg/html/pages/style.css15
5 files changed, 59 insertions, 1 deletions
diff --git a/dashboard/app/handler.go b/dashboard/app/handler.go
index 2cb0d2739..7c6e9a23e 100644
--- a/dashboard/app/handler.go
+++ b/dashboard/app/handler.go
@@ -32,6 +32,7 @@ func handlerWrapper(fn contextHandler) http.Handler {
func handleContext(fn contextHandler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
+ c = context.WithValue(c, currentURLKey, r.URL.RequestURI())
if err := fn(c, w, r); err != nil {
hdr := commonHeaderRaw(c, r)
data := &struct {
@@ -73,6 +74,16 @@ func handleContext(fn contextHandler) http.Handler {
})
}
+const currentURLKey = "current_url"
+
+func getCurrentURL(c context.Context) string {
+ val, ok := c.Value(currentURLKey).(string)
+ if ok {
+ return val
+ }
+ return ""
+}
+
type (
ErrClient struct{ error }
ErrRedirect struct{ error }
diff --git a/dashboard/app/main.go b/dashboard/app/main.go
index 9d1340425..05eee1687 100644
--- a/dashboard/app/main.go
+++ b/dashboard/app/main.go
@@ -234,6 +234,12 @@ type uiBug struct {
MissingOn []string
NumManagers int
LastActivity time.Time
+ Subsystems []*uiBugSubsystem
+}
+
+type uiBugSubsystem struct {
+ Name string
+ Link string
}
type uiCrash struct {
@@ -1120,6 +1126,12 @@ func createUIBug(c context.Context, bug *Bug, state *ReportingState, managers []
NumManagers: len(managers),
LastActivity: bug.LastActivity,
}
+ for _, entry := range bug.Tags.Subsystems {
+ uiBug.Subsystems = append(uiBug.Subsystems, &uiBugSubsystem{
+ Name: entry.Name,
+ Link: html.AmendURL(getCurrentURL(c), "subsystem", entry.Name),
+ })
+ }
updateBugBadness(c, uiBug)
if len(bug.Commits) != 0 {
for i, com := range bug.Commits {
diff --git a/dashboard/app/templates.html b/dashboard/app/templates.html
index 12b51072a..01055dd5c 100644
--- a/dashboard/app/templates.html
+++ b/dashboard/app/templates.html
@@ -125,7 +125,12 @@ Use of this source code is governed by Apache 2 LICENSE that can be found in the
{{range $b := .Bugs}}
<tr>
{{if $.ShowNamespace}}<td>{{$b.Namespace}}</td>{{end}}
- <td class="title"><a href="{{$b.Link}}">{{$b.Title}}</a></td>
+ <td class="title">
+ <a href="{{$b.Link}}">{{$b.Title}}</a>
+ {{- range $b.Subsystems}}
+ <span class="subsystem">{{link .Link .Name}}</span>
+ {{- end}}
+ </td>
<td class="stat">{{formatReproLevel $b.ReproLevel}}</td>
<td class="bisect_status">{{print $b.BisectCause}}</td>
<td class="bisect_status">{{print $b.BisectFix}}</td>
diff --git a/pkg/html/html.go b/pkg/html/html.go
index 8dc075bb6..c89c42fbb 100644
--- a/pkg/html/html.go
+++ b/pkg/html/html.go
@@ -6,6 +6,7 @@ package html
import (
"fmt"
"html/template"
+ "net/url"
"reflect"
"strings"
texttemplate "text/template"
@@ -191,3 +192,17 @@ func dereferencePointer(v interface{}) interface{} {
func commitLink(repo, commit string) string {
return vcs.CommitLink(repo, commit)
}
+
+func AmendURL(baseURL, key, value string) string {
+ if baseURL == "" {
+ return ""
+ }
+ parsed, err := url.Parse(baseURL)
+ if err != nil {
+ return ""
+ }
+ values := parsed.Query()
+ values.Set(key, value)
+ parsed.RawQuery = values.Encode()
+ return parsed.String()
+}
diff --git a/pkg/html/pages/style.css b/pkg/html/pages/style.css
index d5ceef253..71a3efe71 100644
--- a/pkg/html/pages/style.css
+++ b/pkg/html/pages/style.css
@@ -194,6 +194,21 @@ table td, table th {
display: inline-block;
}
+.list_table .subsystem {
+ background: white;
+ border: 1pt solid black;
+ display: inline-block;
+ padding-left: 2pt;
+ padding-right: 2pt;
+ margin-left: 4pt;
+ font-size: small;
+}
+
+.list_table .subsystem a {
+ text-decoration: none;
+ color: black;
+}
+
.bad {
color: #f00;
font-weight: bold;