Skip to content

Commit fef3f2e

Browse files
committed
Don't display pagination on user dashboard by default but with prev and next buttons
1 parent 0fee4f1 commit fef3f2e

File tree

6 files changed

+43
-7
lines changed

6 files changed

+43
-7
lines changed

custom/conf/app.example.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,6 +1357,9 @@ LEVEL = Info
13571357
;; Number of orgs that are displayed on profile page
13581358
;ORG_PAGING_NUM = 15
13591359

1360+
;; Whether to show the pagination on the user dashbaord page
1361+
;DASHBOARD_ACTIVITIES_PAGINATION = false
1362+
13601363
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13611364
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13621365
;[ui.meta]

modules/setting/ui.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,9 @@ var UI = struct {
6363
OrgPagingNum int
6464
} `ini:"ui.admin"`
6565
User struct {
66-
RepoPagingNum int
67-
OrgPagingNum int
66+
RepoPagingNum int
67+
OrgPagingNum int
68+
DashboardActivitiesPagination bool // display pagination for dashboard activities
6869
} `ini:"ui.user"`
6970
Meta struct {
7071
Author string
@@ -129,11 +130,13 @@ var UI = struct {
129130
OrgPagingNum: 50,
130131
},
131132
User: struct {
132-
RepoPagingNum int
133-
OrgPagingNum int
133+
RepoPagingNum int
134+
OrgPagingNum int
135+
DashboardActivitiesPagination bool
134136
}{
135-
RepoPagingNum: 15,
136-
OrgPagingNum: 15,
137+
RepoPagingNum: 15,
138+
OrgPagingNum: 15,
139+
DashboardActivitiesPagination: false,
137140
},
138141
Meta: struct {
139142
Author string

routers/web/user/home.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ func Dashboard(ctx *context.Context) {
142142
pager := context.NewPagination(int(count), setting.UI.FeedPagingNum, page, 5)
143143
pager.AddParamFromRequest(ctx.Req)
144144
ctx.Data["Page"] = pager
145+
ctx.Data["ShowPagination"] = setting.UI.User.DashboardActivitiesPagination
145146

146147
ctx.HTML(http.StatusOK, tplDashboard)
147148
}

services/feed/feed.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package feed
66
import (
77
"context"
88
"fmt"
9+
"math"
910

1011
activities_model "code.gitea.io/gitea/models/activities"
1112
"code.gitea.io/gitea/models/db"
@@ -27,6 +28,10 @@ func GetFeedsForDashboard(ctx context.Context, opts activities_model.GetFeedsOpt
2728
if err != nil {
2829
return nil, 0, err
2930
}
31+
if !setting.UI.User.DashboardActivitiesPagination {
32+
return results, math.MaxInt32, nil
33+
}
34+
3035
if opts.DontCount {
3136
cnt, err = cache.GetInt64(userFeedCacheKey(opts.Actor.ID), func() (int64, error) {
3237
return activities_model.CountUserFeeds(ctx, opts.Actor.ID)

templates/base/pre_next.tmpl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{{$paginationParams := .Page.GetParams}}
2+
{{$paginationLink := $.Link}}
3+
{{if eq $paginationLink AppSubUrl}}{{$paginationLink = print $paginationLink "/"}}{{end}}
4+
{{with .Page.Paginater}}
5+
<div class="center page buttons">
6+
<div class="ui borderless pagination menu">
7+
<a class="{{if not .HasPrevious}}disabled{{end}} item navigation" {{if .HasPrevious}}href="{{$paginationLink}}?page={{.Previous}}{{if $paginationParams}}&{{$paginationParams}}{{end}}"{{end}}>
8+
{{svg "octicon-chevron-left" 16 "tw-mr-1"}}
9+
<span class="navigation_label">{{ctx.Locale.Tr "repo.issues.previous"}}</span>
10+
</a>
11+
<a class="{{if not .HasNext}}disabled{{end}} item navigation" {{if .HasNext}}href="{{$paginationLink}}?page={{.Next}}{{if $paginationParams}}&{{$paginationParams}}{{end}}"{{end}}>
12+
<span class="navigation_label">{{ctx.Locale.Tr "repo.issues.next"}}</span>
13+
{{svg "octicon-chevron-right" 16 "tw-ml-1"}}
14+
</a>
15+
</div>
16+
</div>
17+
{{end}}

templates/user/dashboard/feeds.tmpl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,5 +126,12 @@
126126
</div>
127127
</div>
128128
{{end}}
129-
{{template "base/paginate" .}}
129+
{{$paginater := .Page.Paginater}}
130+
{{if $paginater}}
131+
{{if .ShowPagination}}
132+
{{template "base/paginate" .}}
133+
{{else}}
134+
{{template "base/pre_next" .}}
135+
{{end}}
136+
{{end}}
130137
</div>

0 commit comments

Comments
 (0)