this repo has no description
1{{ define "title" }}{{ .Issue.Title }} · issue #{{ .Issue.IssueId }} · {{ .RepoInfo.FullName }}{{ end }}
2
3
4{{ define "extrameta" }}
5 {{ $title := printf "%s · issue #%d · %s" .Issue.Title .Issue.IssueId .RepoInfo.FullName }}
6 {{ $url := printf "https://tangled.sh/%s/issues/%d" .RepoInfo.FullName .Issue.IssueId }}
7
8 {{ template "repo/fragments/og" (dict "RepoInfo" .RepoInfo "Title" $title "Url" $url) }}
9{{ end }}
10
11{{ define "repoContent" }}
12 <header class="pb-4">
13 <h1 class="text-2xl">
14 {{ .Issue.Title }}
15 <span class="text-gray-500 dark:text-gray-400">#{{ .Issue.IssueId }}</span>
16 </h1>
17 </header>
18
19 {{ $bgColor := "bg-gray-800 dark:bg-gray-700" }}
20 {{ $icon := "ban" }}
21 {{ if eq .State "open" }}
22 {{ $bgColor = "bg-green-600 dark:bg-green-700" }}
23 {{ $icon = "circle-dot" }}
24 {{ end }}
25
26 <section class="mt-2">
27 <div class="inline-flex items-center gap-2">
28 <div id="state"
29 class="inline-flex items-center rounded px-3 py-1 {{ $bgColor }}">
30 {{ i $icon "w-4 h-4 mr-1.5 text-white" }}
31 <span class="text-white">{{ .State }}</span>
32 </div>
33 <span class="text-gray-500 dark:text-gray-400 text-sm flex flex-wrap items-center gap-1">
34 opened by
35 {{ $owner := didOrHandle .Issue.OwnerDid .IssueOwnerHandle }}
36 {{ template "user/fragments/picHandle" $owner }}
37 <span class="select-none before:content-['\00B7']"></span>
38 <time title="{{ .Issue.Created | longTimeFmt }}">
39 {{ .Issue.Created | timeFmt }}
40 </time>
41 </span>
42 </div>
43
44 {{ if .Issue.Body }}
45 <article id="body" class="mt-8 prose dark:prose-invert">
46 {{ .Issue.Body | markdown }}
47 </article>
48 {{ end }}
49 </section>
50{{ end }}
51
52{{ define "repoAfter" }}
53 <section id="comments" class="my-2 mt-2 space-y-2 relative">
54 {{ range $index, $comment := .Comments }}
55 <div
56 id="comment-{{ .CommentId }}"
57 class="bg-white dark:bg-gray-800 rounded drop-shadow-sm py-2 px-4 relative w-full md:max-w-3/5 md:w-fit">
58 {{ if gt $index 0 }}
59 <div class="absolute left-8 -top-2 w-px h-2 bg-gray-300 dark:bg-gray-600"></div>
60 {{ end }}
61 {{ template "repo/issues/fragments/issueComment" (dict "RepoInfo" $.RepoInfo "LoggedInUser" $.LoggedInUser "DidHandleMap" $.DidHandleMap "Issue" $.Issue "Comment" .)}}
62 </div>
63 {{ end }}
64 </section>
65
66 {{ block "newComment" . }} {{ end }}
67
68{{ end }}
69
70{{ define "newComment" }}
71 {{ if .LoggedInUser }}
72 <form
73 id="comment-form"
74 hx-post="/{{ .RepoInfo.FullName }}/issues/{{ .Issue.IssueId }}/comment"
75 hx-on::after-request="if(event.detail.successful) this.reset()"
76 >
77 <div class="bg-white dark:bg-gray-800 rounded drop-shadow-sm py-4 px-4 relative w-full md:w-3/5">
78 <div class="text-sm pb-2 text-gray-500 dark:text-gray-400">
79 {{ didOrHandle .LoggedInUser.Did .LoggedInUser.Handle }}
80 </div>
81 <textarea
82 id="comment-textarea"
83 name="body"
84 class="w-full p-2 rounded border border-gray-200 dark:border-gray-700"
85 placeholder="Add to the discussion. Markdown is supported."
86 onkeyup="updateCommentForm()"
87 ></textarea>
88 <div id="issue-comment"></div>
89 <div id="issue-action" class="error"></div>
90 </div>
91
92 <div class="flex gap-2 mt-2">
93 <button
94 id="comment-button"
95 hx-post="/{{ .RepoInfo.FullName }}/issues/{{ .Issue.IssueId }}/comment"
96 type="submit"
97 hx-disabled-elt="#comment-button"
98 class="btn p-2 flex items-center gap-2 no-underline hover:no-underline group"
99 disabled
100 >
101 {{ i "message-square-plus" "w-4 h-4" }}
102 comment
103 {{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }}
104 </button>
105
106 {{ $isIssueAuthor := and .LoggedInUser (eq .LoggedInUser.Did .Issue.OwnerDid) }}
107 {{ $isRepoCollaborator := .RepoInfo.Roles.IsCollaborator }}
108 {{ $isRepoOwner := .RepoInfo.Roles.IsOwner }}
109 {{ if and (or $isIssueAuthor $isRepoCollaborator $isRepoOwner) (eq .State "open") }}
110 <button
111 id="close-button"
112 type="button"
113 class="btn flex items-center gap-2"
114 hx-indicator="#close-spinner"
115 hx-trigger="click"
116 >
117 {{ i "ban" "w-4 h-4" }}
118 close
119 <span id="close-spinner" class="group">
120 {{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }}
121 </span>
122 </button>
123 <div
124 id="close-with-comment"
125 hx-post="/{{ .RepoInfo.FullName }}/issues/{{ .Issue.IssueId }}/comment"
126 hx-trigger="click from:#close-button"
127 hx-disabled-elt="#close-with-comment"
128 hx-target="#issue-comment"
129 hx-indicator="#close-spinner"
130 hx-vals="js:{body: document.getElementById('comment-textarea').value.trim() !== '' ? document.getElementById('comment-textarea').value : ''}"
131 hx-swap="none"
132 >
133 </div>
134 <div
135 id="close-issue"
136 hx-disabled-elt="#close-issue"
137 hx-post="/{{ .RepoInfo.FullName }}/issues/{{ .Issue.IssueId }}/close"
138 hx-trigger="click from:#close-button"
139 hx-target="#issue-action"
140 hx-indicator="#close-spinner"
141 hx-swap="none"
142 >
143 </div>
144 <script>
145 document.addEventListener('htmx:configRequest', function(evt) {
146 if (evt.target.id === 'close-with-comment') {
147 const commentText = document.getElementById('comment-textarea').value.trim();
148 if (commentText === '') {
149 evt.detail.parameters = {};
150 evt.preventDefault();
151 }
152 }
153 });
154 </script>
155 {{ else if and (or $isIssueAuthor $isRepoCollaborator $isRepoOwner) (eq .State "closed") }}
156 <button
157 type="button"
158 class="btn flex items-center gap-2"
159 hx-post="/{{ .RepoInfo.FullName }}/issues/{{ .Issue.IssueId }}/reopen"
160 hx-indicator="#reopen-spinner"
161 hx-swap="none"
162 >
163 {{ i "refresh-ccw-dot" "w-4 h-4" }}
164 reopen
165 <span id="reopen-spinner" class="group">
166 {{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }}
167 </span>
168 </button>
169 {{ end }}
170
171 <script>
172 function updateCommentForm() {
173 const textarea = document.getElementById('comment-textarea');
174 const commentButton = document.getElementById('comment-button');
175 const closeButton = document.getElementById('close-button');
176
177 if (textarea.value.trim() !== '') {
178 commentButton.removeAttribute('disabled');
179 } else {
180 commentButton.setAttribute('disabled', '');
181 }
182
183 if (closeButton) {
184 if (textarea.value.trim() !== '') {
185 closeButton.innerHTML = `
186{{ i "ban" "w-4 h-4" }}
187<span>close with comment</span>
188<span id="close-spinner" class="group">
189 {{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }}
190</span>`;
191 } else {
192 closeButton.innerHTML = `
193{{ i "ban" "w-4 h-4" }}
194<span>close</span>
195<span id="close-spinner" class="group">
196 {{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }}
197</span>`;
198 }
199 }
200 }
201
202 document.addEventListener('DOMContentLoaded', function() {
203 updateCommentForm();
204 });
205 </script>
206 </div>
207 </form>
208 {{ else }}
209 <div class="bg-white dark:bg-gray-800 rounded drop-shadow-sm py-4 px-4 relative w-fit">
210 <a href="/login" class="underline">login</a> to join the discussion
211 </div>
212 {{ end }}
213{{ end }}