Skip to content

Commit c0a7899

Browse files
ethantkoeniglunny
authored andcommitted
Sort repos in issues dashboard sidebar (#3072)
* Sort repos in issues dashboard sidebar * Sort repos by name
1 parent 3c1b1ca commit c0a7899

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

models/repo_list.go

+12
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@ import (
1616
// RepositoryList contains a list of repositories
1717
type RepositoryList []*Repository
1818

19+
func (repos RepositoryList) Len() int {
20+
return len(repos)
21+
}
22+
23+
func (repos RepositoryList) Less(i, j int) bool {
24+
return repos[i].FullName() < repos[j].FullName()
25+
}
26+
27+
func (repos RepositoryList) Swap(i, j int) {
28+
repos[i], repos[j] = repos[j], repos[i]
29+
}
30+
1931
// RepositoryListOfMap make list from values of map
2032
func RepositoryListOfMap(repoMap map[int64]*Repository) RepositoryList {
2133
return RepositoryList(valuesRepository(repoMap))

routers/user/home.go

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package user
77
import (
88
"bytes"
99
"fmt"
10+
"sort"
1011

1112
"github.com/Unknwon/com"
1213
"github.com/Unknwon/paginater"
@@ -302,6 +303,7 @@ func Issues(ctx *context.Context) {
302303
}
303304

304305
showRepos := models.RepositoryListOfMap(showReposMap)
306+
sort.Sort(showRepos)
305307
if err = showRepos.LoadAttributes(); err != nil {
306308
ctx.Handle(500, "LoadAttributes", fmt.Errorf("%v", err))
307309
return

0 commit comments

Comments
 (0)