@@ -20,6 +20,7 @@ import (
2020 "code.gitea.io/gitea/modules/markup"
2121 "code.gitea.io/gitea/modules/markup/markdown"
2222 "code.gitea.io/gitea/modules/setting"
23+ "code.gitea.io/gitea/modules/translation"
2324 "code.gitea.io/gitea/modules/util"
2425)
2526
@@ -118,10 +119,15 @@ func RenderIssueTitle(ctx context.Context, text string, metas map[string]string)
118119}
119120
120121// 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+ )
123130
124- textColor := "#111"
125131 r , g , b := util .HexToRBGColor (label .Color )
126132 // Determine if label text should be light or dark to be readable on background color
127133 if util .UseLightTextOnBackground (r , g , b ) {
@@ -130,10 +136,15 @@ func RenderLabel(ctx context.Context, label *issues_model.Label) template.HTML {
130136
131137 description := emoji .ReplaceAliases (template .HTMLEscapeString (label .Description ))
132138
139+ if isArchived {
140+ archivedCSSClass = "archived-label"
141+ description = fmt .Sprintf ("(%s) %s" , locale .TrString ("archived" ), description )
142+ }
143+
133144 if labelScope == "" {
134145 // 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 ))
137148 return template .HTML (s )
138149 }
139150
@@ -166,11 +177,11 @@ func RenderLabel(ctx context.Context, label *issues_model.Label) template.HTML {
166177 itemColor := "#" + hex .EncodeToString (itemBytes )
167178 scopeColor := "#" + hex .EncodeToString (scopeBytes )
168179
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'>" +
170181 "<div class='ui label scope-left' style='color: %s !important; background-color: %s !important'>%s</div>" +
171182 "<div class='ui label scope-right' style='color: %s !important; background-color: %s !important'>%s</div>" +
172183 "</span>" ,
173- description ,
184+ archivedCSSClass , description ,
174185 textColor , scopeColor , scopeText ,
175186 textColor , itemColor , itemText )
176187 return template .HTML (s )
@@ -211,15 +222,15 @@ func RenderMarkdownToHtml(ctx context.Context, input string) template.HTML { //n
211222 return output
212223}
213224
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 {
215226 htmlCode := `<span class="labels-list">`
216227 for _ , label := range labels {
217228 // Protect against nil value in labels - shouldn't happen but would cause a panic if so
218229 if label == nil {
219230 continue
220231 }
221232 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 ))
223234 }
224235 htmlCode += "</span>"
225236 return template .HTML (htmlCode )
0 commit comments