web: the merge request diff view is wide !402

merged merged by cmc on 2026-09-18 04:23 UTC · krz/gitbay:stack-219 into main

2 files changed, +7 −2

Layout: unified · split

internal/web/templates/mr.html +1
@@ -1,3 +1,4 @@
1{{define "width"}}{{if eq .View "diff"}}wide{{else}}reading{{end}}{{end}}
1{{define "title"}}!{{.MR.Number}} · {{.Repo.OwnerName}}/{{.Repo.Name}}{{end}} 2{{define "title"}}!{{.MR.Number}} · {{.Repo.OwnerName}}/{{.Repo.Name}}{{end}}
2{{define "content"}} 3{{define "content"}}
3{{$base := printf "/%s/%s/mrs/%d" .Repo.OwnerName .Repo.Name .MR.Number}} 4{{$base := printf "/%s/%s/mrs/%d" .Repo.OwnerName .Repo.Name .MR.Number}}
internal/web/web_test.go +6 −2
@@ -86,10 +86,12 @@ func TestWhenNamesTheZone(t *testing.T) {
86 86
87// TestMainWidthClass checks each template's source for the width define 87// TestMainWidthClass checks each template's source for the width define
88// the spec assigns it (wide or bounded), and that a reading page defines 88// the spec assigns it (wide or bounded), and that a reading page defines
89// none. 89// none. The merge request page picks wide for its diff view, so it gets
90// a per-view define instead of a fixed one.
90func TestMainWidthClass(t *testing.T) { 91func TestMainWidthClass(t *testing.T) {
91 wide := map[string]bool{"tree.html": true, "blob.html": true, "blame.html": true, "log.html": true, "commit.html": true, "compare.html": true, "builds.html": true, "build.html": true, "search.html": true, "globalsearch.html": true} 92 wide := map[string]bool{"tree.html": true, "blob.html": true, "blame.html": true, "log.html": true, "commit.html": true, "compare.html": true, "builds.html": true, "build.html": true, "search.html": true, "globalsearch.html": true}
92 bounded := map[string]bool{"landing.html": true, "login.html": true, "register.html": true, "registered.html": true, "new.html": true, "issuenew.html": true, "mrnew.html": true, "settings.html": true, "account.html": true, "admin.html": true, "edit.html": true, "snippetnew.html": true, "privacy.html": true, "404.html": true} 93 bounded := map[string]bool{"landing.html": true, "login.html": true, "register.html": true, "registered.html": true, "new.html": true, "issuenew.html": true, "mrnew.html": true, "settings.html": true, "account.html": true, "admin.html": true, "edit.html": true, "snippetnew.html": true, "privacy.html": true, "404.html": true}
94 perView := map[string]string{"mr.html": `{{define "width"}}{{if eq .View "diff"}}wide{{else}}reading{{end}}{{end}}`}
93 for _, name := range Pages() { 95 for _, name := range Pages() {
94 src, err := TemplateSource(name) 96 src, err := TemplateSource(name)
95 if err != nil { 97 if err != nil {
@@ -97,11 +99,13 @@ func TestMainWidthClass(t *testing.T) {
97 } 99 }
98 has := strings.Contains(src, `{{define "width"}}`) 100 has := strings.Contains(src, `{{define "width"}}`)
99 switch { 101 switch {
102 case perView[name] != "" && !strings.Contains(src, perView[name]):
103 t.Errorf("%s: want per-view width define %s", name, perView[name])
100 case wide[name] && !strings.Contains(src, `{{define "width"}}wide{{end}}`): 104 case wide[name] && !strings.Contains(src, `{{define "width"}}wide{{end}}`):
101 t.Errorf("%s: want width wide", name) 105 t.Errorf("%s: want width wide", name)
102 case bounded[name] && !strings.Contains(src, `{{define "width"}}bounded{{end}}`): 106 case bounded[name] && !strings.Contains(src, `{{define "width"}}bounded{{end}}`):
103 t.Errorf("%s: want width bounded", name) 107 t.Errorf("%s: want width bounded", name)
104 case !wide[name] && !bounded[name] && has: 108 case !wide[name] && !bounded[name] && perView[name] == "" && has:
105 t.Errorf("%s: defines a width but the spec calls it reading", name) 109 t.Errorf("%s: defines a width but the spec calls it reading", name)
106 } 110 }
107 } 111 }