Skip to content

Commit 4ee9746

Browse files
6543techknowlogickzeripath
committed
[Fix] AllowedReaction code (#9518)
* optimize * CI.restart() Co-authored-by: techknowlogick <[email protected]> Co-authored-by: zeripath <[email protected]>
1 parent e64880e commit 4ee9746

File tree

8 files changed

+11
-10
lines changed

8 files changed

+11
-10
lines changed

modules/templates/helper.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ func NewFuncMap() []template.FuncMap {
8181
"LoadTimes": func(startTime time.Time) string {
8282
return fmt.Sprint(time.Since(startTime).Nanoseconds()/1e6) + "ms"
8383
},
84+
"AllowedReactions": func() []string {
85+
return setting.UI.Reactions
86+
},
8487
"AvatarLink": base.AvatarLink,
8588
"Safe": Safe,
8689
"SafeJS": SafeJS,

routers/repo/issue.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,6 @@ func ViewIssue(ctx *context.Context) {
705705
}
706706
}
707707
ctx.Data["IssueWatch"] = iw
708-
ctx.Data["AllowedReactions"] = setting.UI.Reactions
709708

710709
issue.RenderedContent = string(markdown.Render([]byte(issue.Content), ctx.Repo.RepoLink,
711710
ctx.Repo.Repository.ComposeMetas()))

routers/repo/pull.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,6 @@ func PrepareViewPullInfo(ctx *context.Context, issue *models.Issue) *git.Compare
423423

424424
ctx.Data["NumCommits"] = compareInfo.Commits.Len()
425425
ctx.Data["NumFiles"] = compareInfo.NumFiles
426-
ctx.Data["AllowedReactions"] = setting.UI.Reactions
427426
return compareInfo
428427
}
429428

templates/repo/diff/comments.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
{{$reactions := .Reactions.GroupByType}}
3939
{{if $reactions}}
4040
<div class="ui attached segment reactions">
41-
{{template "repo/issue/view_content/reactions" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.root.RepoLink .ID) "Reactions" $reactions "AllowedReactions" $.AllowedReactions }}
41+
{{template "repo/issue/view_content/reactions" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.root.RepoLink .ID) "Reactions" $reactions}}
4242
</div>
4343
{{end}}
4444
</div>

templates/repo/issue/view_content.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
{{end}}
2929
{{if not $.Repository.IsArchived}}
3030
<div class="ui right actions">
31-
{{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/issues/%d/reactions" $.RepoLink .Issue.Index) "AllowedReactions" $.AllowedReactions}}
31+
{{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/issues/%d/reactions" $.RepoLink .Issue.Index)}}
3232
{{template "repo/issue/view_content/context_menu" Dict "ctx" $ "item" .Issue "delete" false "diff" false }}
3333
</div>
3434
{{end}}
@@ -47,7 +47,7 @@
4747
{{$reactions := .Issue.Reactions.GroupByType}}
4848
{{if $reactions}}
4949
<div class="ui attached segment reactions">
50-
{{template "repo/issue/view_content/reactions" Dict "ctx" $ "ActionURL" (Printf "%s/issues/%d/reactions" $.RepoLink .Issue.Index) "Reactions" $reactions "AllowedReactions" $.AllowedReactions}}
50+
{{template "repo/issue/view_content/reactions" Dict "ctx" $ "ActionURL" (Printf "%s/issues/%d/reactions" $.RepoLink .Issue.Index) "Reactions" $reactions}}
5151
</div>
5252
{{end}}
5353
{{if .Issue.Attachments}}

templates/repo/issue/view_content/add_reaction.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<div class="menu has-emoji">
88
<div class="header">{{ .ctx.i18n.Tr "repo.pick_reaction"}}</div>
99
<div class="divider"></div>
10-
{{range $value := .AllowedReactions}}
10+
{{range $value := AllowedReactions}}
1111
{{if eq $value "hooray"}}
1212
<div class="item" data-content="hooray">:tada:</div>
1313
{{else if eq $value "laugh"}}

templates/repo/issue/view_content/comments.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
{{end}}
3838
</div>
3939
{{end}}
40-
{{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID) "AllowedReactions" $.AllowedReactions}}
40+
{{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID)}}
4141
{{template "repo/issue/view_content/context_menu" Dict "ctx" $ "item" . "delete" true "diff" false }}
4242
</div>
4343
{{end}}
@@ -56,7 +56,7 @@
5656
{{$reactions := .Reactions.GroupByType}}
5757
{{if $reactions}}
5858
<div class="ui attached segment reactions">
59-
{{template "repo/issue/view_content/reactions" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID) "Reactions" $reactions "AllowedReactions" $.AllowedReactions}}
59+
{{template "repo/issue/view_content/reactions" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID) "Reactions" $reactions}}
6060
</div>
6161
{{end}}
6262
{{if .Attachments}}

templates/repo/issue/view_content/reactions.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
{{len $value}}
1111
</a>
1212
{{end}}
13-
{{if $.AllowedReactions}}
14-
{{template "repo/issue/view_content/add_reaction" Dict "ctx" $.ctx "ActionURL" .ActionURL "AllowedReactions" $.AllowedReactions}}
13+
{{if AllowedReactions}}
14+
{{template "repo/issue/view_content/add_reaction" Dict "ctx" $.ctx "ActionURL" .ActionURL}}
1515
{{end}}

0 commit comments

Comments
 (0)