Skip to content

Commit b4eb270

Browse files
Zettat123zeripath
authored andcommitted
Show empty repos in Admin Repository Management page (go-gitea#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 [go-gitea#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: Andrew Thornton <[email protected]>
1 parent 8adc6a1 commit b4eb270

File tree

2 files changed

+23
-19
lines changed

2 files changed

+23
-19
lines changed

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

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

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

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

+19-16
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")
@@ -90,7 +92,7 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
9092
onlyShowRelevant = false
9193
}
9294

93-
ctx.Data["OnlyShowRelevant"] = onlyShowRelevant
95+
ctx.Data["OnlyShowRelevant"] = opts.OnlyShowRelevant
9496

9597
topicOnly := ctx.FormBool("topic")
9698
ctx.Data["TopicOnly"] = topicOnly
@@ -113,7 +115,7 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
113115
TopicOnly: topicOnly,
114116
Language: language,
115117
IncludeDescription: setting.UI.SearchRepoDescription,
116-
OnlyShowRelevant: onlyShowRelevant,
118+
OnlyShowRelevant: opts.OnlyShowRelevant,
117119
})
118120
if err != nil {
119121
ctx.ServerError("SearchRepository", err)
@@ -160,9 +162,10 @@ func Repos(ctx *context.Context) {
160162
}
161163

162164
RenderRepoSearch(ctx, &RepoSearchOptions{
163-
PageSize: setting.UI.ExplorePagingNum,
164-
OwnerID: ownerID,
165-
Private: ctx.Doer != nil,
166-
TplName: tplExploreRepos,
165+
PageSize: setting.UI.ExplorePagingNum,
166+
OwnerID: ownerID,
167+
Private: ctx.Doer != nil,
168+
TplName: tplExploreRepos,
169+
OnlyShowRelevant: !ctx.FormBool(relevantReposOnlyParam),
167170
})
168171
}

0 commit comments

Comments
 (0)