{{ define "repo/pulls/fragments/pullActions" }} {{ $lastIdx := sub (len .Pull.Submissions) 1 }} {{ $roundNumber := .RoundNumber }} {{ $stack := .Stack }} {{ $loading := .Loading }} {{ $totalPulls := sub 0 1 }} {{ $below := sub 0 1 }} {{ $stackCount := "" }} {{ if (gt (len .Stack) 1) }} {{ $totalPulls = len $stack }} {{ $below = $stack.Below .Pull }} {{ $mergeable := len $below.Mergeable }} {{ $stackCount = printf "%d/%d" $mergeable $totalPulls }} {{ end }} {{ $isPushAllowed := .RepoInfo.Roles.IsPushAllowed }} {{ $isMerged := .Pull.State.IsMerged }} {{ $isClosed := .Pull.State.IsClosed }} {{ $isOpen := .Pull.State.IsOpen }} {{ $isConflicted := and .MergeCheck (or .MergeCheck.Error .MergeCheck.IsConflicted) }} {{ $isPullAuthor := and .LoggedInUser (eq .LoggedInUser.Did .Pull.OwnerDid) }} {{ $isLastRound := eq $roundNumber $lastIdx }} {{ $isSameRepoBranch := .Pull.IsBranchBased }} {{ $isUpToDate := .ResubmitCheck.No }} {{ $isForkBased := .Pull.IsForkBased }} {{ $showRunCI := and (not $loading) $isPushAllowed $isOpen $isLastRound $isForkBased (not .HasPipeline) (ne .RepoInfo.Spindle "") }}
{{ if and (not $loading) $isLastRound }} {{ if and $isOpen $isForkBased (not .HasPipeline) (ne .RepoInfo.Spindle "") }} {{ template "workflowWarning" . }} {{ end }} {{ template "mergeCheck" . }} {{ template "resubmitStatus" . }} {{ end }}
{{ if .LoggedInUser }} {{ end }} {{ if and (not $loading) .BranchDeleteStatus }} {{ end }} {{ if $showRunCI }} {{ template "runCiModal" . }} {{ end }} {{ if and $isPushAllowed $isOpen $isLastRound }} {{ end }} {{ if and $isPullAuthor $isOpen $isLastRound }} {{ end }} {{ if and (or $isPullAuthor $isPushAllowed) $isOpen $isLastRound }} {{ end }} {{ if and (or $isPullAuthor $isPushAllowed) $isClosed $isLastRound }} {{ end }}
{{ end }} {{ define "workflowWarning" }} {{ if .WorkflowsChanged }}
{{ i "triangle-alert" "w-4 h-4 text-amber-600 dark:text-amber-500" }} Workflow files changed in this round
Expand
{{ else }}
{{ i "triangle-alert" "w-4 h-4" }} Workflow needs approval
{{ end }} {{ end }} {{ define "runCiModal" }}
{{ if .WorkflowsChanged }}
{{ i "triangle-alert" "size-4" }} Workflow files changed in this round

Workflow files changed in this round. Are you sure you want to run CI?

{{ else }}
{{ i "triangle-alert" "size-4" }} Workflow needs approval

This fork-based pull request needs approval to run CI. Are you sure?

{{ end }}
{{ end }} {{ define "mergeCheck" }} {{ $isOpen := .Pull.State.IsOpen }} {{ if and $isOpen .MergeCheck .MergeCheck.Error }}
{{ i "triangle-alert" "w-4 h-4" }} {{ .MergeCheck.Error }}
{{ else if and $isOpen .MergeCheck .MergeCheck.IsConflicted }}
{{ i "triangle-alert" "w-4 h-4" }} Merge conflicts detected
Expand
{{ if gt (len .MergeCheck.Conflicts) 0 }} {{ end }}
{{ else if and $isOpen .MergeCheck }}
{{ i "check" "w-4 h-4" }} No conflicts, ready to merge
{{ end }} {{ end }} {{ define "resubmitStatus" }} {{ if .ResubmitCheck.Yes }}
{{ i "triangle-alert" "w-4 h-4" }} This branch has been updated, consider resubmitting
{{ end }} {{ end }}