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

Sort repos in issues dashboard sidebar #3072

Merged
merged 3 commits into from
Dec 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 12 additions & 0 deletions models/repo_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ import (
// RepositoryList contains a list of repositories
type RepositoryList []*Repository

func (repos RepositoryList) Len() int {
return len(repos)
}

func (repos RepositoryList) Less(i, j int) bool {
return repos[i].FullName() < repos[j].FullName()
}

func (repos RepositoryList) Swap(i, j int) {
repos[i], repos[j] = repos[j], repos[i]
}

// RepositoryListOfMap make list from values of map
func RepositoryListOfMap(repoMap map[int64]*Repository) RepositoryList {
return RepositoryList(valuesRepository(repoMap))
Expand Down
2 changes: 2 additions & 0 deletions routers/user/home.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package user
import (
"bytes"
"fmt"
"sort"

"github.com/Unknwon/com"
"github.com/Unknwon/paginater"
Expand Down Expand Up @@ -302,6 +303,7 @@ func Issues(ctx *context.Context) {
}

showRepos := models.RepositoryListOfMap(showReposMap)
sort.Sort(showRepos)
if err = showRepos.LoadAttributes(); err != nil {
ctx.Handle(500, "LoadAttributes", fmt.Errorf("%v", err))
return
Expand Down