Skip to content

Commit 80c1264

Browse files
yardenshohamZettat123zeripath
authored
Show empty repos in Admin Repository Management page (#23114) (#23130)
Backport #23114 The **Admin Repository Management** page and the **Explore Repository** page both use the `RenderRepoSearch` function. In this function, the `OnlyShowRelevant` search option is `true` when querying repositories for admin page. https://github.com/go-gitea/gitea/blob/edf98a2dc30956c8e04b778bb7f1ce55c14ba963/routers/web/explore/repo.go#L99-L115 Refer to [#19361](https://github.com/go-gitea/gitea/pull/19361/files#diff-8058dfb85557010e0592d586675ec62ce406af7068e6311f39c160deac37f149R497), the repositories with `is_empty=true` will be hidden if `OnlyShowRelevant` is `true`. Administrators should be able to see all repositories. So `OnlyShowRelevant` shouldn't be set to `true` . Co-authored-by: Zettat123 <[email protected]> Co-authored-by: Andrew Thornton <[email protected]>
1 parent f0340c2 commit 80c1264

File tree

2 files changed

+23
-21
lines changed

2 files changed

+23
-21
lines changed

Diff for: routers/web/admin/repos.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ func Repos(ctx *context.Context) {
3333
ctx.Data["PageIsAdminRepositories"] = true
3434

3535
explore.RenderRepoSearch(ctx, &explore.RepoSearchOptions{
36-
Private: true,
37-
PageSize: setting.UI.Admin.RepoPagingNum,
38-
TplName: tplRepos,
36+
Private: true,
37+
PageSize: setting.UI.Admin.RepoPagingNum,
38+
TplName: tplRepos,
39+
OnlyShowRelevant: false,
3940
})
4041
}
4142

Diff for: routers/web/explore/repo.go

+19-18
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,17 @@ const (
2323

2424
// RepoSearchOptions when calling search repositories
2525
type RepoSearchOptions struct {
26-
OwnerID int64
27-
Private bool
28-
Restricted bool
29-
PageSize int
30-
TplName base.TplName
26+
OwnerID int64
27+
Private bool
28+
Restricted bool
29+
PageSize int
30+
OnlyShowRelevant bool
31+
TplName base.TplName
3132
}
3233

3334
// RenderRepoSearch render repositories search page
35+
// This function is also used to render the Admin Repository Management page.
36+
// The isAdmin param should be set to true when rendering the Admin page.
3437
func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
3538
// Sitemap index for sitemap paths
3639
page := int(ctx.ParamsInt64("idx"))
@@ -48,11 +51,10 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
4851
}
4952

5053
var (
51-
repos []*repo_model.Repository
52-
count int64
53-
err error
54-
orderBy db.SearchOrderBy
55-
onlyShowRelevant bool
54+
repos []*repo_model.Repository
55+
count int64
56+
err error
57+
orderBy db.SearchOrderBy
5658
)
5759

5860
ctx.Data["SortType"] = ctx.FormString("sort")
@@ -84,11 +86,9 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
8486
orderBy = db.SearchOrderByRecentUpdated
8587
}
8688

87-
onlyShowRelevant = !ctx.FormBool(relevantReposOnlyParam)
88-
8989
keyword := ctx.FormTrim("q")
9090

91-
ctx.Data["OnlyShowRelevant"] = onlyShowRelevant
91+
ctx.Data["OnlyShowRelevant"] = opts.OnlyShowRelevant
9292

9393
topicOnly := ctx.FormBool("topic")
9494
ctx.Data["TopicOnly"] = topicOnly
@@ -111,7 +111,7 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
111111
TopicOnly: topicOnly,
112112
Language: language,
113113
IncludeDescription: setting.UI.SearchRepoDescription,
114-
OnlyShowRelevant: onlyShowRelevant,
114+
OnlyShowRelevant: opts.OnlyShowRelevant,
115115
})
116116
if err != nil {
117117
ctx.ServerError("SearchRepository", err)
@@ -158,9 +158,10 @@ func Repos(ctx *context.Context) {
158158
}
159159

160160
RenderRepoSearch(ctx, &RepoSearchOptions{
161-
PageSize: setting.UI.ExplorePagingNum,
162-
OwnerID: ownerID,
163-
Private: ctx.Doer != nil,
164-
TplName: tplExploreRepos,
161+
PageSize: setting.UI.ExplorePagingNum,
162+
OwnerID: ownerID,
163+
Private: ctx.Doer != nil,
164+
TplName: tplExploreRepos,
165+
OnlyShowRelevant: !ctx.FormBool(relevantReposOnlyParam),
165166
})
166167
}

0 commit comments

Comments
 (0)