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