Commit c0b5c739d1

c0b5c739d1cd4e2fe71c7eb6bcbaf6f966e57cf6

parent: f7a4bb91fd

Verified · cmc

cmc <hello@cleberg.net> · 2026-09-28 22:20 UTC

web: watch button names all three states, muted included

Ref #271

Layout: unified · split

internal/httpd/mrpage_test.go +17
@@ -59,6 +59,23 @@ func TestMRDiffViewNamesAPrunedHead(t *testing.T) {
59 } 59 }
60} 60}
61 61
62// The watch button names all three states it cycles through, including
63// muted, which MR 1 made reachable (#271).
64func TestRepoHeaderWatchButtonNamesMutedState(t *testing.T) {
65 var sb strings.Builder
66 rp := testRepoPage()
67 rp.Viewer = "cmc" // the watch button only renders for a signed-in viewer
68 rp.Watch = "muted"
69 if err := web.Render(&sb, "mr.html", mrPageData{
70 repoPage: rp, MR: testMR("open"), View: "conversation",
71 }); err != nil {
72 t.Fatalf("render: %v", err)
73 }
74 if !strings.Contains(sb.String(), "Muted") {
75 t.Error(`watch button does not render "Muted" for a muted repo`)
76 }
77}
78
62func renderMR(t *testing.T, m store.MR, reviews []store.MRReview, checks []store.Check) string { 79func renderMR(t *testing.T, m store.MR, reviews []store.MRReview, checks []store.Check) string {
63 rows := make([]reviewRow, 0, len(reviews)) 80 rows := make([]reviewRow, 0, len(reviews))
64 for _, r := range reviews { 81 for _, r := range reviews {
internal/httpd/repohead_test.go +1 −1
@@ -39,7 +39,7 @@ func TestRepoHeaderTwoRows(t *testing.T) {
39 } 39 }
40 for _, want := range []string{ 40 for _, want := range []string{
41 `title="Pinned repositories show on your dashboard"`, 41 `title="Pinned repositories show on your dashboard"`,
42 `title="Watching sends every issue, request and build to your inbox"`, 42 `title="Only what involves you. Click to watch everything."`,
43 `title="Bookmarked lists it under Bookmarks"`, 43 `title="Bookmarked lists it under Bookmarks"`,
44 `<p class="repodesc">A CLI-first git forge.`, 44 `<p class="repodesc">A CLI-first git forge.`,
45 } { 45 } {
internal/web/templates/layout.html +1 −1
@@ -61,7 +61,7 @@
61 {{if eq $top "code"}}{{if or (field $ "Desc") (field $ "Topics") $.Repo.Settings.Website}}<p class="repodesc">{{with field $ "Desc"}}{{.}}{{end}} {{with field $ "Topics"}}{{range .}}<a class="chip topic" href="/explore?q={{.}}">{{.}}</a> {{end}}{{end}}{{with $.Repo.Settings.Website}}<a class="site" href="{{.}}" rel="nofollow">{{.}}</a>{{end}}</p>{{end}}{{end}} 61 {{if eq $top "code"}}{{if or (field $ "Desc") (field $ "Topics") $.Repo.Settings.Website}}<p class="repodesc">{{with field $ "Desc"}}{{.}}{{end}} {{with field $ "Topics"}}{{range .}}<a class="chip topic" href="/explore?q={{.}}">{{.}}</a> {{end}}{{end}}{{with $.Repo.Settings.Website}}<a class="site" href="{{.}}" rel="nofollow">{{.}}</a>{{end}}</p>{{end}}{{end}}
62 <span class="grow"></span> 62 <span class="grow"></span>
63 {{if $.Viewer}}<form method="post" action="/{{.OwnerName}}/{{.Name}}/pin" class="inline"><button type="submit" class="btn" aria-pressed="{{if field $ "Pinned"}}true{{else}}false{{end}}" title="Pinned repositories show on your dashboard"><span aria-hidden="true">{{if field $ "Pinned"}}★{{else}}☆{{end}}</span> {{if field $ "Pinned"}}Pinned{{else}}Pin{{end}}</button></form> 63 {{if $.Viewer}}<form method="post" action="/{{.OwnerName}}/{{.Name}}/pin" class="inline"><button type="submit" class="btn" aria-pressed="{{if field $ "Pinned"}}true{{else}}false{{end}}" title="Pinned repositories show on your dashboard"><span aria-hidden="true">{{if field $ "Pinned"}}★{{else}}☆{{end}}</span> {{if field $ "Pinned"}}Pinned{{else}}Pin{{end}}</button></form>
64 <form method="post" action="/{{.OwnerName}}/{{.Name}}/watch" class="inline"><button type="submit" class="btn" aria-pressed="{{if eq (str $ "Watch") "watching"}}true{{else}}false{{end}}" title="Watching sends every issue, request and build to your inbox">{{if eq (str $ "Watch") "watching"}}Watching{{else}}Watch{{end}}</button></form> 64 <form method="post" action="/{{.OwnerName}}/{{.Name}}/watch" class="inline"><button type="submit" class="btn" aria-pressed="{{if ne (str $ "Watch") ""}}true{{else}}false{{end}}" title="{{if eq (str $ "Watch") "watching"}}Watching: every issue, request and build. Click to mute.{{else if eq (str $ "Watch") "muted"}}Muted: nothing from this repository. Click to stop muting.{{else}}Only what involves you. Click to watch everything.{{end}}">{{if eq (str $ "Watch") "watching"}}Watching{{else if eq (str $ "Watch") "muted"}}Muted{{else}}Watch{{end}}</button></form>
65 <form method="post" action="/{{.OwnerName}}/{{.Name}}/bookmark" class="inline"><button type="submit" class="btn" aria-pressed="{{if field $ "Marked"}}true{{else}}false{{end}}" title="Bookmarked lists it under Bookmarks">{{if field $ "Marked"}}Bookmarked{{else}}Bookmark{{end}}</button></form> 65 <form method="post" action="/{{.OwnerName}}/{{.Name}}/bookmark" class="inline"><button type="submit" class="btn" aria-pressed="{{if field $ "Marked"}}true{{else}}false{{end}}" title="Bookmarked lists it under Bookmarks">{{if field $ "Marked"}}Bookmarked{{else}}Bookmark{{end}}</button></form>
66 <a class="button btn" href="/{{.OwnerName}}/{{.Name}}/fork">Fork</a>{{end}} 66 <a class="button btn" href="/{{.OwnerName}}/{{.Name}}/fork">Fork</a>{{end}}
67 </div> 67 </div>