1
Fork 0

Allow to set explore page default sort (#27951)

as title


---
*Sponsored by Kithara Software GmbH*
This commit is contained in:
6543 2023-11-09 11:11:45 +01:00 committed by GitHub
parent 69d98f83f9
commit 16ba16dbe9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 28 additions and 15 deletions

View file

@ -23,12 +23,6 @@ const (
tplExploreUsers base.TplName = "explore/users"
)
// UserSearchDefaultSortType is the default sort type for user search
const (
UserSearchDefaultSortType = "recentupdate"
UserSearchDefaultAdminSort = "alphabetically"
)
var nullByte = []byte{0x00}
func isKeywordValid(keyword string) bool {
@ -60,8 +54,13 @@ func RenderUserSearch(ctx *context.Context, opts *user_model.SearchUserOptions,
// we can not set orderBy to `models.SearchOrderByXxx`, because there may be a JOIN in the statement, different tables may have the same name columns
ctx.Data["SortType"] = ctx.FormString("sort")
switch ctx.FormString("sort") {
sortOrder := ctx.FormString("sort")
if sortOrder == "" {
sortOrder = setting.UI.ExploreDefaultSort
}
ctx.Data["SortType"] = sortOrder
switch sortOrder {
case "newest":
orderBy = "`user`.id DESC"
case "oldest":
@ -134,7 +133,7 @@ func Users(ctx *context.Context) {
ctx.Data["IsRepoIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled
if ctx.FormString("sort") == "" {
ctx.SetFormString("sort", UserSearchDefaultSortType)
ctx.SetFormString("sort", setting.UI.ExploreDefaultSort)
}
RenderUserSearch(ctx, &user_model.SearchUserOptions{