Refactor template empty checks (#28351) (#28354)

Backport #28351 by @KN4CK3R

Fix #28347

As there is no info how to reproduce it, I can't test it.
Fix may be `section_split.tmpl @ 126/130`.

Other changes are "empty check" refactorings.

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
pull/28360/head
Giteabot 12 months ago committed by GitHub
parent b71d4c3ec0
commit 08445d5d86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      templates/repo/actions/runs_list.tmpl
  2. 22
      templates/repo/diff/section_split.tmpl
  3. 2
      templates/repo/diff/section_unified.tmpl
  4. 6
      templates/repo/header.tmpl
  5. 2
      templates/repo/issue/filters.tmpl
  6. 2
      templates/repo/issue/view_content/sidebar.tmpl
  7. 2
      templates/shared/issuelist.tmpl
  8. 2
      templates/user/dashboard/feeds.tmpl
  9. 2
      templates/user/notification/notification_div.tmpl
  10. 2
      templates/user/notification/notification_subscriptions.tmpl
  11. 2
      templates/user/settings/keys_gpg.tmpl

@ -1,5 +1,5 @@
<div class="flex-list"> <div class="flex-list">
{{if eq (len .Runs) 0}} {{if not .Runs}}
<div class="empty-placeholder"> <div class="empty-placeholder">
{{svg "octicon-no-entry" 48}} {{svg "octicon-no-entry" 48}}
<h2>{{if $.IsFiltered}}{{ctx.Locale.Tr "actions.runs.no_results"}}{{else}}{{ctx.Locale.Tr "actions.runs.no_runs"}}{{end}}</h2> <h2>{{if $.IsFiltered}}{{ctx.Locale.Tr "actions.runs.no_results"}}{{else}}{{ctx.Locale.Tr "actions.runs.no_runs"}}{{end}}</h2>

@ -108,25 +108,27 @@
</tr> </tr>
{{if and (eq .GetType 3) $hasmatch}} {{if and (eq .GetType 3) $hasmatch}}
{{$match := index $section.Lines $line.Match}} {{$match := index $section.Lines $line.Match}}
{{if or (gt (len $line.Comments) 0) (gt (len $match.Comments) 0)}} {{if or $line.Comments $match.Comments}}
<tr class="add-comment" data-line-type="{{.GetHTMLDiffLineType}}"> <tr class="add-comment" data-line-type="{{.GetHTMLDiffLineType}}">
<td class="add-comment-left" colspan="4"> <td class="add-comment-left" colspan="4">
{{if gt (len $line.Comments) 0}} {{if $line.Comments}}
{{if eq $line.GetCommentSide "previous"}} {{if eq $line.GetCommentSide "previous"}}
{{template "repo/diff/conversation" dict "." $.root "comments" $line.Comments}} {{template "repo/diff/conversation" dict "." $.root "comments" $line.Comments}}
{{end}} {{end}}
{{end}} {{end}}
{{if gt (len $match.Comments) 0}} {{if $match.Comments}}
{{if eq $match.GetCommentSide "previous"}} {{if eq $match.GetCommentSide "previous"}}
{{template "repo/diff/conversation" dict "." $.root "comments" $match.Comments}} {{template "repo/diff/conversation" dict "." $.root "comments" $match.Comments}}
{{end}} {{end}}
{{end}} {{end}}
</td> </td>
<td class="add-comment-right" colspan="4"> <td class="add-comment-right" colspan="4">
{{if eq $line.GetCommentSide "proposed"}} {{if $line.Comments}}
{{template "repo/diff/conversation" dict "." $.root "comments" $line.Comments}} {{if eq $line.GetCommentSide "proposed"}}
{{template "repo/diff/conversation" dict "." $.root "comments" $line.Comments}}
{{end}}
{{end}} {{end}}
{{if gt (len $match.Comments) 0}} {{if $match.Comments}}
{{if eq $match.GetCommentSide "proposed"}} {{if eq $match.GetCommentSide "proposed"}}
{{template "repo/diff/conversation" dict "." $.root "comments" $match.Comments}} {{template "repo/diff/conversation" dict "." $.root "comments" $match.Comments}}
{{end}} {{end}}
@ -134,13 +136,11 @@
</td> </td>
</tr> </tr>
{{end}} {{end}}
{{else if gt (len $line.Comments) 0}} {{else if $line.Comments}}
<tr class="add-comment" data-line-type="{{.GetHTMLDiffLineType}}"> <tr class="add-comment" data-line-type="{{.GetHTMLDiffLineType}}">
<td class="add-comment-left" colspan="4"> <td class="add-comment-left" colspan="4">
{{if gt (len $line.Comments) 0}} {{if eq $line.GetCommentSide "previous"}}
{{if eq $line.GetCommentSide "previous"}} {{template "repo/diff/conversation" dict "." $.root "comments" $line.Comments}}
{{template "repo/diff/conversation" dict "." $.root "comments" $line.Comments}}
{{end}}
{{end}} {{end}}
</td> </td>
<td class="add-comment-right" colspan="4"> <td class="add-comment-right" colspan="4">

@ -60,7 +60,7 @@
*/}}</td> */}}</td>
{{end}} {{end}}
</tr> </tr>
{{if gt (len $line.Comments) 0}} {{if $line.Comments}}
<tr class="add-comment" data-line-type="{{.GetHTMLDiffLineType}}"> <tr class="add-comment" data-line-type="{{.GetHTMLDiffLineType}}">
<td class="add-comment-left add-comment-right" colspan="5"> <td class="add-comment-left add-comment-right" colspan="5">
{{template "repo/diff/conversation" dict "." $.root "comments" $line.Comments}} {{template "repo/diff/conversation" dict "." $.root "comments" $line.Comments}}

@ -81,12 +81,12 @@
{{end}} {{end}}
{{if and (not .IsEmpty) ($.Permission.CanRead $.UnitTypeCode)}} {{if and (not .IsEmpty) ($.Permission.CanRead $.UnitTypeCode)}}
<div class="ui labeled button <div class="ui labeled button
{{if or (not $.IsSigned) (and (not $.CanSignedUserFork) (eq (len $.UserAndOrgForks) 0))}} {{if or (not $.IsSigned) (and (not $.CanSignedUserFork) (not $.UserAndOrgForks))}}
disabled disabled
{{end}}" {{end}}"
{{if not $.IsSigned}} {{if not $.IsSigned}}
data-tooltip-content="{{ctx.Locale.Tr "repo.fork_guest_user"}}" data-tooltip-content="{{ctx.Locale.Tr "repo.fork_guest_user"}}"
{{else if and (not $.CanSignedUserFork) (eq (len $.UserAndOrgForks) 0)}} {{else if and (not $.CanSignedUserFork) (not $.UserAndOrgForks)}}
data-tooltip-content="{{ctx.Locale.Tr "repo.fork_from_self"}}" data-tooltip-content="{{ctx.Locale.Tr "repo.fork_from_self"}}"
{{end}} {{end}}
> >
@ -98,7 +98,7 @@
href="{{AppSubUrl}}/{{(index $.UserAndOrgForks 0).FullName}}" href="{{AppSubUrl}}/{{(index $.UserAndOrgForks 0).FullName}}"
{{/*else is not required here, because the button shouldn't link to any site if you can't create a fork*/}} {{/*else is not required here, because the button shouldn't link to any site if you can't create a fork*/}}
{{end}} {{end}}
{{else if eq (len $.UserAndOrgForks) 0}} {{else if not $.UserAndOrgForks}}
href="{{AppSubUrl}}/repo/fork/{{.ID}}" href="{{AppSubUrl}}/repo/fork/{{.ID}}"
{{else}} {{else}}
data-modal="#fork-repo-modal" data-modal="#fork-repo-modal"

@ -1,6 +1,6 @@
<div id="issue-filters" class="issue-list-toolbar"> <div id="issue-filters" class="issue-list-toolbar">
<div class="issue-list-toolbar-left"> <div class="issue-list-toolbar-left">
{{if and ($.CanWriteIssuesOrPulls) (gt (len .Issues) 0)}} {{if and $.CanWriteIssuesOrPulls .Issues}}
<input type="checkbox" autocomplete="off" class="issue-checkbox-all gt-mr-4" title="{{ctx.Locale.Tr "repo.issues.action_check_all"}}"> <input type="checkbox" autocomplete="off" class="issue-checkbox-all gt-mr-4" title="{{ctx.Locale.Tr "repo.issues.action_check_all"}}">
{{end}} {{end}}
{{template "repo/issue/openclose" .}} {{template "repo/issue/openclose" .}}

@ -339,7 +339,7 @@
</div> </div>
</div> </div>
{{end}} {{end}}
{{if gt (len .WorkingUsers) 0}} {{if .WorkingUsers}}
<div class="divider"></div> <div class="divider"></div>
<div class="ui comments"> <div class="ui comments">
<span class="text"><strong>{{ctx.Locale.Tr "repo.issues.time_spent_from_all_authors" ($.Issue.TotalTrackedTime | Sec2Time) | Safe}}</strong></span> <span class="text"><strong>{{ctx.Locale.Tr "repo.issues.time_spent_from_all_authors" ($.Issue.TotalTrackedTime | Sec2Time) | Safe}}</strong></span>

@ -140,7 +140,7 @@
{{ctx.Locale.TrN $waitingOfficial "repo.pulls.waiting_count_1" "repo.pulls.waiting_count_n" $waitingOfficial}} {{ctx.Locale.TrN $waitingOfficial "repo.pulls.waiting_count_1" "repo.pulls.waiting_count_n" $waitingOfficial}}
</span> </span>
{{end}} {{end}}
{{if and (not .PullRequest.HasMerged) (gt (len .PullRequest.ConflictedFiles) 0)}} {{if and (not .PullRequest.HasMerged) .PullRequest.ConflictedFiles}}
<span class="conflicting flex-text-inline"> <span class="conflicting flex-text-inline">
{{svg "octicon-x" 14}} {{svg "octicon-x" 14}}
{{ctx.Locale.TrN (len .PullRequest.ConflictedFiles) "repo.pulls.num_conflicting_files_1" "repo.pulls.num_conflicting_files_n" (len .PullRequest.ConflictedFiles)}} {{ctx.Locale.TrN (len .PullRequest.ConflictedFiles) "repo.pulls.num_conflicting_files_1" "repo.pulls.num_conflicting_files_n" (len .PullRequest.ConflictedFiles)}}

@ -105,7 +105,7 @@
{{else if .GetOpType.InActions "comment_issue" "approve_pull_request" "reject_pull_request" "comment_pull"}} {{else if .GetOpType.InActions "comment_issue" "approve_pull_request" "reject_pull_request" "comment_pull"}}
<a href="{{.GetCommentLink ctx}}" class="text truncate issue title">{{(.GetIssueTitle ctx) | RenderEmoji $.Context | RenderCodeBlock}}</a> <a href="{{.GetCommentLink ctx}}" class="text truncate issue title">{{(.GetIssueTitle ctx) | RenderEmoji $.Context | RenderCodeBlock}}</a>
{{$comment := index .GetIssueInfos 1}} {{$comment := index .GetIssueInfos 1}}
{{if gt (len $comment) 0}} {{if $comment}}
<div class="markup gt-font-14">{{RenderMarkdownToHtml ctx $comment}}</div> <div class="markup gt-font-14">{{RenderMarkdownToHtml ctx $comment}}</div>
{{end}} {{end}}
{{else if .GetOpType.InActions "merge_pull_request"}} {{else if .GetOpType.InActions "merge_pull_request"}}

@ -24,7 +24,7 @@
</div> </div>
<div class="gt-p-0"> <div class="gt-p-0">
<div id="notification_table"> <div id="notification_table">
{{if eq (len .Notifications) 0}} {{if not .Notifications}}
<div class="gt-df gt-ac gt-fc gt-p-4"> <div class="gt-df gt-ac gt-fc gt-p-4">
{{svg "octicon-inbox" 56 "gt-mb-4"}} {{svg "octicon-inbox" 56 "gt-mb-4"}}
{{if eq .Status 1}} {{if eq .Status 1}}

@ -63,7 +63,7 @@
</div> </div>
</div> </div>
<div class="divider"></div> <div class="divider"></div>
{{if eq (len .Issues) 0}} {{if not .Issues}}
{{ctx.Locale.Tr "notification.no_subscriptions"}} {{ctx.Locale.Tr "notification.no_subscriptions"}}
{{else}} {{else}}
{{template "shared/issuelist" dict "." . "listType" "dashboard"}} {{template "shared/issuelist" dict "." . "listType" "dashboard"}}

@ -55,7 +55,7 @@
{{if .Verified}} {{if .Verified}}
<span class="flex-text-block" data-tooltip-content="{{ctx.Locale.Tr "settings.gpg_key_verified_long"}}">{{svg "octicon-verified"}} <strong>{{ctx.Locale.Tr "settings.gpg_key_verified"}}</strong></span> <span class="flex-text-block" data-tooltip-content="{{ctx.Locale.Tr "settings.gpg_key_verified_long"}}">{{svg "octicon-verified"}} <strong>{{ctx.Locale.Tr "settings.gpg_key_verified"}}</strong></span>
{{end}} {{end}}
{{if gt (len .Emails) 0}} {{if .Emails}}
<span class="flex-text-block" data-tooltip-content="{{ctx.Locale.Tr "settings.gpg_key_matched_identities_long"}}">{{svg "octicon-mail"}} {{ctx.Locale.Tr "settings.gpg_key_matched_identities"}} {{range .Emails}}<strong>{{.Email}} </strong>{{end}}</span> <span class="flex-text-block" data-tooltip-content="{{ctx.Locale.Tr "settings.gpg_key_matched_identities_long"}}">{{svg "octicon-mail"}} {{ctx.Locale.Tr "settings.gpg_key_matched_identities"}} {{range .Emails}}<strong>{{.Email}} </strong>{{end}}</span>
{{end}} {{end}}
<div class="flex-item-body"> <div class="flex-item-body">

Loading…
Cancel
Save