1{{ define "repo/pulls/fragments/pullActions" }}
2 {{ $lastIdx := sub (len .Pull.Submissions) 1 }}
3 {{ $roundNumber := .RoundNumber }}
4
5 {{ $isPushAllowed := .RepoInfo.Roles.IsPushAllowed }}
6 {{ $isMerged := .Pull.State.IsMerged }}
7 {{ $isClosed := .Pull.State.IsClosed }}
8 {{ $isOpen := .Pull.State.IsOpen }}
9 {{ $isConflicted := and .MergeCheck (or .MergeCheck.Error .MergeCheck.IsConflicted) }}
10 {{ $isPullAuthor := and .LoggedInUser (eq .LoggedInUser.Did .Pull.OwnerDid) }}
11 {{ $isLastRound := eq $roundNumber $lastIdx }}
12 {{ $isSameRepoBranch := .Pull.IsBranchBased }}
13 {{ $isUpToDate := .ResubmitCheck.No }}
14 <div class="relative w-fit">
15 <div id="actions-{{$roundNumber}}" class="flex flex-wrap gap-2">
16 <button
17 hx-get="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/round/{{ $roundNumber }}/comment"
18 hx-target="#actions-{{$roundNumber}}"
19 hx-swap="outerHtml"
20 class="btn p-2 flex items-center gap-2 no-underline hover:no-underline group">
21 {{ i "message-square-plus" "w-4 h-4" }}
22 <span>comment</span>
23 {{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }}
24 </button>
25 {{ if and $isPushAllowed $isOpen $isLastRound }}
26 {{ $disabled := "" }}
27 {{ if $isConflicted }}
28 {{ $disabled = "disabled" }}
29 {{ end }}
30 <button
31 hx-post="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/merge"
32 hx-swap="none"
33 hx-confirm="Are you sure you want to merge pull #{{ .Pull.PullId }} into the `{{ .Pull.TargetBranch }}` branch?"
34 class="btn p-2 flex items-center gap-2 group" {{ $disabled }}>
35 {{ i "git-merge" "w-4 h-4" }}
36 <span>merge</span>
37 {{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }}
38 </button>
39 {{ end }}
40
41 {{ if and $isPullAuthor $isOpen $isLastRound }}
42 {{ $disabled := "" }}
43 {{ if $isUpToDate }}
44 {{ $disabled = "disabled" }}
45 {{ end }}
46 <button id="resubmitBtn"
47 {{ if not .Pull.IsPatchBased }}
48 hx-post="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/resubmit"
49 {{ else }}
50 hx-get="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/resubmit"
51 hx-target="#actions-{{$roundNumber}}"
52 hx-swap="outerHtml"
53 {{ end }}
54
55 hx-disabled-elt="#resubmitBtn"
56 class="btn p-2 flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed group" {{ $disabled }}
57
58 {{ if $disabled }}
59 title="Update this branch to resubmit this pull request"
60 {{ else }}
61 title="Resubmit this pull request"
62 {{ end }}
63 >
64 {{ i "rotate-ccw" "w-4 h-4" }}
65 <span>resubmit</span>
66 {{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }}
67 </button>
68 {{ end }}
69
70 {{ if and (or $isPullAuthor $isPushAllowed) $isOpen $isLastRound }}
71 <button
72 hx-post="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/close"
73 hx-swap="none"
74 class="btn p-2 flex items-center gap-2 group">
75 {{ i "ban" "w-4 h-4" }}
76 <span>close</span>
77 {{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }}
78 </button>
79 {{ end }}
80
81 {{ if and (or $isPullAuthor $isPushAllowed) $isClosed $isLastRound }}
82 <button
83 hx-post="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/reopen"
84 hx-swap="none"
85 class="btn p-2 flex items-center gap-2 group">
86 {{ i "refresh-ccw-dot" "w-4 h-4" }}
87 <span>reopen</span>
88 {{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }}
89 </button>
90 {{ end }}
91 </div>
92 </div>
93{{ end }}
94
95