Skip to content

Commit bf1441b

Browse files
authored
Ensure that search term and page are not lost on adoption page-turn (#14133) (#14143)
Backport #14133 Fix #14111 Signed-off-by: Andrew Thornton <[email protected]>
1 parent fae18bd commit bf1441b

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")
@@ -141,5 +150,5 @@ func AdoptOrDeleteRepository(ctx *context.Context) {
141150
}
142151
ctx.Flash.Success(ctx.Tr("repo.delete_preexisting_success", dir))
143152
}
144-
ctx.Redirect(setting.AppSubURL + "/admin/repos/unadopted")
153+
ctx.Redirect(setting.AppSubURL + "/admin/repos/unadopted?search=true&q=" + url.QueryEscape(q) + "&page=" + strconv.Itoa(page))
145154
}

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
<i class="remove icon"></i>
@@ -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
<i class="remove icon"></i>

0 commit comments

Comments
 (0)