Skip to content

Commit e6ab6e6

Browse files
authored
code optimization (#31315)
Simplifying complex if-else to existing Iif operations
1 parent 397930d commit e6ab6e6

File tree

14 files changed

+90
-48
lines changed

14 files changed

+90
-48
lines changed

modules/templates/helper.go

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"html"
1010
"html/template"
1111
"net/url"
12+
"reflect"
1213
"slices"
1314
"strings"
1415
"time"
@@ -237,15 +238,41 @@ func DotEscape(raw string) string {
237238

238239
// Iif is an "inline-if", similar util.Iif[T] but templates need the non-generic version,
239240
// and it could be simply used as "{{Iif expr trueVal}}" (omit the falseVal).
240-
func Iif(condition bool, vals ...any) any {
241-
if condition {
241+
func Iif(condition any, vals ...any) any {
242+
if IsTruthy(condition) {
242243
return vals[0]
243244
} else if len(vals) > 1 {
244245
return vals[1]
245246
}
246247
return nil
247248
}
248249

250+
func IsTruthy(v any) bool {
251+
if v == nil {
252+
return false
253+
}
254+
255+
rv := reflect.ValueOf(v)
256+
switch rv.Kind() {
257+
case reflect.Bool:
258+
return rv.Bool()
259+
case reflect.String:
260+
return rv.String() != ""
261+
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
262+
return rv.Int() != 0
263+
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
264+
return rv.Uint() != 0
265+
case reflect.Float32, reflect.Float64:
266+
return rv.Float() != 0
267+
case reflect.Slice, reflect.Array, reflect.Map:
268+
return rv.Len() > 0
269+
case reflect.Ptr:
270+
return !rv.IsNil() && IsTruthy(reflect.Indirect(rv).Interface())
271+
default:
272+
return rv.Kind() == reflect.Struct && !rv.IsNil()
273+
}
274+
}
275+
249276
// Eval the expression and return the result, see the comment of eval.Expr for details.
250277
// To use this helper function in templates, pass each token as a separate parameter.
251278
//

modules/templates/helper_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,18 @@ func TestHTMLFormat(t *testing.T) {
6565
func TestSanitizeHTML(t *testing.T) {
6666
assert.Equal(t, template.HTML(`<a href="/" rel="nofollow">link</a> xss <div>inline</div>`), SanitizeHTML(`<a href="/">link</a> <a href="javascript:">xss</a> <div style="dangerous">inline</div>`))
6767
}
68+
69+
func TestIsTruthy(t *testing.T) {
70+
var test any
71+
assert.Equal(t, false, IsTruthy(test))
72+
assert.Equal(t, false, IsTruthy(nil))
73+
assert.Equal(t, false, IsTruthy(""))
74+
assert.Equal(t, true, IsTruthy("non-empty"))
75+
assert.Equal(t, true, IsTruthy(-1))
76+
assert.Equal(t, false, IsTruthy(0))
77+
assert.Equal(t, true, IsTruthy(42))
78+
assert.Equal(t, false, IsTruthy(0.0))
79+
assert.Equal(t, true, IsTruthy(3.14))
80+
assert.Equal(t, false, IsTruthy([]int{}))
81+
assert.Equal(t, true, IsTruthy([]int{1}))
82+
}

templates/admin/auth/list.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<td>{{.ID}}</td>
2626
<td><a href="{{AppSubUrl}}/admin/auths/{{.ID}}">{{.Name}}</a></td>
2727
<td>{{.TypeName}}</td>
28-
<td>{{if .IsActive}}{{svg "octicon-check"}}{{else}}{{svg "octicon-x"}}{{end}}</td>
28+
<td>{{svg (Iif .IsActive "octicon-check" "octicon-x")}}</td>
2929
<td>{{DateTime "short" .UpdatedUnix}}</td>
3030
<td>{{DateTime "short" .CreatedUnix}}</td>
3131
<td><a href="{{AppSubUrl}}/admin/auths/{{.ID}}">{{svg "octicon-pencil"}}</a></td>

templates/admin/config.tmpl

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
<dt>{{ctx.Locale.Tr "admin.config.domain"}}</dt>
1717
<dd>{{.Domain}}</dd>
1818
<dt>{{ctx.Locale.Tr "admin.config.offline_mode"}}</dt>
19-
<dd>{{if .OfflineMode}}{{svg "octicon-check"}}{{else}}{{svg "octicon-x"}}{{end}}</dd>
19+
<dd>{{svg (Iif .OfflineMode "octicon-check" "octicon-x")}}</dd>
2020
<dt>{{ctx.Locale.Tr "admin.config.disable_router_log"}}</dt>
21-
<dd>{{if .DisableRouterLog}}{{svg "octicon-check"}}{{else}}{{svg "octicon-x"}}{{end}}</dd>
21+
<dd>{{svg (Iif .DisableRouterLog "octicon-check" "octicon-x")}}</dd>
2222

2323
<div class="divider"></div>
2424

@@ -55,10 +55,10 @@
5555
<div class="ui attached table segment">
5656
<dl class="admin-dl-horizontal">
5757
<dt>{{ctx.Locale.Tr "admin.config.ssh_enabled"}}</dt>
58-
<dd>{{if not .SSH.Disabled}}{{svg "octicon-check"}}{{else}}{{svg "octicon-x"}}{{end}}</dd>
58+
<dd>{{svg (Iif (not .SSH.Disabled) "octicon-check" "octicon-x")}}</dd>
5959
{{if not .SSH.Disabled}}
6060
<dt>{{ctx.Locale.Tr "admin.config.ssh_start_builtin_server"}}</dt>
61-
<dd>{{if .SSH.StartBuiltinServer}}{{svg "octicon-check"}}{{else}}{{svg "octicon-x"}}{{end}}</dd>
61+
<dd>{{svg (Iif .SSH.StartBuiltinServer "octicon-check" "octicon-x")}}</dd>
6262
<dt>{{ctx.Locale.Tr "admin.config.ssh_domain"}}</dt>
6363
<dd>{{.SSH.Domain}}</dd>
6464
<dt>{{ctx.Locale.Tr "admin.config.ssh_port"}}</dt>
@@ -74,7 +74,7 @@
7474
<dt>{{ctx.Locale.Tr "admin.config.ssh_keygen_path"}}</dt>
7575
<dd>{{.SSH.KeygenPath}}</dd>
7676
<dt>{{ctx.Locale.Tr "admin.config.ssh_minimum_key_size_check"}}</dt>
77-
<dd>{{if .SSH.MinimumKeySizeCheck}}{{svg "octicon-check"}}{{else}}{{svg "octicon-x"}}{{end}}</dd>
77+
<dd>{{svg (Iif .SSH.MinimumKeySizeCheck "octicon-check" "octicon-x")}}</dd>
7878
{{if .SSH.MinimumKeySizeCheck}}
7979
<dt>{{ctx.Locale.Tr "admin.config.ssh_minimum_key_sizes"}}</dt>
8080
<dd>{{.SSH.MinimumKeySizes}}</dd>
@@ -90,7 +90,7 @@
9090
<div class="ui attached table segment">
9191
<dl class="admin-dl-horizontal">
9292
<dt>{{ctx.Locale.Tr "admin.config.lfs_enabled"}}</dt>
93-
<dd>{{if .LFS.StartServer}}{{svg "octicon-check"}}{{else}}{{svg "octicon-x"}}{{end}}</dd>
93+
<dd>{{svg (Iif .LFS.StartServer "octicon-check" "octicon-x")}}</dd>
9494
{{if .LFS.StartServer}}
9595
<dt>{{ctx.Locale.Tr "admin.config.lfs_content_path"}}</dt>
9696
<dd>{{JsonUtils.EncodeToString .LFS.Storage.ToShadowCopy}}</dd>
@@ -134,44 +134,44 @@
134134
<div class="ui attached table segment">
135135
<dl class="admin-dl-horizontal">
136136
<dt>{{ctx.Locale.Tr "admin.config.register_email_confirm"}}</dt>
137-
<dd>{{if .Service.RegisterEmailConfirm}}{{svg "octicon-check"}}{{else}}{{svg "octicon-x"}}{{end}}</dd>
137+
<dd>{{svg (Iif .Service.RegisterEmailConfirm "octicon-check" "octicon-x")}}</dd>
138138
<dt>{{ctx.Locale.Tr "admin.config.disable_register"}}</dt>
139-
<dd>{{if .Service.DisableRegistration}}{{svg "octicon-check"}}{{else}}{{svg "octicon-x"}}{{end}}</dd>
139+
<dd>{{svg (Iif .Service.DisableRegistration "octicon-check" "octicon-x")}}</dd>
140140
<dt>{{ctx.Locale.Tr "admin.config.allow_only_internal_registration"}}</dt>
141-
<dd>{{if .Service.AllowOnlyInternalRegistration}}{{svg "octicon-check"}}{{else}}{{svg "octicon-x"}}{{end}}</dd>
141+
<dd>{{svg (Iif .Service.AllowOnlyInternalRegistration "octicon-check" "octicon-x")}}</dd>
142142
<dt>{{ctx.Locale.Tr "admin.config.allow_only_external_registration"}}</dt>
143-
<dd>{{if .Service.AllowOnlyExternalRegistration}}{{svg "octicon-check"}}{{else}}{{svg "octicon-x"}}{{end}}</dd>
143+
<dd>{{svg (Iif .Service.AllowOnlyExternalRegistration "octicon-check" "octicon-x")}}</dd>
144144
<dt>{{ctx.Locale.Tr "admin.config.show_registration_button"}}</dt>
145-
<dd>{{if .Service.ShowRegistrationButton}}{{svg "octicon-check"}}{{else}}{{svg "octicon-x"}}{{end}}</dd>
145+
<dd>{{svg (Iif .Service.ShowRegistrationButton "octicon-check" "octicon-x")}}</dd>
146146
<dt>{{ctx.Locale.Tr "admin.config.enable_openid_signup"}}</dt>
147-
<dd>{{if .Service.EnableOpenIDSignUp}}{{svg "octicon-check"}}{{else}}{{svg "octicon-x"}}{{end}}</dd>
147+
<dd>{{svg (Iif .Service.EnableOpenIDSignUp "octicon-check" "octicon-x")}}</dd>
148148
<dt>{{ctx.Locale.Tr "admin.config.enable_openid_signin"}}</dt>
149-
<dd>{{if .Service.EnableOpenIDSignIn}}{{svg "octicon-check"}}{{else}}{{svg "octicon-x"}}{{end}}</dd>
149+
<dd>{{svg (Iif .Service.EnableOpenIDSignIn "octicon-check" "octicon-x")}}</dd>
150150
<dt>{{ctx.Locale.Tr "admin.config.require_sign_in_view"}}</dt>
151-
<dd>{{if .Service.RequireSignInView}}{{svg "octicon-check"}}{{else}}{{svg "octicon-x"}}{{end}}</dd>
151+
<dd>{{svg (Iif .Service.RequireSignInView "octicon-check" "octicon-x")}}</dd>
152152
<dt>{{ctx.Locale.Tr "admin.config.mail_notify"}}</dt>
153-
<dd>{{if .Service.EnableNotifyMail}}{{svg "octicon-check"}}{{else}}{{svg "octicon-x"}}{{end}}</dd>
153+
<dd>{{svg (Iif .Service.EnableNotifyMail "octicon-check" "octicon-x")}}</dd>
154154
<dt>{{ctx.Locale.Tr "admin.config.enable_captcha"}}</dt>
155-
<dd>{{if .Service.EnableCaptcha}}{{svg "octicon-check"}}{{else}}{{svg "octicon-x"}}{{end}}</dd>
155+
<dd>{{svg (Iif .Service.EnableCaptcha "octicon-check" "octicon-x")}}</dd>
156156
<dt>{{ctx.Locale.Tr "admin.config.default_keep_email_private"}}</dt>
157-
<dd>{{if .Service.DefaultKeepEmailPrivate}}{{svg "octicon-check"}}{{else}}{{svg "octicon-x"}}{{end}}</dd>
157+
<dd>{{svg (Iif .Service.DefaultKeepEmailPrivate "octicon-check" "octicon-x")}}</dd>
158158
<dt>{{ctx.Locale.Tr "admin.config.default_allow_create_organization"}}</dt>
159-
<dd>{{if .Service.DefaultAllowCreateOrganization}}{{svg "octicon-check"}}{{else}}{{svg "octicon-x"}}{{end}}</dd>
159+
<dd>{{svg (Iif .Service.DefaultAllowCreateOrganization "octicon-check" "octicon-x")}}</dd>
160160
<dt>{{ctx.Locale.Tr "admin.config.enable_timetracking"}}</dt>
161-
<dd>{{if .Service.EnableTimetracking}}{{svg "octicon-check"}}{{else}}{{svg "octicon-x"}}{{end}}</dd>
161+
<dd>{{svg (Iif .Service.EnableTimetracking "octicon-check" "octicon-x")}}</dd>
162162
{{if .Service.EnableTimetracking}}
163163
<dt>{{ctx.Locale.Tr "admin.config.default_enable_timetracking"}}</dt>
164-
<dd>{{if .Service.DefaultEnableTimetracking}}{{svg "octicon-check"}}{{else}}{{svg "octicon-x"}}{{end}}</dd>
164+
<dd>{{svg (Iif .Service.DefaultEnableTimetracking "octicon-check" "octicon-x")}}</dd>
165165
<dt>{{ctx.Locale.Tr "admin.config.default_allow_only_contributors_to_track_time"}}</dt>
166-
<dd>{{if .Service.DefaultAllowOnlyContributorsToTrackTime}}{{svg "octicon-check"}}{{else}}{{svg "octicon-x"}}{{end}}</dd>
166+
<dd>{{svg (Iif .Service.DefaultAllowOnlyContributorsToTrackTime "octicon-check" "octicon-x")}}</dd>
167167
{{end}}
168168
<dt>{{ctx.Locale.Tr "admin.config.default_visibility_organization"}}</dt>
169169
<dd>{{.Service.DefaultOrgVisibility}}</dd>
170170

171171
<dt>{{ctx.Locale.Tr "admin.config.no_reply_address"}}</dt>
172172
<dd>{{if .Service.NoReplyAddress}}{{.Service.NoReplyAddress}}{{else}}-{{end}}</dd>
173173
<dt>{{ctx.Locale.Tr "admin.config.default_enable_dependencies"}}</dt>
174-
<dd>{{if .Service.DefaultEnableDependencies}}{{svg "octicon-check"}}{{else}}{{svg "octicon-x"}}{{end}}</dd>
174+
<dd>{{svg (Iif .Service.DefaultEnableDependencies "octicon-check" "octicon-x")}}</dd>
175175
<div class="divider"></div>
176176
<dt>{{ctx.Locale.Tr "admin.config.active_code_lives"}}</dt>
177177
<dd>{{.Service.ActiveCodeLives}} {{ctx.Locale.Tr "tool.raw_minutes"}}</dd>
@@ -190,7 +190,7 @@
190190
<dt>{{ctx.Locale.Tr "admin.config.deliver_timeout"}}</dt>
191191
<dd>{{.Webhook.DeliverTimeout}} {{ctx.Locale.Tr "tool.raw_seconds"}}</dd>
192192
<dt>{{ctx.Locale.Tr "admin.config.skip_tls_verify"}}</dt>
193-
<dd>{{if .Webhook.SkipTLSVerify}}{{svg "octicon-check"}}{{else}}{{svg "octicon-x"}}{{end}}</dd>
193+
<dd>{{svg (Iif .Webhook.SkipTLSVerify "octicon-check" "octicon-x")}}</dd>
194194
</dl>
195195
</div>
196196

@@ -200,7 +200,7 @@
200200
<div class="ui attached table segment">
201201
<dl class="admin-dl-horizontal">
202202
<dt>{{ctx.Locale.Tr "admin.config.mailer_enabled"}}</dt>
203-
<dd>{{if .MailerEnabled}}{{svg "octicon-check"}}{{else}}{{svg "octicon-x"}}{{end}}</dd>
203+
<dd>{{svg (Iif .MailerEnabled "octicon-check" "octicon-x")}}</dd>
204204
{{if .MailerEnabled}}
205205
<dt>{{ctx.Locale.Tr "admin.config.mailer_name"}}</dt>
206206
<dd>{{.Mailer.Name}}</dd>
@@ -220,7 +220,7 @@
220220
<dt>{{ctx.Locale.Tr "admin.config.mailer_protocol"}}</dt>
221221
<dd>{{.Mailer.Protocol}}</dd>
222222
<dt>{{ctx.Locale.Tr "admin.config.mailer_enable_helo"}}</dt>
223-
<dd>{{if .Mailer.EnableHelo}}{{svg "octicon-check"}}{{else}}{{svg "octicon-x"}}{{end}}</dd>
223+
<dd>{{svg (Iif .Mailer.EnableHelo "octicon-check" "octicon-x")}}</dd>
224224
<dt>{{ctx.Locale.Tr "admin.config.mailer_smtp_addr"}}</dt>
225225
<dd>{{.Mailer.SMTPAddr}}</dd>
226226
<dt>{{ctx.Locale.Tr "admin.config.mailer_smtp_port"}}</dt>
@@ -279,7 +279,7 @@
279279
<dt>{{ctx.Locale.Tr "admin.config.session_life_time"}}</dt>
280280
<dd>{{.SessionConfig.Maxlifetime}} {{ctx.Locale.Tr "tool.raw_seconds"}}</dd>
281281
<dt>{{ctx.Locale.Tr "admin.config.https_only"}}</dt>
282-
<dd>{{if .SessionConfig.Secure}}{{svg "octicon-check"}}{{else}}{{svg "octicon-x"}}{{end}}</dd>
282+
<dd>{{svg (Iif .SessionConfig.Secure "octicon-check" "octicon-x")}}</dd>
283283
</dl>
284284
</div>
285285

@@ -289,7 +289,7 @@
289289
<div class="ui attached table segment">
290290
<dl class="admin-dl-horizontal">
291291
<dt>{{ctx.Locale.Tr "admin.config.git_disable_diff_highlight"}}</dt>
292-
<dd>{{if .Git.DisableDiffHighlight}}{{svg "octicon-check"}}{{else}}{{svg "octicon-x"}}{{end}}</dd>
292+
<dd>{{svg (Iif .Git.DisableDiffHighlight "octicon-check" "octicon-x")}}</dd>
293293
<dt>{{ctx.Locale.Tr "admin.config.git_max_diff_lines"}}</dt>
294294
<dd>{{.Git.MaxGitDiffLines}}</dd>
295295
<dt>{{ctx.Locale.Tr "admin.config.git_max_diff_line_characters"}}</dt>
@@ -321,7 +321,7 @@
321321
<dl class="admin-dl-horizontal">
322322
{{if .Loggers.xorm.IsEnabled}}
323323
<dt>{{ctx.Locale.Tr "admin.config.xorm_log_sql"}}</dt>
324-
<dd>{{if $.LogSQL}}{{svg "octicon-check"}}{{else}}{{svg "octicon-x"}}{{end}}</dd>
324+
<dd>{{svg (Iif $.LogSQL "octicon-check" "octicon-x")}}</dd>
325325
{{end}}
326326

327327
{{if .Loggers.access.IsEnabled}}

templates/admin/cron.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<td>{{DateTime "full" .Next}}</td>
2727
<td>{{if gt .Prev.Year 1}}{{DateTime "full" .Prev}}{{else}}-{{end}}</td>
2828
<td>{{.ExecTimes}}</td>
29-
<td {{if ne .Status ""}}data-tooltip-content="{{.FormatLastMessage ctx.Locale}}"{{end}} >{{if eq .Status ""}}—{{else if eq .Status "finished"}}{{svg "octicon-check" 16}}{{else}}{{svg "octicon-x" 16}}{{end}}</td>
29+
<td {{if ne .Status ""}}data-tooltip-content="{{.FormatLastMessage ctx.Locale}}"{{end}} >{{if eq .Status ""}}—{{else}}{{svg (Iif (eq .Status "finished") "octicon-check" "octicon-x") 16}}{{end}}</td>
3030
</tr>
3131
{{end}}
3232
</tbody>

templates/admin/emails/list.tmpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,17 @@
4646
<td><a href="{{AppSubUrl}}/{{.Name | PathEscape}}">{{.Name}}</a></td>
4747
<td class="gt-ellipsis tw-max-w-48">{{.FullName}}</td>
4848
<td class="gt-ellipsis tw-max-w-48">{{.Email}}</td>
49-
<td>{{if .IsPrimary}}{{svg "octicon-check"}}{{else}}{{svg "octicon-x"}}{{end}}</td>
49+
<td>{{svg (Iif .IsPrimary "octicon-check" "octicon-x")}}</td>
5050
<td>
5151
{{if .CanChange}}
5252
<a class="link-email-action" href data-uid="{{.UID}}"
5353
data-email="{{.Email}}"
5454
data-primary="{{if .IsPrimary}}1{{else}}0{{end}}"
5555
data-activate="{{if .IsActivated}}0{{else}}1{{end}}">
56-
{{if .IsActivated}}{{svg "octicon-check"}}{{else}}{{svg "octicon-x"}}{{end}}
56+
{{svg (Iif .IsActivated "octicon-check" "octicon-x")}}
5757
</a>
5858
{{else}}
59-
{{if .IsActivated}}{{svg "octicon-check"}}{{else}}{{svg "octicon-x"}}{{end}}
59+
{{svg (Iif .IsActivated "octicon-check" "octicon-x")}}
6060
{{end}}
6161
</td>
6262
</tr>

templates/admin/user/list.tmpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@
9393
{{end}}
9494
</td>
9595
<td class="gt-ellipsis tw-max-w-48">{{.Email}}</td>
96-
<td>{{if .IsActive}}{{svg "octicon-check"}}{{else}}{{svg "octicon-x"}}{{end}}</td>
97-
<td>{{if .IsRestricted}}{{svg "octicon-check"}}{{else}}{{svg "octicon-x"}}{{end}}</td>
98-
<td>{{if index $.UsersTwoFaStatus .ID}}{{svg "octicon-check"}}{{else}}{{svg "octicon-x"}}{{end}}</td>
96+
<td>{{svg (Iif .IsActive "octicon-check" "octicon-x")}}</td>
97+
<td>{{svg (Iif .IsRestricted "octicon-check" "octicon-x")}}</td>
98+
<td>{{svg (Iif (index $.UsersTwoFaStatus .ID) "octicon-check" "octicon-x")}}</td>
9999
<td>{{DateTime "short" .CreatedUnix}}</td>
100100
{{if .LastLoginUnix}}
101101
<td>{{DateTime "short" .LastLoginUnix}}</td>

templates/repo/diff/whitespace_dropdown.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@
2727
</a>
2828
</div>
2929
</div>
30-
<a class="ui tiny basic button" href="?style={{if .IsSplitStyle}}unified{{else}}split{{end}}&whitespace={{$.WhitespaceBehavior}}&show-outdated={{$.ShowOutdatedComments}}" data-tooltip-content="{{if .IsSplitStyle}}{{ctx.Locale.Tr "repo.diff.show_unified_view"}}{{else}}{{ctx.Locale.Tr "repo.diff.show_split_view"}}{{end}}">{{if .IsSplitStyle}}{{svg "gitea-join"}}{{else}}{{svg "gitea-split"}}{{end}}</a>
30+
<a class="ui tiny basic button" href="?style={{if .IsSplitStyle}}unified{{else}}split{{end}}&whitespace={{$.WhitespaceBehavior}}&show-outdated={{$.ShowOutdatedComments}}" data-tooltip-content="{{if .IsSplitStyle}}{{ctx.Locale.Tr "repo.diff.show_unified_view"}}{{else}}{{ctx.Locale.Tr "repo.diff.show_split_view"}}{{end}}">{{svg (Iif .IsSplitStyle "gitea-join" "gitea-split")}}</a>

templates/repo/issue/filter_actions.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
{{end}}
3131
{{$previousExclusiveScope = $exclusiveScope}}
3232
<div class="item issue-action tw-flex tw-justify-between" data-action="toggle" data-element-id="{{.ID}}" data-url="{{$.RepoLink}}/issues/labels">
33-
{{if SliceUtils.Contains $.SelLabelIDs .ID}}{{if $exclusiveScope}}{{svg "octicon-dot-fill"}}{{else}}{{svg "octicon-check"}}{{end}}{{end}} {{RenderLabel $.Context ctx.Locale .}}
33+
{{if SliceUtils.Contains $.SelLabelIDs .ID}}{{svg (Iif $exclusiveScope "octicon-dot-fill" "octicon-check")}}{{end}} {{RenderLabel $.Context ctx.Locale .}}
3434
{{template "repo/issue/labels/label_archived" .}}
3535
</div>
3636
{{end}}

templates/repo/issue/labels/labels_selector_field.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<div class="divider"></div>
2222
{{end}}
2323
{{$previousExclusiveScope = $exclusiveScope}}
24-
<a class="{{if .IsChecked}}checked{{end}} item" href="#" data-id="{{.ID}}" {{if .IsArchived}}data-is-archived{{end}} data-id-selector="#label_{{.ID}}" data-scope="{{$exclusiveScope}}"><span class="octicon-check {{if not .IsChecked}}tw-invisible{{end}}">{{if $exclusiveScope}}{{svg "octicon-dot-fill"}}{{else}}{{svg "octicon-check"}}{{end}}</span>&nbsp;&nbsp;{{RenderLabel $.Context ctx.Locale .}}
24+
<a class="{{if .IsChecked}}checked{{end}} item" href="#" data-id="{{.ID}}" {{if .IsArchived}}data-is-archived{{end}} data-id-selector="#label_{{.ID}}" data-scope="{{$exclusiveScope}}"><span class="octicon-check {{if not .IsChecked}}tw-invisible{{end}}">{{svg (Iif $exclusiveScope "octicon-dot-fill" "octicon-check")}}</span>&nbsp;&nbsp;{{RenderLabel $.Context ctx.Locale .}}
2525
{{if .Description}}<br><small class="desc">{{.Description | RenderEmoji $.Context}}</small>{{end}}
2626
<p class="archived-label-hint">{{template "repo/issue/labels/label_archived" .}}</p>
2727
</a>
@@ -34,7 +34,7 @@
3434
<div class="divider"></div>
3535
{{end}}
3636
{{$previousExclusiveScope = $exclusiveScope}}
37-
<a class="{{if .IsChecked}}checked{{end}} item" href="#" data-id="{{.ID}}" {{if .IsArchived}}data-is-archived{{end}} data-id-selector="#label_{{.ID}}" data-scope="{{$exclusiveScope}}"><span class="octicon-check {{if not .IsChecked}}tw-invisible{{end}}">{{if $exclusiveScope}}{{svg "octicon-dot-fill"}}{{else}}{{svg "octicon-check"}}{{end}}</span>&nbsp;&nbsp;{{RenderLabel $.Context ctx.Locale .}}
37+
<a class="{{if .IsChecked}}checked{{end}} item" href="#" data-id="{{.ID}}" {{if .IsArchived}}data-is-archived{{end}} data-id-selector="#label_{{.ID}}" data-scope="{{$exclusiveScope}}"><span class="octicon-check {{if not .IsChecked}}tw-invisible{{end}}">{{svg (Iif $exclusiveScope "octicon-dot-fill" "octicon-check")}}</span>&nbsp;&nbsp;{{RenderLabel $.Context ctx.Locale .}}
3838
{{if .Description}}<br><small class="desc">{{.Description | RenderEmoji $.Context}}</small>{{end}}
3939
<p class="archived-label-hint">{{template "repo/issue/labels/label_archived" .}}</p>
4040
</a>

templates/repo/issue/view_content/sidebar.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
</span>
9393
{{end}}
9494
{{if and .CanChange (or .Checked (and (not $.Issue.IsClosed) (not $.Issue.PullRequest.HasMerged)))}}
95-
<a href="#" class="ui muted icon re-request-review{{if .Checked}} checked{{end}}" data-tooltip-content="{{if .Checked}}{{ctx.Locale.Tr "repo.issues.remove_request_review"}}{{else}}{{ctx.Locale.Tr "repo.issues.re_request_review"}}{{end}}" data-issue-id="{{$.Issue.ID}}" data-id="{{.ItemID}}" data-update-url="{{$.RepoLink}}/issues/request_review">{{if .Checked}}{{svg "octicon-trash"}}{{else}}{{svg "octicon-sync"}}{{end}}</a>
95+
<a href="#" class="ui muted icon re-request-review{{if .Checked}} checked{{end}}" data-tooltip-content="{{if .Checked}}{{ctx.Locale.Tr "repo.issues.remove_request_review"}}{{else}}{{ctx.Locale.Tr "repo.issues.re_request_review"}}{{end}}" data-issue-id="{{$.Issue.ID}}" data-id="{{.ItemID}}" data-update-url="{{$.RepoLink}}/issues/request_review">{{svg (Iif .Checked "octicon-trash" "octicon-sync")}}</a>
9696
{{end}}
9797
{{svg (printf "octicon-%s" .Review.Type.Icon) 16 (printf "text %s" (.Review.HTMLTypeColorName))}}
9898
</div>

0 commit comments

Comments
 (0)