{{ 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 }}
{{ 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 $isPullAuthor }}
{{ 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 }}
{{ 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 "submissions" }} {{ $lastIdx := sub (len .Pull.Submissions) 1 }} {{ range $idx, $item := .Pull.Submissions }} {{ with $item }}
round #{{ .RoundNumber }}, {{ .Created | timeFmt }}, received {{ len .Comments }} comments

patch submitted by {{index $.DidHandleMap $.Pull.OwnerDid}}

{{- .Patch -}}
{{ range .Comments }}
{{ index $.DidHandleMap .OwnerDid }} commented {{ .Created | timeFmt }}: {{ .Body }}
{{ end }} {{ block "newComment" (list $ .ID) }} {{ end }}
{{ end }} {{ end }} {{ end }} {{ define "newComment" }} {{ $rootObj := index . 0 }} {{ $submissionId := index . 1 }} {{ with $rootObj }} {{ if .LoggedInUser }}
{{ else }}
login to join the discussion
{{ end }} {{ end }} {{ end }} {{ define "alreadyMergedCard" }}
{{ if gt (len .Comments) 0 }}
{{ else }}
{{ end }}
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 }}
ready to merge
No conflicts detected with the base branch. This pull request can be merged safely.
{{ if $isPushAllowed }} {{ end }}
{{ end }} {{ define "resubmitCard" }}
Resubmit your patch
You can update this patch to address reviews if any. This begins a new round of reviews, you can still view your previous submissions and reviews.
{{ end }}