BlueGit

timfa bluegit

Overzicht: tabs Repositories en Groepen, 50 per pagina; API sort=pushed

timfa Tim Falken · pushed by timfa

Authored 2026-10-27 · 3 weeks ago

Hash
a61b51335365b8ca795dfce583f44dd7758adfad
Parent
6c48fa9e
Pipeline
Passed
7 files changed +126 −18
internal/i18n/catalog_dashlimit.go +4 −4
@@ -1,8 +1,8 @@
1 1 package i18n
2 2
3 3 func init() {
4 addCatalog(en, map[string]string{"dash.showAll": "Show all (%d more)", "dash.moreTip": "The overview shows the 10 most recently pushed.", "dash.groupsTip": "Sorted by the most recent push in a repository of the group; groups without pushes come last."})
5 addCatalog(nl, map[string]string{"dash.showAll": "Alles tonen (nog %d)", "dash.moreTip": "Het overzicht toont de 10 waarin het laatst gepusht is.", "dash.groupsTip": "Gesorteerd op de laatste push in een repository van de groep; groepen zonder push staan onderaan."})
6 addCatalog(de, map[string]string{"dash.showAll": "Alle anzeigen (%d weitere)", "dash.moreTip": "Die Übersicht zeigt die 10 mit dem jüngsten Push.", "dash.groupsTip": "Nach dem letzten Push in einem Repository der Gruppe sortiert; Gruppen ohne Push stehen unten."})
7 addCatalog(fr, map[string]string{"dash.showAll": "Tout afficher (%d de plus)", "dash.moreTip": "L'aperçu montre les 10 avec le push le plus récent.", "dash.groupsTip": "Trié par dernier push dans un dépôt du groupe ; les groupes sans push sont en bas."})
4 addCatalog(en, map[string]string{"dash.tabOverview": "Overview", "dash.tabReposTip": "All repositories you can access, most recent push first, 50 per page.", "dash.tabGroupsTip": "Groups you are a member of, most recent push first, 50 per page.", "dash.prev": "Previous", "dash.next": "Next", "dash.pageOf": "Page %d of %d", "dash.showAll": "Show all (%d more)", "dash.moreTip": "The overview shows the 10 most recently pushed.", "dash.groupsTip": "Sorted by the most recent push in a repository of the group; groups without pushes come last."})
5 addCatalog(nl, map[string]string{"dash.tabOverview": "Overzicht", "dash.tabReposTip": "Alle repositories waar je toegang toe hebt, laatste push eerst, 50 per pagina.", "dash.tabGroupsTip": "Groepen waar je lid van bent, laatste push eerst, 50 per pagina.", "dash.prev": "Vorige", "dash.next": "Volgende", "dash.pageOf": "Pagina %d van %d", "dash.showAll": "Alles tonen (nog %d)", "dash.moreTip": "Het overzicht toont de 10 waarin het laatst gepusht is.", "dash.groupsTip": "Gesorteerd op de laatste push in een repository van de groep; groepen zonder push staan onderaan."})
6 addCatalog(de, map[string]string{"dash.tabOverview": "Übersicht", "dash.tabReposTip": "Alle Repositories, auf die du Zugriff hast, jüngster Push zuerst, 50 pro Seite.", "dash.tabGroupsTip": "Gruppen, in denen du Mitglied bist, jüngster Push zuerst, 50 pro Seite.", "dash.prev": "Zurück", "dash.next": "Weiter", "dash.pageOf": "Seite %d von %d", "dash.showAll": "Alle anzeigen (%d weitere)", "dash.moreTip": "Die Übersicht zeigt die 10 mit dem jüngsten Push.", "dash.groupsTip": "Nach dem letzten Push in einem Repository der Gruppe sortiert; Gruppen ohne Push stehen unten."})
7 addCatalog(fr, map[string]string{"dash.tabOverview": "Aperçu", "dash.tabReposTip": "Tous les dépôts auxquels tu as accès, dernier push en premier, 50 par page.", "dash.tabGroupsTip": "Groupes dont tu es membre, dernier push en premier, 50 par page.", "dash.prev": "Précédent", "dash.next": "Suivant", "dash.pageOf": "Page %d sur %d", "dash.showAll": "Tout afficher (%d de plus)", "dash.moreTip": "L'aperçu montre les 10 avec le push le plus récent.", "dash.groupsTip": "Trié par dernier push dans un dépôt du groupe ; les groupes sans push sont en bas."})
8 8 }
@@ -1,8 +1,8 @@
1package i18n
1package i18n
2
2
3func init() {
3func init() {
4 addCatalog(en, map[string]string{"dash.showAll": "Show all (%d more)", "dash.moreTip": "The overview shows the 10 most recently pushed.", "dash.groupsTip": "Sorted by the most recent push in a repository of the group; groups without pushes come last."})
4 addCatalog(en, map[string]string{"dash.tabOverview": "Overview", "dash.tabReposTip": "All repositories you can access, most recent push first, 50 per page.", "dash.tabGroupsTip": "Groups you are a member of, most recent push first, 50 per page.", "dash.prev": "Previous", "dash.next": "Next", "dash.pageOf": "Page %d of %d", "dash.showAll": "Show all (%d more)", "dash.moreTip": "The overview shows the 10 most recently pushed.", "dash.groupsTip": "Sorted by the most recent push in a repository of the group; groups without pushes come last."})
5 addCatalog(nl, map[string]string{"dash.showAll": "Alles tonen (nog %d)", "dash.moreTip": "Het overzicht toont de 10 waarin het laatst gepusht is.", "dash.groupsTip": "Gesorteerd op de laatste push in een repository van de groep; groepen zonder push staan onderaan."})
5 addCatalog(nl, map[string]string{"dash.tabOverview": "Overzicht", "dash.tabReposTip": "Alle repositories waar je toegang toe hebt, laatste push eerst, 50 per pagina.", "dash.tabGroupsTip": "Groepen waar je lid van bent, laatste push eerst, 50 per pagina.", "dash.prev": "Vorige", "dash.next": "Volgende", "dash.pageOf": "Pagina %d van %d", "dash.showAll": "Alles tonen (nog %d)", "dash.moreTip": "Het overzicht toont de 10 waarin het laatst gepusht is.", "dash.groupsTip": "Gesorteerd op de laatste push in een repository van de groep; groepen zonder push staan onderaan."})
6 addCatalog(de, map[string]string{"dash.showAll": "Alle anzeigen (%d weitere)", "dash.moreTip": "Die Übersicht zeigt die 10 mit dem jüngsten Push.", "dash.groupsTip": "Nach dem letzten Push in einem Repository der Gruppe sortiert; Gruppen ohne Push stehen unten."})
6 addCatalog(de, map[string]string{"dash.tabOverview": "Übersicht", "dash.tabReposTip": "Alle Repositories, auf die du Zugriff hast, jüngster Push zuerst, 50 pro Seite.", "dash.tabGroupsTip": "Gruppen, in denen du Mitglied bist, jüngster Push zuerst, 50 pro Seite.", "dash.prev": "Zurück", "dash.next": "Weiter", "dash.pageOf": "Seite %d von %d", "dash.showAll": "Alle anzeigen (%d weitere)", "dash.moreTip": "Die Übersicht zeigt die 10 mit dem jüngsten Push.", "dash.groupsTip": "Nach dem letzten Push in einem Repository der Gruppe sortiert; Gruppen ohne Push stehen unten."})
7 addCatalog(fr, map[string]string{"dash.showAll": "Tout afficher (%d de plus)", "dash.moreTip": "L'aperçu montre les 10 avec le push le plus récent.", "dash.groupsTip": "Trié par dernier push dans un dépôt du groupe ; les groupes sans push sont en bas."})
7 addCatalog(fr, map[string]string{"dash.tabOverview": "Aperçu", "dash.tabReposTip": "Tous les dépôts auxquels tu as accès, dernier push en premier, 50 par page.", "dash.tabGroupsTip": "Groupes dont tu es membre, dernier push en premier, 50 par page.", "dash.prev": "Précédent", "dash.next": "Suivant", "dash.pageOf": "Page %d sur %d", "dash.showAll": "Tout afficher (%d de plus)", "dash.moreTip": "L'aperçu montre les 10 avec le push le plus récent.", "dash.groupsTip": "Trié par dernier push dans un dépôt du groupe ; les groupes sans push sont en bas."})
8}
8}
internal/server/api_collab.go +8 −0
@@ -34,6 +34,11 @@ func (s *Server) apiListGroups(w http.ResponseWriter, r *http.Request) {
34 34 if !s.apiOK(w, r, err) {
35 35 return
36 36 }
37 if r.URL.Query().Get("sort") == "pushed" {
38 if at, err := s.Store.GroupPushTimes(r.Context()); err == nil {
39 store.SortGroupsByPush(list, at)
40 }
41 }
37 42 page, per := pageQuery(r)
38 43 rows := make([]map[string]any, 0, len(list))
39 44 for _, g := range list {
@@ -154,6 +159,9 @@ func (s *Server) apiListProjects(w http.ResponseWriter, r *http.Request) {
154 159 if !s.apiOK(w, r, err) {
155 160 return
156 161 }
162 if r.URL.Query().Get("sort") == "pushed" {
163 store.SortReposByPush(list)
164 }
157 165 s.writeProjects(w, r, list)
158 166 }
159 167
@@ -34,6 +34,11 @@ func (s *Server) apiListGroups(w http.ResponseWriter, r *http.Request) {
34 if !s.apiOK(w, r, err) {
34 if !s.apiOK(w, r, err) {
35 return
35 return
36 }
36 }
37 if r.URL.Query().Get("sort") == "pushed" {
38 if at, err := s.Store.GroupPushTimes(r.Context()); err == nil {
39 store.SortGroupsByPush(list, at)
40 }
41 }
37 page, per := pageQuery(r)
42 page, per := pageQuery(r)
38 rows := make([]map[string]any, 0, len(list))
43 rows := make([]map[string]any, 0, len(list))
39 for _, g := range list {
44 for _, g := range list {
@@ -154,6 +159,9 @@ func (s *Server) apiListProjects(w http.ResponseWriter, r *http.Request) {
154 if !s.apiOK(w, r, err) {
159 if !s.apiOK(w, r, err) {
155 return
160 return
156 }
161 }
162 if r.URL.Query().Get("sort") == "pushed" {
163 store.SortReposByPush(list)
164 }
157 s.writeProjects(w, r, list)
165 s.writeProjects(w, r, list)
158}
166}
159
167
internal/server/api_routes.go +2 −2
@@ -60,7 +60,7 @@ var apiCatalog = []apiRoute{
60 60 {http.MethodPost, "/api/v1/user/keys", access.ScopeWrite, authUser, "Add SSH key", (*Server).apiAddKey},
61 61 {http.MethodDelete, "/api/v1/user/keys/{id}", access.ScopeWrite, authUser, "Remove SSH key", (*Server).apiDeleteKey},
62 62
63 {http.MethodGet, "/api/v1/groups", access.ScopeRead, authUser, "List groups", (*Server).apiListGroups},
63 {http.MethodGet, "/api/v1/groups", access.ScopeRead, authUser, "List groups you are a member of. page and per_page paginate; sort=pushed orders by the most recent push, like the dashboard.", (*Server).apiListGroups},
64 64 {http.MethodPost, "/api/v1/groups", access.ScopeWrite, authUser, "Create group", (*Server).apiCreateGroup},
65 65 {http.MethodGet, "/api/v1/groups/{path}", access.ScopeRead, authUser, "Get group", (*Server).apiGetGroup},
66 66 {http.MethodPut, "/api/v1/groups/{path}", access.ScopeWrite, authUser, "Update group", (*Server).apiPutGroup},
@@ -82,7 +82,7 @@ var apiCatalog = []apiRoute{
82 82 {http.MethodGet, "/api/v1/groups/{path}/logo", access.ScopeRead, authUser, "Group logo", (*Server).apiGroupLogo},
83 83 {http.MethodPost, "/api/v1/groups/{path}/logo", access.ScopeWrite, authUser, "Upload group logo", (*Server).apiGroupLogo},
84 84
85 {http.MethodGet, "/api/v1/projects", access.ScopeRead, authUser, "List projects", (*Server).apiListProjects},
85 {http.MethodGet, "/api/v1/projects", access.ScopeRead, authUser, "List projects you can access. page and per_page paginate; sort=pushed orders by the most recent push, like the dashboard.", (*Server).apiListProjects},
86 86 {http.MethodPost, "/api/v1/projects", access.ScopeWrite, authUser, "Create project", (*Server).apiCreateProject},
87 87 {http.MethodGet, "/api/v1/projects/{owner}/{repo}", access.ScopeRepoRead, authOptional, "Get project", (*Server).apiGetProject},
88 88 {http.MethodPut, "/api/v1/projects/{owner}/{repo}", access.ScopeWrite, authUser, "Update project", (*Server).apiPutProject},
@@ -60,7 +60,7 @@ var apiCatalog = []apiRoute{
60 {http.MethodPost, "/api/v1/user/keys", access.ScopeWrite, authUser, "Add SSH key", (*Server).apiAddKey},
60 {http.MethodPost, "/api/v1/user/keys", access.ScopeWrite, authUser, "Add SSH key", (*Server).apiAddKey},
61 {http.MethodDelete, "/api/v1/user/keys/{id}", access.ScopeWrite, authUser, "Remove SSH key", (*Server).apiDeleteKey},
61 {http.MethodDelete, "/api/v1/user/keys/{id}", access.ScopeWrite, authUser, "Remove SSH key", (*Server).apiDeleteKey},
62
62
63 {http.MethodGet, "/api/v1/groups", access.ScopeRead, authUser, "List groups", (*Server).apiListGroups},
63 {http.MethodGet, "/api/v1/groups", access.ScopeRead, authUser, "List groups you are a member of. page and per_page paginate; sort=pushed orders by the most recent push, like the dashboard.", (*Server).apiListGroups},
64 {http.MethodPost, "/api/v1/groups", access.ScopeWrite, authUser, "Create group", (*Server).apiCreateGroup},
64 {http.MethodPost, "/api/v1/groups", access.ScopeWrite, authUser, "Create group", (*Server).apiCreateGroup},
65 {http.MethodGet, "/api/v1/groups/{path}", access.ScopeRead, authUser, "Get group", (*Server).apiGetGroup},
65 {http.MethodGet, "/api/v1/groups/{path}", access.ScopeRead, authUser, "Get group", (*Server).apiGetGroup},
66 {http.MethodPut, "/api/v1/groups/{path}", access.ScopeWrite, authUser, "Update group", (*Server).apiPutGroup},
66 {http.MethodPut, "/api/v1/groups/{path}", access.ScopeWrite, authUser, "Update group", (*Server).apiPutGroup},
@@ -82,7 +82,7 @@ var apiCatalog = []apiRoute{
82 {http.MethodGet, "/api/v1/groups/{path}/logo", access.ScopeRead, authUser, "Group logo", (*Server).apiGroupLogo},
82 {http.MethodGet, "/api/v1/groups/{path}/logo", access.ScopeRead, authUser, "Group logo", (*Server).apiGroupLogo},
83 {http.MethodPost, "/api/v1/groups/{path}/logo", access.ScopeWrite, authUser, "Upload group logo", (*Server).apiGroupLogo},
83 {http.MethodPost, "/api/v1/groups/{path}/logo", access.ScopeWrite, authUser, "Upload group logo", (*Server).apiGroupLogo},
84
84
85 {http.MethodGet, "/api/v1/projects", access.ScopeRead, authUser, "List projects", (*Server).apiListProjects},
85 {http.MethodGet, "/api/v1/projects", access.ScopeRead, authUser, "List projects you can access. page and per_page paginate; sort=pushed orders by the most recent push, like the dashboard.", (*Server).apiListProjects},
86 {http.MethodPost, "/api/v1/projects", access.ScopeWrite, authUser, "Create project", (*Server).apiCreateProject},
86 {http.MethodPost, "/api/v1/projects", access.ScopeWrite, authUser, "Create project", (*Server).apiCreateProject},
87 {http.MethodGet, "/api/v1/projects/{owner}/{repo}", access.ScopeRepoRead, authOptional, "Get project", (*Server).apiGetProject},
87 {http.MethodGet, "/api/v1/projects/{owner}/{repo}", access.ScopeRepoRead, authOptional, "Get project", (*Server).apiGetProject},
88 {http.MethodPut, "/api/v1/projects/{owner}/{repo}", access.ScopeWrite, authUser, "Update project", (*Server).apiPutProject},
88 {http.MethodPut, "/api/v1/projects/{owner}/{repo}", access.ScopeWrite, authUser, "Update project", (*Server).apiPutProject},
internal/server/auth_handlers.go +49 −3
@@ -3,6 +3,7 @@ package server
3 3 import (
4 4 "encoding/json"
5 5 "net/http"
6 "strconv"
6 7 "strings"
7 8 "time"
8 9
@@ -106,8 +107,20 @@ func (s *Server) home(w http.ResponseWriter, r *http.Request) {
106 107 return
107 108 }
108 109 store.SortReposByPush(repos)
109 all := r.URL.Query().Get("all")
110 if len(repos) > dashLimit && all != "repos" {
110 // Oude links ?all=repos / ?all=groups gaan naar de tabs.
111 if all := r.URL.Query().Get("all"); all == "repos" || all == "groups" {
112 http.Redirect(w, r, "/?tab="+all, http.StatusSeeOther)
113 return
114 }
115 tab := r.URL.Query().Get("tab")
116 if tab != "repos" && tab != "groups" {
117 tab = ""
118 }
119 v.DashTab = tab
120 v.DashRepoN = len(repos)
121 if tab == "repos" {
122 repos = dashPage(&v, r, repos)
123 } else if len(repos) > dashLimit {
111 124 v.MoreRepos = len(repos) - dashLimit
112 125 repos = repos[:dashLimit]
113 126 }
@@ -121,7 +134,10 @@ func (s *Server) home(w http.ResponseWriter, r *http.Request) {
121 134 if at, err := s.Store.GroupPushTimes(r.Context()); err == nil {
122 135 store.SortGroupsByPush(groups, at)
123 136 }
124 if len(groups) > dashLimit && all != "groups" {
137 v.DashGroupN = len(groups)
138 if tab == "groups" {
139 groups = dashPage(&v, r, groups)
140 } else if len(groups) > dashLimit {
125 141 v.MoreGroups = len(groups) - dashLimit
126 142 groups = groups[:dashLimit]
127 143 }
@@ -268,3 +284,33 @@ var errBadID = http.ErrMissingFile
268 284
269 285 // dashLimit is het aantal repos en groepen op het overzicht.
270 286 const dashLimit = 10
287
288 // dashPerPage: de tabs Repositories en Groepen tonen 50 per pagina.
289 const dashPerPage = 50
290
291 func dashPage[T any](v *View, r *http.Request, list []T) []T {
292 pages := (len(list) + dashPerPage - 1) / dashPerPage
293 if pages < 1 {
294 pages = 1
295 }
296 page, _ := strconv.Atoi(r.URL.Query().Get("page"))
297 if page < 1 {
298 page = 1
299 }
300 if page > pages {
301 page = pages
302 }
303 v.DashPage, v.DashPages = page, pages
304 if page > 1 {
305 v.DashPrev = page - 1
306 }
307 if page < pages {
308 v.DashNext = page + 1
309 }
310 from := (page - 1) * dashPerPage
311 to := from + dashPerPage
312 if to > len(list) {
313 to = len(list)
314 }
315 return list[from:to]
316 }
@@ -3,6 +3,7 @@ package server
3import (
3import (
4 "encoding/json"
4 "encoding/json"
5 "net/http"
5 "net/http"
6 "strconv"
6 "strings"
7 "strings"
7 "time"
8 "time"
8
9
@@ -106,8 +107,20 @@ func (s *Server) home(w http.ResponseWriter, r *http.Request) {
106 return
107 return
107 }
108 }
108 store.SortReposByPush(repos)
109 store.SortReposByPush(repos)
109 all := r.URL.Query().Get("all")
110 // Oude links ?all=repos / ?all=groups gaan naar de tabs.
110 if len(repos) > dashLimit && all != "repos" {
111 if all := r.URL.Query().Get("all"); all == "repos" || all == "groups" {
112 http.Redirect(w, r, "/?tab="+all, http.StatusSeeOther)
113 return
114 }
115 tab := r.URL.Query().Get("tab")
116 if tab != "repos" && tab != "groups" {
117 tab = ""
118 }
119 v.DashTab = tab
120 v.DashRepoN = len(repos)
121 if tab == "repos" {
122 repos = dashPage(&v, r, repos)
123 } else if len(repos) > dashLimit {
111 v.MoreRepos = len(repos) - dashLimit
124 v.MoreRepos = len(repos) - dashLimit
112 repos = repos[:dashLimit]
125 repos = repos[:dashLimit]
113 }
126 }
@@ -121,7 +134,10 @@ func (s *Server) home(w http.ResponseWriter, r *http.Request) {
121 if at, err := s.Store.GroupPushTimes(r.Context()); err == nil {
134 if at, err := s.Store.GroupPushTimes(r.Context()); err == nil {
122 store.SortGroupsByPush(groups, at)
135 store.SortGroupsByPush(groups, at)
123 }
136 }
124 if len(groups) > dashLimit && all != "groups" {
137 v.DashGroupN = len(groups)
138 if tab == "groups" {
139 groups = dashPage(&v, r, groups)
140 } else if len(groups) > dashLimit {
125 v.MoreGroups = len(groups) - dashLimit
141 v.MoreGroups = len(groups) - dashLimit
126 groups = groups[:dashLimit]
142 groups = groups[:dashLimit]
127 }
143 }
@@ -268,3 +284,33 @@ var errBadID = http.ErrMissingFile
268
284
269// dashLimit is het aantal repos en groepen op het overzicht.
285// dashLimit is het aantal repos en groepen op het overzicht.
270const dashLimit = 10
286const dashLimit = 10
287
288// dashPerPage: de tabs Repositories en Groepen tonen 50 per pagina.
289const dashPerPage = 50
290
291func dashPage[T any](v *View, r *http.Request, list []T) []T {
292 pages := (len(list) + dashPerPage - 1) / dashPerPage
293 if pages < 1 {
294 pages = 1
295 }
296 page, _ := strconv.Atoi(r.URL.Query().Get("page"))
297 if page < 1 {
298 page = 1
299 }
300 if page > pages {
301 page = pages
302 }
303 v.DashPage, v.DashPages = page, pages
304 if page > 1 {
305 v.DashPrev = page - 1
306 }
307 if page < pages {
308 v.DashNext = page + 1
309 }
310 from := (page - 1) * dashPerPage
311 to := from + dashPerPage
312 if to > len(list) {
313 to = len(list)
314 }
315 return list[from:to]
316}
internal/server/dash_limit_test.go +26 −7
@@ -53,12 +53,12 @@ func TestDashboardLimitsToTen(t *testing.T) {
53 53 ts := httptest.NewServer(srv.Handler())
54 54 t.Cleanup(ts.Close)
55 55
56 for i := 0; i < 12; i++ {
56 for i := 0; i < 55; i++ {
57 57 r, err := st.CreateRepo(ctx, "user", ada.ID, fmt.Sprintf("r%02d", i), "", "master", "private")
58 58 if err != nil {
59 59 t.Fatal(err)
60 60 }
61 _ = st.TouchPushed(ctx, r.ID, time.Date(2026, 1, 1+i, 0, 0, 0, 0, time.UTC))
61 _ = st.TouchPushed(ctx, r.ID, time.Date(2026, 1, 1, i, 0, 0, 0, time.UTC))
62 62 }
63 63 _, _ = devTok, adaTok
64 64 jar, _ := cookiejar.New(nil)
@@ -79,14 +79,33 @@ func TestDashboardLimitsToTen(t *testing.T) {
79 79 if n := strings.Count(dash, `class="reponame" href="/ada/r`); n != 10 {
80 80 t.Fatalf("dashboard toont %d repos", n)
81 81 }
82 if !strings.Contains(dash, `href="/?all=repos"`) || !strings.Contains(dash, "(2 more)") {
82 if !strings.Contains(dash, `href="/?tab=repos"`) || !strings.Contains(dash, "(45 more)") {
83 83 t.Fatal("alles-tonen-link ontbreekt")
84 84 }
85 if strings.Index(dash, `href="/ada/r11"`) > strings.Index(dash, `href="/ada/r10"`) || strings.Contains(dash, `href="/ada/r01"`) {
85 if strings.Index(dash, `href="/ada/r54"`) > strings.Index(dash, `href="/ada/r53"`) || strings.Contains(dash, `href="/ada/r01"`) {
86 86 t.Fatal("volgorde of afkapping klopt niet")
87 87 }
88 full := get("/?all=repos")
89 if n := strings.Count(full, `class="reponame" href="/ada/r`); n != 12 {
90 t.Fatalf("alles tonen geeft %d", n)
88 full := get("/?all=repos") // oude link: redirect naar de tab
89 if n := strings.Count(full, `class="reponame" href="/ada/r`); n != 50 {
90 t.Fatalf("tab pagina 1 geeft %d", n)
91 }
92 if !strings.Contains(full, `page=2`) || !strings.Contains(full, `href="/ada/r54"`) {
93 t.Fatal("paginering of volgorde")
94 }
95 p2 := get("/?tab=repos&page=2")
96 if n := strings.Count(p2, `class="reponame" href="/ada/r`); n != 5 || !strings.Contains(p2, `href="/ada/r00"`) {
97 t.Fatalf("pagina 2 geeft %d", n)
98 }
99 if g := get("/?tab=groups"); !strings.Contains(g, `href="/?tab=groups" class="on"`) {
100 t.Fatal("groepentab")
101 }
102 req, _ := http.NewRequest(http.MethodGet, ts.URL+"/api/v1/projects?sort=pushed&per_page=2", nil)
103 req.Header.Set("Authorization", "Bearer "+adaTok)
104 res, err = http.DefaultClient.Do(req)
105 if err != nil {
106 t.Fatal(err)
107 }
108 if body := read(t, res); !strings.Contains(body, `"r54"`) || strings.Contains(body, `"r00"`) {
109 t.Fatalf("api sort: %s", body)
91 110 }
92 111 }
@@ -53,12 +53,12 @@ func TestDashboardLimitsToTen(t *testing.T) {
53 ts := httptest.NewServer(srv.Handler())
53 ts := httptest.NewServer(srv.Handler())
54 t.Cleanup(ts.Close)
54 t.Cleanup(ts.Close)
55
55
56 for i := 0; i < 12; i++ {
56 for i := 0; i < 55; i++ {
57 r, err := st.CreateRepo(ctx, "user", ada.ID, fmt.Sprintf("r%02d", i), "", "master", "private")
57 r, err := st.CreateRepo(ctx, "user", ada.ID, fmt.Sprintf("r%02d", i), "", "master", "private")
58 if err != nil {
58 if err != nil {
59 t.Fatal(err)
59 t.Fatal(err)
60 }
60 }
61 _ = st.TouchPushed(ctx, r.ID, time.Date(2026, 1, 1+i, 0, 0, 0, 0, time.UTC))
61 _ = st.TouchPushed(ctx, r.ID, time.Date(2026, 1, 1, i, 0, 0, 0, time.UTC))
62 }
62 }
63 _, _ = devTok, adaTok
63 _, _ = devTok, adaTok
64 jar, _ := cookiejar.New(nil)
64 jar, _ := cookiejar.New(nil)
@@ -79,14 +79,33 @@ func TestDashboardLimitsToTen(t *testing.T) {
79 if n := strings.Count(dash, `class="reponame" href="/ada/r`); n != 10 {
79 if n := strings.Count(dash, `class="reponame" href="/ada/r`); n != 10 {
80 t.Fatalf("dashboard toont %d repos", n)
80 t.Fatalf("dashboard toont %d repos", n)
81 }
81 }
82 if !strings.Contains(dash, `href="/?all=repos"`) || !strings.Contains(dash, "(2 more)") {
82 if !strings.Contains(dash, `href="/?tab=repos"`) || !strings.Contains(dash, "(45 more)") {
83 t.Fatal("alles-tonen-link ontbreekt")
83 t.Fatal("alles-tonen-link ontbreekt")
84 }
84 }
85 if strings.Index(dash, `href="/ada/r11"`) > strings.Index(dash, `href="/ada/r10"`) || strings.Contains(dash, `href="/ada/r01"`) {
85 if strings.Index(dash, `href="/ada/r54"`) > strings.Index(dash, `href="/ada/r53"`) || strings.Contains(dash, `href="/ada/r01"`) {
86 t.Fatal("volgorde of afkapping klopt niet")
86 t.Fatal("volgorde of afkapping klopt niet")
87 }
87 }
88 full := get("/?all=repos")
88 full := get("/?all=repos") // oude link: redirect naar de tab
89 if n := strings.Count(full, `class="reponame" href="/ada/r`); n != 12 {
89 if n := strings.Count(full, `class="reponame" href="/ada/r`); n != 50 {
90 t.Fatalf("alles tonen geeft %d", n)
90 t.Fatalf("tab pagina 1 geeft %d", n)
91 }
92 if !strings.Contains(full, `page=2`) || !strings.Contains(full, `href="/ada/r54"`) {
93 t.Fatal("paginering of volgorde")
94 }
95 p2 := get("/?tab=repos&page=2")
96 if n := strings.Count(p2, `class="reponame" href="/ada/r`); n != 5 || !strings.Contains(p2, `href="/ada/r00"`) {
97 t.Fatalf("pagina 2 geeft %d", n)
98 }
99 if g := get("/?tab=groups"); !strings.Contains(g, `href="/?tab=groups" class="on"`) {
100 t.Fatal("groepentab")
101 }
102 req, _ := http.NewRequest(http.MethodGet, ts.URL+"/api/v1/projects?sort=pushed&per_page=2", nil)
103 req.Header.Set("Authorization", "Bearer "+adaTok)
104 res, err = http.DefaultClient.Do(req)
105 if err != nil {
106 t.Fatal(err)
107 }
108 if body := read(t, res); !strings.Contains(body, `"r54"`) || strings.Contains(body, `"r00"`) {
109 t.Fatalf("api sort: %s", body)
91 }
110 }
92}
111}
internal/server/server.go +7 −0
@@ -711,6 +711,13 @@ type View struct {
711 711 SortBy string
712 712 MoreRepos int
713 713 MoreGroups int
714 DashTab string
715 DashPage int
716 DashPages int
717 DashPrev int
718 DashNext int
719 DashRepoN int
720 DashGroupN int
714 721 FlipDir string
715 722 Cards []RepoCard
716 723 Head *CommitRow
@@ -711,6 +711,13 @@ type View struct {
711 SortBy string
711 SortBy string
712 MoreRepos int
712 MoreRepos int
713 MoreGroups int
713 MoreGroups int
714 DashTab string
715 DashPage int
716 DashPages int
717 DashPrev int
718 DashNext int
719 DashRepoN int
720 DashGroupN int
714 FlipDir string
721 FlipDir string
715 Cards []RepoCard
722 Cards []RepoCard
716 Head *CommitRow
723 Head *CommitRow
internal/server/templates/pages.html +30 −2
@@ -88,6 +88,33 @@
88 88 <div class="pageacts"><a class="btn" href="/new">{{t "nav.new"}}</a></div>
89 89 </header>
90 90 {{if .StorageUnset}}<p class="flash bad">{{t "home.storage"}}</p>{{end}}
91 <p class="sub">
92 <a href="/"{{if not .DashTab}} class="on"{{end}}>{{t "dash.tabOverview"}}</a>
93 <a href="/?tab=repos"{{if eq .DashTab "repos"}} class="on"{{end}} data-tip="{{t "dash.tabReposTip"}}">{{t "dash.repos"}} <span class="count">{{.DashRepoN}}</span></a>
94 <a href="/?tab=groups"{{if eq .DashTab "groups"}} class="on"{{end}} data-tip="{{t "dash.tabGroupsTip"}}">{{t "dash.groups"}} <span class="count">{{.DashGroupN}}</span></a>
95 </p>
96 {{if .DashTab}}
97 <section class="panel">
98 {{if eq .DashTab "repos"}}
99 <h2><span data-tip="{{t "repo.sortPushedTip"}}">{{t "dash.repos"}}</span></h2>
100 {{if not .Repos}}<p class="muted">{{t "dash.noRepos"}}</p>{{end}}
101 <ul class="repolist">
102 {{range .Repos}}<li>{{template "namemark" .}}<div class="grown"><a class="reponame" href="/{{.FullPath}}" title="{{pushedLabel .}}">{{.FullPath}}</a> <span class="pill">{{visName .Visibility}}</span>{{if .Description}}<div class="muted">{{.Description}}</div>{{end}}</div></li>{{end}}
103 </ul>
104 {{else}}
105 <h2><span data-tip="{{t "dash.groupsTip"}}">{{t "dash.groups"}}</span></h2>
106 {{if not .Groups}}<p class="muted">{{t "dash.noGroups"}}</p>{{end}}
107 <ul class="repolist">
108 {{range .Groups}}<li>{{template "namemark" .}}<div class="grown"><a class="reponame" href="/groups/{{.Path}}">{{.Name}}</a> <span class="muted">{{.Path}}</span></div></li>{{end}}
109 </ul>
110 {{end}}
111 {{if gt .DashPages 1}}<p class="row">
112 {{if .DashPrev}}<a class="btn ghost tiny" href="/?tab={{.DashTab}}&page={{.DashPrev}}">{{t "dash.prev"}}</a>{{end}}
113 <span class="muted">{{t "dash.pageOf" .DashPage .DashPages}}</span>
114 {{if .DashNext}}<a class="btn ghost tiny" href="/?tab={{.DashTab}}&page={{.DashNext}}">{{t "dash.next"}}</a>{{end}}
115 </p>{{end}}
116 </section>
117 {{else}}
91 118 {{if .Card}}{{template "usercard" .Card}}{{end}}
92 119 {{if .Heat}}{{template "heatmap" .Heat}}{{end}}
93 120 <div class="grid-2">
@@ -97,7 +124,7 @@
97 124 <ul class="repolist">
98 125 {{range .Repos}}<li>{{template "namemark" .}}<div class="grown"><a class="reponame" href="/{{.FullPath}}" title="{{pushedLabel .}}">{{.FullPath}}</a> <span class="pill">{{visName .Visibility}}</span>{{if .Description}}<div class="muted">{{.Description}}</div>{{end}}</div></li>{{end}}
99 126 </ul>
100 {{if .MoreRepos}}<p><a class="btn ghost tiny" href="/?all=repos" data-tip="{{t "dash.moreTip"}}">{{t "dash.showAll" .MoreRepos}}</a></p>{{end}}
127 {{if .MoreRepos}}<p><a class="btn ghost tiny" href="/?tab=repos" data-tip="{{t "dash.moreTip"}}">{{t "dash.showAll" .MoreRepos}}</a></p>{{end}}
101 128 </section>
102 129 <section class="panel">
103 130 <h2><span data-tip="{{t "dash.groupsTip"}}">{{t "dash.groups"}}</span></h2>
@@ -105,10 +132,11 @@
105 132 <ul class="repolist">
106 133 {{range .Groups}}<li>{{template "namemark" .}}<div class="grown"><a class="reponame" href="/groups/{{.Path}}">{{.Name}}</a> <span class="muted">{{.Path}}</span></div></li>{{end}}
107 134 </ul>
108 {{if .MoreGroups}}<p><a class="btn ghost tiny" href="/?all=groups" data-tip="{{t "dash.moreTip"}}">{{t "dash.showAll" .MoreGroups}}</a></p>{{end}}
135 {{if .MoreGroups}}<p><a class="btn ghost tiny" href="/?tab=groups" data-tip="{{t "dash.moreTip"}}">{{t "dash.showAll" .MoreGroups}}</a></p>{{end}}
109 136 </section>
110 137 </div>
111 138 {{template "releaserepos" .}}
139 {{end}}
112 140 {{template "layout-end" .}}
113 141 {{end}}
114 142
@@ -88,6 +88,33 @@
88 <div class="pageacts"><a class="btn" href="/new">{{t "nav.new"}}</a></div>
88 <div class="pageacts"><a class="btn" href="/new">{{t "nav.new"}}</a></div>
89</header>
89</header>
90{{if .StorageUnset}}<p class="flash bad">{{t "home.storage"}}</p>{{end}}
90{{if .StorageUnset}}<p class="flash bad">{{t "home.storage"}}</p>{{end}}
91<p class="sub">
92 <a href="/"{{if not .DashTab}} class="on"{{end}}>{{t "dash.tabOverview"}}</a>
93 <a href="/?tab=repos"{{if eq .DashTab "repos"}} class="on"{{end}} data-tip="{{t "dash.tabReposTip"}}">{{t "dash.repos"}} <span class="count">{{.DashRepoN}}</span></a>
94 <a href="/?tab=groups"{{if eq .DashTab "groups"}} class="on"{{end}} data-tip="{{t "dash.tabGroupsTip"}}">{{t "dash.groups"}} <span class="count">{{.DashGroupN}}</span></a>
95</p>
96{{if .DashTab}}
97<section class="panel">
98 {{if eq .DashTab "repos"}}
99 <h2><span data-tip="{{t "repo.sortPushedTip"}}">{{t "dash.repos"}}</span></h2>
100 {{if not .Repos}}<p class="muted">{{t "dash.noRepos"}}</p>{{end}}
101 <ul class="repolist">
102 {{range .Repos}}<li>{{template "namemark" .}}<div class="grown"><a class="reponame" href="/{{.FullPath}}" title="{{pushedLabel .}}">{{.FullPath}}</a> <span class="pill">{{visName .Visibility}}</span>{{if .Description}}<div class="muted">{{.Description}}</div>{{end}}</div></li>{{end}}
103 </ul>
104 {{else}}
105 <h2><span data-tip="{{t "dash.groupsTip"}}">{{t "dash.groups"}}</span></h2>
106 {{if not .Groups}}<p class="muted">{{t "dash.noGroups"}}</p>{{end}}
107 <ul class="repolist">
108 {{range .Groups}}<li>{{template "namemark" .}}<div class="grown"><a class="reponame" href="/groups/{{.Path}}">{{.Name}}</a> <span class="muted">{{.Path}}</span></div></li>{{end}}
109 </ul>
110 {{end}}
111 {{if gt .DashPages 1}}<p class="row">
112 {{if .DashPrev}}<a class="btn ghost tiny" href="/?tab={{.DashTab}}&page={{.DashPrev}}">{{t "dash.prev"}}</a>{{end}}
113 <span class="muted">{{t "dash.pageOf" .DashPage .DashPages}}</span>
114 {{if .DashNext}}<a class="btn ghost tiny" href="/?tab={{.DashTab}}&page={{.DashNext}}">{{t "dash.next"}}</a>{{end}}
115 </p>{{end}}
116</section>
117{{else}}
91{{if .Card}}{{template "usercard" .Card}}{{end}}
118{{if .Card}}{{template "usercard" .Card}}{{end}}
92{{if .Heat}}{{template "heatmap" .Heat}}{{end}}
119{{if .Heat}}{{template "heatmap" .Heat}}{{end}}
93<div class="grid-2">
120<div class="grid-2">
@@ -97,7 +124,7 @@
97 <ul class="repolist">
124 <ul class="repolist">
98 {{range .Repos}}<li>{{template "namemark" .}}<div class="grown"><a class="reponame" href="/{{.FullPath}}" title="{{pushedLabel .}}">{{.FullPath}}</a> <span class="pill">{{visName .Visibility}}</span>{{if .Description}}<div class="muted">{{.Description}}</div>{{end}}</div></li>{{end}}
125 {{range .Repos}}<li>{{template "namemark" .}}<div class="grown"><a class="reponame" href="/{{.FullPath}}" title="{{pushedLabel .}}">{{.FullPath}}</a> <span class="pill">{{visName .Visibility}}</span>{{if .Description}}<div class="muted">{{.Description}}</div>{{end}}</div></li>{{end}}
99 </ul>
126 </ul>
100 {{if .MoreRepos}}<p><a class="btn ghost tiny" href="/?all=repos" data-tip="{{t "dash.moreTip"}}">{{t "dash.showAll" .MoreRepos}}</a></p>{{end}}
127 {{if .MoreRepos}}<p><a class="btn ghost tiny" href="/?tab=repos" data-tip="{{t "dash.moreTip"}}">{{t "dash.showAll" .MoreRepos}}</a></p>{{end}}
101 </section>
128 </section>
102 <section class="panel">
129 <section class="panel">
103 <h2><span data-tip="{{t "dash.groupsTip"}}">{{t "dash.groups"}}</span></h2>
130 <h2><span data-tip="{{t "dash.groupsTip"}}">{{t "dash.groups"}}</span></h2>
@@ -105,10 +132,11 @@
105 <ul class="repolist">
132 <ul class="repolist">
106 {{range .Groups}}<li>{{template "namemark" .}}<div class="grown"><a class="reponame" href="/groups/{{.Path}}">{{.Name}}</a> <span class="muted">{{.Path}}</span></div></li>{{end}}
133 {{range .Groups}}<li>{{template "namemark" .}}<div class="grown"><a class="reponame" href="/groups/{{.Path}}">{{.Name}}</a> <span class="muted">{{.Path}}</span></div></li>{{end}}
107 </ul>
134 </ul>
108 {{if .MoreGroups}}<p><a class="btn ghost tiny" href="/?all=groups" data-tip="{{t "dash.moreTip"}}">{{t "dash.showAll" .MoreGroups}}</a></p>{{end}}
135 {{if .MoreGroups}}<p><a class="btn ghost tiny" href="/?tab=groups" data-tip="{{t "dash.moreTip"}}">{{t "dash.showAll" .MoreGroups}}</a></p>{{end}}
109 </section>
136 </section>
110</div>
137</div>
111{{template "releaserepos" .}}
138{{template "releaserepos" .}}
139{{end}}
112{{template "layout-end" .}}
140{{template "layout-end" .}}
113{{end}}
141{{end}}
114
142