mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Refactor AddParam to AddParamIfExist (#29834)
When read the code: `pager.AddParam(ctx, "search", "search")`, the question always comes: What is it doing? Where is the value from? Why "search" / "search" ? Now it is clear: `pager.AddParamIfExist("search", ctx.Data["search"])`
This commit is contained in:
@@ -163,8 +163,8 @@ func Graph(ctx *context.Context) {
|
||||
ctx.Data["CommitCount"] = commitsCount
|
||||
|
||||
paginator := context.NewPagination(int(graphCommitsCount), setting.UI.GraphMaxCommitNum, page, 5)
|
||||
paginator.AddParam(ctx, "mode", "Mode")
|
||||
paginator.AddParam(ctx, "hide-pr-refs", "HidePRRefs")
|
||||
paginator.AddParamIfExist("mode", ctx.Data["Mode"])
|
||||
paginator.AddParamIfExist("hide-pr-refs", ctx.Data["HidePRRefs"])
|
||||
for _, branch := range branches {
|
||||
paginator.AddParamString("branch", branch)
|
||||
}
|
||||
|
@@ -472,16 +472,16 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption opt
|
||||
}
|
||||
ctx.Data["ShowArchivedLabels"] = archived
|
||||
|
||||
pager.AddParam(ctx, "q", "Keyword")
|
||||
pager.AddParam(ctx, "type", "ViewType")
|
||||
pager.AddParam(ctx, "sort", "SortType")
|
||||
pager.AddParam(ctx, "state", "State")
|
||||
pager.AddParam(ctx, "labels", "SelectLabels")
|
||||
pager.AddParam(ctx, "milestone", "MilestoneID")
|
||||
pager.AddParam(ctx, "project", "ProjectID")
|
||||
pager.AddParam(ctx, "assignee", "AssigneeID")
|
||||
pager.AddParam(ctx, "poster", "PosterID")
|
||||
pager.AddParam(ctx, "archived", "ShowArchivedLabels")
|
||||
pager.AddParamIfExist("q", ctx.Data["Keyword"])
|
||||
pager.AddParamIfExist("type", ctx.Data["ViewType"])
|
||||
pager.AddParamIfExist("sort", ctx.Data["SortType"])
|
||||
pager.AddParamIfExist("state", ctx.Data["State"])
|
||||
pager.AddParamIfExist("labels", ctx.Data["SelectLabels"])
|
||||
pager.AddParamIfExist("milestone", ctx.Data["MilestoneID"])
|
||||
pager.AddParamIfExist("project", ctx.Data["ProjectID"])
|
||||
pager.AddParamIfExist("assignee", ctx.Data["AssigneeID"])
|
||||
pager.AddParamIfExist("poster", ctx.Data["PosterID"])
|
||||
pager.AddParamIfExist("archived", ctx.Data["ShowArchivedLabels"])
|
||||
|
||||
ctx.Data["Page"] = pager
|
||||
}
|
||||
|
@@ -106,8 +106,8 @@ func Milestones(ctx *context.Context) {
|
||||
ctx.Data["IsShowClosed"] = isShowClosed
|
||||
|
||||
pager := context.NewPagination(int(total), setting.UI.IssuePagingNum, page, 5)
|
||||
pager.AddParam(ctx, "state", "State")
|
||||
pager.AddParam(ctx, "q", "Keyword")
|
||||
pager.AddParamIfExist("state", ctx.Data["State"])
|
||||
pager.AddParamIfExist("q", ctx.Data["Keyword"])
|
||||
ctx.Data["Page"] = pager
|
||||
|
||||
ctx.HTML(http.StatusOK, tplMilestone)
|
||||
|
@@ -70,8 +70,8 @@ func Packages(ctx *context.Context) {
|
||||
ctx.Data["RepositoryAccessMap"] = map[int64]bool{ctx.Repo.Repository.ID: true} // There is only the current repository
|
||||
|
||||
pager := context.NewPagination(int(total), setting.UI.PackagesPagingNum, page, 5)
|
||||
pager.AddParam(ctx, "q", "Query")
|
||||
pager.AddParam(ctx, "type", "PackageType")
|
||||
pager.AddParamIfExist("q", ctx.Data["Query"])
|
||||
pager.AddParamIfExist("type", ctx.Data["PackageType"])
|
||||
ctx.Data["Page"] = pager
|
||||
|
||||
ctx.HTML(http.StatusOK, tplPackagesList)
|
||||
|
@@ -118,7 +118,7 @@ func Projects(ctx *context.Context) {
|
||||
}
|
||||
|
||||
pager := context.NewPagination(total, setting.UI.IssuePagingNum, page, numPages)
|
||||
pager.AddParam(ctx, "state", "State")
|
||||
pager.AddParamIfExist("state", ctx.Data["State"])
|
||||
ctx.Data["Page"] = pager
|
||||
|
||||
ctx.Data["CanWriteProjects"] = ctx.Repo.Permission.CanWrite(unit.TypeProjects)
|
||||
|
@@ -59,7 +59,7 @@ func Search(ctx *context.Context) {
|
||||
|
||||
pager := context.NewPagination(total, setting.UI.RepoSearchPagingNum, page, 5)
|
||||
pager.SetDefaultParams(ctx)
|
||||
pager.AddParam(ctx, "l", "Language")
|
||||
pager.AddParamIfExist("l", ctx.Data["Language"])
|
||||
ctx.Data["Page"] = pager
|
||||
|
||||
ctx.HTML(http.StatusOK, tplSearch)
|
||||
|
Reference in New Issue
Block a user