Monorepo for Tangled
tangled.org
1{{ define "title" }}issues · {{ .RepoInfo.FullName }}{{ end }}
2
3{{ define "extrameta" }}
4 {{ $title := "issues"}}
5 {{ $url := printf "https://tangled.org/%s/issues" .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 .FilteringByOpen }}
13 {{ $active = "open" }}
14 {{ end }}
15
16 {{ $open :=
17 (dict
18 "Key" "open"
19 "Value" "open"
20 "Icon" "circle-dot"
21 "Meta" (string .RepoInfo.Stats.IssueCount.Open)) }}
22 {{ $closed :=
23 (dict
24 "Key" "closed"
25 "Value" "closed"
26 "Icon" "ban"
27 "Meta" (string .RepoInfo.Stats.IssueCount.Closed)) }}
28 {{ $values := list $open $closed }}
29
30 <div class="grid gap-2 grid-cols-[auto_1fr_auto] grid-row-2">
31 <form class="flex relative col-span-3 sm:col-span-1 sm:col-start-2" method="GET">
32 <input type="hidden" name="state" value="{{ if .FilteringByOpen }}open{{ else }}closed{{ end }}">
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 focus:border-0 focus:outline-none focus:ring focus:ring-blue-400 ring-inset peer"
37 type="text"
38 name="q"
39 value="{{ .FilterQuery }}"
40 placeholder=" "
41 >
42 <a
43 href="?state={{ if .FilteringByOpen }}open{{ else }}closed{{ 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-400 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") }}
58 </div>
59 <a
60 href="/{{ .RepoInfo.FullName }}/issues/new"
61 class="col-start-3 btn-create text-sm flex items-center justify-center gap-2 no-underline hover:no-underline hover:text-white"
62 >
63 {{ i "circle-plus" "w-4 h-4" }}
64 <span>new</span>
65 </a>
66 </div>
67 <div class="error" id="issues"></div>
68{{ end }}
69
70{{ define "repoAfter" }}
71 <div class="mt-2">
72 {{ template "repo/issues/fragments/issueListing" (dict "Issues" .Issues "RepoPrefix" .RepoInfo.FullName "LabelDefs" .LabelDefs) }}
73 </div>
74 {{if gt .IssueCount .Page.Limit }}
75 {{ block "pagination" . }} {{ end }}
76 {{ end }}
77{{ end }}
78
79{{ define "pagination" }}
80<div class="flex justify-center items-center mt-4 gap-2">
81 {{ $currentState := "closed" }}
82 {{ if .FilteringByOpen }}
83 {{ $currentState = "open" }}
84 {{ end }}
85
86 {{ $prev := .Page.Previous.Offset }}
87 {{ $next := .Page.Next.Offset }}
88 {{ $lastPage := sub .IssueCount (mod .IssueCount .Page.Limit) }}
89
90 <a
91 class="
92 btn flex items-center gap-2 no-underline hover:no-underline
93 dark:text-white dark:hover:bg-gray-700
94 {{ if le .Page.Offset 0 }}
95 cursor-not-allowed opacity-50
96 {{ end }}
97 "
98 {{ if gt .Page.Offset 0 }}
99 hx-boost="true"
100 href = "/{{ $.RepoInfo.FullName }}/issues?state={{ $currentState }}&q={{ .FilterQuery }}&offset={{ $prev }}&limit={{ .Page.Limit }}"
101 {{ end }}
102 >
103 {{ i "chevron-left" "w-4 h-4" }}
104 previous
105 </a>
106
107 <!-- dont show first page if current page is first page -->
108 {{ if gt .Page.Offset 0 }}
109 <a
110 hx-boost="true"
111 href = "/{{ $.RepoInfo.FullName }}/issues?state={{ $currentState }}&q={{ .FilterQuery }}&offset=0&limit={{ .Page.Limit }}"
112 >
113 1
114 </a>
115 {{ end }}
116
117 <!-- if previous page is not first or second page (prev > limit) -->
118 {{ if gt $prev .Page.Limit }}
119 <span>...</span>
120 {{ end }}
121
122 <!-- if previous page is not the first page -->
123 {{ if gt $prev 0 }}
124 <a
125 hx-boost="true"
126 href = "/{{ $.RepoInfo.FullName }}/issues?state={{ $currentState }}&q={{ .FilterQuery }}&offset={{ $prev }}&limit={{ .Page.Limit }}"
127 >
128 {{ add (div $prev .Page.Limit) 1 }}
129 </a>
130 {{ end }}
131
132 <!-- current page. this is always visible -->
133 <span class="font-bold">
134 {{ add (div .Page.Offset .Page.Limit) 1 }}
135 </span>
136
137 <!-- if next page is not last page -->
138 {{ if lt $next $lastPage }}
139 <a
140 hx-boost="true"
141 href = "/{{ $.RepoInfo.FullName }}/issues?state={{ $currentState }}&q={{ .FilterQuery }}&offset={{ $next }}&limit={{ .Page.Limit }}"
142 >
143 {{ add (div $next .Page.Limit) 1 }}
144 </a>
145 {{ end }}
146
147 <!-- if next page is not second last or last page (next < issues - 2 * limit) -->
148 {{ if lt ($next) (sub .IssueCount (mul (2) .Page.Limit)) }}
149 <span>...</span>
150 {{ end }}
151
152 <!-- if its not the last page -->
153 {{ if lt .Page.Offset $lastPage }}
154 <a
155 hx-boost="true"
156 href = "/{{ $.RepoInfo.FullName }}/issues?state={{ $currentState }}&q={{ .FilterQuery }}&offset={{ $lastPage }}&limit={{ .Page.Limit }}"
157 >
158 {{ add (div $lastPage .Page.Limit) 1 }}
159 </a>
160 {{ end }}
161
162 <a
163 class="
164 btn flex items-center gap-2 no-underline hover:no-underline
165 dark:text-white dark:hover:bg-gray-700
166 {{ if ne (len .Issues) .Page.Limit }}
167 cursor-not-allowed opacity-50
168 {{ end }}
169 "
170 {{ if eq (len .Issues) .Page.Limit }}
171 hx-boost="true"
172 href="/{{ $.RepoInfo.FullName }}/issues?state={{ $currentState }}&q={{ .FilterQuery }}&offset={{ $next }}&limit={{ .Page.Limit }}"
173 {{ end }}
174 >
175 next
176 {{ i "chevron-right" "w-4 h-4" }}
177 </a>
178</div>
179{{ end }}