fix(profile): show only pinned repositories
4 files changed, +6 −8
- flow_test.go modified +3 −0
- templates/org.html modified +1 −1
- templates/user.html modified +1 −1
- web.go modified +1 −6
flow_test.go modified
| @@ -278,6 +278,9 @@ func TestPins(t *testing.T) { | ||
| 278 | 278 | r, _ := s.store.CreateRepo(alice, n, "", Public, "") |
| 279 | 279 | ids = append(ids, r.ID) |
| 280 | 280 | } |
| 281 | + if strings.Contains(get(h, "/~alice", "").Body.String(), `href="/~alice/a"`) { | |
| 282 | + t.Error("unpinned repos shown on the profile") | |
| 283 | + } | |
| 281 | 284 | own, _ := s.store.CreateSession(alice.ID) |
| 282 | 285 | other, _ := s.store.CreateSession(mallory.ID) |
| 283 | 286 | names := map[int64]string{} |
templates/org.html modified
| @@ -18,7 +18,7 @@ | ||
| 18 | 18 | <div class="columns orgbody"> |
| 19 | 19 | <div class="main"> |
| 20 | 20 | {{with .Data.Activity}}<section class="activity"><div class="heathead"><p class="muted small">{{.Total}} commit{{if ne .Total 1}}s{{end}} across the organisation {{if .Year}}in {{.Year}}{{else}}in the past 12 months{{end}}</p><nav class="years"><a href="?"{{if not .Year}} class="active"{{end}}>past 12 months</a>{{range .Years}}<a href="?year={{.}}"{{if eq . $.Data.Activity.Year}} class="active"{{end}}>{{.}}</a>{{end}}</nav></div>{{.Grid}}<p class="legend muted small">less <i class="h0"></i><i class="h1"></i><i class="h2"></i><i class="h3"></i><i class="h4"></i> more</p></section>{{end}} |
| 21 | -{{if .Data.Repos}}<div class="events">{{range .Data.Repos}}{{template "repoitem" .}}{{end}}</div>{{else}}<p class="info">This organisation does not have any repositories.</p>{{end}} | |
| 21 | +{{if .Data.Repos}}<div class="events">{{range .Data.Repos}}{{template "repoitem" .}}{{end}}</div>{{end}} | |
| 22 | 22 | </div> |
| 23 | 23 | <aside class="people"> |
| 24 | 24 | <h4>People <span class="count">{{len .Data.Members}}</span></h4> |
templates/user.html modified
| @@ -21,7 +21,7 @@ | ||
| 21 | 21 | </aside> |
| 22 | 22 | <div class="main"> |
| 23 | 23 | {{with .Data.Activity}}<section class="activity"><div class="heathead"><p class="muted small">{{.Total}} commit{{if ne .Total 1}}s{{end}} {{if .Year}}in {{.Year}}{{else}}in the past 12 months{{end}}</p><nav class="years"><a href="?"{{if not .Year}} class="active"{{end}}>past 12 months</a>{{range .Years}}<a href="?year={{.}}"{{if eq . $.Data.Activity.Year}} class="active"{{end}}>{{.}}</a>{{end}}</nav></div>{{.Grid}}<p class="legend muted small">less <i class="h0"></i><i class="h1"></i><i class="h2"></i><i class="h3"></i><i class="h4"></i> more</p></section>{{end}} |
| 24 | -{{if .Data.Repos}}<div class="events">{{range .Data.Repos}}{{template "repoitem" .}}{{end}}</div>{{else}}<p class="info">This user does not have any repositories.</p>{{end}} | |
| 24 | +{{if .Data.Repos}}<div class="events">{{range .Data.Repos}}{{template "repoitem" .}}{{end}}</div>{{end}} | |
| 25 | 25 | </div> |
| 26 | 26 | </div> |
| 27 | 27 | {{end}} |
web.go modified
| @@ -827,12 +827,7 @@ func (s *Server) route(w http.ResponseWriter, r *http.Request) { | ||
| 827 | 827 | if year < 1970 || year > time.Now().Year() { |
| 828 | 828 | year = 0 |
| 829 | 829 | } |
| 830 | - shown := pinnedRepos(repos, s.store.Pins(owner.ID)) | |
| 831 | - pinned := len(shown) > 0 | |
| 832 | - if !pinned { | |
| 833 | - shown = repos[:min(len(repos), maxPins)] | |
| 834 | - } | |
| 835 | - data := map[string]any{"Owner": owner, "Repos": shown, "Total": len(repos), "Pinned": pinned, "Profile": profile, "Bio": bio, "Count": len(starred), "Activity": s.activity(owner, year), "Member": member} | |
| 830 | + data := map[string]any{"Owner": owner, "Repos": pinnedRepos(repos, s.store.Pins(owner.ID)), "Total": len(repos), "Profile": profile, "Bio": bio, "Count": len(starred), "Activity": s.activity(owner, year), "Member": member} | |
| 836 | 831 | if org { |
| 837 | 832 | var people []userHit |
| 838 | 833 | for _, m := range s.store.Members(owner.ID) { |