refactor(templates): remove ctxData from tmpl files, use ctx.RootData instead (#37567)

Sub-templates have direct access to `ctx.RootData` (the root data map),
so there is no need for callers to explicitly pass it as `ctxData` via `dict`.

Also fix #37569 by the way

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: wxiaoguang <2114189+wxiaoguang@users.noreply.github.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
Copilot
2026-05-06 18:21:48 +00:00
committed by GitHub
parent ebc058f682
commit b093c2c43c
95 changed files with 140 additions and 140 deletions
@@ -86,7 +86,7 @@
{{template "shared/user/avatarlink" dict "user" .Poster}}
{{end}}
<span class="comment-text-line">
{{template "repo/issue/view_content/comments_authorlink" dict "ctxData" $ "comment" .}}
{{template "repo/issue/view_content/comments_authorlink" dict "comment" .}}
{{if .Issue.IsPull}}
{{ctx.Locale.Tr "repo.pulls.reopened_at" .EventTag $createdStr}}
{{else}}
@@ -101,7 +101,7 @@
{{template "shared/user/avatarlink" dict "user" .Poster}}
{{end}}
<span class="comment-text-line">
{{template "repo/issue/view_content/comments_authorlink" dict "ctxData" $ "comment" .}}
{{template "repo/issue/view_content/comments_authorlink" dict "comment" .}}
{{if .Issue.IsPull}}
{{ctx.Locale.Tr "repo.pulls.closed_at" .EventTag $createdStr}}
{{else}}
@@ -116,7 +116,7 @@
{{template "shared/user/avatarlink" dict "user" .Poster}}
{{end}}
<span class="comment-text-line">
{{template "repo/issue/view_content/comments_authorlink" dict "ctxData" $ "comment" .}}
{{template "repo/issue/view_content/comments_authorlink" dict "comment" .}}
{{$link := printf "%s/commit/%s" $.Repository.Link ($.Issue.PullRequest.MergedCommitID|PathEscape)}}
{{if eq $.Issue.PullRequest.Status 3}}
{{ctx.Locale.Tr "repo.issues.comment_manually_pull_merged_at" (HTMLFormat `<a class="ui sha" href="%[1]s"><b>%[2]s</b></a>` $link (ShortSha $.Issue.PullRequest.MergedCommitID)) (HTMLFormat "<b>%[1]s</b>" $.BaseTarget) $createdStr}}
@@ -256,7 +256,7 @@
{{if not $timeStr}}{{$timeStr = .Content|Sec2Hour}}{{end}}
{{ctx.Locale.Tr "repo.issues.stop_tracking_history" $timeStr $createdStr}}
</span>
{{template "repo/issue/view_content/comments_delete_time" dict "ctxData" $ "comment" .}}
{{template "repo/issue/view_content/comments_delete_time" dict "comment" .}}
</div>
{{else if eq .Type 14}}
<div class="timeline-item event" id="{{.HashTag}}">
@@ -268,7 +268,7 @@
{{if not $timeStr}}{{$timeStr = .Content|Sec2Hour}}{{end}}
{{ctx.Locale.Tr "repo.issues.add_time_history" $timeStr $createdStr}}
</span>
{{template "repo/issue/view_content/comments_delete_time" dict "ctxData" $ "comment" .}}
{{template "repo/issue/view_content/comments_delete_time" dict "comment" .}}
</div>
{{else if eq .Type 15}}
<div class="timeline-item event" id="{{.HashTag}}">
@@ -380,7 +380,7 @@
{{- end -}}
</span>
<span class="comment-text-line">
{{template "repo/issue/view_content/comments_authorlink" dict "ctxData" $ "comment" .}}
{{template "repo/issue/view_content/comments_authorlink" dict "comment" .}}
{{if eq $reviewType 1}}
{{ctx.Locale.Tr "repo.issues.review.approve" $createdStr}}
{{else if eq $reviewType 3}}
@@ -490,7 +490,7 @@
{{template "shared/user/avatarlink" dict "user" .Poster}}
{{end}}
<span class="comment-text-line">
{{template "repo/issue/view_content/comments_authorlink" dict "ctxData" $ "comment" .}}
{{template "repo/issue/view_content/comments_authorlink" dict "comment" .}}
{{ctx.Locale.Tr "repo.pulls.change_target_branch_at" .OldRef .NewRef $createdStr}}
</span>
</div>
@@ -665,7 +665,7 @@
<div class="timeline-item event" id="{{.HashTag}}">
<span class="badge">{{svg "octicon-git-merge" 16}}</span>
<span class="comment-text-line">
{{template "repo/issue/view_content/comments_authorlink" dict "ctxData" $ "comment" .}}
{{template "repo/issue/view_content/comments_authorlink" dict "comment" .}}
{{if eq .Type 34}}{{ctx.Locale.Tr "repo.pulls.auto_merge_newly_scheduled_comment" $createdStr}}
{{else}}{{ctx.Locale.Tr "repo.pulls.auto_merge_canceled_schedule_comment" $createdStr}}{{end}}
</span>
@@ -1,10 +1,10 @@
{{if .comment.OriginalAuthor}}
<span class="tw-text-text">
{{svg (MigrationIcon .ctxData.Repository.GetOriginalURLHostname)}}
{{svg (MigrationIcon ctx.RootData.Repository.GetOriginalURLHostname)}}
{{.comment.OriginalAuthor}}
</span>
{{if .ctxData.Repository.OriginalURL}}
<span class="migrate">({{ctx.Locale.Tr "repo.migrated_from" .ctxData.Repository.OriginalURL .ctxData.Repository.GetOriginalURLHostname}})</span>
{{if ctx.RootData.Repository.OriginalURL}}
<span class="migrate">({{ctx.Locale.Tr "repo.migrated_from" ctx.RootData.Repository.OriginalURL ctx.RootData.Repository.GetOriginalURLHostname}})</span>
{{end}}
{{else}}
{{template "shared/user/authorlink" .comment.Poster}}
@@ -1,9 +1,9 @@
{{if and .comment.Time (.ctxData.Repository.IsTimetrackerEnabled ctx)}} {{/* compatibility with time comments made before v1.14 */}}
{{if and .comment.Time (ctx.RootData.Repository.IsTimetrackerEnabled ctx)}} {{/* compatibility with time comments made before v1.14 */}}
{{if (not .comment.Time.Deleted)}}
{{if (or .ctxData.IsAdmin (and .ctxData.IsSigned (eq .ctxData.SignedUserID .comment.PosterID)))}}
{{if (or ctx.RootData.IsAdmin (and ctx.RootData.IsSigned (eq ctx.RootData.SignedUserID .comment.PosterID)))}}
<span class="tw-ml-auto">
<button class="ui icon button compact mini link-action" data-tooltip-content="{{ctx.Locale.Tr "repo.issues.del_time"}}"
data-url="{{.ctxData.RepoLink}}/issues/{{.ctxData.Issue.Index}}/times/{{.comment.TimeID}}/delete?id={{.comment.Time.ID}}"
data-url="{{ctx.RootData.RepoLink}}/issues/{{ctx.RootData.Issue.Index}}/times/{{.comment.TimeID}}/delete?id={{.comment.Time.ID}}"
data-modal-confirm="{{ctx.Locale.Tr "repo.issues.del_time"}}"
>
{{svg "octicon-trash"}}