Commit a9eb95e41b

a9eb95e41bd83b37a2c2c1e28c254adfcd315e0f

parent: 6009cab89c

Verified · cmc

cmc <hello@cleberg.net> · 2026-09-12 05:11 UTC

web: the labels page hides an empty colour column

Ref #182
internal/httpd/labels.go +9 −1
@@ -28,13 +28,21 @@ func (s *Server) labels(w http.ResponseWriter, r *http.Request) {
2828 http.Error(w, "internal error", http.StatusInternalServerError)
2929 return
3030 }
31 anyColor := false
32 for _, l := range labels {
33 if l.Color != "" {
34 anyColor = true
35 break
36 }
37 }
3138 s.render(w, "labels.html", struct {
3239 repoPage
3340 Labels []store.Label
3441 LabelColors map[string]template.CSS
3542 CanWrite bool
43 AnyColor bool
3644 Notice string
37 }{p, labels, s.labelColors(p.Repo), s.canWriteRepo(r, p.Repo), s.takeFlash(w, r)})
45 }{p, labels, s.labelColors(p.Repo), s.canWriteRepo(r, p.Repo), anyColor, s.takeFlash(w, r)})
3846}
3947
4048// labelSubmit creates a label, sets its colour, or removes it, through
internal/web/templates/labels.html +3 −3
@@ -3,14 +3,14 @@
33<h1>Labels</h1>
44{{if .Notice}}<p class="error" role="alert">{{.Notice}}</p>{{end}}
55{{if .Labels}}<div class="tablewrap"><table class="keys">
6<tr class="cols"><th scope="col">label</th><th scope="col">colour</th><th scope="col">issues</th><th scope="col"></th></tr>
6<tr class="cols"><th scope="col">label</th>{{if or $.CanWrite $.AnyColor}}<th scope="col">colour</th>{{end}}<th scope="col">issues</th><th scope="col"></th></tr>
77{{range .Labels}}<tr>
88 <td><a class="chip label" style="{{index $.LabelColors .Name}}" href="/{{$.Repo.OwnerName}}/{{$.Repo.Name}}/issues?label={{.Name}}">{{.Name}}</a>{{if .Org}} <span class="chip chip-neutral">org</span>{{end}}</td>
9 <td>{{if and $.CanWrite (not .Org)}}<form method="post" action="/{{$.Repo.OwnerName}}/{{$.Repo.Name}}/labels" class="inline">
9 {{if or $.CanWrite $.AnyColor}}<td>{{if and $.CanWrite (not .Org)}}<form method="post" action="/{{$.Repo.OwnerName}}/{{$.Repo.Name}}/labels" class="inline">
1010 <input type="hidden" name="name" value="{{.Name}}">
1111 <input type="text" name="color" value="{{.Color}}" aria-label="Colour for {{.Name}}" placeholder="rrggbb" size="8">
1212 <button type="submit" class="btn">Save</button>
13 </form>{{else}}<span class="mono">{{if .Color}}{{.Color}}{{else}}—{{end}}</span>{{end}}</td>
13 </form>{{else}}<span class="mono">{{if .Color}}{{.Color}}{{else}}—{{end}}</span>{{end}}</td>{{end}}
1414 <td>{{.Issues}}</td>
1515 <td class="act">{{if and $.CanWrite (not .Org)}}<form method="post" action="/{{$.Repo.OwnerName}}/{{$.Repo.Name}}/labels" class="inline">
1616 <input type="hidden" name="action" value="remove">