[pkgsite] internal/frontend: evaluations tab

0 views
Skip to first unread message

Gopher Robot (Gerrit)

unread,
Jul 16, 2026, 4:39:46 PM (yesterday) Jul 16
to Jonathan Amsterdam, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, kokoro, golang...@luci-project-accounts.iam.gserviceaccount.com, Ethan Lee, Hyang-Ah Hana Kim, golang-co...@googlegroups.com

Gopher Robot submitted the change with unreviewed changes

Unreviewed changes

1 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:

```
The name of the file: internal/frontend/templates/templates_test.go
Insertions: 9, Deletions: 9.

@@ -24,26 +24,26 @@
}
}

-func TestMakeBoxes(t *testing.T) {
+func TestScoreBoxClasses(t *testing.T) {
for _, test := range []struct {
score, maxScore int
want []string
}{
- {score: 2, maxScore: 5, want: []string{"score-box-marked", "score-box-marked", "score-box-unmarked", "score-box-unmarked", "score-box-unmarked"}},
- {score: 0, maxScore: 3, want: []string{"score-box-unmarked", "score-box-unmarked", "score-box-unmarked"}},
- {score: 3, maxScore: 3, want: []string{"score-box-marked", "score-box-marked", "score-box-marked"}},
- {score: 5, maxScore: 3, want: []string{"score-box-marked", "score-box-marked", "score-box-marked"}},
- {score: -1, maxScore: 3, want: []string{"score-box-unmarked", "score-box-unmarked", "score-box-unmarked"}},
+ {score: 2, maxScore: 5, want: []string{scoreBoxMarked, scoreBoxMarked, scoreBoxUnmarked, scoreBoxUnmarked, scoreBoxUnmarked}},
+ {score: 0, maxScore: 3, want: []string{scoreBoxUnmarked, scoreBoxUnmarked, scoreBoxUnmarked}},
+ {score: 3, maxScore: 3, want: []string{scoreBoxMarked, scoreBoxMarked, scoreBoxMarked}},
+ {score: 5, maxScore: 3, want: []string{scoreBoxMarked, scoreBoxMarked, scoreBoxMarked}},
+ {score: -1, maxScore: 3, want: []string{scoreBoxUnmarked, scoreBoxUnmarked, scoreBoxUnmarked}},
{score: 2, maxScore: 0, want: nil},
} {
- got := makeBoxes(test.score, test.maxScore)
+ got := scoreBoxClasses(test.score, test.maxScore)
if len(got) != len(test.want) {
- t.Errorf("makeBoxes(%d, %d) len = %d, want %d", test.score, test.maxScore, len(got), len(test.want))
+ t.Errorf("scoreBoxClasses(%d, %d) len = %d, want %d", test.score, test.maxScore, len(got), len(test.want))
continue
}
for i := range got {
if got[i] != test.want[i] {
- t.Errorf("makeBoxes(%d, %d)[%d] = %q, want %q", test.score, test.maxScore, i, got[i], test.want[i])
+ t.Errorf("scoreBoxClasses(%d, %d)[%d] = %q, want %q", test.score, test.maxScore, i, got[i], test.want[i])
}
}
}
```
```
The name of the file: internal/frontend/templates/templates.go
Insertions: 19, Deletions: 17.

@@ -27,29 +27,31 @@
"commaseparate": func(s []string) string {
return strings.Join(s, ", ")
},
- "stripscheme": stripScheme,
- "capitalize": cases.Title(language.Und).String,
- "queryescape": url.QueryEscape,
- "makeBoxes": makeBoxes,
+ "stripscheme": stripScheme,
+ "capitalize": cases.Title(language.Und).String,
+ "queryescape": url.QueryEscape,
+ "scoreBoxClasses": scoreBoxClasses,
}

-func makeBoxes(score, maxScore int) []string {
+const (
+ scoreBoxMarked = "score-box-marked"
+ scoreBoxUnmarked = "score-box-unmarked"
+)
+
+// scoreBoxClasses returns a list of maxScore CSS classes
+// for evaluation score boxes. The first score boxes
+// will have a different class from the rest.
+func scoreBoxClasses(score, maxScore int) []string {
if maxScore <= 0 {
return nil
}
- if score > maxScore {
- score = maxScore
+ score = min(maxScore, max(0, score))
+ var classes []string
+ for range score {
+ classes = append(classes, scoreBoxMarked)
}
- if score < 0 {
- score = 0
- }
- classes := make([]string, maxScore)
- for i := range maxScore {
- if i < score {
- classes[i] = "score-box-marked"
- } else {
- classes[i] = "score-box-unmarked"
- }
+ for range maxScore - score {
+ classes = append(classes, scoreBoxUnmarked)
}
return classes
}
```

Change information

Commit message:
internal/frontend: evaluations tab

Add a tab for the evaluations page, along with
a template. The template is just a placeholder
for now.

For golang/go#80385.
Change-Id: I4f349c6ef12956b1b5eba31fa8436449a91055d1
Reviewed-by: Ethan Lee <etha...@google.com>
Auto-Submit: Jonathan Amsterdam <j...@google.com>
kokoro-CI: kokoro <noreply...@google.com>
Files:
  • M internal/frontend/tabs.go
  • M internal/frontend/templates/templates.go
  • M internal/frontend/templates/templates_test.go
  • M internal/frontend/unit_test.go
  • A static/frontend/unit/evals/evals.tmpl
Change size: M
Delta: 5 files changed, 89 insertions(+), 8 deletions(-)
Branch: refs/heads/master
Submit Requirements:
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: pkgsite
Gerrit-Branch: master
Gerrit-Change-Id: I4f349c6ef12956b1b5eba31fa8436449a91055d1
Gerrit-Change-Number: 800921
Gerrit-PatchSet: 4
Gerrit-Owner: Jonathan Amsterdam <j...@google.com>
Gerrit-Reviewer: Ethan Lee <etha...@google.com>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-Reviewer: Hyang-Ah Hana Kim <hya...@gmail.com>
Gerrit-Reviewer: Jonathan Amsterdam <j...@google.com>
Gerrit-Reviewer: kokoro <noreply...@google.com>
Gerrit-CC: kokoro <noreply...@google.com>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages