diff --git a/appview/db/vouch.go b/appview/db/vouch.go --- a/appview/db/vouch.go +++ b/appview/db/vouch.go @@ -308,6 +308,15 @@ } return batch[subjectDid], nil } +func IsVouchSkipped(e Execer, did, subjectDid string) (bool, error) { + var exists bool + err := e.QueryRow( + `select exists(select 1 from vouch_skips where did = ? and subject_did = ?)`, + did, subjectDid, + ).Scan(&exists) + return exists, err +} + func SkipVouchSuggestion(e Execer, did, subjectDid string) error { _, err := e.Exec( `insert or ignore into vouch_skips (did, subject_did) values (?, ?)`, diff --git a/appview/pages/pages.go b/appview/pages/pages.go --- a/appview/pages/pages.go +++ b/appview/pages/pages.go @@ -1384,6 +1384,7 @@ UserReacted map[models.ReactionKind]bool LabelDefs map[string]*models.LabelDefinition VouchRelationships map[syntax.DID]*models.VouchRelationship + VouchSkips map[syntax.DID]bool } func (p *Pages) RepoSinglePull(w io.Writer, params RepoSinglePullParams) error { diff --git a/appview/pages/templates/repo/pulls/fragments/pullVouchNudge.html b/appview/pages/templates/repo/pulls/fragments/pullVouchNudge.html new file mode 100644 --- /dev/null +++ b/appview/pages/templates/repo/pulls/fragments/pullVouchNudge.html @@ -0,0 +1,38 @@ +{{ define "repo/pulls/fragments/pullVouchNudge" }} + {{ $owner := .Pull.OwnerDid }} + {{ $vr := index .VouchRelationships (did $owner) }} + {{ $skipped := index .VouchSkips (did $owner) }} + + {{ if and + .LoggedInUser + (ne .LoggedInUser.Did $owner) + (or .Pull.State.IsOpen .Pull.State.IsMerged) + (or (not $vr) $vr.IsEmpty) + (not $skipped) }} + +
+ + {{ i "shield-question-mark" "size-4" }} + Would you like to vouch for + + + {{ resolve $owner }} + + for their contribution? + + +
+ {{ template "user/fragments/vouch" (dict "VouchRelationship" $vr "Evidences" (list .Pull.AtUri.String) "PopoverId" (printf "vouch-nudge-modal-%s" (normalizeForHtmlId $owner))) }} +
+
+ {{ end }} +{{ end }} diff --git a/appview/pages/templates/repo/pulls/pull.html b/appview/pages/templates/repo/pulls/pull.html --- a/appview/pages/templates/repo/pulls/pull.html +++ b/appview/pages/templates/repo/pulls/pull.html @@ -80,9 +80,12 @@ {{ end }} {{ define "repoContentLayout" }}
-
- {{ block "repoContent" . }}{{ end }} -
+
+
+ {{ block "repoContent" . }}{{ end }} +
+ {{ template "repo/pulls/fragments/pullVouchNudge" . }} +
{{ template "repo/fragments/labelPanel" (dict "RepoInfo" $.RepoInfo diff --git a/appview/pages/templates/timeline/fragments/vouchSuggestions.html b/appview/pages/templates/timeline/fragments/vouchSuggestions.html --- a/appview/pages/templates/timeline/fragments/vouchSuggestions.html +++ b/appview/pages/templates/timeline/fragments/vouchSuggestions.html @@ -19,7 +19,7 @@ {{ resolve .Did.String }} {{ .Reason }}
- {{ template "user/fragments/vouch" . }} + {{ template "user/fragments/vouch" (dict "VouchRelationship" .VouchRelationship) }}
{{ end }} diff --git a/appview/pages/templates/user/fragments/profileCard.html b/appview/pages/templates/user/fragments/profileCard.html --- a/appview/pages/templates/user/fragments/profileCard.html +++ b/appview/pages/templates/user/fragments/profileCard.html @@ -109,7 +109,7 @@ {{ if ne .FollowStatus.String "IsSelf" }} - {{ template "user/fragments/vouch" . }} + {{ template "user/fragments/vouch" (dict "VouchRelationship" .VouchRelationship) }} {{ if .VouchRelationship }} {{ if .VouchRelationship.IndirectVouches }} diff --git a/appview/pages/templates/user/fragments/profilePopover.html b/appview/pages/templates/user/fragments/profilePopover.html --- a/appview/pages/templates/user/fragments/profilePopover.html +++ b/appview/pages/templates/user/fragments/profilePopover.html @@ -39,7 +39,7 @@ {{ if and .LoggedInUser (ne .FollowStatus.String "IsSelf") }}
{{ template "user/fragments/follow" . }} - {{ template "user/fragments/vouchButton" . }} + {{ template "user/fragments/vouchButton" (dict "VouchRelationship" .VouchRelationship) }}
{{ if .VouchRelationship }} @@ -54,6 +54,6 @@ {{/* render the vouch modal outside the popover content div so the popover api places it in the top layer correctly */}} {{ if and .LoggedInUser (ne .FollowStatus.String "IsSelf") }} - {{ template "user/fragments/vouchPopover" . }} + {{ template "user/fragments/vouchPopover" (dict "VouchRelationship" .VouchRelationship) }} {{ end }} {{ end }} diff --git a/appview/pages/templates/user/fragments/vouch.html b/appview/pages/templates/user/fragments/vouch.html --- a/appview/pages/templates/user/fragments/vouch.html +++ b/appview/pages/templates/user/fragments/vouch.html @@ -1,6 +1,9 @@ {{ define "user/fragments/vouch" }}
+ {{ $vr := index . "VouchRelationship" }} + {{ $ev := index . "Evidences" }} + {{ $popoverId := index . "PopoverId" }} {{ template "user/fragments/vouchButton" . }} - {{ template "user/fragments/vouchPopover" . }} + {{ template "user/fragments/vouchPopover" (dict "VouchRelationship" $vr "Evidences" $ev "PopoverId" $popoverId) }}
{{ end }} diff --git a/appview/pages/templates/user/fragments/vouchButton.html b/appview/pages/templates/user/fragments/vouchButton.html --- a/appview/pages/templates/user/fragments/vouchButton.html +++ b/appview/pages/templates/user/fragments/vouchButton.html @@ -13,10 +13,12 @@ {{ $userDid := "" }} {{ with .VouchRelationship }} {{ $userDid = .SubjectDid.String }} {{ end }} +{{ $popoverId := index . "PopoverId" }} +{{ if not $popoverId }}{{ $popoverId = printf "vouch-modal-%s" (normalizeForHtmlId $userDid) }}{{ end }}