Skip to content

Commit b838252

Browse files
Fix label display on new issues (#13590)
* Fix label display on new issues PR #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. * remove wrapper element and style tweaks * style tweaks * use shared template for whole label list Co-authored-by: techknowlogick <[email protected]>
1 parent 0a6ce3e commit b838252

File tree

6 files changed

+26
-40
lines changed

6 files changed

+26
-40
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: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<a
2+
class="ui label item {{if not .label.IsChecked}}hide{{end}}"
3+
id="label_{{.label.ID}}"
4+
href="{{.root.RepoLink}}/{{if or .root.IsPull .root.Issue.IsPull}}pulls{{else}}issues{{end}}?labels={{.label.ID}}"
5+
style="color: {{.label.ForegroundColor}}; background-color: {{.label.Color}}"
6+
title="{{.label.Description | RenderEmojiPlain}}"
7+
>
8+
{{.label.Name | RenderEmoji}}
9+
</a>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<div class="ui labels list">
2+
<span class="no-select item {{if .ctx.HasSelectedLabel}}hide{{end}}">{{.ctx.i18n.Tr "repo.issues.new.no_label"}}</span>
3+
{{range .ctx.Labels}}
4+
{{template "repo/issue/labels/label" dict "root" $ "label" .}}
5+
{{end}}
6+
{{range .ctx.OrgLabels}}
7+
{{template "repo/issue/labels/label" dict "root" $ "label" .}}
8+
{{end}}
9+
</div>

templates/repo/issue/new_form.tmpl

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,7 @@
7070
{{end}}
7171
</div>
7272
</div>
73-
<div class="ui labels list">
74-
<span class="no-select item {{if .HasSelectedLabel}}hide{{end}}">{{.i18n.Tr "repo.issues.new.no_label"}}</span>
75-
{{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}}
79-
{{end}}
80-
{{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}}
84-
{{end}}
85-
</div>
73+
{{template "repo/issue/labels/labels_sidebar" dict "root" $ "ctx" .}}
8674

8775
<div class="ui divider"></div>
8876

templates/repo/issue/view_content/sidebar.tmpl

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -125,25 +125,7 @@
125125
{{end}}
126126
</div>
127127
</div>
128-
<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}}
132-
{{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}}
138-
{{end}}
139-
{{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}}
145-
{{end}}
146-
</div>
128+
{{template "repo/issue/labels/labels_sidebar" dict "root" $ "ctx" .}}
147129

148130
<div class="ui divider"></div>
149131

web_src/less/_repository.less

Lines changed: 5 additions & 8 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 {
@@ -2985,12 +2980,14 @@
29852980
}
29862981

29872982
.labels.list .item {
2988-
padding: 0 !important;
2989-
margin-bottom: 2px;
2983+
padding: .3em .5em !important;
2984+
margin-left: 0;
2985+
margin-right: 0;
2986+
margin-bottom: 3px;
29902987
}
29912988

29922989
.labels.list .item + .item {
2993-
margin-left: 2px;
2990+
margin-left: 3px;
29942991
}
29952992

29962993
tbody.commit-list {

0 commit comments

Comments
 (0)