summaryrefslogtreecommitdiffstats
path: root/templates/repo
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2019-12-01 23:57:24 +0100
committertechknowlogick <techknowlogick@gitea.io>2019-12-01 17:57:24 -0500
commit668eaf95d581f68507523563d0701000a4505055 (patch)
tree4a0bf0aea58ca92f7fde2af0881dd518861512cd /templates/repo
parent674bc772fb213e2b79478438d16835d387865ac3 (diff)
downloadgitea-668eaf95d581f68507523563d0701000a4505055.tar.gz
gitea-668eaf95d581f68507523563d0701000a4505055.zip
[Feature] Custom Reactions (#8886)
* add [ui] Reactions * move contend check from form to go functions * use else if * check if reaction is allowed only on react (so previous custom reaction can be still removed) * use $.AllowedReactions in templates * use ctx.Flash.Error * use it there too * add redirection * back to server error because a wrong reaction is a template issue ... * add emoji list link * add docs entry * small wording nit suggestions from @jolheiser - thx * same reactions as github * fix PR reactions * handle error so template JS could check * Add Integrations Test * add REACTIONS setting to cheat-sheet doc page
Diffstat (limited to 'templates/repo')
-rw-r--r--templates/repo/diff/comments.tmpl2
-rw-r--r--templates/repo/issue/view_content.tmpl4
-rw-r--r--templates/repo/issue/view_content/add_reaction.tmpl15
-rw-r--r--templates/repo/issue/view_content/comments.tmpl4
-rw-r--r--templates/repo/issue/view_content/reactions.tmpl12
5 files changed, 20 insertions, 17 deletions
diff --git a/templates/repo/diff/comments.tmpl b/templates/repo/diff/comments.tmpl
index cc62f19a32..d86cf4077d 100644
--- a/templates/repo/diff/comments.tmpl
+++ b/templates/repo/diff/comments.tmpl
@@ -38,7 +38,7 @@
{{$reactions := .Reactions.GroupByType}}
{{if $reactions}}
<div class="ui attached segment reactions">
- {{template "repo/issue/view_content/reactions" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.root.RepoLink .ID) "Reactions" $reactions }}
+ {{template "repo/issue/view_content/reactions" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.root.RepoLink .ID) "Reactions" $reactions "AllowedReactions" $.AllowedReactions }}
</div>
{{end}}
</div>
diff --git a/templates/repo/issue/view_content.tmpl b/templates/repo/issue/view_content.tmpl
index 5b5d7c45d7..8490841f97 100644
--- a/templates/repo/issue/view_content.tmpl
+++ b/templates/repo/issue/view_content.tmpl
@@ -28,7 +28,7 @@
{{end}}
{{if not $.Repository.IsArchived}}
<div class="ui right actions">
- {{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/issues/%d/reactions" $.RepoLink .Issue.Index) }}
+ {{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/issues/%d/reactions" $.RepoLink .Issue.Index) "AllowedReactions" $.AllowedReactions}}
{{template "repo/issue/view_content/context_menu" Dict "ctx" $ "item" .Issue "delete" false "diff" false }}
</div>
{{end}}
@@ -47,7 +47,7 @@
{{$reactions := .Issue.Reactions.GroupByType}}
{{if $reactions}}
<div class="ui attached segment reactions">
- {{template "repo/issue/view_content/reactions" Dict "ctx" $ "ActionURL" (Printf "%s/issues/%d/reactions" $.RepoLink .Issue.Index) "Reactions" $reactions }}
+ {{template "repo/issue/view_content/reactions" Dict "ctx" $ "ActionURL" (Printf "%s/issues/%d/reactions" $.RepoLink .Issue.Index) "Reactions" $reactions "AllowedReactions" $.AllowedReactions}}
</div>
{{end}}
{{if .Issue.Attachments}}
diff --git a/templates/repo/issue/view_content/add_reaction.tmpl b/templates/repo/issue/view_content/add_reaction.tmpl
index 626db5c261..3bd64ff786 100644
--- a/templates/repo/issue/view_content/add_reaction.tmpl
+++ b/templates/repo/issue/view_content/add_reaction.tmpl
@@ -7,12 +7,15 @@
<div class="menu has-emoji">
<div class="header">{{ .ctx.i18n.Tr "repo.pick_reaction"}}</div>
<div class="divider"></div>
- <div class="item" data-content="+1">:+1:</div>
- <div class="item" data-content="-1">:-1:</div>
- <div class="item" data-content="laugh">:laughing:</div>
- <div class="item" data-content="confused">:confused:</div>
- <div class="item" data-content="heart">:heart:</div>
- <div class="item" data-content="hooray">:tada:</div>
+ {{range $value := .AllowedReactions}}
+ {{if eq $value "hooray"}}
+ <div class="item" data-content="hooray">:tada:</div>
+ {{else if eq $value "laugh"}}
+ <div class="item" data-content="laugh">:laughing:</div>
+ {{else}}
+ <div class="item" data-content="{{$value}}">:{{$value}}:</div>
+ {{end}}
+ {{end}}
</div>
</div>
{{end}}
diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl
index 1ea626ab84..49d2e9bc5f 100644
--- a/templates/repo/issue/view_content/comments.tmpl
+++ b/templates/repo/issue/view_content/comments.tmpl
@@ -36,7 +36,7 @@
{{end}}
</div>
{{end}}
- {{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID) }}
+ {{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID) "AllowedReactions" $.AllowedReactions}}
{{template "repo/issue/view_content/context_menu" Dict "ctx" $ "item" . "delete" true "diff" false }}
</div>
{{end}}
@@ -55,7 +55,7 @@
{{$reactions := .Reactions.GroupByType}}
{{if $reactions}}
<div class="ui attached segment reactions">
- {{template "repo/issue/view_content/reactions" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID) "Reactions" $reactions }}
+ {{template "repo/issue/view_content/reactions" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID) "Reactions" $reactions "AllowedReactions" $.AllowedReactions}}
</div>
{{end}}
{{if .Attachments}}
diff --git a/templates/repo/issue/view_content/reactions.tmpl b/templates/repo/issue/view_content/reactions.tmpl
index f4810f4849..4837370d22 100644
--- a/templates/repo/issue/view_content/reactions.tmpl
+++ b/templates/repo/issue/view_content/reactions.tmpl
@@ -2,14 +2,14 @@
<a class="ui label basic{{if $value.HasUser $.ctx.SignedUserID}} blue{{end}}{{if not $.ctx.IsSigned}} disabled{{end}} has-emoji" data-title="{{$value.GetFirstUsers}}{{if gt ($value.GetMoreUserCount) 0}} {{ $.ctx.i18n.Tr "repo.reactions_more" $value.GetMoreUserCount}}{{end}}" data-content="{{ $key }}" data-action-url="{{ $.ActionURL }}">
{{if eq $key "hooray"}}
:tada:
+ {{else if eq $key "laugh"}}
+ :laughing:
{{else}}
- {{if eq $key "laugh"}}
- :laughing:
- {{else}}
- :{{$key}}:
- {{end}}
+ :{{$key}}:
{{end}}
{{len $value}}
</a>
{{end}}
-{{template "repo/issue/view_content/add_reaction" Dict "ctx" $.ctx "ActionURL" .ActionURL }}
+{{if $.AllowedReactions}}
+ {{template "repo/issue/view_content/add_reaction" Dict "ctx" $.ctx "ActionURL" .ActionURL "AllowedReactions" $.AllowedReactions}}
+{{end}}