Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show empty repos in Admin Repository Management page #23114

Merged
merged 3 commits into from
Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion routers/web/admin/repos.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func Repos(ctx *context.Context) {
Private: true,
PageSize: setting.UI.Admin.RepoPagingNum,
TplName: tplRepos,
})
}, true)
}

// DeleteRepo delete one repository
Expand Down
10 changes: 7 additions & 3 deletions routers/web/explore/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ type RepoSearchOptions struct {
}

// RenderRepoSearch render repositories search page
func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
// 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, isAdmin bool) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although isAdmin looks like an ugly parameter, it can remind the developers that RenderRepoSearch is used by the admin page.

Maybe we can avoid mixed use in the future, it's fine for me now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be better to change the callers of this function to just set the only show relevant option as appropriately?

Certainly this parameter should really be referencing the fact that it is setting OnlyShowRelevant to false - and thus be named more appropriately.

// Sitemap index for sitemap paths
page := int(ctx.ParamsInt64("idx"))
isSitemap := ctx.Params("idx") != ""
Expand Down Expand Up @@ -84,7 +86,9 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
orderBy = db.SearchOrderByRecentUpdated
}

onlyShowRelevant = !ctx.FormBool(relevantReposOnlyParam)
if !isAdmin {
onlyShowRelevant = !ctx.FormBool(relevantReposOnlyParam)
}

keyword := ctx.FormTrim("q")

Expand Down Expand Up @@ -162,5 +166,5 @@ func Repos(ctx *context.Context) {
OwnerID: ownerID,
Private: ctx.Doer != nil,
TplName: tplExploreRepos,
})
}, false)
}