This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

core / appview / pages / templates / repo / pulls / fragments / pullActions.html
7.9 kB 186 lines
1{{ define "repo/pulls/fragments/pullActions" }} 2 {{ $lastIdx := sub (len .Pull.Submissions) 1 }} 3 {{ $roundNumber := .RoundNumber }} 4 {{ $stack := .Stack }} 5 {{ $loading := .Loading }} 6 7 {{ $totalPulls := sub 0 1 }} 8 {{ $below := sub 0 1 }} 9 {{ $stackCount := "" }} 10 {{ if (gt (len .Stack) 1) }} 11 {{ $totalPulls = len $stack }} 12 {{ $below = $stack.Below .Pull }} 13 {{ $mergeable := len $below.Mergeable }} 14 {{ $stackCount = printf "%d/%d" $mergeable $totalPulls }} 15 {{ end }} 16 17 {{ $isPushAllowed := .RepoInfo.Roles.IsPushAllowed }} 18 {{ $isMerged := .Pull.State.IsMerged }} 19 {{ $isClosed := .Pull.State.IsClosed }} 20 {{ $isOpen := .Pull.State.IsOpen }} 21 {{ $isConflicted := and .MergeCheck (or .MergeCheck.Error .MergeCheck.IsConflicted) }} 22 {{ $isPullAuthor := and .LoggedInUser (eq .LoggedInUser.Did .Pull.OwnerDid) }} 23 {{ $isLastRound := eq $roundNumber $lastIdx }} 24 {{ $isSameRepoBranch := .Pull.IsBranchBased }} 25 {{ $isUpToDate := .ResubmitCheck.No }} 26 <div id="actions-{{$roundNumber}}" hx-target="this" class="{{ if .LoggedInUser }}flex flex-wrap gap-2 relative p-2{{ else }}hidden{{ end }}" 27 {{ if $loading }} 28 hx-get="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/round/{{ $roundNumber }}/actions" 29 hx-trigger="load" 30 hx-swap="outerHTML" 31 {{ end }} 32 > 33 {{ if .LoggedInUser }} 34 <button 35 hx-get="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/round/{{ $roundNumber }}/comment" 36 class="btn-flat p-2 flex items-center gap-2 no-underline hover:no-underline group"> 37 {{ i "message-square-plus" "w-4 h-4 inline group-[.htmx-request]:hidden" }} 38 {{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }} 39 Comment 40 </button> 41 {{ end }} 42 {{ if and (not $loading) .BranchDeleteStatus }} 43 <button 44 hx-delete="/{{ resolve .BranchDeleteStatus.Repo.Did }}/{{ .BranchDeleteStatus.Repo.Slug }}/branches" 45 hx-vals='{"branch": "{{ .BranchDeleteStatus.Branch }}" }' 46 hx-swap="none" 47 class="btn-flat p-2 flex items-center gap-2 no-underline hover:no-underline group text-red-500 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300"> 48 {{ i "git-branch" "w-4 h-4 inline group-[.htmx-request]:hidden" }} 49 {{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }} 50 Delete branch 51 </button> 52 {{ end }} 53 {{ if and $isPushAllowed $isOpen $isLastRound }} 54 <button 55 hx-post="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/merge" 56 hx-swap="none" 57 hx-confirm="Are you sure you want to merge pull #{{ .Pull.PullId }} into the `{{ .Pull.TargetBranch }}` branch?" 58 class="btn-flat p-2 flex items-center gap-2 group" 59 {{ if or $loading $isConflicted }}disabled{{ end }} 60 > 61 {{ if $loading }} 62 {{ i "loader-circle" "w-4 h-4 animate-spin" }} 63 {{ else }} 64 {{ i "git-merge" "w-4 h-4 inline group-[.htmx-request]:hidden" }} 65 {{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }} 66 {{ end }} 67 Merge{{if $stackCount}} {{$stackCount}}{{end}} 68 </button> 69 {{ end }} 70 71 {{ if and $isPullAuthor $isOpen $isLastRound }} 72 <button id="resubmitBtn" 73 {{ if not .Pull.IsPatchBased }} 74 hx-post="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/resubmit" 75 hx-swap="none" 76 {{ else }} 77 hx-get="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/resubmit" 78 {{ end }} 79 80 hx-disabled-elt="#resubmitBtn" 81 class="btn-flat p-2 flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed group" 82 83 {{ if $loading }} 84 title="Checking for updates…" 85 disabled 86 {{ else if $isUpToDate }} 87 title="Update this branch to resubmit this pull request" 88 disabled 89 {{ else }} 90 title="Resubmit this pull request" 91 {{ end }} 92 > 93 {{ if $loading }} 94 {{ i "loader-circle" "w-4 h-4 animate-spin" }} 95 {{ else }} 96 {{ i "rotate-ccw" "w-4 h-4 inline group-[.htmx-request]:hidden" }} 97 {{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }} 98 {{ end }} 99 Resubmit 100 </button> 101 {{ end }} 102 103 {{ if and (or $isPullAuthor $isPushAllowed) $isOpen $isLastRound }} 104 <button 105 hx-post="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/close" 106 hx-swap="none" 107 class="btn-flat p-2 flex items-center gap-2 group"> 108 {{ i "ban" "w-4 h-4 inline group-[.htmx-request]:hidden" }} 109 {{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }} 110 Close 111 </button> 112 {{ end }} 113 114 {{ if and (or $isPullAuthor $isPushAllowed) $isClosed $isLastRound }} 115 <button 116 hx-post="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/reopen" 117 hx-swap="none" 118 class="btn-flat p-2 flex items-center gap-2 group"> 119 {{ i "refresh-ccw-dot" "w-4 h-4 inline group-[.htmx-request]:hidden" }} 120 {{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }} 121 Reopen 122 </button> 123 {{ end }} 124 </div> 125 126 {{ if and (not $loading) $isLastRound }} 127 <div id="mergecheck-banner" hx-swap-oob="innerHTML">{{ template "mergeCheck" . }}</div> 128 <div id="resubmit-banner" hx-swap-oob="innerHTML">{{ template "resubmitStatus" . }}</div> 129 {{ end }} 130{{ end }} 131 132{{ define "mergeCheck" }} 133 {{ $isOpen := .Pull.State.IsOpen }} 134 {{ if and $isOpen .MergeCheck .MergeCheck.Error }} 135 <div class="flex items-center gap-2 text-red-600 dark:text-red-500"> 136 {{ i "triangle-alert" "w-4 h-4" }} 137 <span class="font-medium">{{ .MergeCheck.Error }}</span> 138 </div> 139 {{ else if and $isOpen .MergeCheck .MergeCheck.IsConflicted }} 140 <details class="group/conflict"> 141 <summary class="flex items-center justify-between cursor-pointer list-none"> 142 <div class="flex items-center gap-2 text-red-600 dark:text-red-500"> 143 {{ i "triangle-alert" "w-4 h-4" }} 144 <span class="font-medium">Merge conflicts detected</span> 145 <div class="text-sm text-gray-500 dark:text-gray-400"> 146 <span class="group-open/conflict:hidden inline">Expand</span> 147 <span class="hidden group-open/conflict:inline">Collapse</span> 148 </div> 149 </div> 150 </summary> 151 {{ if gt (len .MergeCheck.Conflicts) 0 }} 152 <ul class="space-y-1 mt-2 overflow-x-auto"> 153 {{ range .MergeCheck.Conflicts }} 154 {{ if .Filename }} 155 <li class="flex items-center whitespace-nowrap"> 156 {{ i "file-warning" "inline-flex w-4 h-4 mr-1.5 text-red-600 dark:text-red-500 flex-shrink-0" }} 157 <span class="font-mono">{{ .Filename }}</span> 158 </li> 159 {{ else if .Reason }} 160 <li class="flex items-center whitespace-nowrap"> 161 {{ i "file-warning" "w-4 h-4 mr-1.5 text-red-600 dark:text-red-500 " }} 162 <span>{{.Reason}}</span> 163 </li> 164 {{ end }} 165 {{ end }} 166 </ul> 167 {{ end }} 168 </details> 169 {{ else if and $isOpen .MergeCheck }} 170 <div class="flex items-center gap-2 text-green-600 dark:text-green-500"> 171 {{ i "check" "w-4 h-4" }} 172 <span class="font-medium">No conflicts, ready to merge</span> 173 </div> 174 {{ end }} 175{{ end }} 176 177{{ define "resubmitStatus" }} 178 {{ if .ResubmitCheck.Yes }} 179 <div class="bg-amber-50 dark:bg-amber-900 border border-amber-500 rounded shadow-sm px-6 py-2 relative"> 180 <div class="flex items-center gap-2 text-amber-500 dark:text-amber-300"> 181 {{ i "triangle-alert" "w-4 h-4" }} 182 <span class="font-medium">This branch has been updated, consider resubmitting</span> 183 </div> 184 </div> 185 {{ end }} 186{{ end }}