From defc401b275ae5cbcb983a6685e083e71da9e341 Mon Sep 17 00:00:00 2001 From: Blender Defender Date: Mon, 12 Sep 2022 19:45:14 +0200 Subject: [PATCH] Make labels clickable in the comments section. (#21137) This commit adds the possibility to click the labels in the message "User added/removed the X label", which will lead to the issues page, filtered by the clicked label. This pull requests aims to fix #19768 _I've tried to follow the contribution guidelines as carefully as possible, but in case I made a mistake: Please correct me._ Co-authored-by: wxiaoguang Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: techknowlogick --- modules/templates/helper.go | 6 +++--- templates/repo/issue/view_content/comments.tmpl | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/templates/helper.go b/modules/templates/helper.go index fd7018a39..2879d68e3 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -376,15 +376,15 @@ func NewFuncMap() []template.FuncMap { // the table is NOT sorted with this header return "" }, - "RenderLabels": func(labels []*issues_model.Label) template.HTML { + "RenderLabels": func(labels []*issues_model.Label, repoLink string) template.HTML { html := `` for _, label := range labels { // Protect against nil value in labels - shouldn't happen but would cause a panic if so if label == nil { continue } - html += fmt.Sprintf("
%s
", - label.ForegroundColor(), label.Color, RenderEmoji(label.Name)) + html += fmt.Sprintf("%s ", + repoLink, label.ID, label.ForegroundColor(), label.Color, RenderEmoji(label.Name)) } html += "
" return template.HTML(html) diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl index 8e0308c2d..7ed8cf3bd 100644 --- a/templates/repo/issue/view_content/comments.tmpl +++ b/templates/repo/issue/view_content/comments.tmpl @@ -182,11 +182,11 @@ {{template "shared/user/authorlink" .Poster}} {{if and .AddedLabels (not .RemovedLabels)}} - {{$.locale.TrN (len .AddedLabels) "repo.issues.add_label" "repo.issues.add_labels" (RenderLabels .AddedLabels) $createdStr | Safe}} + {{$.locale.TrN (len .AddedLabels) "repo.issues.add_label" "repo.issues.add_labels" (RenderLabels .AddedLabels $.RepoLink) $createdStr | Safe}} {{else if and (not .AddedLabels) .RemovedLabels}} - {{$.locale.TrN (len .RemovedLabels) "repo.issues.remove_label" "repo.issues.remove_labels" (RenderLabels .RemovedLabels) $createdStr | Safe}} + {{$.locale.TrN (len .RemovedLabels) "repo.issues.remove_label" "repo.issues.remove_labels" (RenderLabels .RemovedLabels $.RepoLink) $createdStr | Safe}} {{else}} - {{$.locale.Tr "repo.issues.add_remove_labels" (RenderLabels .AddedLabels) (RenderLabels .RemovedLabels) $createdStr | Safe}} + {{$.locale.Tr "repo.issues.add_remove_labels" (RenderLabels .AddedLabels $.RepoLink) (RenderLabels .RemovedLabels $.RepoLink) $createdStr | Safe}} {{end}}