@@ -20,6 +20,7 @@ import (
20
20
"code.gitea.io/gitea/modules/markup"
21
21
"code.gitea.io/gitea/modules/markup/markdown"
22
22
"code.gitea.io/gitea/modules/setting"
23
+ "code.gitea.io/gitea/modules/translation"
23
24
"code.gitea.io/gitea/modules/util"
24
25
)
25
26
@@ -118,10 +119,15 @@ func RenderIssueTitle(ctx context.Context, text string, metas map[string]string)
118
119
}
119
120
120
121
// RenderLabel renders a label
121
- func RenderLabel (ctx context.Context , label * issues_model.Label ) template.HTML {
122
- labelScope := label .ExclusiveScope ()
122
+ // locale is needed due to an import cycle with our context providing the `Tr` function
123
+ func RenderLabel (ctx context.Context , locale translation.Locale , label * issues_model.Label ) template.HTML {
124
+ var (
125
+ archivedCSSClass string
126
+ textColor = "#111"
127
+ isArchived = ! label .ArchivedUnix .IsZero ()
128
+ labelScope = label .ExclusiveScope ()
129
+ )
123
130
124
- textColor := "#111"
125
131
r , g , b := util .HexToRBGColor (label .Color )
126
132
// Determine if label text should be light or dark to be readable on background color
127
133
if util .UseLightTextOnBackground (r , g , b ) {
@@ -130,10 +136,15 @@ func RenderLabel(ctx context.Context, label *issues_model.Label) template.HTML {
130
136
131
137
description := emoji .ReplaceAliases (template .HTMLEscapeString (label .Description ))
132
138
139
+ if isArchived {
140
+ archivedCSSClass = "archived-label"
141
+ description = fmt .Sprintf ("(%s) %s" , locale .TrString ("archived" ), description )
142
+ }
143
+
133
144
if labelScope == "" {
134
145
// Regular label
135
- s := fmt .Sprintf ("<div class='ui label' style='color: %s !important; background-color: %s !important' data-tooltip-content title='%s'>%s</div>" ,
136
- textColor , label .Color , description , RenderEmoji (ctx , label .Name ))
146
+ s := fmt .Sprintf ("<div class='ui label %s ' style='color: %s !important; background-color: %s !important; ' data-tooltip-content title='%s'>%s</div>" ,
147
+ archivedCSSClass , textColor , label .Color , description , RenderEmoji (ctx , label .Name ))
137
148
return template .HTML (s )
138
149
}
139
150
@@ -166,11 +177,11 @@ func RenderLabel(ctx context.Context, label *issues_model.Label) template.HTML {
166
177
itemColor := "#" + hex .EncodeToString (itemBytes )
167
178
scopeColor := "#" + hex .EncodeToString (scopeBytes )
168
179
169
- s := fmt .Sprintf ("<span class='ui label scope-parent' data-tooltip-content title='%s'>" +
180
+ s := fmt .Sprintf ("<span class='ui label %s scope-parent' data-tooltip-content title='%s'>" +
170
181
"<div class='ui label scope-left' style='color: %s !important; background-color: %s !important'>%s</div>" +
171
182
"<div class='ui label scope-right' style='color: %s !important; background-color: %s !important'>%s</div>" +
172
183
"</span>" ,
173
- description ,
184
+ archivedCSSClass , description ,
174
185
textColor , scopeColor , scopeText ,
175
186
textColor , itemColor , itemText )
176
187
return template .HTML (s )
@@ -211,15 +222,15 @@ func RenderMarkdownToHtml(ctx context.Context, input string) template.HTML { //n
211
222
return output
212
223
}
213
224
214
- func RenderLabels (ctx context.Context , labels []* issues_model.Label , repoLink string ) template.HTML {
225
+ func RenderLabels (ctx context.Context , locale translation. Locale , labels []* issues_model.Label , repoLink string ) template.HTML {
215
226
htmlCode := `<span class="labels-list">`
216
227
for _ , label := range labels {
217
228
// Protect against nil value in labels - shouldn't happen but would cause a panic if so
218
229
if label == nil {
219
230
continue
220
231
}
221
232
htmlCode += fmt .Sprintf ("<a href='%s/issues?labels=%d'>%s</a> " ,
222
- repoLink , label .ID , RenderLabel (ctx , label ))
233
+ repoLink , label .ID , RenderLabel (ctx , locale , label ))
223
234
}
224
235
htmlCode += "</span>"
225
236
return template .HTML (htmlCode )
0 commit comments