this repo has no description
1{{ define "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 <div class="relative w-fit">
13 <div class="absolute left-8 -top-2 w-px h-2 bg-gray-300"></div>
14 <div id="actions-{{$roundNumber}}" class="flex flex-wrap gap-2">
15 <button
16 hx-get="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/round/{{ $roundNumber }}/comment"
17 hx-target="#actions-{{$roundNumber}}"
18 hx-swap="outerHtml"
19 class="btn p-2 flex items-center gap-2 no-underline hover:no-underline">
20 {{ i "message-square-plus" "w-4 h-4" }}
21 <span>comment</span>
22 </button>
23 {{ if and $isPushAllowed $isOpen $isLastRound }}
24 {{ $disabled := "" }}
25 {{ if $isConflicted }}
26 {{ $disabled = "disabled" }}
27 {{ end }}
28 <button
29 hx-post="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/merge"
30 hx-swap="none"
31 hx-confirm="Are you sure you want to merge pull #{{ .Pull.PullId }} into the `{{ .Pull.TargetBranch }}` branch?"
32 class="btn p-2 flex items-center gap-2" {{ $disabled }}>
33 {{ i "git-merge" "w-4 h-4" }}
34 <span>merge</span>
35 </button>
36 {{ end }}
37
38 {{ if and $isPullAuthor $isOpen $isLastRound }}
39 <button
40 hx-get="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/resubmit"
41 hx-target="#actions-{{$roundNumber}}"
42 hx-swap="outerHtml"
43 class="btn p-2 flex items-center gap-2">
44 {{ i "rotate-ccw" "w-4 h-4" }}
45 <span>resubmit</span>
46 </button>
47 {{ end }}
48
49 {{ if and (or $isPullAuthor $isPushAllowed) $isOpen $isLastRound }}
50 <button
51 hx-post="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/close"
52 hx-swap="none"
53 class="btn p-2 flex items-center gap-2">
54 {{ i "ban" "w-4 h-4" }}
55 <span>close</span>
56 </button>
57 {{ end }}
58
59 {{ if and (or $isPullAuthor $isPushAllowed) $isClosed $isLastRound }}
60 <button
61 hx-post="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/reopen"
62 hx-swap="none"
63 class="btn p-2 flex items-center gap-2">
64 {{ i "circle-dot" "w-4 h-4" }}
65 <span>reopen</span>
66 </button>
67 {{ end }}
68 </div>
69 </div>
70{{ end }}
71
72