forked from
tangled.org/core
Monorepo for Tangled
1{{ define "title" }}pulls · {{ .RepoInfo.FullName }}{{ end }}
2
3{{ define "extrameta" }}
4 {{ $title := "pulls"}}
5 {{ $url := printf "https://tangled.org/%s/pulls" .RepoInfo.FullName }}
6
7 {{ template "repo/fragments/og" (dict "RepoInfo" .RepoInfo "Title" $title "Url" $url) }}
8{{ end }}
9
10{{ define "repoContent" }}
11 {{ $active := "closed" }}
12 {{ if .FilteringBy.IsOpen }}
13 {{ $active = "open" }}
14 {{ else if .FilteringBy.IsMerged }}
15 {{ $active = "merged" }}
16 {{ end }}
17 {{ $open :=
18 (dict
19 "Key" "open"
20 "Value" "open"
21 "Icon" "git-pull-request"
22 "Meta" (string .RepoInfo.Stats.PullCount.Open)) }}
23 {{ $merged :=
24 (dict
25 "Key" "merged"
26 "Value" "merged"
27 "Icon" "git-merge"
28 "Meta" (string .RepoInfo.Stats.PullCount.Merged)) }}
29 {{ $closed :=
30 (dict
31 "Key" "closed"
32 "Value" "closed"
33 "Icon" "ban"
34 "Meta" (string .RepoInfo.Stats.PullCount.Closed)) }}
35 {{ $values := list $open $merged $closed }}
36 <div class="grid gap-2 grid-cols-[auto_1fr_auto] grid-row-2">
37 <form class="flex relative col-span-3 sm:col-span-1 sm:col-start-2" method="GET">
38 <input type="hidden" name="state" value="{{ .FilteringBy.String }}">
39 <div class="flex-1 flex relative">
40 <input
41 id="search-q"
42 class="flex-1 py-1 pl-2 pr-10 mr-[-1px] rounded-r-none peer"
43 type="text"
44 name="q"
45 value="{{ .FilterQuery }}"
46 placeholder="search pulls..."
47 >
48 <a
49 href="?state={{ .FilteringBy.String }}"
50 class="absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hidden peer-[:not(:placeholder-shown)]:block"
51 >
52 {{ i "x" "w-4 h-4" }}
53 </a>
54 </div>
55 <button
56 type="submit"
57 class="p-2 text-gray-400 border rounded-r border-gray-300 dark:border-gray-600"
58 >
59 {{ i "search" "w-4 h-4" }}
60 </button>
61 </form>
62 <div class="sm:row-start-1">
63 {{ template "fragments/tabSelector" (dict "Name" "state" "Values" $values "Active" $active "Include" "#search-q") }}
64 </div>
65 <a
66 href="/{{ .RepoInfo.FullName }}/pulls/new"
67 class="col-start-3 btn-create text-sm flex items-center gap-2 no-underline hover:no-underline hover:text-white"
68 >
69 {{ i "git-pull-request-create" "w-4 h-4" }}
70 <span>new</span>
71 </a>
72 </div>
73 <div class="error" id="pulls"></div>
74{{ end }}
75
76{{ define "repoAfter" }}
77 <div class="flex flex-col gap-2 mt-2">
78 {{ range .Pulls }}
79 <div class="rounded bg-white dark:bg-gray-800">
80 <div class="px-6 py-4 z-5">
81 <div class="pb-2">
82 <a href="/{{ $.RepoInfo.FullName }}/pulls/{{ .PullId }}" class="dark:text-white">
83 {{ .Title | description }}
84 <span class="text-gray-500 dark:text-gray-400">#{{ .PullId }}</span>
85 </a>
86 </div>
87 <div class="text-sm text-gray-500 dark:text-gray-400 flex flex-wrap items-center gap-1">
88 {{ $bgColor := "bg-gray-800 dark:bg-gray-700" }}
89 {{ $icon := "ban" }}
90
91 {{ if .State.IsOpen }}
92 {{ $bgColor = "bg-green-600 dark:bg-green-700" }}
93 {{ $icon = "git-pull-request" }}
94 {{ else if .State.IsMerged }}
95 {{ $bgColor = "bg-purple-600 dark:bg-purple-700" }}
96 {{ $icon = "git-merge" }}
97 {{ end }}
98
99
100 <span
101 class="inline-flex items-center rounded px-2 py-[5px] {{ $bgColor }} text-sm"
102 >
103 {{ i $icon "w-3 h-3 mr-1.5 text-white" }}
104 <span class="text-white">{{ .State.String }}</span>
105 </span>
106
107 <span class="ml-1">
108 {{ template "user/fragments/picHandleLink" .OwnerDid }}
109 </span>
110
111 <span class="before:content-['·']">
112 {{ template "repo/fragments/time" .Created }}
113 </span>
114
115 <span class="before:content-['·']">
116 {{ $commentCount := .TotalComments }}
117 {{ $commentCount }} comment{{ if ne $commentCount 1 }}s{{ end }}
118 </span>
119
120 <span class="before:content-['·']">
121 round
122 <span class="font-mono">
123 #{{ .LastRoundNumber }}
124 </span>
125 </span>
126
127 {{ $pipeline := index $.Pipelines .LatestSha }}
128 {{ if and $pipeline $pipeline.Id }}
129 <span class="before:content-['·']"></span>
130 {{ template "repo/pipelines/fragments/pipelineSymbol" (dict "Pipeline" $pipeline "ShortSummary" true) }}
131 {{ end }}
132
133 {{ $state := .Labels }}
134 {{ range $k, $d := $.LabelDefs }}
135 {{ range $v, $s := $state.GetValSet $d.AtUri.String }}
136 {{ template "labels/fragments/label" (dict "def" $d "val" $v "withPrefix" true) }}
137 {{ end }}
138 {{ end }}
139 </div>
140 </div>
141 {{ if .StackId }}
142 {{ $otherPulls := index $.Stacks .StackId }}
143 {{ if gt (len $otherPulls) 0 }}
144 <details class="bg-white dark:bg-gray-800 group">
145 <summary class="pb-4 px-6 text-xs list-none cursor-pointer hover:text-gray-500 hover:dark:text-gray-400">
146 {{ $s := "s" }}
147 {{ if eq (len $otherPulls) 1 }}
148 {{ $s = "" }}
149 {{ end }}
150 <div class="group-open:hidden flex items-center gap-2">
151 {{ i "chevrons-up-down" "w-4 h-4" }} expand {{ len $otherPulls }} pull{{$s}} in this stack
152 </div>
153 <div class="hidden group-open:flex items-center gap-2">
154 {{ i "chevrons-down-up" "w-4 h-4" }} hide {{ len $otherPulls }} pull{{$s}} in this stack
155 </div>
156 </summary>
157 {{ block "stackedPullList" (list $otherPulls $) }} {{ end }}
158 </details>
159 {{ end }}
160 {{ end }}
161 </div>
162 {{ end }}
163 </div>
164 {{if gt .PullCount .Page.Limit }}
165 {{ template "fragments/pagination" (dict
166 "Page" .Page
167 "TotalCount" .PullCount
168 "BasePath" (printf "/%s/pulls" .RepoInfo.FullName)
169 "QueryParams" (queryParams "state" .FilteringBy.String "q" .FilterQuery)
170 ) }}
171 {{ end }}
172{{ end }}
173
174{{ define "stackedPullList" }}
175 {{ $list := index . 0 }}
176 {{ $root := index . 1 }}
177 <div class="grid grid-cols-1 rounded-b border-b border-t border-gray-200 dark:border-gray-900 divide-y divide-gray-200 dark:divide-gray-900">
178 {{ range $pull := $list }}
179 {{ $pipeline := index $root.Pipelines $pull.LatestSha }}
180 <a href="/{{ $root.RepoInfo.FullName }}/pulls/{{ $pull.PullId }}" class="no-underline hover:no-underline hover:bg-gray-100/25 hover:dark:bg-gray-700/25">
181 <div class="flex gap-2 items-center px-6">
182 <div class="flex-grow min-w-0 w-full py-2">
183 {{ template "repo/pulls/fragments/summarizedPullHeader" (list $pull $pipeline) }}
184 </div>
185 </div>
186 </a>
187 {{ end }}
188 </div>
189{{ end }}