diff --git a/modules/templates/helper.go b/modules/templates/helper.go index e0cdcbf60a6f6..deaa9526be8ba 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -81,6 +81,9 @@ func NewFuncMap() []template.FuncMap { "LoadTimes": func(startTime time.Time) string { return fmt.Sprint(time.Since(startTime).Nanoseconds()/1e6) + "ms" }, + "AllowedReactions": func() []string { + return setting.UI.Reactions + }, "AvatarLink": base.AvatarLink, "Safe": Safe, "SafeJS": SafeJS, diff --git a/routers/repo/issue.go b/routers/repo/issue.go index ae0c2d3b8f118..4810eecdc6fb2 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -705,7 +705,6 @@ func ViewIssue(ctx *context.Context) { } } ctx.Data["IssueWatch"] = iw - ctx.Data["AllowedReactions"] = setting.UI.Reactions issue.RenderedContent = string(markdown.Render([]byte(issue.Content), ctx.Repo.RepoLink, ctx.Repo.Repository.ComposeMetas())) diff --git a/routers/repo/pull.go b/routers/repo/pull.go index 932e99290b441..418c2e9438bd5 100644 --- a/routers/repo/pull.go +++ b/routers/repo/pull.go @@ -423,7 +423,6 @@ func PrepareViewPullInfo(ctx *context.Context, issue *models.Issue) *git.Compare ctx.Data["NumCommits"] = compareInfo.Commits.Len() ctx.Data["NumFiles"] = compareInfo.NumFiles - ctx.Data["AllowedReactions"] = setting.UI.Reactions return compareInfo } diff --git a/templates/repo/diff/comments.tmpl b/templates/repo/diff/comments.tmpl index 26029dbaa6e0e..64080f990f4cb 100644 --- a/templates/repo/diff/comments.tmpl +++ b/templates/repo/diff/comments.tmpl @@ -38,7 +38,7 @@ {{$reactions := .Reactions.GroupByType}} {{if $reactions}}
- {{template "repo/issue/view_content/reactions" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.root.RepoLink .ID) "Reactions" $reactions "AllowedReactions" $.AllowedReactions }} + {{template "repo/issue/view_content/reactions" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.root.RepoLink .ID) "Reactions" $reactions}}
{{end}} diff --git a/templates/repo/issue/view_content.tmpl b/templates/repo/issue/view_content.tmpl index 8490841f9740c..bee8a3dfe5da7 100644 --- a/templates/repo/issue/view_content.tmpl +++ b/templates/repo/issue/view_content.tmpl @@ -28,7 +28,7 @@ {{end}} {{if not $.Repository.IsArchived}}
- {{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/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/issues/%d/reactions" $.RepoLink .Issue.Index)}} {{template "repo/issue/view_content/context_menu" Dict "ctx" $ "item" .Issue "delete" false "diff" false }}
{{end}} @@ -47,7 +47,7 @@ {{$reactions := .Issue.Reactions.GroupByType}} {{if $reactions}}
- {{template "repo/issue/view_content/reactions" Dict "ctx" $ "ActionURL" (Printf "%s/issues/%d/reactions" $.RepoLink .Issue.Index) "Reactions" $reactions "AllowedReactions" $.AllowedReactions}} + {{template "repo/issue/view_content/reactions" Dict "ctx" $ "ActionURL" (Printf "%s/issues/%d/reactions" $.RepoLink .Issue.Index) "Reactions" $reactions}}
{{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 3bd64ff786caf..9e1dc3cc87596 100644 --- a/templates/repo/issue/view_content/add_reaction.tmpl +++ b/templates/repo/issue/view_content/add_reaction.tmpl @@ -7,7 +7,7 @@ {{end}} - {{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID) "AllowedReactions" $.AllowedReactions}} + {{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID)}} {{template "repo/issue/view_content/context_menu" Dict "ctx" $ "item" . "delete" true "diff" false }} {{end}} @@ -56,7 +56,7 @@ {{$reactions := .Reactions.GroupByType}} {{if $reactions}}
- {{template "repo/issue/view_content/reactions" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID) "Reactions" $reactions "AllowedReactions" $.AllowedReactions}} + {{template "repo/issue/view_content/reactions" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID) "Reactions" $reactions}}
{{end}} {{if .Attachments}} diff --git a/templates/repo/issue/view_content/reactions.tmpl b/templates/repo/issue/view_content/reactions.tmpl index 4837370d22578..b2aa9339d192d 100644 --- a/templates/repo/issue/view_content/reactions.tmpl +++ b/templates/repo/issue/view_content/reactions.tmpl @@ -10,6 +10,6 @@ {{len $value}} {{end}} -{{if $.AllowedReactions}} - {{template "repo/issue/view_content/add_reaction" Dict "ctx" $.ctx "ActionURL" .ActionURL "AllowedReactions" $.AllowedReactions}} +{{if AllowedReactions}} + {{template "repo/issue/view_content/add_reaction" Dict "ctx" $.ctx "ActionURL" .ActionURL}} {{end}}