diff --git a/policy/common/result.go b/policy/common/result.go index 9685ab22..e0abf7fd 100644 --- a/policy/common/result.go +++ b/policy/common/result.go @@ -17,7 +17,7 @@ package common type EvaluationStatus int const ( - StatusSkipped EvaluationStatus = iota + StatusSkipped EvaluationStatus = iota // note: values used for ordering StatusPending StatusApproved StatusDisapproved diff --git a/server/handler/frontend.go b/server/handler/frontend.go index 51448229..0a8e818d 100644 --- a/server/handler/frontend.go +++ b/server/handler/frontend.go @@ -17,9 +17,12 @@ package handler import ( "html/template" "net/http" + "sort" "strings" "github.com/bluekeyes/templatetree" + + "github.com/palantir/policy-bot/policy/common" ) const ( @@ -35,6 +38,16 @@ type FilesConfig struct { func LoadTemplates(c *FilesConfig) (templatetree.HTMLTree, error) { root := template.New("root").Funcs(template.FuncMap{ "titlecase": strings.Title, + "sortByStatus": func(results []*common.Result) []*common.Result { + r := make([]*common.Result, len(results)) + copy(r, results) + + sort.SliceStable(r, func(i, j int) bool { + return r[i].Status > r[j].Status + }) + + return r + }, }) dir := c.Templates diff --git a/server/templates/details.html.tmpl b/server/templates/details.html.tmpl index 131d46b8..573ad57b 100644 --- a/server/templates/details.html.tmpl +++ b/server/templates/details.html.tmpl @@ -30,7 +30,7 @@
{{end}} @@ -44,7 +44,7 @@ {{if .Children}} {{end}}