Skip to content

Commit fa2e349

Browse files
zeripathlunny
andauthored
Ensure that search term and page are not lost on adoption page-turn (#14133)
Fix #14111 Signed-off-by: Andrew Thornton <[email protected]> Co-authored-by: Lunny Xiao <[email protected]>
1 parent 4c2a1c0 commit fa2e349

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

routers/admin/repos.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
package admin
66

77
import (
8+
"net/url"
9+
"strconv"
810
"strings"
911

1012
"code.gitea.io/gitea/models"
@@ -71,6 +73,8 @@ func UnadoptedRepos(ctx *context.Context) {
7173
opts.Page = 1
7274
}
7375

76+
ctx.Data["CurrentPage"] = opts.Page
77+
7478
doSearch := ctx.QueryBool("search")
7579

7680
ctx.Data["search"] = doSearch
@@ -79,6 +83,7 @@ func UnadoptedRepos(ctx *context.Context) {
7983
if !doSearch {
8084
pager := context.NewPagination(0, opts.PageSize, opts.Page, 5)
8185
pager.SetDefaultParams(ctx)
86+
pager.AddParam(ctx, "search", "search")
8287
ctx.Data["Page"] = pager
8388
ctx.HTML(200, tplUnadoptedRepos)
8489
return
@@ -92,6 +97,7 @@ func UnadoptedRepos(ctx *context.Context) {
9297
ctx.Data["Dirs"] = repoNames
9398
pager := context.NewPagination(int(count), opts.PageSize, opts.Page, 5)
9499
pager.SetDefaultParams(ctx)
100+
pager.AddParam(ctx, "search", "search")
95101
ctx.Data["Page"] = pager
96102
ctx.HTML(200, tplUnadoptedRepos)
97103
}
@@ -100,6 +106,9 @@ func UnadoptedRepos(ctx *context.Context) {
100106
func AdoptOrDeleteRepository(ctx *context.Context) {
101107
dir := ctx.Query("id")
102108
action := ctx.Query("action")
109+
page := ctx.QueryInt("page")
110+
q := ctx.Query("q")
111+
103112
dirSplit := strings.SplitN(dir, "/", 2)
104113
if len(dirSplit) != 2 {
105114
ctx.Redirect(setting.AppSubURL + "/admin/repos")
@@ -148,5 +157,5 @@ func AdoptOrDeleteRepository(ctx *context.Context) {
148157
}
149158
ctx.Flash.Success(ctx.Tr("repo.delete_preexisting_success", dir))
150159
}
151-
ctx.Redirect(setting.AppSubURL + "/admin/repos/unadopted")
160+
ctx.Redirect(setting.AppSubURL + "/admin/repos/unadopted?search=true&q=" + url.QueryEscape(q) + "&page=" + strconv.Itoa(page))
152161
}

templates/admin/repo/unadopted.tmpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
{{$.CsrfTokenHtml}}
4242
<input type="hidden" name="id" value="{{$dir}}">
4343
<input type="hidden" name="action" value="adopt">
44+
<input type="hidden" name="q" value="{{$.Keyword}}">
45+
<input type="hidden" name="page" value="{{$.CurrentPage}}">
4446
<div class="actions">
4547
<div class="ui red basic inverted cancel button">
4648
{{svg "octicon-trashcan" 16 "mr-2"}}
@@ -66,6 +68,8 @@
6668
{{$.CsrfTokenHtml}}
6769
<input type="hidden" name="id" value="{{$dir}}">
6870
<input type="hidden" name="action" value="delete">
71+
<input type="hidden" name="q" value="{{$.Keyword}}">
72+
<input type="hidden" name="page" value="{{$.CurrentPage}}">
6973
<div class="actions">
7074
<div class="ui red basic inverted cancel button">
7175
{{svg "octicon-trashcan" 16 "mr-2"}}

0 commit comments

Comments
 (0)