Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

vole
Site
Clone

Read only, no credentials:

https://rodent.software/vole.git

Write over SSH with a registered key:

git clone ssh://git@rodent.software/vole.git

Self-hosted forge that lives in your Git repo.

Keep channels above a paginated release list

77d3fde66af0594afabd4860317dbeb95d78558f · Keenan Nemetz · 15d ago · parent ef3a07d6

Keep channels above a paginated release list

Channels are few and releases can run to hundreds, so the channel list now sits
first and stays on every page while the tag list pages underneath it at the same
25 rows the issue, change, and run lists use. The pager keeps `?page=` on the
releases URL, and the first page keeps the bare URL.

The total is the tag count, so the lightweight note still describes the whole
repository, and the editable column is decided from every tag rather than the
current page so it does not disappear between pages.

The regression test builds 31 tags and one channel, then checks both pages: the
channel section stays above the releases, page one links to page two, and page
two links back to the bare URL.

Refs 01M7QSTRTDSAAH7MW0YC1G1TD3.

server/releases_test.go +88−10

@@ -119,10 +119,10 @@ func TestReleaseListAndNotes(t *testing.T) {
119 119 }
120 120 }
121 121
122 // TestReleaseSections covers the page's shape: releases and channels are two
123 // H1 sections with their own actions, and each one's empty list is a
124 // region-level empty state rather than a bare muted line. The Files region has
125 // the same shape.
122 // TestReleaseSections covers the page's shape: channels and releases are two
123 // H1 sections with their own actions, channels first because they stay put
124 // while releases page, and each one's empty list is a region-level empty state
125 // rather than a bare muted line. The Files region has the same shape.
126 126 func TestReleaseSectionsAndEmptyStates(t *testing.T) {
127 127 t.Parallel()
128 128 f := newFixture(t)
@@ -131,8 +131,8 @@ func TestReleaseSectionsAndEmptyStates(t *testing.T) {
131 131
132 132 releases := strings.Index(page, `<section id="releases"`)
133 133 channels := strings.Index(page, `<section id="channels"`)
134 if releases < 0 || channels < 0 || releases > channels {
135 t.Fatalf("releases page does not put releases above channels:\n%s", page)
134 if releases < 0 || channels < 0 || channels > releases {
135 t.Fatalf("releases page does not put channels above releases:\n%s", page)
136 136 }
137 137 for _, heading := range []string{"<h1>Releases</h1>", "<h1>Channels</h1>"} {
138 138 if !strings.Contains(page, heading) {
@@ -152,12 +152,12 @@ func TestReleaseSectionsAndEmptyStates(t *testing.T) {
152 152 }
153 153 newRelease := strings.Index(page, "/releases/new")
154 154 newChannel := strings.Index(page, "/releases/channels/new")
155 if newRelease < releases || newRelease > channels {
156 t.Fatalf("New release is not with the releases header:\n%s", page)
157 }
158 if newChannel < channels {
155 if newChannel < channels || newChannel > releases {
159 156 t.Fatalf("New channel is not with the channels header:\n%s", page)
160 157 }
158 if newRelease < releases {
159 t.Fatalf("New release is not with the releases header:\n%s", page)
160 }
161 161 if got := strings.Count(page, `class="empty-state"`); got != 2 {
162 162 t.Fatalf("releases page has %d empty states, want one per section:\n%s", got, page)
163 163 }
@@ -175,6 +175,84 @@ func TestReleaseSectionsAndEmptyStates(t *testing.T) {
175 175 }
176 176 }
177 177
178 // TestReleaseListPaginatesUnderChannels pins the reason channels sit first: the
179 // channel list stays on every page while the tags, which can run to hundreds,
180 // page underneath it.
181 func TestReleaseListPaginatesUnderChannels(t *testing.T) {
182 t.Parallel()
183 f := newFixture(t)
184 f.publish(f.repo)
185 work := workRepo(t, map[string]string{"readme.md": "many releases\n"})
186 if _, errs, err := f.git(work, "push", f.sshURL(f.repo), "main:refs/heads/main"); err != nil {
187 t.Fatalf("push: %s", errs)
188 }
189 if _, errs, err := runGit(t, work, "tag", "-a", "v1.0.0", "-m", "First release\n"); err != nil {
190 t.Fatalf("tag v1.0.0: %s", errs)
191 }
192 // 31 tags: one full page plus six rows on the second.
193 for i := 0; i < 30; i++ {
194 name := fmt.Sprintf("v0.%02d.0", i)
195 if _, errs, err := runGit(t, work, "tag", name); err != nil {
196 t.Fatalf("tag %s: %s", name, errs)
197 }
198 }
199 if _, errs, err := f.git(work, "push", f.sshURL(f.repo), "--tags"); err != nil {
200 t.Fatalf("push tags: %s", errs)
201 }
202 m := mustRepo(t, f)
203 tag, err := m.Git().Tag("v1.0.0")
204 if err != nil {
205 t.Fatal(err)
206 }
207 if err := f.srv.Channels.Set(m.ID, channel.Channel{
208 Name: "stable",
209 Release: "v1.0.0",
210 ReleaseObject: tag.OID,
211 UpdatedBy: "keenan",
212 UpdatedAt: time.Now().UTC(),
213 }); err != nil {
214 t.Fatal(err)
215 }
216
217 code, first := f.get("/" + f.repo + "/releases")
218 if code != 200 {
219 t.Fatalf("releases page = %d:\n%s", code, first)
220 }
221 channels := strings.Index(first, `<section id="channels"`)
222 releases := strings.Index(first, `<section id="releases"`)
223 if channels < 0 || releases < 0 || channels > releases {
224 t.Fatalf("channels are not above the paginated releases:\n%s", first)
225 }
226 for _, want := range []string{
227 "Showing 1–25 of 31 · page 1 of 2",
228 `href="/` + f.repo + `/releases?page=2"`,
229 `href="/` + f.repo + `/channels/stable"`,
230 } {
231 if !strings.Contains(first, want) {
232 t.Fatalf("first release page does not show %q:\n%s", want, first)
233 }
234 }
235
236 code, second := f.get("/" + f.repo + "/releases?page=2")
237 if code != 200 {
238 t.Fatalf("second release page = %d:\n%s", code, second)
239 }
240 channels = strings.Index(second, `<section id="channels"`)
241 releases = strings.Index(second, `<section id="releases"`)
242 if channels < 0 || releases < 0 || channels > releases {
243 t.Fatalf("channels did not stay above the second page:\n%s", second)
244 }
245 for _, want := range []string{
246 "Showing 26–31 of 31 · page 2 of 2",
247 `href="/` + f.repo + `/releases"`,
248 `href="/` + f.repo + `/channels/stable"`,
249 } {
250 if !strings.Contains(second, want) {
251 t.Fatalf("second release page does not show %q:\n%s", want, second)
252 }
253 }
254 }
255
178 256 // TestReleaseNotesAreSanitised matters because the notes are somebody's markdown:
179 257 // a tag message is pushed content, so it goes through the same renderer as every
180 258 // other pushed body.