Skip to content

Commit b545c86

Browse files
committed
Fix label display on new issues
PR go-gitea#13570 broke label rendering for new issues and pulls because missed the fact that the code was relying on the DOM elements being toggled by JavaScript. On top of that, the label rendering for new issues and pull was using an outdated template which I consolidated in a new shared template.
1 parent 859e3d3 commit b545c86

File tree

5 files changed

+17
-24
lines changed

5 files changed

+17
-24
lines changed

routers/repo/compare.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ func ParseCompareInfo(ctx *context.Context) (*models.User, *models.Repository, *
184184
ctx.Data["BaseIsCommit"] = baseIsCommit
185185
ctx.Data["BaseIsBranch"] = baseIsBranch
186186
ctx.Data["BaseIsTag"] = baseIsTag
187+
ctx.Data["IsPull"] = true
187188

188189
// Now we have the repository that represents the base
189190

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<div class="item">
2+
<a
3+
class="ui label {{if not .label.IsChecked}}hide{{end}}"
4+
id="label_{{.label.ID}}"
5+
href="{{.root.RepoLink}}/{{if or .root.IsPull .root.Issue.IsPull}}pulls{{else}}issues{{end}}?labels={{.label.ID}}"
6+
style="color: {{.label.ForegroundColor}}; background-color: {{.label.Color}}"
7+
title="{{.label.Description | RenderEmojiPlain}}"
8+
>
9+
{{.label.Name | RenderEmoji}}
10+
</a>
11+
</div>

templates/repo/issue/new_form.tmpl

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,10 @@
7373
<div class="ui labels list">
7474
<span class="no-select item {{if .HasSelectedLabel}}hide{{end}}">{{.i18n.Tr "repo.issues.new.no_label"}}</span>
7575
{{range .Labels}}
76-
{{if .IsChecked}}
77-
<a class="item" id="label_{{.ID}}" href="{{$.RepoLink}}/issues?labels={{.ID}}"><span class="label color" style="background-color: {{.Color}}"></span> <span class="text">{{.Name | RenderEmoji}}</span></a>
78-
{{end}}
76+
{{template "repo/issue/labels/label" dict "root" $ "label" .}}
7977
{{end}}
8078
{{range .OrgLabels}}
81-
{{if .IsChecked}}
82-
<a class="item" id="label_{{.ID}}" href="/issues?labels={{.ID}}"><span class="label color" style="background-color: {{.Color}}"></span> <span class="text">{{.Name | RenderEmoji}}</span></a>
83-
{{end}}
79+
{{template "repo/issue/labels/label" dict "root" $ "label" .}}
8480
{{end}}
8581
</div>
8682

templates/repo/issue/view_content/sidebar.tmpl

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -126,22 +126,12 @@
126126
</div>
127127
</div>
128128
<div class="ui labels list">
129-
{{if not .HasSelectedLabel}}
130-
<span class="no-select item">{{.i18n.Tr "repo.issues.new.no_label"}}</span>
131-
{{end}}
129+
<span class="no-select item {{if .HasSelectedLabel}}hide{{end}}">{{.i18n.Tr "repo.issues.new.no_label"}}</span>
132130
{{range .Labels}}
133-
{{if .IsChecked}}
134-
<div class="item">
135-
<a class="ui label" id="label_{{.ID}}" href="{{$.RepoLink}}/{{if $.Issue.IsPull}}pulls{{else}}issues{{end}}?labels={{.ID}}" style="color: {{.ForegroundColor}}; background-color: {{.Color}}" title="{{.Description | RenderEmojiPlain}}">{{.Name | RenderEmoji}}</a>
136-
</div>
137-
{{end}}
131+
{{template "repo/issue/labels/label" dict "root" $ "label" .}}
138132
{{end}}
139133
{{range .OrgLabels}}
140-
{{if .IsChecked}}
141-
<div class="item">
142-
<a class="ui label" id="label_{{.ID}}" href="{{$.RepoLink}}/{{if $.Issue.IsPull}}pulls{{else}}issues{{end}}?labels={{.ID}}" style="color: {{.ForegroundColor}}; background-color: {{.Color}}" title="{{.Description | RenderEmojiPlain}}">{{.Name | RenderEmoji}}</a>
143-
</div>
144-
{{end}}
134+
{{template "repo/issue/labels/label" dict "root" $ "label" .}}
145135
{{end}}
146136
</div>
147137

web_src/less/_repository.less

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,6 @@
133133
max-width: 100px;
134134
}
135135
}
136-
137-
.label.color {
138-
padding: 0 8px;
139-
margin-right: 5px;
140-
}
141136
}
142137

143138
#deadlineForm input {

0 commit comments

Comments
 (0)