From 4ee97465e97ae6b9d3ac6ea57246f67715246afe Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Sat, 28 Dec 2019 00:43:56 +0100 Subject: [PATCH] [Fix] AllowedReaction code (#9518) * optimize * CI.restart() Co-authored-by: techknowlogick Co-authored-by: zeripath --- modules/templates/helper.go | 3 +++ routers/repo/issue.go | 1 - routers/repo/pull.go | 1 - templates/repo/diff/comments.tmpl | 2 +- templates/repo/issue/view_content.tmpl | 4 ++-- templates/repo/issue/view_content/add_reaction.tmpl | 2 +- templates/repo/issue/view_content/comments.tmpl | 4 ++-- templates/repo/issue/view_content/reactions.tmpl | 4 ++-- 8 files changed, 11 insertions(+), 10 deletions(-) diff --git a/modules/templates/helper.go b/modules/templates/helper.go index e0cdcbf60a..deaa9526be 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 ae0c2d3b8f..4810eecdc6 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 932e99290b..418c2e9438 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 26029dbaa6..64080f990f 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 8490841f97..bee8a3dfe5 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 3bd64ff786..9e1dc3cc87 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 4837370d22..b2aa9339d1 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}} -- 2.39.5