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 {{ if gt (len .Comments) 0 }}
48 <section id="comments" class="my-4 space-y-2 relative">
49 {{ range $index, $comment := .Comments }}
50 <div
51 id="comment-{{ .CommentId }}"
52 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">
53 {{ if gt $index 0 }}
54 <div class="absolute left-8 -top-2 w-px h-2 bg-gray-300 dark:bg-gray-600"></div>
55 {{ end }}
56 {{ template "fragments/issueComment" (dict "RepoInfo" $.RepoInfo "LoggedInUser" $.LoggedInUser "DidHandleMap" $.DidHandleMap "Issue" $.Issue "Comment" .)}}
57 </div>
58 {{ end }}
59 </section>
60 {{ end }}
61
62 {{ block "newComment" . }} {{ end }}
63
64{{ end }}
65
66{{ define "newComment" }}
67 {{ if .LoggedInUser }}
68
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="absolute left-8 -top-4 w-px h-4 bg-gray-300 dark:bg-gray-600"></div>
76 <div class="text-sm pb-2 text-gray-500 dark:text-gray-400">
77 {{ didOrHandle .LoggedInUser.Did .LoggedInUser.Handle }}
78 </div>
79 <textarea
80 id="comment-textarea"
81 name="body"
82 class="w-full p-2 rounded border border-gray-200 dark:border-gray-700"
83 placeholder="Add to the discussion. Markdown is supported."
84 onkeyup="updateCommentForm()"
85 ></textarea>
86 <div id="issue-comment"></div>
87
88 <div id="issue-action" class="error"></div>
89 </div>
90
91 <div class="flex gap-2 mt-2">
92 <button
93 id="comment-button"
94 hx-post="/{{ .RepoInfo.FullName }}/issues/{{ .Issue.IssueId }}/comment"
95 type="submit"
96 hx-disabled-elt="#comment-button"
97 class="btn p-2 flex items-center gap-2 no-underline hover:no-underline"
98 disabled
99 >
100 {{ i "message-square-plus" "w-4 h-4" }}
101 comment
102 </button>
103
104 {{ $isIssueAuthor := and .LoggedInUser (eq .LoggedInUser.Did .Issue.OwnerDid) }}
105 {{ $isRepoCollaborator := .RepoInfo.Roles.IsCollaborator }}
106 {{ if and (or $isIssueAuthor $isRepoCollaborator) (eq .State "open") }}
107 <button
108 id="close-button"
109 type="button"
110 class="btn flex items-center gap-2"
111 hx-trigger="click"
112 >
113 {{ i "ban" "w-4 h-4" }}
114 close
115 </button>
116 <div
117 id="close-with-comment"
118 hx-post="/{{ .RepoInfo.FullName }}/issues/{{ .Issue.IssueId }}/comment"
119 hx-trigger="click from:#close-button"
120 hx-disabled-elt="#close-with-comment"
121 hx-target="#issue-comment"
122 hx-vals="js:{body: document.getElementById('comment-textarea').value.trim() !== '' ? document.getElementById('comment-textarea').value : null}">
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, revealed from:#close-with-comment"
129 hx-target="#issue-action"
130 hx-swap="none">
131 </div>
132 {{ else if and (or $isIssueAuthor $isRepoCollaborator) (eq .State "closed") }}
133 <button
134 type="button"
135 class="btn flex items-center gap-2"
136 hx-post="/{{ .RepoInfo.FullName }}/issues/{{ .Issue.IssueId }}/reopen"
137 hx-swap="none"
138 >
139 {{ i "circle-dot" "w-4 h-4" }}
140 reopen
141 </button>
142 {{ end }}
143
144 <script>
145 function updateCommentForm() {
146 const textarea = document.getElementById('comment-textarea');
147 const commentButton = document.getElementById('comment-button');
148 const closeButton = document.getElementById('close-button');
149
150 if (textarea.value.trim() !== '') {
151 commentButton.removeAttribute('disabled');
152 } else {
153 commentButton.setAttribute('disabled', '');
154 }
155
156 if (closeButton) {
157 if (textarea.value.trim() !== '') {
158 closeButton.innerHTML = '{{ i "ban" "w-4 h-4" }} close with comment';
159 } else {
160 closeButton.innerHTML = '{{ i "ban" "w-4 h-4" }} close';
161 }
162 }
163 }
164
165 document.addEventListener('DOMContentLoaded', function() {
166 updateCommentForm();
167 });
168 </script>
169 </div>
170 </form>
171 {{ else }}
172 <div class="bg-white dark:bg-gray-800 dark:text-gray-400 rounded drop-shadow-sm px-6 py-4 mt-8">
173 <div class="absolute left-8 -top-2 w-px h-2 bg-gray-300 dark:bg-gray-600"></div>
174 <a href="/login" class="underline">login</a> to join the discussion
175 </div>
176 {{ end }}
177{{ end }}