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