Skip to content

Commit

Permalink
Show empty repos in Admin Repository Management page (go-gitea#23114)
Browse files Browse the repository at this point in the history
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 <art27@cantab.net>
  • Loading branch information
2 people authored and yardenshoham committed Feb 24, 2023
1 parent f0340c2 commit 32a896c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 21 deletions.
7 changes: 4 additions & 3 deletions routers/web/admin/repos.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ func Repos(ctx *context.Context) {
ctx.Data["PageIsAdminRepositories"] = true

explore.RenderRepoSearch(ctx, &explore.RepoSearchOptions{
Private: true,
PageSize: setting.UI.Admin.RepoPagingNum,
TplName: tplRepos,
Private: true,
PageSize: setting.UI.Admin.RepoPagingNum,
TplName: tplRepos,
OnlyShowRelevant: false,
})
}

Expand Down
37 changes: 19 additions & 18 deletions routers/web/explore/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,17 @@ const (

// RepoSearchOptions when calling search repositories
type RepoSearchOptions struct {
OwnerID int64
Private bool
Restricted bool
PageSize int
TplName base.TplName
OwnerID int64
Private bool
Restricted bool
PageSize int
OnlyShowRelevant bool
TplName base.TplName
}

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

var (
repos []*repo_model.Repository
count int64
err error
orderBy db.SearchOrderBy
onlyShowRelevant bool
repos []*repo_model.Repository
count int64
err error
orderBy db.SearchOrderBy
)

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

onlyShowRelevant = !ctx.FormBool(relevantReposOnlyParam)

keyword := ctx.FormTrim("q")

ctx.Data["OnlyShowRelevant"] = onlyShowRelevant
ctx.Data["OnlyShowRelevant"] = opts.OnlyShowRelevant

topicOnly := ctx.FormBool("topic")
ctx.Data["TopicOnly"] = topicOnly
Expand All @@ -111,7 +111,7 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
TopicOnly: topicOnly,
Language: language,
IncludeDescription: setting.UI.SearchRepoDescription,
OnlyShowRelevant: onlyShowRelevant,
OnlyShowRelevant: opts.OnlyShowRelevant,
})
if err != nil {
ctx.ServerError("SearchRepository", err)
Expand Down Expand Up @@ -158,9 +158,10 @@ func Repos(ctx *context.Context) {
}

RenderRepoSearch(ctx, &RepoSearchOptions{
PageSize: setting.UI.ExplorePagingNum,
OwnerID: ownerID,
Private: ctx.Doer != nil,
TplName: tplExploreRepos,
PageSize: setting.UI.ExplorePagingNum,
OwnerID: ownerID,
Private: ctx.Doer != nil,
TplName: tplExploreRepos,
OnlyShowRelevant: !ctx.FormBool(relevantReposOnlyParam),
})
}

0 comments on commit 32a896c

Please sign in to comment.