Files
gitea/templates/repo/pulls/status.tmpl
Zettat123 897e48dde3 Add quick approve button on PR page (#35678)
This PR adds a quick approve button on PR page to allow reviewers to
approve all pending checks. Only users with write permission to the 
Actions unit can approve.

---------

Signed-off-by: Zettat123 <zettat123@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-10-20 18:46:37 +08:00

76 lines
3.0 KiB
Handlebars

{{/* Template Attributes:
* CommitStatus: summary of all commit status state
* CommitStatuses: all commit status elements
* ShowHideChecks: whether use a button to show/hide the checks
* StatusCheckData: additional status check data, see backend pullCommitStatusCheckData struct
*/}}
{{$statusCheckData := .StatusCheckData}}
{{if .CommitStatus}}
<div class="commit-status-panel">
<div class="ui top attached header commit-status-header">
{{if or (eq .CommitStatus.State "pending") (.MissingRequiredChecks)}}
{{ctx.Locale.Tr "repo.pulls.status_checking"}}
{{else if eq .CommitStatus.State "success"}}
{{ctx.Locale.Tr "repo.pulls.status_checks_success"}}
{{else if eq .CommitStatus.State "warning"}}
{{ctx.Locale.Tr "repo.pulls.status_checks_warning"}}
{{else if eq .CommitStatus.State "failure"}}
{{ctx.Locale.Tr "repo.pulls.status_checks_failure"}}
{{else if eq .CommitStatus.State "error"}}
{{ctx.Locale.Tr "repo.pulls.status_checks_error"}}
{{else}}
{{ctx.Locale.Tr "repo.pulls.status_checking"}}
{{end}}
{{if .ShowHideChecks}}
<div class="ui right">
<button class="commit-status-hide-checks btn interact-fg"
data-show-all="{{ctx.Locale.Tr "repo.pulls.status_checks_show_all"}}"
data-hide-all="{{ctx.Locale.Tr "repo.pulls.status_checks_hide_all"}}">
{{ctx.Locale.Tr "repo.pulls.status_checks_hide_all"}}</button>
</div>
{{end}}
</div>
{{if and $statusCheckData $statusCheckData.RequireApprovalRunCount}}
<div class="ui attached segment flex-text-block tw-justify-between" id="approve-status-checks">
<div>
<strong>
{{ctx.Locale.Tr "repo.pulls.status_checks_need_approvals" $statusCheckData.RequireApprovalRunCount}}
</strong>
<p>{{ctx.Locale.Tr "repo.pulls.status_checks_need_approvals_helper"}}</p>
</div>
{{if $statusCheckData.CanApprove}}
<button class="ui basic button link-action" data-url="{{$statusCheckData.ApproveLink}}">
{{ctx.Locale.Tr "repo.pulls.status_checks_approve_all"}}
</button>
{{end}}
</div>
{{end}}
<div class="commit-status-list">
{{range .CommitStatuses}}
<div class="commit-status-item">
{{template "repo/commit_status" .}}
<div class="status-context gt-ellipsis">{{.Context}} <span class="text light-2">{{.Description}}</span></div>
<div class="ui status-details">
{{if and $statusCheckData $statusCheckData.IsContextRequired}}
{{if (call $statusCheckData.IsContextRequired .Context)}}<div class="ui label">{{ctx.Locale.Tr "repo.pulls.status_checks_requested"}}</div>{{end}}
{{end}}
<span>{{if .TargetURL}}<a href="{{.TargetURL}}">{{ctx.Locale.Tr "repo.pulls.status_checks_details"}}</a>{{end}}</span>
</div>
</div>
{{end}}
{{if $statusCheckData}}
{{range $statusCheckData.MissingRequiredChecks}}
<div class="commit-status-item">
{{svg "octicon-dot-fill" 18 "commit-status icon text yellow"}}
<div class="status-context gt-ellipsis">{{.}}</div>
<div class="ui label">{{ctx.Locale.Tr "repo.pulls.status_checks_requested"}}</div>
</div>
{{end}}
{{end}}
</div>
</div>
{{end}}