Skip to content

Commit

Permalink
Sort repos in issues dashboard sidebar (#3072)
Browse files Browse the repository at this point in the history
* Sort repos in issues dashboard sidebar

* Sort repos by name
  • Loading branch information
ethantkoenig authored and lunny committed Dec 4, 2017
1 parent 3c1b1ca commit c0a7899
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
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

0 comments on commit c0a7899

Please sign in to comment.