Files
gitea/templates/repo/issue/view_content.tmpl
wxiaoguang 6ba907d89c Fix various problems (#37547)
1. Fix ugly commit form "warning" message
2. Use JSONError for "Update PR Branch" response 
3. Remove useless "timeline" class
4. Make timeline review default to "comment" to avoid icon missing
5. Align PR's "command line instructions" UI
6. Simply "Update PR branch" button logic

And then some TODOs are fixed.

---------

Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
2026-05-05 15:54:07 +00:00

185 lines
8.0 KiB
Handlebars

<div class="issue-content">
{{$createdStr:= DateUtils.TimeSince .Issue.CreatedUnix}}
<div class="issue-content-left">
<div class="comment-list">
<div id="{{.Issue.HashTag}}" class="timeline-item comment issue-content-comment">
{{if .Issue.OriginalAuthor}}
<span class="timeline-avatar">
{{ctx.AvatarUtils.Avatar nil 40}}
</span>
{{else}}
<a class="timeline-avatar" {{if gt .Issue.Poster.ID 0}}href="{{.Issue.Poster.HomeLink}}"{{end}}>
{{ctx.AvatarUtils.Avatar .Issue.Poster 40}}
</a>
{{end}}
<div class="content comment-container">
<div class="comment-header avatar-content-left-arrow" role="heading" aria-level="3">
<div class="comment-header-left">
{{if .Issue.OriginalAuthor}}
<span class="tw-text-text tw-font-semibold">
{{svg (MigrationIcon .Repository.GetOriginalURLHostname)}}
{{.Issue.OriginalAuthor}}
</span>
<span class="tw-text-text-light muted-links">
{{ctx.Locale.Tr "repo.issues.commented_at" .Issue.HashTag $createdStr}}
</span>
<span class="text migrate">
{{if .Repository.OriginalURL}} ({{ctx.Locale.Tr "repo.migrated_from" .Repository.OriginalURL .Repository.GetOriginalURLHostname}}){{end}}
</span>
{{else}}
<a class="inline-timeline-avatar" href="{{.Issue.Poster.HomeLink}}">
{{ctx.AvatarUtils.Avatar .Issue.Poster 24}}
</a>
<span class="tw-text-text-light muted-links">
{{template "shared/user/authorlink" .Issue.Poster}}
{{ctx.Locale.Tr "repo.issues.commented_at" .Issue.HashTag $createdStr}}
</span>
{{end}}
</div>
<div class="comment-header-right">
{{template "repo/issue/view_content/show_role" dict "ShowRole" .Issue.ShowRole "IgnorePoster" true}}
{{if not $.Repository.IsArchived}}
{{template "repo/issue/view_content/add_reaction" dict "ActionURL" (printf "%s/issues/%d/reactions" $.RepoLink .Issue.Index)}}
{{end}}
{{template "repo/issue/view_content/context_menu" dict "item" .Issue "delete" false "issue" true "diff" false "IsCommentPoster" $.IsIssuePoster}}
</div>
</div>
<div class="ui attached segment comment-body" role="article">
<div class="render-content markup" {{if or $.Permission.IsAdmin $.HasIssuesOrPullsWritePermission $.IsIssuePoster}}data-can-edit="true"{{end}}>
{{if .Issue.RenderedContent}}
{{.Issue.RenderedContent}}
{{else}}
<span class="no-content">{{ctx.Locale.Tr "repo.issues.no_content"}}</span>
{{end}}
</div>
<div id="{{.Issue.HashTag}}-raw" class="raw-content tw-hidden">{{.Issue.Content}}</div>
<div class="edit-content-zone tw-hidden" data-update-url="{{$.RepoLink}}/issues/{{.Issue.Index}}/content" data-content-version="{{.Issue.ContentVersion}}" 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}}
{{template "repo/issue/view_content/attachments" dict "Attachments" .Issue.Attachments "RenderedContent" .Issue.RenderedContent}}
{{end}}
</div>
{{$reactions := .Issue.Reactions.GroupByType}}
{{if $reactions}}
{{template "repo/issue/view_content/reactions" dict "ActionURL" (printf "%s/issues/%d/reactions" $.RepoLink .Issue.Index) "Reactions" $reactions}}
{{end}}
</div>
</div>
{{template "repo/issue/view_content/comments" .}}
<div class="timeline-item tw-hidden" id="timeline-comments-end"></div>
{{if and .Issue.IsPull (not $.Repository.IsArchived)}}
{{template "repo/issue/view_content/pull_merge_box".}}
{{end}}
{{if .IsSigned}}
{{if and (or .IsRepoAdmin .HasIssuesOrPullsWritePermission (not .Issue.IsLocked)) (not .Repository.IsArchived)}}
<div class="timeline-item comment form">
<a class="timeline-avatar" href="{{.SignedUser.HomeLink}}">
{{ctx.AvatarUtils.Avatar .SignedUser 40}}
</a>
<div class="content">
<div class="ui segment avatar-content-left-arrow">
<form class="ui form form-fetch-action" id="comment-form" action="{{$.RepoLink}}/issues/{{.Issue.Index}}/comments" method="post">
{{template "repo/issue/comment_tab" .}}
<div class="field footer">
<div class="flex-text-block tw-justify-end">
{{if and (or .HasIssuesOrPullsWritePermission .IsIssuePoster) (not .DisableStatusChange)}}
{{$btnIconColor := ""}}{{$btnIcon := ""}}{{$btnTextNoComment := ""}}{{$btnTextWithComment := ""}}{{$btnValue := ""}}
{{if .Issue.IsClosed}}
{{$btnValue = "reopen"}}
{{$btnIconColor = "tw-text-green"}}
{{$btnIcon = Iif .Issue.IsPull "octicon-git-pull-request" "octicon-issue-reopened"}}
{{$btnTextNoComment = ctx.Locale.Tr (Iif .Issue.IsPull "repo.pulls.reopen" "repo.issues.reopen_issue")}}
{{$btnTextWithComment = ctx.Locale.Tr "repo.issues.reopen_comment_issue"}}{{/* general: Reopen with Comment */}}
{{else}}
{{$btnValue = "close"}}
{{$btnIconColor = "tw-text-red"}}
{{$btnIcon = Iif .Issue.IsPull "octicon-git-pull-request-closed" "octicon-issue-closed"}}
{{$btnTextNoComment = ctx.Locale.Tr (Iif .Issue.IsPull "repo.pulls.close" "repo.issues.close")}}
{{$btnTextWithComment = ctx.Locale.Tr "repo.issues.close_comment_issue"}}{{/* general: Close with Comment */}}
{{end}}
<button id="status-button" class="ui button" data-status="{{$btnTextNoComment}}" data-status-and-comment="{{$btnTextWithComment}}" name="status" value="{{$btnValue}}">
<span class="status-button-icon {{$btnIconColor}}">{{svg $btnIcon}}</span>
<span class="status-button-text">{{$btnTextNoComment}}</span>
</button>
{{end}}
<button id="comment-button" class="ui primary button">
{{ctx.Locale.Tr "repo.issues.create_comment"}}
</button>
</div>
</div>
</form>
</div>
</div>
</div>
{{else if .Repository.IsArchived}}
<div class="ui warning message tw-text-center">
{{if .Issue.IsPull}}
{{ctx.Locale.Tr "repo.archive.pull.nocomment"}}
{{else}}
{{ctx.Locale.Tr "repo.archive.issue.nocomment"}}
{{end}}
</div>
{{end}}
{{else}} {{/* not .IsSigned */}}
{{if .Repository.IsArchived}}
<div class="ui warning message tw-text-center">
{{if .Issue.IsPull}}
{{ctx.Locale.Tr "repo.archive.pull.nocomment"}}
{{else}}
{{ctx.Locale.Tr "repo.archive.issue.nocomment"}}
{{end}}
</div>
{{else}}
<div class="ui warning message">
{{ctx.Locale.Tr "repo.issues.sign_in_require_desc" .SignInLink}}
</div>
{{end}}
{{end}}{{/* end if: .IsSigned */}}
</div>
</div>
{{template "repo/issue/view_content/sidebar" .}}
</div>
<template id="issue-comment-editor-template">
<form class="ui form comment">
<div class="field">
{{template "shared/combomarkdowneditor" (dict
"CustomInit" true
"MarkdownEditorContext" (ctx.MiscUtils.MarkdownEditorComment $.Repository)
"TextareaName" "content"
"DropzoneParentContainer" ".ui.form"
)}}
</div>
{{if .IsAttachmentEnabled}}
<div class="field">
{{template "repo/upload" .}}
</div>
{{end}}
<div class="field">
<div class="flex-text-block tw-justify-end">
<button type="button" class="ui cancel button">{{ctx.Locale.Tr "repo.issues.cancel"}}</button>
<button type="submit" class="ui primary button">{{ctx.Locale.Tr "repo.issues.save"}}</button>
</div>
</div>
</form>
</template>
{{template "repo/issue/view_content/reference_issue_dialog" .}}
{{template "shared/user/block_user_dialog" .}}
<div class="ui g-modal-confirm delete modal">
<div class="header">
{{svg "octicon-trash"}}
{{ctx.Locale.Tr "repo.branch.delete" .HeadTarget}}
</div>
<div class="content">
<p>{{ctx.Locale.Tr "repo.branch.delete_desc"}}</p>
</div>
{{template "base/modal_actions_confirm" .}}
</div>