Use JSON attribute instead of inline script --------- Co-authored-by: Nicolas <bircni@icloud.com>
317 lines
12 KiB
Handlebars
317 lines
12 KiB
Handlebars
{{$data := $.PullMergeBoxData}}
|
|
{{if $data.ShowMergeBox}}
|
|
<div class="timeline-item comment pull-merge-box"
|
|
data-global-init="initRepoPullMergeBox"
|
|
{{if $data.ReloadingInterval}}
|
|
data-pull-merge-box-reloading-interval="{{$data.ReloadingInterval}}"
|
|
data-pull-link="{{$.Issue.Link}}"
|
|
{{end}}
|
|
>
|
|
{{$statusCheckData := .StatusCheckData}}
|
|
{{$requiredStatusCheckState := $statusCheckData.RequiredChecksState}}
|
|
<div class="timeline-avatar {{if .Issue.PullRequest.HasMerged}}tw-text-purple
|
|
{{- else if .Issue.IsClosed}}tw-text-text-light
|
|
{{- else if .IsPullWorkInProgress}}tw-text-text-light
|
|
{{- else if .IsFilesConflicted}}tw-text-text-light
|
|
{{- else if .IsPullRequestBroken}}tw-text-red
|
|
{{- else if .IsBlockedByApprovals}}tw-text-red
|
|
{{- else if .IsBlockedByRejection}}tw-text-red
|
|
{{- else if .IsBlockedByOfficialReviewRequests}}tw-text-red
|
|
{{- else if .IsBlockedByOutdatedBranch}}tw-text-red
|
|
{{- else if .IsBlockedByChangedProtectedFiles}}tw-text-red
|
|
{{- else if and .EnableStatusCheck (or $requiredStatusCheckState.IsFailure $requiredStatusCheckState.IsError)}}tw-text-red
|
|
{{- else if and .EnableStatusCheck (or (not $.LatestCommitStatus) $requiredStatusCheckState.IsPending $requiredStatusCheckState.IsWarning)}}tw-text-yellow
|
|
{{- else if and .AllowMerge .RequireSigned (not .WillSign)}}tw-text-red
|
|
{{- else if .Issue.PullRequest.IsChecking}}tw-text-yellow
|
|
{{- else if .Issue.PullRequest.IsEmpty}}tw-text-text-light
|
|
{{- else if .Issue.PullRequest.IsStatusMergeable}}tw-text-green
|
|
{{- else}}tw-text-red{{end}}">{{svg "octicon-git-merge" 40}}</div>
|
|
<div class="content">
|
|
{{if .LatestCommitStatus}}
|
|
<div class="ui attached segment fitted">
|
|
{{template "repo/pulls/status" (dict
|
|
"CommitStatus" .LatestCommitStatus
|
|
"CommitStatuses" .LatestCommitStatuses
|
|
"ShowHideChecks" true
|
|
"StatusCheckData" $statusCheckData
|
|
)}}
|
|
</div>
|
|
{{end}}
|
|
{{$showGeneralMergeForm := false}}
|
|
<div class="ui attached segment merge-section {{if not $.LatestCommitStatus}}avatar-content-left-arrow{{end}} flex-items-block">
|
|
{{if .Issue.PullRequest.HasMerged}}
|
|
{{if .IsPullBranchDeletable}}
|
|
<div class="item item-section text tw-flex-1">
|
|
<div class="item-section-left">
|
|
<h3 class="tw-mb-2">
|
|
{{ctx.Locale.Tr "repo.pulls.merged_success"}}
|
|
</h3>
|
|
<div class="merge-section-info">
|
|
{{ctx.Locale.Tr "repo.pulls.merged_info_text" (HTMLFormat "<code>%s</code>" .HeadTarget)}}
|
|
</div>
|
|
</div>
|
|
<div class="item-section-right">
|
|
<button class="ui button link-action delete-branch-after-merge" data-url="{{.DeleteBranchLink}}">{{ctx.Locale.Tr "repo.branch.delete_html"}}</button>
|
|
</div>
|
|
</div>
|
|
{{end}}
|
|
{{else if .Issue.IsClosed}}
|
|
<div class="item item-section text tw-flex-1">
|
|
<div class="item-section-left">
|
|
<h3 class="tw-mb-2">{{ctx.Locale.Tr "repo.pulls.closed"}}</h3>
|
|
<div class="merge-section-info">
|
|
{{if .IsPullRequestBroken}}
|
|
{{ctx.Locale.Tr "repo.pulls.cant_reopen_deleted_branch"}}
|
|
{{else}}
|
|
{{ctx.Locale.Tr "repo.pulls.reopen_to_merge"}}
|
|
{{end}}
|
|
</div>
|
|
</div>
|
|
{{if and .IsPullBranchDeletable (not .IsPullRequestBroken)}}
|
|
<div class="item-section-right">
|
|
<button class="ui button link-action delete-branch-after-merge" data-url="{{.DeleteBranchLink}}">{{ctx.Locale.Tr "repo.branch.delete_html"}}</button>
|
|
</div>
|
|
{{end}}
|
|
</div>
|
|
{{else if .IsPullFilesConflicted}}
|
|
<div class="item">
|
|
{{svg "octicon-x"}}
|
|
{{ctx.Locale.Tr "repo.pulls.files_conflicted"}}
|
|
</div>
|
|
<ul>
|
|
{{range .ConflictedFiles}}
|
|
<li>{{.}}</li>
|
|
{{else}}
|
|
<li>{{ctx.Locale.Tr "repo.pulls.files_conflicted_no_listed_files"}}</li>
|
|
{{end}}
|
|
</ul>
|
|
{{else if .IsPullRequestBroken}}
|
|
<div class="item">
|
|
{{svg "octicon-x"}}
|
|
{{ctx.Locale.Tr "repo.pulls.data_broken"}}
|
|
</div>
|
|
{{else if .IsPullWorkInProgress}}
|
|
<div class="item">
|
|
<div class="item-section-left flex-text-inline tw-flex-1">
|
|
{{svg "octicon-x"}}
|
|
{{ctx.Locale.Tr "repo.pulls.cannot_merge_work_in_progress"}}
|
|
</div>
|
|
{{if or .HasIssuesOrPullsWritePermission .IsIssuePoster}}
|
|
<button class="ui compact button" data-global-init="initPullRequestWipToggle" data-title="{{.Issue.Title}}" data-wip-prefix="{{.WorkInProgressPrefix}}" data-update-url="{{.Issue.Link}}/title">
|
|
{{ctx.Locale.Tr "repo.pulls.remove_prefix" .WorkInProgressPrefix}}
|
|
</button>
|
|
{{end}}
|
|
</div>
|
|
{{template "repo/issue/view_content/update_branch_by_merge" $}}
|
|
{{else if .Issue.PullRequest.IsChecking}}
|
|
<div class="item">
|
|
{{svg "gitea-running" 16 "rotate-clockwise"}}
|
|
{{ctx.Locale.Tr "repo.pulls.is_checking"}}
|
|
</div>
|
|
{{else if .Issue.PullRequest.IsAncestor}}
|
|
<div class="item">
|
|
{{svg "octicon-alert"}}
|
|
{{ctx.Locale.Tr "repo.pulls.is_ancestor"}}
|
|
</div>
|
|
{{else if or .Issue.PullRequest.IsStatusMergeable .Issue.PullRequest.IsEmpty}}
|
|
{{if .IsBlockedByApprovals}}
|
|
<div class="item">
|
|
{{svg "octicon-x"}}
|
|
{{if .RequireApprovalsWhitelist}}
|
|
{{ctx.Locale.Tr "repo.pulls.blocked_by_approvals_whitelisted" .GrantedApprovals .ProtectedBranch.RequiredApprovals}}
|
|
{{else}}
|
|
{{ctx.Locale.Tr "repo.pulls.blocked_by_approvals" .GrantedApprovals .ProtectedBranch.RequiredApprovals}}
|
|
{{end}}
|
|
</div>
|
|
{{else if .IsBlockedByRejection}}
|
|
<div class="item">
|
|
{{svg "octicon-x"}}
|
|
{{ctx.Locale.Tr "repo.pulls.blocked_by_rejection"}}
|
|
</div>
|
|
{{else if .IsBlockedByOfficialReviewRequests}}
|
|
<div class="item">
|
|
{{svg "octicon-x"}}
|
|
{{ctx.Locale.Tr "repo.pulls.blocked_by_official_review_requests"}}
|
|
</div>
|
|
{{else if .IsBlockedByOutdatedBranch}}
|
|
<div class="item">
|
|
{{svg "octicon-x"}}
|
|
{{ctx.Locale.Tr "repo.pulls.blocked_by_outdated_branch"}}
|
|
</div>
|
|
{{else if .IsBlockedByChangedProtectedFiles}}
|
|
<div class="item">
|
|
{{svg "octicon-x"}}
|
|
{{ctx.Locale.TrN $.ChangedProtectedFilesNum "repo.pulls.blocked_by_changed_protected_files_1" "repo.pulls.blocked_by_changed_protected_files_n"}}
|
|
</div>
|
|
<ul>
|
|
{{range .ChangedProtectedFiles}}
|
|
<li>{{.}}</li>
|
|
{{end}}
|
|
</ul>
|
|
{{else if and .EnableStatusCheck (or $requiredStatusCheckState.IsError $requiredStatusCheckState.IsFailure)}}
|
|
<div class="item">
|
|
{{svg "octicon-x"}}
|
|
{{ctx.Locale.Tr "repo.pulls.required_status_check_failed"}}
|
|
</div>
|
|
{{else if and .EnableStatusCheck (not $requiredStatusCheckState.IsSuccess)}}
|
|
<div class="item">
|
|
{{svg "octicon-x"}}
|
|
{{ctx.Locale.Tr "repo.pulls.required_status_check_missing"}}
|
|
</div>
|
|
{{else if and .AllowMerge .RequireSigned (not .WillSign)}}
|
|
<div class="item">
|
|
{{svg "octicon-x"}}
|
|
{{ctx.Locale.Tr "repo.pulls.require_signed_wont_sign"}}
|
|
</div>
|
|
<div class="item">
|
|
{{svg "octicon-unlock"}}
|
|
{{ctx.Locale.Tr (printf "repo.signing.wont_sign.%s" .WontSignReason)}}
|
|
</div>
|
|
{{end}}
|
|
|
|
{{$notAllOverridableChecksOk := $data.HasOverridableBlockers}}
|
|
{{$canMergeNow := $data.CanMergeNow}}
|
|
|
|
{{if $canMergeNow}}
|
|
{{if $notAllOverridableChecksOk}}
|
|
<div class="item">
|
|
{{svg "octicon-dot-fill"}}
|
|
{{ctx.Locale.Tr "repo.pulls.required_status_check_administrator"}}
|
|
</div>
|
|
{{else}}
|
|
<div class="item">
|
|
{{svg "octicon-check"}}
|
|
{{ctx.Locale.Tr "repo.pulls.can_auto_merge_desc"}}
|
|
</div>
|
|
{{end}}
|
|
{{if .WillSign}}
|
|
<div class="item">
|
|
{{svg "octicon-lock" 16 "tw-text-green"}}
|
|
{{ctx.Locale.Tr "repo.signing.will_sign" .SigningKeyMergeDisplay}}
|
|
</div>
|
|
{{else if .IsSigned}}
|
|
<div class="item">
|
|
{{svg "octicon-unlock"}}
|
|
{{ctx.Locale.Tr (printf "repo.signing.wont_sign.%s" .WontSignReason)}}
|
|
</div>
|
|
{{end}}
|
|
{{end}}
|
|
|
|
{{template "repo/issue/view_content/update_branch_by_merge" $}}
|
|
|
|
{{if .Issue.PullRequest.IsEmpty}}
|
|
<div class="divider"></div>
|
|
<div class="item">
|
|
{{svg "octicon-alert"}}
|
|
{{ctx.Locale.Tr "repo.pulls.is_empty"}}
|
|
</div>
|
|
{{end}}
|
|
|
|
{{if .AllowMerge}} {{/* user is allowed to merge */}}
|
|
{{if $data.MergeFormProps}}
|
|
<div class="divider"></div>
|
|
{{$showGeneralMergeForm = true}}
|
|
{{/* The merge form is a Vue component. After mounted, it has a button for choosing merge style, so make it have min-height to avoid layout shifting */}}
|
|
<div id="pull-request-merge-form" class="tw-min-h-[40px]" data-merge-form-props="{{JsonUtils.EncodeToString $data.MergeFormProps}}"></div>
|
|
{{else}}
|
|
{{/* no merge style was set in repo setting: not or ($prUnit.PullRequestsConfig.AllowMerge ...) */}}
|
|
<div class="divider"></div>
|
|
<div class="item tw-text-red">
|
|
{{svg "octicon-x"}}
|
|
{{ctx.Locale.Tr "repo.pulls.no_merge_desc"}}
|
|
</div>
|
|
<div class="item">
|
|
{{svg "octicon-info"}}
|
|
{{ctx.Locale.Tr "repo.pulls.no_merge_helper"}}
|
|
</div>
|
|
{{end}} {{/* end if the repo was set to use any merge style */}}
|
|
{{else}}
|
|
{{/* user is not allowed to merge */}}
|
|
<div class="divider"></div>
|
|
<div class="item">
|
|
{{svg "octicon-info"}}
|
|
{{ctx.Locale.Tr "repo.pulls.no_merge_access"}}
|
|
</div>
|
|
{{end}} {{/* end if user is allowed to merge or not */}}
|
|
{{else}}
|
|
{{/* Merge conflict without specific file. Suggest manual merge, only if all reviews and status checks OK. */}}
|
|
{{if .IsBlockedByApprovals}}
|
|
<div class="item tw-text-red">
|
|
{{svg "octicon-x"}}
|
|
{{ctx.Locale.Tr "repo.pulls.blocked_by_approvals" .GrantedApprovals .ProtectedBranch.RequiredApprovals}}
|
|
</div>
|
|
{{else if .IsBlockedByRejection}}
|
|
<div class="item tw-text-red">
|
|
{{svg "octicon-x"}}
|
|
{{ctx.Locale.Tr "repo.pulls.blocked_by_rejection"}}
|
|
</div>
|
|
{{else if .IsBlockedByOfficialReviewRequests}}
|
|
<div class="item tw-text-red">
|
|
{{svg "octicon-x"}}
|
|
{{ctx.Locale.Tr "repo.pulls.blocked_by_official_review_requests"}}
|
|
</div>
|
|
{{else if .IsBlockedByOutdatedBranch}}
|
|
<div class="item tw-text-red">
|
|
{{svg "octicon-x"}}
|
|
{{ctx.Locale.Tr "repo.pulls.blocked_by_outdated_branch"}}
|
|
</div>
|
|
{{else if .IsBlockedByChangedProtectedFiles}}
|
|
<div class="item tw-text-red">
|
|
{{svg "octicon-x"}}
|
|
{{ctx.Locale.TrN $.ChangedProtectedFilesNum "repo.pulls.blocked_by_changed_protected_files_1" "repo.pulls.blocked_by_changed_protected_files_n"}}
|
|
</div>
|
|
<ul>
|
|
{{range .ChangedProtectedFiles}}
|
|
<li>{{.}}</li>
|
|
{{end}}
|
|
</ul>
|
|
{{else if and .EnableStatusCheck (not $requiredStatusCheckState.IsSuccess)}}
|
|
<div class="item tw-text-red">
|
|
{{svg "octicon-x"}}
|
|
{{ctx.Locale.Tr "repo.pulls.required_status_check_failed"}}
|
|
</div>
|
|
{{else if and .RequireSigned (not .WillSign)}}
|
|
<div class="item tw-text-red">
|
|
{{svg "octicon-x"}}
|
|
{{ctx.Locale.Tr "repo.pulls.require_signed_wont_sign"}}
|
|
</div>
|
|
{{else}}
|
|
<div class="item tw-text-red">
|
|
{{svg "octicon-x"}}
|
|
{{ctx.Locale.Tr "repo.pulls.cannot_auto_merge_desc"}}
|
|
</div>
|
|
<div class="item">
|
|
{{svg "octicon-info"}}
|
|
{{ctx.Locale.Tr "repo.pulls.cannot_auto_merge_helper"}}
|
|
</div>
|
|
{{end}}
|
|
{{end}}{{/* end if: pull request status */}}
|
|
|
|
{{/* Manually Merged is not a well-known feature, it is used to mark a non-mergeable PR (already merged, conflicted) as merged
|
|
To test it:
|
|
* Enable "Manually Merged" feature in the Repository Settings
|
|
* Create a pull request, either:
|
|
* - Merge the pull request branch locally and push the merged commit to Gitea
|
|
* - Make some conflicts between the base branch and the pull request branch
|
|
* Then the Manually Merged form will be shown in the merge form
|
|
*/}}
|
|
{{if and $.StillCanManualMerge (not $showGeneralMergeForm)}}
|
|
<div class="divider"></div>
|
|
<form class="ui form form-fetch-action" action="{{.Issue.Link}}/merge" method="post">{{/* another similar form is in PullRequestMergeForm.vue*/}}
|
|
<div class="field">
|
|
<input type="text" name="merge_commit_id" placeholder="{{ctx.Locale.Tr "repo.pulls.merge_commit_id"}}">
|
|
</div>
|
|
<button class="ui red button" type="submit" name="do" value="manually-merged">
|
|
{{ctx.Locale.Tr "repo.pulls.merge_manually"}}
|
|
</button>
|
|
</form>
|
|
{{end}}
|
|
|
|
{{if $data.ShowPullCommands}}
|
|
{{template "repo/issue/view_content/pull_merge_instruction" dict "PullRequest" .Issue.PullRequest "MergeBoxData" $data}}
|
|
{{end}}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{{end}}
|