chore: fine tune pull request merge box and commit status item (#38060)

This commit is contained in:
wxiaoguang
2026-06-10 22:44:21 +00:00
committed by GitHub
co-authored by GitHub
parent 988f0ea54a
commit 442f5e7d06
6 changed files with 15 additions and 29 deletions
+5 -9
View File
@@ -525,10 +525,7 @@ func (prInfo *pullRequestViewInfo) prepareMergeBoxCommitSigning(ctx *context.Con
} }
if data.requireSigned && !data.willSign { if data.requireSigned && !data.willSign {
data.infoProtectionBlockers.AddErrorItem( data.infoProtectionBlockers.AddErrorItem(ctx.Locale.Tr("repo.pulls.require_signed_wont_sign"))
svg.RenderHTML("octicon-x"),
ctx.Locale.Tr("repo.pulls.require_signed_wont_sign"),
)
if wontSignReason != "" { if wontSignReason != "" {
data.infoProtectionBlockers.AddInfoItem( data.infoProtectionBlockers.AddInfoItem(
svg.RenderHTML("octicon-unlock"), svg.RenderHTML("octicon-unlock"),
@@ -1053,29 +1050,28 @@ func (prInfo *pullRequestViewInfo) prepareMergeBoxProtectedRules(ctx *context.Co
if pb.EnableApprovalsWhitelist { if pb.EnableApprovalsWhitelist {
blockerInfo = ctx.Locale.Tr("repo.pulls.blocked_by_approvals_whitelisted", grantedApprovals, pb.RequiredApprovals) blockerInfo = ctx.Locale.Tr("repo.pulls.blocked_by_approvals_whitelisted", grantedApprovals, pb.RequiredApprovals)
} }
data.infoProtectionBlockers.AddErrorItem(svg.RenderHTML("octicon-x"), blockerInfo) data.infoProtectionBlockers.AddErrorItem(blockerInfo)
} }
data.isBlockedByRejection = issues_model.MergeBlockedByRejectedReview(ctx, pb, pull) data.isBlockedByRejection = issues_model.MergeBlockedByRejectedReview(ctx, pb, pull)
if data.isBlockedByRejection { if data.isBlockedByRejection {
data.infoProtectionBlockers.AddErrorItem(svg.RenderHTML("octicon-x"), ctx.Locale.Tr("repo.pulls.blocked_by_rejection")) data.infoProtectionBlockers.AddErrorItem(ctx.Locale.Tr("repo.pulls.blocked_by_rejection"))
} }
data.isBlockedByOfficialReviewRequests = issues_model.MergeBlockedByOfficialReviewRequests(ctx, pb, pull) data.isBlockedByOfficialReviewRequests = issues_model.MergeBlockedByOfficialReviewRequests(ctx, pb, pull)
if data.isBlockedByOfficialReviewRequests { if data.isBlockedByOfficialReviewRequests {
data.infoProtectionBlockers.AddErrorItem(svg.RenderHTML("octicon-x"), ctx.Locale.Tr("repo.pulls.blocked_by_official_review_requests")) data.infoProtectionBlockers.AddErrorItem(ctx.Locale.Tr("repo.pulls.blocked_by_official_review_requests"))
} }
data.isBlockedByOutdatedBranch = issues_model.MergeBlockedByOutdatedBranch(pb, pull) data.isBlockedByOutdatedBranch = issues_model.MergeBlockedByOutdatedBranch(pb, pull)
if data.isBlockedByOutdatedBranch { if data.isBlockedByOutdatedBranch {
data.infoProtectionBlockers.AddErrorItem(svg.RenderHTML("octicon-x"), ctx.Locale.Tr("repo.pulls.blocked_by_outdated_branch")) data.infoProtectionBlockers.AddErrorItem(ctx.Locale.Tr("repo.pulls.blocked_by_outdated_branch"))
} }
data.isBlockedByChangedProtectedFiles = len(pull.ChangedProtectedFiles) != 0 data.isBlockedByChangedProtectedFiles = len(pull.ChangedProtectedFiles) != 0
if data.isBlockedByChangedProtectedFiles { if data.isBlockedByChangedProtectedFiles {
detailItems := escapeStringSliceToHTML(pull.ChangedProtectedFiles) detailItems := escapeStringSliceToHTML(pull.ChangedProtectedFiles)
data.infoProtectionBlockers.AddErrorItem( data.infoProtectionBlockers.AddErrorItem(
svg.RenderHTML("octicon-x"),
ctx.Locale.TrN(len(pull.ChangedProtectedFiles), "repo.pulls.blocked_by_changed_protected_files_1", "repo.pulls.blocked_by_changed_protected_files_n"), ctx.Locale.TrN(len(pull.ChangedProtectedFiles), "repo.pulls.blocked_by_changed_protected_files_1", "repo.pulls.blocked_by_changed_protected_files_n"),
detailItems, detailItems,
) )
+2 -9
View File
@@ -36,7 +36,6 @@ import (
"gitea.dev/modules/log" "gitea.dev/modules/log"
"gitea.dev/modules/optional" "gitea.dev/modules/optional"
"gitea.dev/modules/setting" "gitea.dev/modules/setting"
"gitea.dev/modules/svg"
"gitea.dev/modules/templates" "gitea.dev/modules/templates"
"gitea.dev/modules/translation" "gitea.dev/modules/translation"
"gitea.dev/modules/util" "gitea.dev/modules/util"
@@ -484,15 +483,9 @@ func (prInfo *pullRequestViewInfo) prepareMergeBoxStatusCheckData(ctx *context.C
if data.enableStatusCheck { if data.enableStatusCheck {
if statusCheckData.RequiredChecksState.IsError() || statusCheckData.RequiredChecksState.IsFailure() { if statusCheckData.RequiredChecksState.IsError() || statusCheckData.RequiredChecksState.IsFailure() {
data.infoProtectionBlockers.AddErrorItem( data.infoProtectionBlockers.AddErrorItem(ctx.Locale.Tr("repo.pulls.required_status_check_failed"))
svg.RenderHTML("octicon-x"),
ctx.Locale.Tr("repo.pulls.required_status_check_failed"),
)
} else if !statusCheckData.RequiredChecksState.IsSuccess() { } else if !statusCheckData.RequiredChecksState.IsSuccess() {
data.infoProtectionBlockers.AddErrorItem( data.infoProtectionBlockers.AddErrorItem(ctx.Locale.Tr("repo.pulls.required_status_check_missing"))
svg.RenderHTML("octicon-x"),
ctx.Locale.Tr("repo.pulls.required_status_check_missing"),
)
} }
} }
} }
+3 -8
View File
@@ -13,7 +13,6 @@ import (
) )
type pullMergeBoxInfoItem struct { type pullMergeBoxInfoItem struct {
ItemClass string
SvgIconHTML template.HTML SvgIconHTML template.HTML
InfoHTML template.HTML InfoHTML template.HTML
ListItems []template.HTML ListItems []template.HTML
@@ -42,10 +41,9 @@ func (c *pullMergeBoxInfoItemCollection) AddInfoItem(svg, info template.HTML, op
}) })
} }
func (c *pullMergeBoxInfoItemCollection) AddErrorItem(svg, info template.HTML, optItems ...[]template.HTML) { func (c *pullMergeBoxInfoItemCollection) AddErrorItem(info template.HTML, optItems ...[]template.HTML) {
c.items = append(c.items, &pullMergeBoxInfoItem{ c.items = append(c.items, &pullMergeBoxInfoItem{
ItemClass: "tw-text-red", SvgIconHTML: svg.RenderHTML("octicon-x", 16, "tw-text-red"),
SvgIconHTML: svg,
InfoHTML: info, InfoHTML: info,
ListItems: util.OptionalArg(optItems), ListItems: util.OptionalArg(optItems),
}) })
@@ -151,10 +149,7 @@ func (prInfo *pullRequestViewInfo) prepareMergeBoxInfoItems(ctx *context.Context
ctx.Locale.Tr("repo.pulls.is_empty"), ctx.Locale.Tr("repo.pulls.is_empty"),
) )
} else { } else {
prInfo.MergeBoxData.infoProtectionBlockers.AddErrorItem( prInfo.MergeBoxData.infoProtectionBlockers.AddErrorItem(ctx.Locale.Tr("repo.pulls.cannot_auto_merge_desc"))
svg.RenderHTML("octicon-x"),
ctx.Locale.Tr("repo.pulls.cannot_auto_merge_desc"),
)
prInfo.MergeBoxData.infoProtectionBlockers.AddInfoItem( prInfo.MergeBoxData.infoProtectionBlockers.AddInfoItem(
svg.RenderHTML("octicon-info"), svg.RenderHTML("octicon-info"),
ctx.Locale.Tr("repo.pulls.cannot_auto_merge_helper"), ctx.Locale.Tr("repo.pulls.cannot_auto_merge_helper"),
@@ -32,7 +32,7 @@
{{if $infoSection.InfoItems}} {{if $infoSection.InfoItems}}
<div class="item"> <div class="item">
{{range $infoItem := $infoSection.InfoItems}} {{range $infoItem := $infoSection.InfoItems}}
<div class="flex-text-block {{$infoItem.ItemClass}}">{{$infoItem.SvgIconHTML}} {{$infoItem.InfoHTML}}</div> <div class="flex-text-block">{{$infoItem.SvgIconHTML}} {{$infoItem.InfoHTML}}</div>
{{if $infoItem.ListItems}} {{if $infoItem.ListItems}}
<ul class="tw-pl-[36px]">{{/* align with the info icon and text */}} <ul class="tw-pl-[36px]">{{/* align with the info icon and text */}}
{{range $listItem := $infoItem.ListItems}} {{range $listItem := $infoItem.ListItems}}
+1 -1
View File
@@ -17,7 +17,7 @@
{{$cs.Context}} <span class="tw-text-text-light-2">{{$cs.Description}}</span> {{$cs.Context}} <span class="tw-text-text-light-2">{{$cs.Description}}</span>
</div> </div>
</div> </div>
<div class="status-details"> <div class="flex-text-block">
{{if and $statusCheckData $statusCheckData.IsContextRequired}} {{if and $statusCheckData $statusCheckData.IsContextRequired}}
{{if (call $statusCheckData.IsContextRequired $cs.Context)}} {{if (call $statusCheckData.IsContextRequired $cs.Context)}}
<div class="ui label">{{ctx.Locale.Tr "repo.pulls.status_checks_requested"}}</div> <div class="ui label">{{ctx.Locale.Tr "repo.pulls.status_checks_requested"}}</div>
+3 -1
View File
@@ -1855,8 +1855,10 @@ tbody.commit-list {
width: 100%; width: 100%;
} }
.commit-status-item { .commit-status-item { /* the item can be used at 2 places: PR's merge box (commit-status-list), commit's status popup (no commit-status-list) */
height: 40px; height: 40px;
padding-top: 0 !important; /* use "height" + "align items center", don't use padding-y (from the list container) to layout */
padding-bottom: 0 !important;
display: flex; display: flex;
gap: var(--gap-block); gap: var(--gap-block);
align-items: center; align-items: center;