{{/* 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">
		{{$statusCheckData.CommitStatusCheckPrompt ctx.Locale}}

		{{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-left-right" 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="tw-text-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 tw-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}}
