From ec529ddfe52fa44e869500f120fa1f5ffd722621 Mon Sep 17 00:00:00 2001 From: Seongmin Lee Date: Sun, 11 Jan 2026 19:54:12 +0900 Subject: [PATCH] appview/pages: use same reactions template for all UI with the introduction of `const` function in funcmap, we can make reusable template for all reaction UI. Signed-off-by: Seongmin Lee --- .../templates/repo/fragments/reactions.html | 50 +++++++++++++++++++ .../repo/fragments/reactionsPopUp.html | 30 ----------- .../pages/templates/repo/issues/issue.html | 26 ++-------- .../repo/pulls/fragments/pullHeader.html | 21 ++------ 4 files changed, 60 insertions(+), 67 deletions(-) create mode 100644 appview/pages/templates/repo/fragments/reactions.html delete mode 100644 appview/pages/templates/repo/fragments/reactionsPopUp.html diff --git a/appview/pages/templates/repo/fragments/reactions.html b/appview/pages/templates/repo/fragments/reactions.html new file mode 100644 index 00000000..4ba3d6c2 --- /dev/null +++ b/appview/pages/templates/repo/fragments/reactions.html @@ -0,0 +1,50 @@ +{{ define "repo/fragments/reactions" }} +
+ {{- $reactions := .Reactions -}} + {{- $userReacted := .UserReacted -}} + {{- $threadAt := .ThreadAt -}} + + {{ template "reactionsPopup" }} + {{ range $kind := const.OrderedReactionKinds }} + {{ $reactionData := index $reactions $kind }} + {{ template "repo/fragments/reaction" + (dict + "Kind" $kind + "Count" $reactionData.Count + "IsReacted" (index $userReacted $kind) + "ThreadAt" $threadAt + "Users" $reactionData.Users) }} + {{ end }} +
+{{ end }} + +{{ define "reactionsPopup" }} +
+ + {{ i "smile" "size-4" }} + +
+ {{ range $kind := const.OrderedReactionKinds }} + + {{ end }} +
+
+{{ end }} diff --git a/appview/pages/templates/repo/fragments/reactionsPopUp.html b/appview/pages/templates/repo/fragments/reactionsPopUp.html deleted file mode 100644 index 1464d3fa..00000000 --- a/appview/pages/templates/repo/fragments/reactionsPopUp.html +++ /dev/null @@ -1,30 +0,0 @@ -{{ define "repo/fragments/reactionsPopUp" }} -
- - {{ i "smile" "size-4" }} - -
- {{ range $kind := . }} - - {{ end }} -
-
-{{ end }} diff --git a/appview/pages/templates/repo/issues/issue.html b/appview/pages/templates/repo/issues/issue.html index ccd9f2bd..ac485f7f 100644 --- a/appview/pages/templates/repo/issues/issue.html +++ b/appview/pages/templates/repo/issues/issue.html @@ -35,8 +35,11 @@ {{ if .Issue.Body }}
{{ .Issue.Body | markdown }}
{{ end }} -
- {{ template "issueReactions" . }} +
+ {{ template "repo/fragments/reactions" + (dict "Reactions" .Reactions + "UserReacted" .UserReacted + "ThreadAt" .Issue.AtUri) }}
{{ end }} @@ -107,25 +110,6 @@ {{ end }} -{{ define "issueReactions" }} -
- {{ template "repo/fragments/reactionsPopUp" const.OrderedReactionKinds }} - {{ range $kind := const.OrderedReactionKinds }} - {{ $reactionData := index $.Reactions $kind }} - {{ - template "repo/fragments/reaction" - (dict - "Kind" $kind - "Count" $reactionData.Count - "IsReacted" (index $.UserReacted $kind) - "ThreadAt" $.Issue.AtUri - "Users" $reactionData.Users) - }} - {{ end }} -
-{{ end }} - - {{ define "repoAfter" }}
{{ diff --git a/appview/pages/templates/repo/pulls/fragments/pullHeader.html b/appview/pages/templates/repo/pulls/fragments/pullHeader.html index 7d2c0eae..df3ce000 100644 --- a/appview/pages/templates/repo/pulls/fragments/pullHeader.html +++ b/appview/pages/templates/repo/pulls/fragments/pullHeader.html @@ -63,23 +63,12 @@ {{ end }} - {{ with const.OrderedReactionKinds }} -
- {{ template "repo/fragments/reactionsPopUp" . }} - {{ range $kind := . }} - {{ $reactionData := index $.Reactions $kind }} - {{ - template "repo/fragments/reaction" - (dict - "Kind" $kind - "Count" $reactionData.Count - "IsReacted" (index $.UserReacted $kind) - "ThreadAt" $.Pull.AtUri - "Users" $reactionData.Users) - }} - {{ end }} +
+ {{ template "repo/fragments/reactions" + (dict "Reactions" .Reactions + "UserReacted" .UserReacted + "ThreadAt" .Pull.AtUri) }}
- {{ end }} -- 2.51.2