diff --git a/appview/pages/pages.go b/appview/pages/pages.go index 883d7611..b6c0eed0 100644 --- a/appview/pages/pages.go +++ b/appview/pages/pages.go @@ -523,6 +523,7 @@ func (p *ProfileCard) GetTabs() [][]any { {"repos", "repos", "book-marked", p.Stats.RepoCount}, {"starred", "starred", "star", p.Stats.StarredCount}, {"strings", "strings", "line-squiggle", p.Stats.StringCount}, + {"pulls", "pulls", "git-pull-request", nil}, } return tabs @@ -578,6 +579,18 @@ func (p *Pages) ProfileStrings(w io.Writer, params ProfileStringsParams) error { return p.executeProfile("user/strings", w, params) } +type ProfilePullsParams struct { + LoggedInUser *oauth.User + Active string + Card *ProfileCard + Pulls []models.Pull +} + +func (p *Pages) ProfilePulls(w io.Writer, params ProfilePullsParams) error { + params.Active = "pulls" + return p.executeProfile("user/pulls", w, params) +} + type FollowCard struct { UserDid string LoggedInUser *oauth.User diff --git a/appview/pages/templates/user/pulls.html b/appview/pages/templates/user/pulls.html new file mode 100644 index 00000000..0becc826 --- /dev/null +++ b/appview/pages/templates/user/pulls.html @@ -0,0 +1,55 @@ +{{ define "title" }}{{ resolve .Card.UserDid }} · pulls {{ end }} + +{{ define "profileContent" }} +
+ {{ block "pulls" . }}{{ end }} +
+{{ end }} + +{{ define "pulls" }} +
+ {{ range .Pulls }} +
+
+ +
+ {{ $bgColor := "bg-gray-800 dark:bg-gray-700" }} + {{ $icon := "ban" }} + + {{ if .State.IsOpen }} + {{ $bgColor = "bg-green-600 dark:bg-green-700" }} + {{ $icon = "git-pull-request" }} + {{ else if .State.IsMerged }} + {{ $bgColor = "bg-purple-600 dark:bg-purple-700" }} + {{ $icon = "git-merge" }} + {{ end }} + + + {{ i $icon "w-3 h-3 mr-1.5 text-white" }} + {{ .State.String }} + + + + + {{ .Repo.Did | resolve }}/{{ .Repo.Name }} + + + + + + {{ template "repo/fragments/time" .Created }} + + +
+
+
+ {{ end }} +
+{{ end }} diff --git a/appview/state/profile.go b/appview/state/profile.go index 576a934e..9e6ef346 100644 --- a/appview/state/profile.go +++ b/appview/state/profile.go @@ -35,6 +35,8 @@ func (s *State) Profile(w http.ResponseWriter, r *http.Request) { s.starredPage(w, r) case "strings": s.stringsPage(w, r) + case "pulls": + s.pullsPage(w, r) default: s.profileOverview(w, r) } @@ -265,6 +267,31 @@ func (s *State) stringsPage(w http.ResponseWriter, r *http.Request) { }) } +func (s *State) pullsPage(w http.ResponseWriter, r *http.Request) { + l := s.logger.With("handler", "pullsPage") + + profile, err := s.profile(r) + if err != nil { + l.Error("failed to build profile card", "err", err) + s.pages.Error500(w) + return + } + l = l.With("profileDid", profile.UserDid) + + pulls, err := db.GetPullsByOwnerDid(s.db, profile.UserDid, "-6 months") + if err != nil { + l.Error("failed to get pulls", "err", err) + s.pages.Error500(w) + return + } + + err = s.pages.ProfilePulls(w, pages.ProfilePullsParams{ + LoggedInUser: s.oauth.GetUser(r), + Pulls: pulls, + Card: profile, + }) +} + type FollowsPageParams struct { Follows []pages.FollowCard Card *pages.ProfileCard