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