1
0
mirror of https://github.com/go-gitea/gitea.git synced 2024-10-31 08:37:35 -04:00

Refactor ctx in templates (#23105)

Before, the `dict "ctx" ...` map is used to pass data between templates.

Now, more and more templates need to use real Go context:

* #22962
* #23092


`ctx` is a Go concept for `Context`, misusing it may cause problems, and
it makes it difficult to review or refactor.

This PR contains 2 major changes:

* In the top scope of a template, the `$` is the same as the `.`, so the
old labels_sidebar's `root` is the `ctx`. So this `ctx` could just be
removed.
bd7f218dce
* Rename all other `ctx` to `ctxData`, and it perfectly matches how it
comes from backend: `"ctxData": ctx.Data`.
7c01260e1d



From now on, there is no `ctx` in templates. There are only:

* `ctxData` for passing data
* `Context` for Go context
This commit is contained in:
wxiaoguang 2023-03-03 01:44:06 +08:00 committed by GitHub
parent 0a9a3c2a6d
commit ce73492d6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 51 additions and 51 deletions

View File

@ -2952,7 +2952,7 @@ func ChangeIssueReaction(ctx *context.Context) {
} }
html, err := ctx.RenderToString(tplReactions, map[string]interface{}{ html, err := ctx.RenderToString(tplReactions, map[string]interface{}{
"ctx": ctx.Data, "ctxData": ctx.Data,
"ActionURL": fmt.Sprintf("%s/issues/%d/reactions", ctx.Repo.RepoLink, issue.Index), "ActionURL": fmt.Sprintf("%s/issues/%d/reactions", ctx.Repo.RepoLink, issue.Index),
"Reactions": issue.Reactions.GroupByType(), "Reactions": issue.Reactions.GroupByType(),
}) })
@ -3054,7 +3054,7 @@ func ChangeCommentReaction(ctx *context.Context) {
} }
html, err := ctx.RenderToString(tplReactions, map[string]interface{}{ html, err := ctx.RenderToString(tplReactions, map[string]interface{}{
"ctx": ctx.Data, "ctxData": ctx.Data,
"ActionURL": fmt.Sprintf("%s/comments/%d/reactions", ctx.Repo.RepoLink, comment.ID), "ActionURL": fmt.Sprintf("%s/comments/%d/reactions", ctx.Repo.RepoLink, comment.ID),
"Reactions": comment.Reactions.GroupByType(), "Reactions": comment.Reactions.GroupByType(),
}) })
@ -3176,7 +3176,7 @@ func updateAttachments(ctx *context.Context, item interface{}, files []string) e
func attachmentsHTML(ctx *context.Context, attachments []*repo_model.Attachment, content string) string { func attachmentsHTML(ctx *context.Context, attachments []*repo_model.Attachment, content string) string {
attachHTML, err := ctx.RenderToString(tplAttachment, map[string]interface{}{ attachHTML, err := ctx.RenderToString(tplAttachment, map[string]interface{}{
"ctx": ctx.Data, "ctxData": ctx.Data,
"Attachments": attachments, "Attachments": attachments,
"Content": content, "Content": content,
}) })

View File

@ -42,8 +42,8 @@
</div> </div>
{{end}} {{end}}
{{end}} {{end}}
{{template "repo/issue/view_content/add_reaction" Dict "ctx" $.root "ActionURL" (Printf "%s/comments/%d/reactions" $.root.RepoLink .ID)}} {{template "repo/issue/view_content/add_reaction" Dict "ctxData" $.root "ActionURL" (Printf "%s/comments/%d/reactions" $.root.RepoLink .ID)}}
{{template "repo/issue/view_content/context_menu" Dict "ctx" $.root "item" . "delete" true "issue" false "diff" true "IsCommentPoster" (and $.root.IsSigned (eq $.root.SignedUserID .PosterID))}} {{template "repo/issue/view_content/context_menu" Dict "ctxData" $.root "item" . "delete" true "issue" false "diff" true "IsCommentPoster" (and $.root.IsSigned (eq $.root.SignedUserID .PosterID))}}
</div> </div>
</div> </div>
<div class="ui attached segment comment-body"> <div class="ui attached segment comment-body">
@ -60,7 +60,7 @@
{{$reactions := .Reactions.GroupByType}} {{$reactions := .Reactions.GroupByType}}
{{if $reactions}} {{if $reactions}}
<div class="ui attached segment reactions"> <div class="ui attached segment reactions">
{{template "repo/issue/view_content/reactions" Dict "ctx" $.root "ActionURL" (Printf "%s/comments/%d/reactions" $.root.RepoLink .ID) "Reactions" $reactions}} {{template "repo/issue/view_content/reactions" Dict "ctxData" $.root "ActionURL" (Printf "%s/comments/%d/reactions" $.root.RepoLink .ID) "Reactions" $reactions}}
</div> </div>
{{end}} {{end}}
</div> </div>

View File

@ -1,10 +1,10 @@
<div class="ui labels list"> <div class="ui labels list">
<span class="no-select item {{if .ctx.HasSelectedLabel}}gt-hidden{{end}}">{{.ctx.locale.Tr "repo.issues.new.no_label"}}</span> <span class="no-select item {{if .root.HasSelectedLabel}}gt-hidden{{end}}">{{.root.locale.Tr "repo.issues.new.no_label"}}</span>
<span class="labels-list"> <span class="labels-list">
{{range .ctx.Labels}} {{range .root.Labels}}
{{template "repo/issue/labels/label" dict "root" $.root "label" .}} {{template "repo/issue/labels/label" dict "root" $.root "label" .}}
{{end}} {{end}}
{{range .ctx.OrgLabels}} {{range .root.OrgLabels}}
{{template "repo/issue/labels/label" dict "root" $.root "label" .}} {{template "repo/issue/labels/label" dict "root" $.root "label" .}}
{{end}} {{end}}
</span> </span>

View File

@ -80,7 +80,7 @@
{{end}} {{end}}
</div> </div>
</div> </div>
{{template "repo/issue/labels/labels_sidebar" dict "root" $ "ctx" .}} {{template "repo/issue/labels/labels_sidebar" dict "root" $}}
<div class="ui divider"></div> <div class="ui divider"></div>

View File

@ -64,8 +64,8 @@
{{end}} {{end}}
{{end}} {{end}}
{{if not $.Repository.IsArchived}} {{if not $.Repository.IsArchived}}
{{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/issues/%d/reactions" $.RepoLink .Issue.Index)}} {{template "repo/issue/view_content/add_reaction" Dict "ctxData" $ "ActionURL" (Printf "%s/issues/%d/reactions" $.RepoLink .Issue.Index)}}
{{template "repo/issue/view_content/context_menu" Dict "ctx" $ "item" .Issue "delete" false "issue" true "diff" false "IsCommentPoster" $.IsIssuePoster}} {{template "repo/issue/view_content/context_menu" Dict "ctxData" $ "item" .Issue "delete" false "issue" true "diff" false "IsCommentPoster" $.IsIssuePoster}}
{{end}} {{end}}
</div> </div>
</div> </div>
@ -80,13 +80,13 @@
<div id="issue-{{.Issue.ID}}-raw" class="raw-content gt-hidden">{{.Issue.Content}}</div> <div id="issue-{{.Issue.ID}}-raw" class="raw-content gt-hidden">{{.Issue.Content}}</div>
<div class="edit-content-zone gt-hidden" data-write="issue-{{.Issue.ID}}-write" data-preview="issue-{{.Issue.ID}}-preview" data-update-url="{{$.RepoLink}}/issues/{{.Issue.Index}}/content" data-context="{{.RepoLink}}" data-attachment-url="{{$.RepoLink}}/issues/{{.Issue.Index}}/attachments" data-view-attachment-url="{{$.RepoLink}}/issues/{{.Issue.Index}}/view-attachments"></div> <div class="edit-content-zone gt-hidden" data-write="issue-{{.Issue.ID}}-write" data-preview="issue-{{.Issue.ID}}-preview" data-update-url="{{$.RepoLink}}/issues/{{.Issue.Index}}/content" data-context="{{.RepoLink}}" data-attachment-url="{{$.RepoLink}}/issues/{{.Issue.Index}}/attachments" data-view-attachment-url="{{$.RepoLink}}/issues/{{.Issue.Index}}/view-attachments"></div>
{{if .Issue.Attachments}} {{if .Issue.Attachments}}
{{template "repo/issue/view_content/attachments" Dict "ctx" $ "Attachments" .Issue.Attachments "Content" .Issue.RenderedContent}} {{template "repo/issue/view_content/attachments" Dict "ctxData" $ "Attachments" .Issue.Attachments "Content" .Issue.RenderedContent}}
{{end}} {{end}}
</div> </div>
{{$reactions := .Issue.Reactions.GroupByType}} {{$reactions := .Issue.Reactions.GroupByType}}
{{if $reactions}} {{if $reactions}}
<div class="ui attached segment reactions" role="note"> <div class="ui attached segment reactions" role="note">
{{template "repo/issue/view_content/reactions" Dict "ctx" $ "ActionURL" (Printf "%s/issues/%d/reactions" $.RepoLink .Issue.Index) "Reactions" $reactions}} {{template "repo/issue/view_content/reactions" Dict "ctxData" $ "ActionURL" (Printf "%s/issues/%d/reactions" $.RepoLink .Issue.Index) "Reactions" $reactions}}
</div> </div>
{{end}} {{end}}
</div> </div>

View File

@ -1,10 +1,10 @@
{{if .ctx.IsSigned}} {{if .ctxData.IsSigned}}
<div class="item action ui pointing select-reaction dropdown top right" data-action-url="{{.ActionURL}}"> <div class="item action ui pointing select-reaction dropdown top right" data-action-url="{{.ActionURL}}">
<a class="add-reaction"> <a class="add-reaction">
{{svg "octicon-smiley"}} {{svg "octicon-smiley"}}
</a> </a>
<div class="menu"> <div class="menu">
<div class="header">{{.ctx.locale.Tr "repo.pick_reaction"}}</div> <div class="header">{{.ctxData.locale.Tr "repo.pick_reaction"}}</div>
<div class="divider"></div> <div class="divider"></div>
{{range $value := AllowedReactions}} {{range $value := AllowedReactions}}
<a class="item reaction tooltip" data-content="{{$value}}">{{ReactionToEmoji $value}}</a> <a class="item reaction tooltip" data-content="{{$value}}">{{ReactionToEmoji $value}}</a>

View File

@ -6,7 +6,7 @@
{{$hasThumbnails := false}} {{$hasThumbnails := false}}
{{- range .Attachments -}} {{- range .Attachments -}}
<div class="twelve wide column" style="padding: 6px;"> <div class="twelve wide column" style="padding: 6px;">
<a target="_blank" rel="noopener noreferrer" href="{{.DownloadURL}}" title='{{$.ctx.locale.Tr "repo.issues.attachment.open_tab" .Name}}'> <a target="_blank" rel="noopener noreferrer" href="{{.DownloadURL}}" title='{{$.ctxData.locale.Tr "repo.issues.attachment.open_tab" .Name}}'>
{{if FilenameIsImage .Name}} {{if FilenameIsImage .Name}}
{{if not (containGeneric $.Content .UUID)}} {{if not (containGeneric $.Content .UUID)}}
{{$hasThumbnails = true}} {{$hasThumbnails = true}}
@ -31,7 +31,7 @@
{{if FilenameIsImage .Name}} {{if FilenameIsImage .Name}}
{{if not (containGeneric $.Content .UUID)}} {{if not (containGeneric $.Content .UUID)}}
<a target="_blank" rel="noopener noreferrer" href="{{.DownloadURL}}"> <a target="_blank" rel="noopener noreferrer" href="{{.DownloadURL}}">
<img src="{{.DownloadURL}}" title='{{$.ctx.locale.Tr "repo.issues.attachment.open_tab" .Name}}'> <img src="{{.DownloadURL}}" title='{{$.ctxData.locale.Tr "repo.issues.attachment.open_tab" .Name}}'>
</a> </a>
{{end}} {{end}}
{{end}} {{end}}

View File

@ -64,8 +64,8 @@
</div> </div>
{{end}} {{end}}
{{if not $.Repository.IsArchived}} {{if not $.Repository.IsArchived}}
{{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID)}} {{template "repo/issue/view_content/add_reaction" Dict "ctxData" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID)}}
{{template "repo/issue/view_content/context_menu" Dict "ctx" $ "item" . "delete" true "issue" true "diff" false "IsCommentPoster" (and $.IsSigned (eq $.SignedUserID .PosterID))}} {{template "repo/issue/view_content/context_menu" Dict "ctxData" $ "item" . "delete" true "issue" true "diff" false "IsCommentPoster" (and $.IsSigned (eq $.SignedUserID .PosterID))}}
{{end}} {{end}}
</div> </div>
</div> </div>
@ -80,13 +80,13 @@
<div id="issuecomment-{{.ID}}-raw" class="raw-content gt-hidden">{{.Content}}</div> <div id="issuecomment-{{.ID}}-raw" class="raw-content gt-hidden">{{.Content}}</div>
<div class="edit-content-zone gt-hidden" data-write="issuecomment-{{.ID}}-write" data-preview="issuecomment-{{.ID}}-preview" data-update-url="{{$.RepoLink}}/comments/{{.ID}}" data-context="{{$.RepoLink}}" data-attachment-url="{{$.RepoLink}}/comments/{{.ID}}/attachments"></div> <div class="edit-content-zone gt-hidden" data-write="issuecomment-{{.ID}}-write" data-preview="issuecomment-{{.ID}}-preview" data-update-url="{{$.RepoLink}}/comments/{{.ID}}" data-context="{{$.RepoLink}}" data-attachment-url="{{$.RepoLink}}/comments/{{.ID}}/attachments"></div>
{{if .Attachments}} {{if .Attachments}}
{{template "repo/issue/view_content/attachments" Dict "ctx" $ "Attachments" .Attachments "Content" .RenderedContent}} {{template "repo/issue/view_content/attachments" Dict "ctxData" $ "Attachments" .Attachments "Content" .RenderedContent}}
{{end}} {{end}}
</div> </div>
{{$reactions := .Reactions.GroupByType}} {{$reactions := .Reactions.GroupByType}}
{{if $reactions}} {{if $reactions}}
<div class="ui attached segment reactions" role="note"> <div class="ui attached segment reactions" role="note">
{{template "repo/issue/view_content/reactions" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID) "Reactions" $reactions}} {{template "repo/issue/view_content/reactions" Dict "ctxData" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID) "Reactions" $reactions}}
</div> </div>
{{end}} {{end}}
</div> </div>
@ -260,7 +260,7 @@
{{template "shared/user/authorlink" .Poster}} {{template "shared/user/authorlink" .Poster}}
{{$.locale.Tr "repo.issues.stop_tracking_history" $createdStr | Safe}} {{$.locale.Tr "repo.issues.stop_tracking_history" $createdStr | Safe}}
</span> </span>
{{template "repo/issue/view_content/comments_delete_time" Dict "ctx" $ "comment" .}} {{template "repo/issue/view_content/comments_delete_time" Dict "ctxData" $ "comment" .}}
<div class="detail"> <div class="detail">
{{svg "octicon-clock"}} {{svg "octicon-clock"}}
<span class="text grey muted-links">{{.Content}}</span> <span class="text grey muted-links">{{.Content}}</span>
@ -274,7 +274,7 @@
{{template "shared/user/authorlink" .Poster}} {{template "shared/user/authorlink" .Poster}}
{{$.locale.Tr "repo.issues.add_time_history" $createdStr | Safe}} {{$.locale.Tr "repo.issues.add_time_history" $createdStr | Safe}}
</span> </span>
{{template "repo/issue/view_content/comments_delete_time" Dict "ctx" $ "comment" .}} {{template "repo/issue/view_content/comments_delete_time" Dict "ctxData" $ "comment" .}}
<div class="detail"> <div class="detail">
{{svg "octicon-clock"}} {{svg "octicon-clock"}}
<span class="text grey muted-links">{{.Content}}</span> <span class="text grey muted-links">{{.Content}}</span>
@ -436,8 +436,8 @@
</div> </div>
{{end}} {{end}}
{{if not $.Repository.IsArchived}} {{if not $.Repository.IsArchived}}
{{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID)}} {{template "repo/issue/view_content/add_reaction" Dict "ctxData" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID)}}
{{template "repo/issue/view_content/context_menu" Dict "ctx" $ "item" . "delete" false "issue" true "diff" false "IsCommentPoster" (and $.IsSigned (eq $.SignedUserID .PosterID))}} {{template "repo/issue/view_content/context_menu" Dict "ctxData" $ "item" . "delete" false "issue" true "diff" false "IsCommentPoster" (and $.IsSigned (eq $.SignedUserID .PosterID))}}
{{end}} {{end}}
</div> </div>
</div> </div>
@ -452,13 +452,13 @@
<div id="issuecomment-{{.ID}}-raw" class="raw-content gt-hidden">{{.Content}}</div> <div id="issuecomment-{{.ID}}-raw" class="raw-content gt-hidden">{{.Content}}</div>
<div class="edit-content-zone gt-hidden" data-write="issuecomment-{{.ID}}-write" data-preview="issuecomment-{{.ID}}-preview" data-update-url="{{$.RepoLink}}/comments/{{.ID}}" data-context="{{$.RepoLink}}" data-attachment-url="{{$.RepoLink}}/comments/{{.ID}}/attachments"></div> <div class="edit-content-zone gt-hidden" data-write="issuecomment-{{.ID}}-write" data-preview="issuecomment-{{.ID}}-preview" data-update-url="{{$.RepoLink}}/comments/{{.ID}}" data-context="{{$.RepoLink}}" data-attachment-url="{{$.RepoLink}}/comments/{{.ID}}/attachments"></div>
{{if .Attachments}} {{if .Attachments}}
{{template "repo/issue/view_content/attachments" Dict "ctx" $ "Attachments" .Attachments "Content" .RenderedContent}} {{template "repo/issue/view_content/attachments" Dict "ctxData" $ "Attachments" .Attachments "Content" .RenderedContent}}
{{end}} {{end}}
</div> </div>
{{$reactions := .Reactions.GroupByType}} {{$reactions := .Reactions.GroupByType}}
{{if $reactions}} {{if $reactions}}
<div class="ui attached segment reactions"> <div class="ui attached segment reactions">
{{template "repo/issue/view_content/reactions" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID) "Reactions" $reactions}} {{template "repo/issue/view_content/reactions" Dict "ctxData" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID) "Reactions" $reactions}}
</div> </div>
{{end}} {{end}}
</div> </div>
@ -563,8 +563,8 @@
</div> </div>
{{end}} {{end}}
{{if not $.Repository.IsArchived}} {{if not $.Repository.IsArchived}}
{{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID)}} {{template "repo/issue/view_content/add_reaction" Dict "ctxData" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID)}}
{{template "repo/issue/view_content/context_menu" Dict "ctx" $ "item" . "delete" true "issue" true "diff" true "IsCommentPoster" (and $.IsSigned (eq $.SignedUserID .PosterID))}} {{template "repo/issue/view_content/context_menu" Dict "ctxData" $ "item" . "delete" true "issue" true "diff" true "IsCommentPoster" (and $.IsSigned (eq $.SignedUserID .PosterID))}}
{{end}} {{end}}
</div> </div>
</div> </div>
@ -582,7 +582,7 @@
{{$reactions := .Reactions.GroupByType}} {{$reactions := .Reactions.GroupByType}}
{{if $reactions}} {{if $reactions}}
<div class="ui attached segment reactions"> <div class="ui attached segment reactions">
{{template "repo/issue/view_content/reactions" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID) "Reactions" $reactions}} {{template "repo/issue/view_content/reactions" Dict "ctxData" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID) "Reactions" $reactions}}
</div> </div>
{{end}} {{end}}
</div> </div>

View File

@ -1,18 +1,18 @@
{{if .comment.Time}} {{/* compatibility with time comments made before v1.14 */}} {{if .comment.Time}} {{/* compatibility with time comments made before v1.14 */}}
{{if (not .comment.Time.Deleted)}} {{if (not .comment.Time.Deleted)}}
{{if (or .ctx.IsAdmin (and .ctx.IsSigned (eq .ctx.SignedUserID .comment.PosterID)))}} {{if (or .ctxData.IsAdmin (and .ctxData.IsSigned (eq .ctxData.SignedUserID .comment.PosterID)))}}
<span class="ui float right"> <span class="ui float right">
<div class="ui mini modal issue-delete-time-modal" data-id="{{.comment.Time.ID}}"> <div class="ui mini modal issue-delete-time-modal" data-id="{{.comment.Time.ID}}">
<form method="POST" class="delete-time-form" action="{{.ctx.RepoLink}}/issues/{{.ctx.Issue.Index}}/times/{{.comment.TimeID}}/delete"> <form method="POST" class="delete-time-form" action="{{.ctxData.RepoLink}}/issues/{{.ctxData.Issue.Index}}/times/{{.comment.TimeID}}/delete">
{{.ctx.CsrfTokenHtml}} {{.ctxData.CsrfTokenHtml}}
</form> </form>
<div class="header">{{.ctx.locale.Tr "repo.issues.del_time"}}</div> <div class="header">{{.ctxData.locale.Tr "repo.issues.del_time"}}</div>
<div class="actions"> <div class="actions">
<div class="ui red approve button">{{.ctx.locale.Tr "repo.issues.context.delete"}}</div> <div class="ui red approve button">{{.ctxData.locale.Tr "repo.issues.context.delete"}}</div>
<div class="ui cancel button">{{.ctx.locale.Tr "repo.issues.add_time_cancel"}}</div> <div class="ui cancel button">{{.ctxData.locale.Tr "repo.issues.add_time_cancel"}}</div>
</div> </div>
</div> </div>
<button class="ui icon button compact mini issue-delete-time tooltip" data-id="{{.comment.Time.ID}}" data-content="{{.ctx.locale.Tr "repo.issues.del_time"}}" data-position="top right"> <button class="ui icon button compact mini issue-delete-time tooltip" data-id="{{.comment.Time.ID}}" data-content="{{.ctxData.locale.Tr "repo.issues.del_time"}}" data-position="top right">
{{svg "octicon-trash"}} {{svg "octicon-trash"}}
</button> </button>
</span> </span>

View File

@ -1,4 +1,4 @@
{{if .ctx.IsSigned}} {{if .ctxData.IsSigned}}
<div class="item action ui pointing custom dropdown top right context-dropdown"> <div class="item action ui pointing custom dropdown top right context-dropdown">
<a class="context-menu"> <a class="context-menu">
{{svg "octicon-kebab-horizontal"}} {{svg "octicon-kebab-horizontal"}}
@ -6,20 +6,20 @@
<div class="menu"> <div class="menu">
{{$referenceUrl := ""}} {{$referenceUrl := ""}}
{{if .issue}} {{if .issue}}
{{$referenceUrl = Printf "%s#%s" .ctx.Issue.Link .item.HashTag}} {{$referenceUrl = Printf "%s#%s" .ctxData.Issue.Link .item.HashTag}}
{{else}} {{else}}
{{$referenceUrl = Printf "%s/files#%s" .ctx.Issue.Link .item.HashTag}} {{$referenceUrl = Printf "%s/files#%s" .ctxData.Issue.Link .item.HashTag}}
{{end}} {{end}}
<a class="item context" data-clipboard-text-type="url" data-clipboard-text="{{AppSubUrl}}{{$referenceUrl}}">{{.ctx.locale.Tr "repo.issues.context.copy_link"}}</a> <a class="item context" data-clipboard-text-type="url" data-clipboard-text="{{AppSubUrl}}{{$referenceUrl}}">{{.ctxData.locale.Tr "repo.issues.context.copy_link"}}</a>
<a class="item context quote-reply {{if .diff}}quote-reply-diff{{end}}" data-target="{{.item.HashTag}}-raw">{{.ctx.locale.Tr "repo.issues.context.quote_reply"}}</a> <a class="item context quote-reply {{if .diff}}quote-reply-diff{{end}}" data-target="{{.item.HashTag}}-raw">{{.ctxData.locale.Tr "repo.issues.context.quote_reply"}}</a>
{{if not .ctx.UnitIssuesGlobalDisabled}} {{if not .ctxData.UnitIssuesGlobalDisabled}}
<a class="item context reference-issue" data-target="{{.item.HashTag}}-raw" data-modal="#reference-issue-modal" data-poster="{{.item.Poster.GetDisplayName}}" data-poster-username="{{.item.Poster.Name}}" data-reference="{{$referenceUrl}}">{{.ctx.locale.Tr "repo.issues.context.reference_issue"}}</a> <a class="item context reference-issue" data-target="{{.item.HashTag}}-raw" data-modal="#reference-issue-modal" data-poster="{{.item.Poster.GetDisplayName}}" data-poster-username="{{.item.Poster.Name}}" data-reference="{{$referenceUrl}}">{{.ctxData.locale.Tr "repo.issues.context.reference_issue"}}</a>
{{end}} {{end}}
{{if or .ctx.Permission.IsAdmin .IsCommentPoster .ctx.HasIssuesOrPullsWritePermission}} {{if or .ctxData.Permission.IsAdmin .IsCommentPoster .ctxData.HasIssuesOrPullsWritePermission}}
<div class="divider"></div> <div class="divider"></div>
<a class="item context edit-content">{{.ctx.locale.Tr "repo.issues.context.edit"}}</a> <a class="item context edit-content">{{.ctxData.locale.Tr "repo.issues.context.edit"}}</a>
{{if .delete}} {{if .delete}}
<a class="item context delete-comment" data-comment-id={{.item.HashTag}} data-url="{{.ctx.RepoLink}}/comments/{{.item.ID}}/delete" data-locale="{{.ctx.locale.Tr "repo.issues.delete_comment_confirm"}}">{{.ctx.locale.Tr "repo.issues.context.delete"}}</a> <a class="item context delete-comment" data-comment-id={{.item.HashTag}} data-url="{{.ctxData.RepoLink}}/comments/{{.item.ID}}/delete" data-locale="{{.ctxData.locale.Tr "repo.issues.delete_comment_confirm"}}">{{.ctxData.locale.Tr "repo.issues.context.delete"}}</a>
{{end}} {{end}}
{{end}} {{end}}
</div> </div>

View File

@ -1,9 +1,9 @@
{{range $key, $value := .Reactions}} {{range $key, $value := .Reactions}}
<a class="ui label basic{{if $value.HasUser $.ctx.SignedUserID}} primary{{end}}{{if not $.ctx.IsSigned}} disabled{{end}}" data-title="{{$value.GetFirstUsers}}{{if gt ($value.GetMoreUserCount) 0}} {{$.ctx.locale.Tr "repo.reactions_more" $value.GetMoreUserCount}}{{end}}" data-content="{{$key}}" data-action-url="{{$.ActionURL}}"> <a class="ui label basic{{if $value.HasUser $.ctxData.SignedUserID}} primary{{end}}{{if not $.ctxData.IsSigned}} disabled{{end}}" data-title="{{$value.GetFirstUsers}}{{if gt ($value.GetMoreUserCount) 0}} {{$.ctxData.locale.Tr "repo.reactions_more" $value.GetMoreUserCount}}{{end}}" data-content="{{$key}}" data-action-url="{{$.ActionURL}}">
<span class="reaction">{{ReactionToEmoji $key}}</span> <span class="reaction">{{ReactionToEmoji $key}}</span>
<span class="reaction-count">{{len $value}}</span> <span class="reaction-count">{{len $value}}</span>
</a> </a>
{{end}} {{end}}
{{if AllowedReactions}} {{if AllowedReactions}}
{{template "repo/issue/view_content/add_reaction" Dict "ctx" $.ctx "ActionURL" .ActionURL}} {{template "repo/issue/view_content/add_reaction" Dict "ctxData" $.ctxData "ActionURL" .ActionURL}}
{{end}} {{end}}

View File

@ -149,7 +149,7 @@
{{end}} {{end}}
</div> </div>
</div> </div>
{{template "repo/issue/labels/labels_sidebar" dict "root" $ "ctx" .}} {{template "repo/issue/labels/labels_sidebar" dict "root" $}}
<div class="ui divider"></div> <div class="ui divider"></div>