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