Allow to set explore page default sort (#27951)
as title --- *Sponsored by Kithara Software GmbH*
This commit is contained in:
parent
69d98f83f9
commit
16ba16dbe9
8 changed files with 28 additions and 15 deletions
|
@ -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{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue