Skip to content

Commit defc401

Browse files
BlenderDefenderwxiaoguang6543techknowlogick
authored
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._ <!-- Please check the following: 1. Make sure you are targeting the `main` branch, pull requests on release branches are only allowed for bug fixes. 2. Read contributing guidelines: https://github.com/go-gitea/gitea/blob/main/CONTRIBUTING.md 3. Describe what your pull request does and which issue you're targeting (if any) --> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
1 parent afdab9d commit defc401

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

modules/templates/helper.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -376,15 +376,15 @@ func NewFuncMap() []template.FuncMap {
376376
// the table is NOT sorted with this header
377377
return ""
378378
},
379-
"RenderLabels": func(labels []*issues_model.Label) template.HTML {
379+
"RenderLabels": func(labels []*issues_model.Label, repoLink string) template.HTML {
380380
html := `<span class="labels-list">`
381381
for _, label := range labels {
382382
// Protect against nil value in labels - shouldn't happen but would cause a panic if so
383383
if label == nil {
384384
continue
385385
}
386-
html += fmt.Sprintf("<div class='ui label' style='color: %s; background-color: %s'>%s</div> ",
387-
label.ForegroundColor(), label.Color, RenderEmoji(label.Name))
386+
html += fmt.Sprintf("<a href='%s/issues?labels=%d' class='ui label' style='color: %s !important; background-color: %s !important'>%s</a> ",
387+
repoLink, label.ID, label.ForegroundColor(), label.Color, RenderEmoji(label.Name))
388388
}
389389
html += "</span>"
390390
return template.HTML(html)

templates/repo/issue/view_content/comments.tmpl

+3-3
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,11 @@
182182
<span class="text grey">
183183
{{template "shared/user/authorlink" .Poster}}
184184
{{if and .AddedLabels (not .RemovedLabels)}}
185-
{{$.locale.TrN (len .AddedLabels) "repo.issues.add_label" "repo.issues.add_labels" (RenderLabels .AddedLabels) $createdStr | Safe}}
185+
{{$.locale.TrN (len .AddedLabels) "repo.issues.add_label" "repo.issues.add_labels" (RenderLabels .AddedLabels $.RepoLink) $createdStr | Safe}}
186186
{{else if and (not .AddedLabels) .RemovedLabels}}
187-
{{$.locale.TrN (len .RemovedLabels) "repo.issues.remove_label" "repo.issues.remove_labels" (RenderLabels .RemovedLabels) $createdStr | Safe}}
187+
{{$.locale.TrN (len .RemovedLabels) "repo.issues.remove_label" "repo.issues.remove_labels" (RenderLabels .RemovedLabels $.RepoLink) $createdStr | Safe}}
188188
{{else}}
189-
{{$.locale.Tr "repo.issues.add_remove_labels" (RenderLabels .AddedLabels) (RenderLabels .RemovedLabels) $createdStr | Safe}}
189+
{{$.locale.Tr "repo.issues.add_remove_labels" (RenderLabels .AddedLabels $.RepoLink) (RenderLabels .RemovedLabels $.RepoLink) $createdStr | Safe}}
190190
{{end}}
191191
</span>
192192
</div>

0 commit comments

Comments
 (0)