Monorepo for Tangled tangled.org

appview: add a pulls tab and page to a users profile #951

closed opened by willdot.net targeting master from willdot.net/tangled-fork: pr-page

Adds a new pulls tab to the user profile which will then display the last 6 months of pull requests for a user.

Ideally this would have some sort of paging or a way to limit the number of pull requests displayed?

Labels

None yet.

assignee

None yet.

Participants 3
AT URI
at://did:plc:dadhhalkfcq3gucaq25hjqon/sh.tangled.repo.pull/3mcfoiddk7w22
+95
Diff #0
+13
appview/pages/pages.go
··· 523 523 {"repos", "repos", "book-marked", p.Stats.RepoCount}, 524 524 {"starred", "starred", "star", p.Stats.StarredCount}, 525 525 {"strings", "strings", "line-squiggle", p.Stats.StringCount}, 526 + {"pulls", "pulls", "git-pull-request", nil}, 526 527 } 527 528 528 529 return tabs ··· 578 579 return p.executeProfile("user/strings", w, params) 579 580 } 580 581 582 + type ProfilePullsParams struct { 583 + LoggedInUser *oauth.User 584 + Active string 585 + Card *ProfileCard 586 + Pulls []models.Pull 587 + } 588 + 589 + func (p *Pages) ProfilePulls(w io.Writer, params ProfilePullsParams) error { 590 + params.Active = "pulls" 591 + return p.executeProfile("user/pulls", w, params) 592 + } 593 + 581 594 type FollowCard struct { 582 595 UserDid string 583 596 LoggedInUser *oauth.User
+55
appview/pages/templates/user/pulls.html
··· 1 + {{ define "title" }}{{ resolve .Card.UserDid }} 路 pulls {{ end }} 2 + 3 + {{ define "profileContent" }} 4 + <div id="all-repos" class="md:col-span-8 order-2 md:order-2"> 5 + {{ block "pulls" . }}{{ end }} 6 + </div> 7 + {{ end }} 8 + 9 + {{ define "pulls" }} 10 + <div id="pulls" class="grid grid-cols-1 gap-4 mb-6"> 11 + {{ range .Pulls }} 12 + <div class="border border-gray-200 dark:border-gray-700 rounded-sm"> 13 + <div class="px-6 py-4 z-5"> 14 + <div class="pb-2"> 15 + <a href="/{{ .Repo.Did | resolve }}/{{ .Repo.Name }}/pulls/{{ .PullId }}" class="dark:text-white"> 16 + {{ .Title | description }} 17 + <span class="text-gray-500 dark:text-gray-400">#{{ .PullId }}</span> 18 + </a> 19 + </div> 20 + <div class="text-sm text-gray-500 dark:text-gray-400 flex flex-wrap items-center gap-1"> 21 + {{ $bgColor := "bg-gray-800 dark:bg-gray-700" }} 22 + {{ $icon := "ban" }} 23 + 24 + {{ if .State.IsOpen }} 25 + {{ $bgColor = "bg-green-600 dark:bg-green-700" }} 26 + {{ $icon = "git-pull-request" }} 27 + {{ else if .State.IsMerged }} 28 + {{ $bgColor = "bg-purple-600 dark:bg-purple-700" }} 29 + {{ $icon = "git-merge" }} 30 + {{ end }} 31 + 32 + <span 33 + class="inline-flex items-center rounded px-2 py-[5px] {{ $bgColor }} text-sm" 34 + > 35 + {{ i $icon "w-3 h-3 mr-1.5 text-white" }} 36 + <span class="text-white">{{ .State.String }}</span> 37 + </span> 38 + 39 + <span class="ml-1"> 40 + <a href="/{{ .Repo.Did | resolve }}/{{ .Repo.Name }}" class="flex items-center gap-1"> 41 + {{ .Repo.Did | resolve }}/{{ .Repo.Name }} 42 + </a> 43 + </span> 44 + 45 + 46 + <span class="before:content-['路']"> 47 + {{ template "repo/fragments/time" .Created }} 48 + </span> 49 + 50 + </div> 51 + </div> 52 + </div> 53 + {{ end }} 54 + </div> 55 + {{ end }}
+27
appview/state/profile.go
··· 35 35 s.starredPage(w, r) 36 36 case "strings": 37 37 s.stringsPage(w, r) 38 + case "pulls": 39 + s.pullsPage(w, r) 38 40 default: 39 41 s.profileOverview(w, r) 40 42 } ··· 265 267 }) 266 268 } 267 269 270 + func (s *State) pullsPage(w http.ResponseWriter, r *http.Request) { 271 + l := s.logger.With("handler", "pullsPage") 272 + 273 + profile, err := s.profile(r) 274 + if err != nil { 275 + l.Error("failed to build profile card", "err", err) 276 + s.pages.Error500(w) 277 + return 278 + } 279 + l = l.With("profileDid", profile.UserDid) 280 + 281 + pulls, err := db.GetPullsByOwnerDid(s.db, profile.UserDid, "-6 months") 282 + if err != nil { 283 + l.Error("failed to get pulls", "err", err) 284 + s.pages.Error500(w) 285 + return 286 + } 287 + 288 + err = s.pages.ProfilePulls(w, pages.ProfilePullsParams{ 289 + LoggedInUser: s.oauth.GetUser(r), 290 + Pulls: pulls, 291 + Card: profile, 292 + }) 293 + } 294 + 268 295 type FollowsPageParams struct { 269 296 Follows []pages.FollowCard 270 297 Card *pages.ProfileCard

History

1 round 7 comments
sign up or login to add to the discussion
willdot.net submitted #0
1 commit
expand
appview: add a pulls tab and page to a users profile
expand 7 comments

This is very simple and naive at the moment. I've tested locally and links work etc but I have a small dataset of pull requests for repos in my local environment.

I actually have a local benanch with a common pagination template I drafted up to get issues and pulls using the same stuff. I鈥檓 yet to create a proposal for it, but if you are down I can brining it in to see if it鈥檚 the direction the tangled folks would be ok with

Oh nice! Just checked out your PR and that would be super useful for this!

is this patch an implementation of https://tangled.org/tangled.org/core/issues/367? looking at the code:

  • this patch adds a pulls tab to the profile page itself
  • this is visible to all users (not that the visibility matters, all data is public)

i assumed the linked issue was a sort of "my work" tab, that surfaces the most recent pulls/issues; so one can quickly jump back in!

I was a bit conflicted with which to do so went with the easiest to implement 馃

I liked the idea of a "work tab" but that seemed like it was a whole other thing that probably needed more thoughts and design around whereas putting a list of pulls (and issues next) as another tab on the user profile didn't really need any thought or design for.

And like you said, pulls and issues are public anyway so it's not really showing any more information that's not available, it's just making the information easier to view.

But if you prefer a dedicated page / section for "my work" (which I'm onboard with and would be super useful) I can switch to starting to do something like that instead.

i think I do prefer a "my work" style tab. this would need more design thought however (maybe it surfaces more "active" issues, contains a list of "unread" comments etc. at the very least, I think it could start off with the most recent pulls and issues submitted by the user. preferably in a single page.

Yh totally fair and that's a nicer feature too.

I'll close this PR and we can move the discussion around what it's going to look like into the issue https://tangled.org/tangled.org/core/issues/367

closed without merging