appview: Update New PR Page #490

The compare forks option dropdown now shows repos in which you are a collaborator on instead of just repos you own.

Changed files
+14 -10
appview
db
pages
templates
repo
pulls
pulls
+8 -5
appview/db/repos.go
··· 467 467 var repos []Repo 468 468 469 469 rows, err := e.Query( 470 - `select did, name, knot, rkey, description, created, at_uri, source 471 - from repos 472 - where did = ? and source is not null and source != '' 473 - order by created desc`, 474 - did, 470 + `select distinct r.did, r.name, r.knot, r.rkey, r.description, r.created, r.at_uri, r.source 471 + from repos r 472 + left join collaborators c on r.at_uri = c.repo_at 473 + where (r.did = ? or c.subject_did = ?) 474 + and r.source is not null 475 + and r.source != '' 476 + order by r.created desc`, 477 + did, did, 475 478 ) 476 479 if err != nil { 477 480 return nil, err
+2 -2
appview/pages/templates/repo/pulls/fragments/pullCompareForks.html
··· 19 19 > 20 20 <option disabled selected>select a fork</option> 21 21 {{ range .Forks }} 22 - <option value="{{ .Name }}" {{ if eq .Name $.Selected }}selected{{ end }} class="py-1"> 23 - {{ .Name }} 22 + <option value="{{ .Did }}/{{ .Name }}" {{ if eq .Name $.Selected }}selected{{ end }} class="py-1"> 23 + {{ .Did | resolve }}/{{ .Name }} 24 24 </option> 25 25 {{ end }} 26 26 </select>
+4 -3
appview/pulls/pulls.go
··· 852 852 } 853 853 854 854 func (s *Pulls) handleForkBasedPull(w http.ResponseWriter, r *http.Request, f *reporesolver.ResolvedRepo, user *oauth.User, forkRepo string, title, body, targetBranch, sourceBranch string, isStacked bool) { 855 - fork, err := db.GetForkByDid(s.db, user.Did, forkRepo) 855 + splits := strings.SplitN(forkRepo, "/", 2) 856 + fork, err := db.GetForkByDid(s.db, splits[0], splits[1]) 856 857 if errors.Is(err, sql.ErrNoRows) { 857 858 s.pages.Notice(w, "pull", "No such fork.") 858 859 return ··· 1269 1270 } 1270 1271 1271 1272 forkVal := r.URL.Query().Get("fork") 1272 - 1273 + split := strings.SplitN(forkVal, "/", 2) 1273 1274 // fork repo 1274 - repo, err := db.GetRepo(s.db, user.Did, forkVal) 1275 + repo, err := db.GetRepo(s.db, split[0], split[1]) 1275 1276 if err != nil { 1276 1277 log.Println("failed to get repo", user.Did, forkVal) 1277 1278 return