Skip to content

Only use prev and next buttons for pagination on user dashboard #33981

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions custom/conf/app.example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1357,6 +1357,9 @@ LEVEL = Info
;; Number of orgs that are displayed on profile page
;ORG_PAGING_NUM = 15

;; Whether to show the pagination on the user dashbaord page
;DASHBOARD_ACTIVITIES_PAGINATION = false

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;[ui.meta]
Expand Down
15 changes: 9 additions & 6 deletions modules/setting/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ var UI = struct {
OrgPagingNum int
} `ini:"ui.admin"`
User struct {
RepoPagingNum int
OrgPagingNum int
RepoPagingNum int
OrgPagingNum int
DashboardActivitiesPagination bool // display pagination for dashboard activities
} `ini:"ui.user"`
Meta struct {
Author string
Expand Down Expand Up @@ -129,11 +130,13 @@ var UI = struct {
OrgPagingNum: 50,
},
User: struct {
RepoPagingNum int
OrgPagingNum int
RepoPagingNum int
OrgPagingNum int
DashboardActivitiesPagination bool
}{
RepoPagingNum: 15,
OrgPagingNum: 15,
RepoPagingNum: 15,
OrgPagingNum: 15,
DashboardActivitiesPagination: false,
},
Meta: struct {
Author string
Expand Down
1 change: 1 addition & 0 deletions routers/web/user/home.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ func Dashboard(ctx *context.Context) {
pager := context.NewPagination(int(count), setting.UI.FeedPagingNum, page, 5)
pager.AddParamFromRequest(ctx.Req)
ctx.Data["Page"] = pager
ctx.Data["ShowPagination"] = setting.UI.User.DashboardActivitiesPagination

ctx.HTML(http.StatusOK, tplDashboard)
}
Expand Down
5 changes: 5 additions & 0 deletions services/feed/feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package feed
import (
"context"
"fmt"
"math"

activities_model "code.gitea.io/gitea/models/activities"
"code.gitea.io/gitea/models/db"
Expand All @@ -27,6 +28,10 @@ func GetFeedsForDashboard(ctx context.Context, opts activities_model.GetFeedsOpt
if err != nil {
return nil, 0, err
}
if !setting.UI.User.DashboardActivitiesPagination {
return results, math.MaxInt32, nil
}

if opts.DontCount {
cnt, err = cache.GetInt64(userFeedCacheKey(opts.Actor.ID), func() (int64, error) {
return activities_model.CountUserFeeds(ctx, opts.Actor.ID)
Expand Down
17 changes: 17 additions & 0 deletions templates/base/pre_next.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{$paginationParams := .Page.GetParams}}
{{$paginationLink := $.Link}}
{{if eq $paginationLink AppSubUrl}}{{$paginationLink = print $paginationLink "/"}}{{end}}
{{with .Page.Paginater}}
<div class="center page buttons">
<div class="ui borderless pagination menu">
<a class="{{if not .HasPrevious}}disabled{{end}} item navigation" {{if .HasPrevious}}href="{{$paginationLink}}?page={{.Previous}}{{if $paginationParams}}&{{$paginationParams}}{{end}}"{{end}}>
{{svg "octicon-chevron-left" 16 "tw-mr-1"}}
<span class="navigation_label">{{ctx.Locale.Tr "repo.issues.previous"}}</span>
</a>
<a class="{{if not .HasNext}}disabled{{end}} item navigation" {{if .HasNext}}href="{{$paginationLink}}?page={{.Next}}{{if $paginationParams}}&{{$paginationParams}}{{end}}"{{end}}>
<span class="navigation_label">{{ctx.Locale.Tr "repo.issues.next"}}</span>
{{svg "octicon-chevron-right" 16 "tw-ml-1"}}
</a>
</div>
</div>
{{end}}
9 changes: 8 additions & 1 deletion templates/user/dashboard/feeds.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,12 @@
</div>
</div>
{{end}}
{{template "base/paginate" .}}
{{$paginater := .Page.Paginater}}
{{if $paginater}}
{{if .ShowPagination}}
{{template "base/paginate" .}}
{{else}}
{{template "base/pre_next" .}}
{{end}}
{{end}}
</div>