Skip to content

Commit 882a236

Browse files
committed
Replace "stars" with watched in user profile
1 parent 9d184f1 commit 882a236

File tree

4 files changed

+39
-5
lines changed

4 files changed

+39
-5
lines changed

models/repo_list.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ type SearchRepoOptions struct {
142142
OrderBy SearchOrderBy
143143
Private bool // Include private repositories in results
144144
StarredByID int64
145+
WatchedByID int64
145146
AllPublic bool // Include also all public repositories of users and public organisations
146147
AllLimited bool // Include also all public repositories of limited organisations
147148
// None -> include public and private
@@ -240,6 +241,11 @@ func SearchRepositoryCondition(opts *SearchRepoOptions) builder.Cond {
240241
cond = cond.And(builder.In("id", builder.Select("repo_id").From("star").Where(builder.Eq{"uid": opts.StarredByID})))
241242
}
242243

244+
// Restrict to watched repositories
245+
if opts.WatchedByID > 0 {
246+
cond = cond.And(builder.In("id", builder.Select("repo_id").From("watch").Where(builder.Eq{"user_id": opts.WatchedByID})))
247+
}
248+
243249
// Restrict repositories to those the OwnerID owns or contributes to as per opts.Collaborate
244250
if opts.OwnerID > 0 {
245251
var accessCond = builder.NewCond()

options/locale/locale_en-US.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,7 @@ repositories = Repositories
412412
activity = Public Activity
413413
followers = Followers
414414
starred = Starred Repositories
415+
watched = Watched Repositories
415416
projects = Projects
416417
following = Following
417418
follow = Follow

routers/user/profile.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,27 @@ func Profile(ctx *context.Context) {
238238
ctx.ServerError("GetProjects", err)
239239
return
240240
}
241+
case "watching":
242+
repos, count, err = models.SearchRepository(&models.SearchRepoOptions{
243+
ListOptions: models.ListOptions{
244+
PageSize: setting.UI.User.RepoPagingNum,
245+
Page: page,
246+
},
247+
Actor: ctx.User,
248+
Keyword: keyword,
249+
OrderBy: orderBy,
250+
Private: ctx.IsSigned,
251+
WatchedByID: ctxUser.ID,
252+
Collaborate: util.OptionalBoolFalse,
253+
TopicOnly: topicOnly,
254+
IncludeDescription: setting.UI.SearchRepoDescription,
255+
})
256+
if err != nil {
257+
ctx.ServerError("SearchRepository", err)
258+
return
259+
}
260+
261+
total = int(count)
241262
default:
242263
repos, count, err = models.SearchRepository(&models.SearchRepoOptions{
243264
ListOptions: models.ListOptions{

templates/user/profile.tmpl

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,22 @@
8484
</div>
8585
<div class="ui eleven wide column">
8686
<div class="ui secondary stackable pointing tight menu">
87-
<a class='{{if and (ne .TabName "activity") (ne .TabName "following") (ne .TabName "followers") (ne .TabName "stars") (ne .TabName "projects")}}active{{end}} item' href="{{.Owner.HomeLink}}">
87+
<a class='{{if and (ne .TabName "activity") (ne .TabName "following") (ne .TabName "followers") (ne .TabName "stars") (ne .TabName "watching") (ne .TabName "projects")}}active{{end}} item' href="{{.Owner.HomeLink}}">
8888
{{svg "octicon-repo"}} {{.i18n.Tr "user.repositories"}}
8989
</a>
9090
<a class='{{if eq .TabName "activity"}}active{{end}} item' href="{{.Owner.HomeLink}}?tab=activity">
9191
{{svg "octicon-rss"}} {{.i18n.Tr "user.activity"}}
9292
</a>
93-
<a class='{{if eq .TabName "stars"}}active{{end}} item' href="{{.Owner.HomeLink}}?tab=stars">
94-
{{svg "octicon-star"}} {{.i18n.Tr "user.starred"}}
95-
<div class="ui label">{{.Owner.NumStars}}</div>
96-
</a>
93+
{{if not .DisableStars}}
94+
<a class='{{if eq .TabName "stars"}}active{{end}} item' href="{{.Owner.HomeLink}}?tab=stars">
95+
{{svg "octicon-star"}} {{.i18n.Tr "user.starred"}}
96+
<div class="ui label">{{.Owner.NumStars}}</div>
97+
</a>
98+
{{else}}
99+
<a class='{{if eq .TabName "watching"}}active{{end}} item' href="{{.Owner.HomeLink}}?tab=watching">
100+
{{svg "octicon-eye"}} {{.i18n.Tr "user.watched"}}
101+
</a>
102+
{{end}}
97103
<a class='{{if eq .TabName "following"}}active{{end}} item' href="{{.Owner.HomeLink}}?tab=following">
98104
{{svg "octicon-person"}} {{.i18n.Tr "user.following"}}
99105
<div class="ui label">{{.Owner.NumFollowing}}</div>

0 commit comments

Comments
 (0)