diff --git a/appview/pages/pages.go b/appview/pages/pages.go index 6d6e6585..4fd2435a 100644 --- a/appview/pages/pages.go +++ b/appview/pages/pages.go @@ -1251,8 +1251,9 @@ type RepoPullsParams struct { Stacks []models.Stack Pipelines map[string]models.Pipeline LabelDefs map[string]*models.LabelDefinition - Page pagination.Page - PullCount int + Page pagination.Page + PullCount int + VouchRelationships map[string]*models.VouchRelationship } func (p *Pages) RepoPulls(w io.Writer, params RepoPullsParams) error { @@ -1297,7 +1298,8 @@ type RepoSinglePullParams struct { Reactions map[models.ReactionKind]models.ReactionDisplayData UserReacted map[models.ReactionKind]bool - LabelDefs map[string]*models.LabelDefinition + LabelDefs map[string]*models.LabelDefinition + VouchRelationships map[string]*models.VouchRelationship } func (p *Pages) RepoSinglePull(w io.Writer, params RepoSinglePullParams) error { diff --git a/appview/pages/templates/repo/pulls/fragments/pullHeader.html b/appview/pages/templates/repo/pulls/fragments/pullHeader.html index bd670842..36b6aae6 100644 --- a/appview/pages/templates/repo/pulls/fragments/pullHeader.html +++ b/appview/pages/templates/repo/pulls/fragments/pullHeader.html @@ -11,7 +11,8 @@ {{ template "repo/pulls/fragments/pullState" .Pull.State }} opened by - {{ template "user/fragments/picHandleLink" .Pull.OwnerDid }} + {{ template "user/fragments/picLink" (list .Pull.OwnerDid "size-6" (index .VouchRelationships .Pull.OwnerDid)) }} + {{ resolve .Pull.OwnerDid }} {{ template "repo/fragments/time" .Pull.Created }} diff --git a/appview/pages/templates/repo/pulls/pull.html b/appview/pages/templates/repo/pulls/pull.html index 6d0773ab..177d7148 100644 --- a/appview/pages/templates/repo/pulls/pull.html +++ b/appview/pages/templates/repo/pulls/pull.html @@ -300,7 +300,7 @@ flex gap-2 sticky top-0 z-20">
- {{ template "user/fragments/picLink" (list $root.Pull.OwnerDid "size-8") }} + {{ template "user/fragments/picLink" (list $root.Pull.OwnerDid "size-8" (index $root.VouchRelationships $root.Pull.OwnerDid)) }}
@@ -592,7 +592,7 @@
{{ range $item.Comments }} - {{ template "submissionComment" . }} + {{ template "submissionComment" (list . $root) }} {{ end }}
{{ if gt $c 0}} @@ -625,25 +625,27 @@ {{ end }} {{ define "submissionComment" }} -
+ {{ $comment := index . 0 }} + {{ $root := index . 1 }} +
- {{ template "user/fragments/picLink" (list .OwnerDid "size-8") }} + {{ template "user/fragments/picLink" (list $comment.OwnerDid "size-8" (index $root.VouchRelationships $comment.OwnerDid)) }}
- {{ .Body | markdown }} + {{ $comment.Body | markdown }}
diff --git a/appview/pages/templates/repo/pulls/pulls.html b/appview/pages/templates/repo/pulls/pulls.html index f0bc0f1e..58b99b5b 100644 --- a/appview/pages/templates/repo/pulls/pulls.html +++ b/appview/pages/templates/repo/pulls/pulls.html @@ -81,8 +81,9 @@
{{ template "repo/pulls/fragments/pullState" $topPR.State }} - - {{ template "user/fragments/picHandleLink" $topPR.OwnerDid }} + + {{ template "user/fragments/picLink" (list $topPR.OwnerDid "size-6" (index $.VouchRelationships $topPR.OwnerDid)) }} + {{ resolve $topPR.OwnerDid }} diff --git a/appview/pages/templates/user/fragments/picLink.html b/appview/pages/templates/user/fragments/picLink.html index 058a475e..d71b4aa8 100644 --- a/appview/pages/templates/user/fragments/picLink.html +++ b/appview/pages/templates/user/fragments/picLink.html @@ -24,7 +24,7 @@ /> {{ if $vouchRelation }} {{ if ne $did $vouchRelation.ViewerDid }} - + {{ if $isVouched }} {{ template "fragments/icons/shield-check" "w-full h-full" }} {{ else if $isDenounced }} diff --git a/appview/pages/templates/user/fragments/vouchTooltip.html b/appview/pages/templates/user/fragments/vouchTooltip.html index 3056f380..914da99b 100644 --- a/appview/pages/templates/user/fragments/vouchTooltip.html +++ b/appview/pages/templates/user/fragments/vouchTooltip.html @@ -3,20 +3,20 @@ {{- if not $vr.IsEmpty -}} {{- $networkPart := "" -}} {{- if and (gt $vr.VouchStrength 0) (eq $vr.DenounceStrength 0) -}} - {{- $networkPart = printf "%s from your network vouched for this user" (plural $vr.VouchStrength "person" "people") -}} + {{- $networkPart = printf "%s from your network vouched for this user." (plural $vr.VouchStrength "person" "people") -}} {{- else if and (gt $vr.DenounceStrength 0) (eq $vr.VouchStrength 0) -}} - {{- $networkPart = printf "%s from your network denounced this user" (plural $vr.DenounceStrength "person" "people") -}} + {{- $networkPart = printf "%s from your network denounced this user." (plural $vr.DenounceStrength "person" "people") -}} {{- else if and (eq $vr.DenounceStrength 0) (eq $vr.VouchStrength 0) -}} {{- $networkPart = "" -}} {{- else -}} - {{- $networkPart = printf "%s and %s from your network" (plural $vr.VouchStrength "vouch" "vouches") (plural $vr.DenounceStrength "denounce" "") -}} + {{- $networkPart = printf "%s and %s from your network." (plural $vr.VouchStrength "vouch" "vouches") (plural $vr.DenounceStrength "denounce" "") -}} {{- end -}} {{- $direct := $vr.GetDirectVouch -}} {{- if $direct -}} {{- if $direct.IsVouch -}} - You vouched for {{ resolve $vr.SubjectDid }} {{ relTimeFmt $direct.CreatedAt }}. {{ $networkPart }}. + You vouched for {{ resolve $vr.SubjectDid }} {{ relTimeFmt $direct.CreatedAt }}. {{ $networkPart }} {{- else -}} - You denounced {{ resolve $vr.SubjectDid }} {{ relTimeFmt $direct.CreatedAt }}. {{ $networkPart }}. + You denounced {{ resolve $vr.SubjectDid }} {{ relTimeFmt $direct.CreatedAt }}. {{ $networkPart }} {{- end -}} {{- else -}} {{- $networkPart -}}. diff --git a/appview/pulls/pulls.go b/appview/pulls/pulls.go index 4bca2346..4b104628 100644 --- a/appview/pulls/pulls.go +++ b/appview/pulls/pulls.go @@ -266,6 +266,15 @@ func (s *Pulls) repoPullHelper(w http.ResponseWriter, r *http.Request, interdiff defs[l.AtUri().String()] = &l } + vouchRelationships := make(map[string]*models.VouchRelationship) + if user != nil { + participants := pull.Participants() + vouchRelationships, err = db.GetVouchRelationshipsBatch(s.db, user.Did, participants) + if err != nil { + l.Error("failed to fetch vouch relationships", "err", err) + } + } + patch := pull.Submissions[roundIdInt].CombinedPatch() var diff types.DiffRenderer diff = patchutil.AsNiceDiff(patch, pull.TargetBranch) @@ -306,7 +315,8 @@ func (s *Pulls) repoPullHelper(w http.ResponseWriter, r *http.Request, interdiff Reactions: reactionMap, UserReacted: userReactions, - LabelDefs: defs, + LabelDefs: defs, + VouchRelationships: vouchRelationships, }) } @@ -782,6 +792,18 @@ func (s *Pulls) RepoPulls(w http.ResponseWriter, r *http.Request) { filterState = state.String() } + vouchRelationships := make(map[string]*models.VouchRelationship) + if user != nil { + dids := make([]string, len(pulls)) + for i, p := range pulls { + dids[i] = p.OwnerDid + } + vouchRelationships, err = db.GetVouchRelationshipsBatch(s.db, user.Did, dids) + if err != nil { + l.Error("failed to fetch vouch relationships", "err", err) + } + } + s.pages.RepoPulls(w, pages.RepoPullsParams{ LoggedInUser: s.oauth.GetMultiAccountUser(r), RepoInfo: repoInfo, @@ -789,10 +811,11 @@ func (s *Pulls) RepoPulls(w http.ResponseWriter, r *http.Request) { LabelDefs: defs, FilterState: filterState, FilterQuery: query.String(), - Stacks: stacks, - Pipelines: m, - Page: page, - PullCount: totalPulls, + Stacks: stacks, + Pipelines: m, + Page: page, + PullCount: totalPulls, + VouchRelationships: vouchRelationships, }) }