forked from tangled.org/core
Monorepo for Tangled — https://tangled.org

appview/pages: show tiny avatar in more places

Also fixes OrderedReactionKinds breaking patch/interdiff pages.

Signed-off-by: Anirudh Oppiliappan <anirudh@tangled.sh>

anirudh.fi 83937565 9b2bf899

verified
Changed files
+53 -44
appview
+20 -18
appview/pages/pages.go
···
DidHandleMap map[string]string
OrderedReactionKinds []db.ReactionKind
-
Reactions map[db.ReactionKind]int
-
UserReacted map[db.ReactionKind]bool
+
Reactions map[db.ReactionKind]int
+
UserReacted map[db.ReactionKind]bool
State string
}
type ThreadReactionFragmentParams struct {
ThreadAt syntax.ATURI
-
Kind db.ReactionKind
-
Count int
+
Kind db.ReactionKind
+
Count int
IsReacted bool
}
···
}
type RepoPullPatchParams struct {
-
LoggedInUser *oauth.User
-
DidHandleMap map[string]string
-
RepoInfo repoinfo.RepoInfo
-
Pull *db.Pull
-
Stack db.Stack
-
Diff *types.NiceDiff
-
Round int
-
Submission *db.PullSubmission
+
LoggedInUser *oauth.User
+
DidHandleMap map[string]string
+
RepoInfo repoinfo.RepoInfo
+
Pull *db.Pull
+
Stack db.Stack
+
Diff *types.NiceDiff
+
Round int
+
Submission *db.PullSubmission
+
OrderedReactionKinds []db.ReactionKind
}
// this name is a mouthful
···
}
type RepoPullInterdiffParams struct {
-
LoggedInUser *oauth.User
-
DidHandleMap map[string]string
-
RepoInfo repoinfo.RepoInfo
-
Pull *db.Pull
-
Round int
-
Interdiff *patchutil.InterdiffResult
+
LoggedInUser *oauth.User
+
DidHandleMap map[string]string
+
RepoInfo repoinfo.RepoInfo
+
Pull *db.Pull
+
Round int
+
Interdiff *patchutil.InterdiffResult
+
OrderedReactionKinds []db.ReactionKind
}
// this name is a mouthful
+1 -1
appview/pages/templates/layouts/topbar.html
···
class="cursor-pointer list-none flex items-center"
>
{{ $user := didOrHandle .Did .Handle }}
-
{{ template "user/fragments/picHandle" $user }}
+
{{ template "user/fragments/picHandleLink" $user }}
</summary>
<div
class="absolute flex flex-col right-0 mt-4 p-4 rounded w-48 bg-white dark:bg-gray-800 dark:text-white border border-gray-200 dark:border-gray-700"
+1 -1
appview/pages/templates/repo/commit.html
···
<div class="flex items-center gap-2 my-2">
{{ i "user" "w-4 h-4" }}
{{ $committerDidOrHandle := index $.EmailToDidOrHandle $commit.Committer.Email }}
-
<a href="/{{ $committerDidOrHandle }}">{{ $committerDidOrHandle }}</a>
+
<a href="/{{ $committerDidOrHandle }}">{{ template "user/fragments/picHandleLink" $committerDidOrHandle }}</a>
</div>
<div class="my-1 pt-2 text-xs border-t">
<div class="text-gray-600 dark:text-gray-300">SSH Key Fingerprint:</div>
+1 -1
appview/pages/templates/repo/index.html
···
{{ end }}"
class="text-gray-500 dark:text-gray-400 no-underline hover:underline"
>{{ if $didOrHandle }}
-
{{ $didOrHandle }}
+
{{ template "user/fragments/picHandleLink" $didOrHandle }}
{{ else }}
{{ .Author.Name }}
{{ end }}</a
+6 -6
appview/pages/templates/repo/issues/fragments/issueComment.html
···
{{ define "repo/issues/fragments/issueComment" }}
{{ with .Comment }}
<div id="comment-container-{{.CommentId}}">
-
<div class="flex items-center gap-2 mb-2 text-gray-500 dark:text-gray-400 text-sm">
+
<div class="flex items-center gap-2 mb-2 text-gray-500 dark:text-gray-400 text-sm flex-wrap">
{{ $owner := index $.DidHandleMap .OwnerDid }}
-
<a href="/{{ $owner }}" class="no-underline hover:underline">{{ $owner }}</a>
+
{{ template "user/fragments/picHandleLink" $owner }}
<span class="before:content-['·']"></span>
<a
···
{{ .Created | timeFmt }}
{{ end }}
</a>
-
+
<!-- show user "hats" -->
{{ $isIssueAuthor := eq .OwnerDid $.Issue.OwnerDid }}
{{ if $isIssueAuthor }}
···
{{ $isCommentOwner := and $.LoggedInUser (eq $.LoggedInUser.Did .OwnerDid) }}
{{ if and $isCommentOwner (not .Deleted) }}
-
<button
-
class="btn px-2 py-1 text-sm"
+
<button
+
class="btn px-2 py-1 text-sm"
hx-get="/{{ $.RepoInfo.FullName }}/issues/{{ .Issue }}/comment/{{ .CommentId }}/edit"
hx-swap="outerHTML"
hx-target="#comment-container-{{.CommentId}}"
>
{{ i "pencil" "w-4 h-4" }}
</button>
-
<button
+
<button
class="btn px-2 py-1 text-sm text-red-500 flex gap-2 items-center group"
hx-delete="/{{ $.RepoInfo.FullName }}/issues/{{ .Issue }}/comment/{{ .CommentId }}/"
hx-confirm="Are you sure you want to delete your comment?"
+1 -1
appview/pages/templates/repo/issues/issue.html
···
>
<div class="bg-white dark:bg-gray-800 rounded drop-shadow-sm py-4 px-4 relative w-full md:w-3/5">
<div class="text-sm pb-2 text-gray-500 dark:text-gray-400">
-
{{ didOrHandle .LoggedInUser.Did .LoggedInUser.Handle }}
+
{{ template "user/fragments/picHandleLink" (didOrHandle .LoggedInUser.Did .LoggedInUser.Handle) }}
</div>
<textarea
id="comment-textarea"
+2 -2
appview/pages/templates/repo/log.html
···
<td class=" py-3 align-top">
{{ $didOrHandle := index $.EmailToDidOrHandle $commit.Author.Email }}
{{ if $didOrHandle }}
-
<a href="/{{ $didOrHandle }}" class="text-gray-700 dark:text-gray-300 no-underline hover:underline">{{ $didOrHandle }}</a>
+
{{ template "user/fragments/picHandleLink" $didOrHandle }}
{{ else }}
<a href="mailto:{{ $commit.Author.Email }}" class="text-gray-700 dark:text-gray-300 no-underline hover:underline">{{ $commit.Author.Name }}</a>
{{ end }}
···
{{ $didOrHandle := index $.EmailToDidOrHandle $commit.Author.Email }}
<a href="{{ if $didOrHandle }}/{{ $didOrHandle }}{{ else }}mailto:{{ $commit.Author.Email }}{{ end }}"
class="text-gray-500 dark:text-gray-400 no-underline hover:underline">
-
{{ if $didOrHandle }}{{ $didOrHandle }}{{ else }}{{ $commit.Author.Name }}{{ end }}
+
{{ if $didOrHandle }}{{ template "user/fragments/picHandleLink" $didOrHandle }}{{ else }}{{ $commit.Author.Name }}{{ end }}
</a>
</span>
<div class="inline-block px-1 select-none after:content-['·']"></div>
+4 -2
appview/pages/templates/repo/pulls/fragments/pullHeader.html
···
</article>
{{ end }}
+
{{ with .OrderedReactionKinds }}
<div class="flex items-center gap-2 mt-2">
-
{{ template "repo/fragments/reactionsPopUp" .OrderedReactionKinds }}
-
{{ range $kind := .OrderedReactionKinds }}
+
{{ template "repo/fragments/reactionsPopUp" . }}
+
{{ range $kind := . }}
{{
template "repo/fragments/reaction"
(dict
···
}}
{{ end }}
</div>
+
{{ end }}
</section>
+3 -4
appview/pages/templates/repo/pulls/fragments/pullNewComment.html
···
{{ define "repo/pulls/fragments/pullNewComment" }}
-
<div
-
id="pull-comment-card-{{ .RoundNumber }}"
+
<div
+
id="pull-comment-card-{{ .RoundNumber }}"
class="bg-white dark:bg-gray-800 rounded drop-shadow-sm p-4 relative w-full flex flex-col gap-2">
<div class="text-sm text-gray-500 dark:text-gray-400">
-
{{ didOrHandle .LoggedInUser.Did .LoggedInUser.Handle }}
+
{{ template "user/fragments/picHandleLink" (didOrHandle .LoggedInUser.Did .LoggedInUser.Handle) }}
</div>
<form
hx-post="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/round/{{ .RoundNumber }}/comment"
···
</form>
</div>
{{ end }}
-
+7 -7
appview/pages/templates/repo/pulls/pull.html
···
{{ define "extrameta" }}
{{ $title := printf "%s &middot; pull #%d &middot; %s" .Pull.Title .Pull.PullId .RepoInfo.FullName }}
{{ $url := printf "https://tangled.sh/%s/pulls/%d" .RepoInfo.FullName .Pull.PullId }}
-
+
{{ template "repo/fragments/og" (dict "RepoInfo" .RepoInfo "Title" $title "Url" $url) }}
{{ end }}
···
</div>
<!-- round summary -->
<div class="rounded drop-shadow-sm bg-white dark:bg-gray-800 p-2 text-gray-500 dark:text-gray-400">
-
<span>
+
<span class="gap-1 flex items-center">
{{ $owner := index $.DidHandleMap $.Pull.OwnerDid }}
{{ $re := "re" }}
{{ if eq .RoundNumber 0 }}
{{ $re = "" }}
{{ end }}
<span class="hidden md:inline">{{$re}}submitted</span>
-
by <a href="/{{ $owner }}">{{ $owner }}</a>
+
by {{ template "user/fragments/picHandleLink" $owner }}
<span class="select-none before:content-['\00B7']"></span>
<a class="text-gray-500 dark:text-gray-400 hover:text-gray-500" href="#round-#{{ .RoundNumber }}"><time>{{ .Created | shortTimeFmt }}</time></a>
<span class="select-none before:content-['·']"></span>
···
<a class="btn flex items-center gap-2 no-underline hover:no-underline p-2 group"
hx-boost="true"
href="/{{ $.RepoInfo.FullName }}/pulls/{{ $.Pull.PullId }}/round/{{.RoundNumber}}">
-
{{ i "file-diff" "w-4 h-4" }}
+
{{ i "file-diff" "w-4 h-4" }}
<span class="hidden md:inline">diff</span>
{{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }}
</a>
···
{{ if gt $cidx 0 }}
<div class="absolute left-8 -top-2 w-px h-2 bg-gray-300 dark:bg-gray-600"></div>
{{ end }}
-
<div class="text-sm text-gray-500 dark:text-gray-400">
-
{{ $owner := index $.DidHandleMap $c.OwnerDid }}
-
<a href="/{{$owner}}">{{$owner}}</a>
+
<div class="text-sm text-gray-500 dark:text-gray-400 flex items-center gap-1">
+
{{ $owner := index $.DidHandleMap $c.OwnerDid }}
+
{{ template "user/fragments/picHandleLink" $owner }}
<span class="before:content-['·']"></span>
<a class="text-gray-500 dark:text-gray-400 hover:text-gray-500 dark:hover:text-gray-300" href="#comment-{{.ID}}"><time>{{ $c.Created | shortTimeFmt }}</time></a>
</div>
+7 -1
appview/pages/templates/repo/tree.html
···
{{ template "repo/fragments/meta" . }}
{{ $title := printf "%s at %s &middot; %s" $path .Ref .RepoInfo.FullName }}
{{ $url := printf "https://tangled.sh/%s/tree/%s%s" .RepoInfo.FullName .Ref $path }}
-
+
{{ template "repo/fragments/og" (dict "RepoInfo" .RepoInfo "Title" $title "Url" $url) }}
{{ end }}
···
</div>
</a>
{{ if .LastCommit}}
+
<div class="flex items-end gap-2">
+
<span class="text text-gray-500 dark:text-gray-400 mr-6">{{ .LastCommit.Message }}</span>
<time class="text-xs text-gray-500 dark:text-gray-400">{{ timeFmt .LastCommit.When }}</time>
+
</div>
{{ end }}
</div>
</div>
···
</div>
</a>
{{ if .LastCommit}}
+
<div class="flex items-end gap-2">
+
<span class="text text-gray-500 dark:text-gray-400 mr-6">{{ .LastCommit.Message }}</span>
<time class="text-xs text-gray-500 dark:text-gray-400">{{ timeFmt .LastCommit.When }}</time>
+
</div>
{{ end }}
</div>
</div>