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
14 kB 329 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 {{ $isForkBased := .Pull.IsForkBased }} 27 {{ $showRunCI := and (not $loading) $isPushAllowed $isOpen $isLastRound $isForkBased (not .HasPipeline) (ne .RepoInfo.Spindle "") }} 28 29 <div id="action-card-{{$roundNumber}}" class="{{ if .LoggedInUser }}relative p-2 flex flex-col gap-2{{ else }}hidden{{ end }}" 30 {{ if $loading }} 31 hx-get="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/round/{{ $roundNumber }}/actions" 32 hx-trigger="load" 33 hx-swap="outerHTML" 34 hx-target="this" 35 {{ end }} 36 > 37 {{ if and (not $loading) $isLastRound }} 38 {{ template "resubmitStatus" . }} 39 {{ end }} 40 <input type="checkbox" id="comment-toggle-{{$roundNumber}}" class="peer/comment hidden"/> 41 <div class="hidden peer-checked/comment:flex flex-col gap-2"> 42 <form 43 class="w-full flex flex-wrap gap-2 group" 44 hx-post="/comment" 45 hx-trigger="submit, keydown[(ctrlKey || metaKey) && key=='Enter'] from:find textarea" 46 hx-target="#pull-comments-{{ .RoundNumber }}" 47 hx-swap="beforeend" 48 hx-disabled-elt="find button[type='submit']" 49 hx-on::after-request="if(event.target === this && event.detail.successful) htmx.ajax('GET', '/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/round/{{ .RoundNumber }}/actions', {target: '#action-card-{{ .RoundNumber }}', swap: 'outerHTML'})" 50 > 51 <input name="subject-uri" type="hidden" value="{{ .Pull.AtUri }}"> 52 <input name="pull-round-idx" type="hidden" value="{{ .RoundNumber }}"> 53 {{ template "fragments/markdownEditor" 54 (dict "Name" "body" 55 "Rows" 8 56 "Required" true 57 "Placeholder" "Add to the discussion...") }} 58 <div class="flex flex-wrap items-stretch justify-end gap-2 text-gray-500 dark:text-gray-400 text-sm w-full"> 59 <label title="Toggle comment form" for="comment-toggle-{{$roundNumber}}" class="btn-flat text-red-500 dark:text-red-400 flex gap-2 items-center"> 60 {{ i "x" "size-4" }} 61 <span>Cancel</span> 62 </label> 63 <button 64 type="submit" 65 class="btn-create-flat flex items-center gap-2"> 66 {{ i "reply" "size-4 inline group-[.htmx-request]:hidden" }} 67 {{ i "loader-circle" "size-4 animate-spin hidden group-[.htmx-request]:inline" }} 68 Reply 69 </button> 70 </div> 71 <div id="comment-error-{{ .RoundNumber }}" class="error"></div> 72 </form> 73 </div> 74 <div id="actions-{{$roundNumber}}" hx-target="this" class="peer-checked/comment:hidden flex flex-wrap gap-2 relative" 75 {{ if $loading }} 76 hx-swap="outerHTML" 77 {{ end }} 78 > 79 {{ if .LoggedInUser }} 80 <label title="Toggle comment form" for="comment-toggle-{{$roundNumber}}" class="btn-flat"> 81 {{ i "message-square-plus" "size-4" }} 82 <span>Comment</span> 83 </label> 84 {{ end }} 85 {{ if and (not $loading) .BranchDeleteStatus }} 86 <button 87 hx-delete="/{{ resolve .BranchDeleteStatus.Repo.Did }}/{{ .BranchDeleteStatus.Repo.Slug }}/branches" 88 hx-vals='{"branch": "{{ .BranchDeleteStatus.Branch }}" }' 89 hx-swap="none" 90 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"> 91 {{ i "git-branch" "w-4 h-4 inline group-[.htmx-request]:hidden" }} 92 {{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }} 93 Delete branch 94 </button> 95 {{ end }} 96 {{ if $showRunCI }} 97 {{ template "runCiModal" . }} 98 {{ end }} 99 {{ if and $isPushAllowed $isOpen $isLastRound }} 100 <button 101 hx-post="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/merge" 102 hx-swap="none" 103 hx-confirm="Are you sure you want to merge pull #{{ .Pull.PullId }} into the `{{ .Pull.TargetBranch }}` branch?" 104 class="btn-flat p-2 flex items-center gap-2 group" 105 {{ if or $loading $isConflicted }}disabled{{ end }} 106 > 107 {{ if $loading }} 108 {{ i "loader-circle" "w-4 h-4 animate-spin" }} 109 {{ else }} 110 {{ i "git-merge" "w-4 h-4 inline group-[.htmx-request]:hidden" }} 111 {{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }} 112 {{ end }} 113 Merge{{if $stackCount}} {{$stackCount}}{{end}} 114 </button> 115 {{ end }} 116 117 {{ if and $isPullAuthor $isOpen $isLastRound }} 118 <button id="resubmitBtn" 119 {{ if not .Pull.IsPatchBased }} 120 hx-post="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/resubmit" 121 hx-swap="none" 122 {{ else }} 123 hx-get="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/resubmit" 124 {{ end }} 125 126 hx-disabled-elt="#resubmitBtn" 127 class="btn-flat p-2 flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed group" 128 129 {{ if $loading }} 130 title="Checking for updates…" 131 disabled 132 {{ else if $isUpToDate }} 133 title="Update this branch to resubmit this pull request" 134 disabled 135 {{ else }} 136 title="Resubmit this pull request" 137 {{ end }} 138 > 139 {{ if $loading }} 140 {{ i "loader-circle" "w-4 h-4 animate-spin" }} 141 {{ else }} 142 {{ i "rotate-ccw" "w-4 h-4 inline group-[.htmx-request]:hidden" }} 143 {{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }} 144 {{ end }} 145 Resubmit 146 </button> 147 {{ end }} 148 149 {{ if and (or $isPullAuthor $isPushAllowed) $isOpen $isLastRound }} 150 <button 151 hx-post="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/close" 152 hx-swap="none" 153 class="btn-flat p-2 flex items-center gap-2 group"> 154 {{ i "ban" "w-4 h-4 inline group-[.htmx-request]:hidden" }} 155 {{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }} 156 Close 157 </button> 158 {{ end }} 159 160 {{ if and (or $isPullAuthor $isPushAllowed) $isClosed $isLastRound }} 161 <button 162 hx-post="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/reopen" 163 hx-swap="none" 164 class="btn-flat p-2 flex items-center gap-2 group"> 165 {{ i "refresh-ccw-dot" "w-4 h-4 inline group-[.htmx-request]:hidden" }} 166 {{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }} 167 Reopen 168 </button> 169 {{ end }} 170 </div> 171 </div> 172 173 {{ if and (not $loading) $isLastRound }} 174 <div id="mergecheck-banner" hx-swap-oob="innerHTML"> 175 {{ if and $isOpen $isForkBased (not .HasPipeline) (ne .RepoInfo.Spindle "") }} 176 {{ template "workflowWarning" . }} 177 {{ end }} 178 {{ template "mergeCheck" . }} 179 </div> 180 {{ end }} 181{{ end }} 182 183{{ define "workflowWarning" }} 184 {{ if .WorkflowsChanged }} 185 <details class="group/ci"> 186 <summary class="flex items-center gap-2 cursor-pointer list-none"> 187 {{ i "triangle-alert" "w-4 h-4 text-amber-600 dark:text-amber-500" }} 188 <span class="font-medium text-amber-600 dark:text-amber-500">Workflow files changed</span> 189 <div class="text-sm text-gray-500 dark:text-gray-400"> 190 <span class="group-open/ci:hidden inline">Expand</span> 191 <span class="hidden group-open/ci:inline">Collapse</span> 192 </div> 193 </summary> 194 <ul class="space-y-1 mt-2 overflow-x-auto"> 195 {{ range .ChangedWorkflowFiles }} 196 <li class="flex items-center whitespace-nowrap"> 197 {{ i "file-warning" "inline-flex w-4 h-4 mr-1.5 text-amber-600 dark:text-amber-500 flex-shrink-0" }} 198 <span class="font-mono">{{ . }}</span> 199 </li> 200 {{ end }} 201 </ul> 202 </details> 203 {{ else }} 204 <div class="flex items-center gap-2 text-amber-600 dark:text-amber-500"> 205 {{ i "triangle-alert" "w-4 h-4" }} 206 <span class="font-medium">Workflow needs approval</span> 207 </div> 208 {{ end }} 209{{ end }} 210 211{{ define "runCiModal" }} 212 <button 213 class="btn-flat p-2 flex items-center gap-2 flex-shrink-0 group" 214 popovertarget="run-ci-{{ .Pull.PullId }}" 215 popovertargetaction="toggle" 216 > 217 {{ i "circle-play" "w-4 h-4 inline" }} 218 Run CI 219 </button> 220 221 <div 222 id="run-ci-{{ .Pull.PullId }}" 223 popover 224 class="bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 dark:text-white backdrop:bg-gray-400/50 dark:backdrop:bg-gray-800/50 w-full md:w-96 p-4 rounded drop-shadow overflow-visible" 225 > 226 <form 227 hx-post="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/trigger-ci?confirm=1" 228 hx-swap="none" 229 hx-indicator="#run-ci-spinner-{{ .Pull.PullId }}" 230 class="flex flex-col gap-2" 231 > 232 <label class="text-lg font-medium p-0">Run CI</label> 233 {{ if .WorkflowsChanged }} 234 <div class="flex items-center gap-2 text-amber-600 dark:text-amber-500"> 235 {{ i "triangle-alert" "size-4" }} 236 <span class="font-medium">Workflow files changed</span> 237 </div> 238 <ul class="space-y-1 overflow-x-auto pl-6"> 239 {{ range .ChangedWorkflowFiles }} 240 <li class="flex items-center whitespace-nowrap"> 241 {{ i "file-warning" "size-4 mr-1.5 text-amber-600 dark:text-amber-500 flex-shrink-0" }} 242 <span class="font-mono text-sm">{{ . }}</span> 243 </li> 244 {{ end }} 245 </ul> 246 <p class="text-sm text-gray-500 dark:text-gray-400">Workflow files changed in this round. Are you sure you want to run CI?</p> 247 {{ else }} 248 <div class="flex items-center gap-2 text-amber-600 dark:text-amber-500"> 249 {{ i "triangle-alert" "size-4" }} 250 <span class="font-medium">Workflow needs approval</span> 251 </div> 252 <p class="text-sm text-gray-500 dark:text-gray-400">This fork-based pull request needs approval to run CI. Are you sure?</p> 253 {{ end }} 254 <div class="flex gap-2 pt-2"> 255 <button 256 type="button" 257 popovertarget="run-ci-{{ .Pull.PullId }}" 258 popovertargetaction="hide" 259 class="btn w-1/2 flex items-center gap-2 text-red-500 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300" 260 > 261 {{ i "x" "size-4" }} Cancel 262 </button> 263 <button type="submit" class="btn w-1/2 flex items-center"> 264 <span class="inline-flex gap-2 items-center">{{ i "shield-check" "size-4" }} Approve</span> 265 <span id="run-ci-spinner-{{ .Pull.PullId }}" class="group"> 266 {{ i "loader-circle" "ml-2 w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }} 267 </span> 268 </button> 269 </div> 270 <div id="pull-error" class="text-red-500 dark:text-red-400"></div> 271 </form> 272 </div> 273{{ end }} 274 275{{ define "mergeCheck" }} 276 {{ $isOpen := .Pull.State.IsOpen }} 277 {{ if and $isOpen .MergeCheck .MergeCheck.Error }} 278 <div class="flex items-center gap-2 text-red-600 dark:text-red-500"> 279 {{ i "triangle-alert" "w-4 h-4" }} 280 <span class="font-medium">{{ .MergeCheck.Error }}</span> 281 </div> 282 {{ else if and $isOpen .MergeCheck .MergeCheck.IsConflicted }} 283 <details class="group/conflict"> 284 <summary class="flex items-center justify-between cursor-pointer list-none"> 285 <div class="flex items-center gap-2 text-red-600 dark:text-red-500"> 286 {{ i "triangle-alert" "w-4 h-4" }} 287 <span class="font-medium">Merge conflicts detected</span> 288 <div class="text-sm text-gray-500 dark:text-gray-400"> 289 <span class="group-open/conflict:hidden inline">Expand</span> 290 <span class="hidden group-open/conflict:inline">Collapse</span> 291 </div> 292 </div> 293 </summary> 294 {{ if gt (len .MergeCheck.Conflicts) 0 }} 295 <ul class="space-y-1 mt-2 overflow-x-auto"> 296 {{ range .MergeCheck.Conflicts }} 297 {{ if .Filename }} 298 <li class="flex items-center whitespace-nowrap"> 299 {{ i "file-warning" "inline-flex w-4 h-4 mr-1.5 text-red-600 dark:text-red-500 flex-shrink-0" }} 300 <span class="font-mono">{{ .Filename }}</span> 301 </li> 302 {{ else if .Reason }} 303 <li class="flex items-center whitespace-nowrap"> 304 {{ i "file-warning" "w-4 h-4 mr-1.5 text-red-600 dark:text-red-500 " }} 305 <span>{{.Reason}}</span> 306 </li> 307 {{ end }} 308 {{ end }} 309 </ul> 310 {{ end }} 311 </details> 312 {{ else if and $isOpen .MergeCheck }} 313 <div class="flex items-center gap-2 text-green-600 dark:text-green-500"> 314 {{ i "check" "w-4 h-4" }} 315 <span class="font-medium">No conflicts, ready to merge</span> 316 </div> 317 {{ end }} 318{{ end }} 319 320{{ define "resubmitStatus" }} 321 {{ if .ResubmitCheck.Yes }} 322 <div class="bg-amber-50 dark:bg-amber-900 border border-amber-500 rounded shadow-sm px-6 py-2 relative"> 323 <div class="flex items-center gap-2 text-amber-500 dark:text-amber-300"> 324 {{ i "triangle-alert" "w-4 h-4" }} 325 <span class="font-medium">This branch has been updated, consider resubmitting</span> 326 </div> 327 </div> 328 {{ end }} 329{{ end }}