{{ define "title" }} {{ .Pull.Title }} · pull #{{ .Pull.PullId }} · {{ .RepoInfo.FullName }} {{ end }} {{ define "repoContent" }}

{{ .Pull.Title }} #{{ .Pull.PullId }}

{{ $bgColor := "bg-gray-800" }} {{ $icon := "ban" }} {{ if .Pull.State.IsOpen }} {{ $bgColor = "bg-green-600" }} {{ $icon = "git-pull-request" }} {{ else if .Pull.State.IsMerged }} {{ $bgColor = "bg-purple-600" }} {{ $icon = "git-merge" }} {{ end }}
{{ .Pull.State.String }}
opened by {{ $owner := index $.DidHandleMap .Pull.OwnerDid }} {{ $owner }} targeting branch {{ .Pull.TargetBranch }}
{{ if .Pull.Body }}
{{ .Pull.Body | markdown }}
{{ end }}
{{ end }} {{ define "repoAfter" }}
{{ block "submissions" . }} {{ end }}
{{ $isPullAuthor := and .LoggedInUser (eq .LoggedInUser.Did .Pull.OwnerDid) }} {{ $isPushAllowed := .RepoInfo.Roles.IsPushAllowed }} {{ if and $isPullAuthor (not .Pull.State.IsMerged) }}
{{ block "resubmitCard" . }} {{ end }}
{{ end }}
{{ if .Pull.State.IsMerged }} {{ block "alreadyMergedCard" . }} {{ end }} {{ else if .MergeCheck }} {{ if .MergeCheck.IsConflicted }} {{ block "isConflictedCard" $ }} {{ end }} {{ else }} {{ block "noConflictsCard" $ }} {{ end }} {{ end }} {{ end }}
{{ end }} {{ define "submissions" }} {{ $lastIdx := sub (len .Pull.Submissions) 1 }} {{ $targetBranch := .Pull.TargetBranch }} {{ $repoName := .RepoInfo.FullName }} {{ range $idx, $item := .Pull.Submissions }} {{ $diff := $item.AsNiceDiff $targetBranch }} {{ with $item }} {{ $oneIndexedRound := add .RoundNumber 1 }}
#{{ $oneIndexedRound }}
{{ $owner := index $.DidHandleMap $.Pull.OwnerDid }} submitted by {{ $owner }} {{ $s := "s" }} {{ if eq (len .Comments) 1 }} {{ $s = "" }} {{ end }} {{ len .Comments }} comment{{$s}} view patch
{{ range .Comments }}
{{ $owner := index $.DidHandleMap .OwnerDid }} {{$owner}}
{{ .Body }}
{{ end }} {{ block "newComment" (list $ .ID) }} {{ end }}

{{ end }} {{ end }} {{ end }} {{ define "newComment" }} {{ $rootObj := index . 0 }} {{ $submissionId := index . 1 }} {{ with $rootObj }} {{ if .LoggedInUser }}
{{ index .DidHandleMap .LoggedInUser.Did }}
{{ else }}
login to join the discussion
{{ end }} {{ end }} {{ end }} {{ define "alreadyMergedCard" }}
pull request successfully merged

This pull request has been merged into the base branch.

{{ end }} {{ define "isConflictedCard" }}
merge conflicts detected

Please resolve these conflicts locally and update the patch to continue with the merge.

{{ end }} {{ define "noConflictsCard" }} {{ $isPushAllowed := .RepoInfo.Roles.IsPushAllowed }} {{ $isPullAuthor := and .LoggedInUser (eq .LoggedInUser.Did .Pull.OwnerDid) }}
ready to merge
No conflicts detected with the base branch. This pull request can be merged safely.
{{ if $isPushAllowed }} {{ end }} {{ if and (or $isPullAuthor $isPushAllowed) (not .Pull.State.IsMerged) }} {{ $action := "close" }} {{ $icon := "circle-x" }} {{ $hoverColor := "red" }} {{ if .Pull.State.IsClosed }} {{ $action = "reopen" }} {{ $icon = "circle-dot" }} {{ $hoverColor = "green" }} {{ end }} {{ end }}
{{ end }} {{ define "resubmitCard" }}
resubmit your patch
You can update this patch to address any reviews. This will begin a new round of reviews, but you'll still be able to view your previous submissions and feedback.
{{ end }}