Monorepo for Tangled
1{{ define "repo/issues/fragments/issueCommentHeader" }}
2 <div class="flex flex-wrap items-center gap-2 text-sm text-gray-500 dark:text-gray-400 ">
3 {{ template "user/fragments/picHandleLink" .Comment.Did }}
4 {{ template "hats" $ }}
5 {{ template "timestamp" . }}
6 {{ $isCommentOwner := and .LoggedInUser (eq .LoggedInUser.Did .Comment.Did) }}
7 {{ if and $isCommentOwner (not .Comment.Deleted) }}
8 {{ template "editIssueComment" . }}
9 {{ template "deleteIssueComment" . }}
10 {{ end }}
11 </div>
12{{ end }}
13
14{{ define "hats" }}
15 {{ $isIssueAuthor := eq .Comment.Did .Issue.Did }}
16 {{ if $isIssueAuthor }}
17 (author)
18 {{ end }}
19{{ end }}
20
21{{ define "timestamp" }}
22 <a href="#comment-{{ .Comment.Id }}"
23 class="text-gray-500 dark:text-gray-400 hover:text-gray-500 dark:hover:text-gray-400 hover:underline no-underline"
24 id="comment-{{ .Comment.Id }}">
25 {{ if .Comment.Deleted }}
26 {{ template "repo/fragments/shortTimeAgo" .Comment.Deleted }}
27 {{ else if .Comment.Edited }}
28 edited {{ template "repo/fragments/shortTimeAgo" .Comment.Edited }}
29 {{ else }}
30 {{ template "repo/fragments/shortTimeAgo" .Comment.Created }}
31 {{ end }}
32 </a>
33{{ end }}
34
35{{ define "editIssueComment" }}
36 <a
37 class="text-gray-500 dark:text-gray-400 flex gap-1 items-center group cursor-pointer"
38 hx-get="/{{ .RepoInfo.FullName }}/issues/{{ .Issue.IssueId }}/comment/{{ .Comment.Id }}/edit"
39 hx-swap="outerHTML"
40 hx-target="#comment-body-{{.Comment.Id}}">
41 {{ i "pencil" "size-3" }}
42 </a>
43{{ end }}
44
45{{ define "deleteIssueComment" }}
46 <a
47 class="text-gray-500 dark:text-gray-400 flex gap-1 items-center group cursor-pointer"
48 hx-delete="/{{ .RepoInfo.FullName }}/issues/{{ .Issue.IssueId }}/comment/{{ .Comment.Id }}/"
49 hx-confirm="Are you sure you want to delete your comment?"
50 hx-swap="outerHTML"
51 hx-target="#comment-body-{{.Comment.Id}}"
52 >
53 {{ i "trash-2" "size-3" }}
54 {{ i "loader-circle" "size-3 animate-spin hidden group-[.htmx-request]:inline" }}
55 </a>
56{{ end }}