Skip to content

Commit e9b3925

Browse files
lunnysilverwindwxiaoguang
authored
Improve pull request merge box when pull request merged and branch deleted. (#24397)
This PR hide the pull request merge box totally if it's merged and branch deleted. It's also add a bold for merge base commit id in merged message comment Before: <img width="989" alt="图片" src="https://user-images.githubusercontent.com/81045/235066590-28deb506-e824-4a42-a9a2-791cd136756e.png"> After: <img width="1030" alt="图片" src="https://user-images.githubusercontent.com/81045/235080749-11d5efe8-a06e-4528-a75f-f6c6d191db50.png"> --------- Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
1 parent a9ed87c commit e9b3925

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed

options/locale/locale_en-US.ini

+2-2
Original file line numberDiff line numberDiff line change
@@ -1414,8 +1414,8 @@ issues.context.edit = Edit
14141414
issues.context.delete = Delete
14151415
issues.no_content = There is no content yet.
14161416
issues.close = Close Issue
1417-
issues.pull_merged_at = `merged commit <a class="ui sha" href="%[1]s"><code>%[2]s</code></a> into <b>%[3]s</b> %[4]s`
1418-
issues.manually_pull_merged_at = `merged commit <a class="ui sha" href="%[1]s"><code>%[2]s</code></a> into <b>%[3]s</b> manually %[4]s`
1417+
issues.comment_pull_merged_at = merged commit %[1]s into %[2]s %[3]s
1418+
issues.comment_manually_pull_merged_at = manually merged commit %[1]s into %[2]s %[3]s
14191419
issues.close_comment_issue = Comment and Close
14201420
issues.reopen_issue = Reopen
14211421
issues.reopen_comment_issue = Comment and Reopen

templates/repo/issue/view_content/comments.tmpl

+2-2
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@
125125
{{template "shared/user/authorlink" .Poster}}
126126
{{$link := printf "%s/commit/%s" $.Repository.Link ($.Issue.PullRequest.MergedCommitID|PathEscape)}}
127127
{{if eq $.Issue.PullRequest.Status 3}}
128-
{{$.locale.Tr "repo.issues.manually_pull_merged_at" ($link|Escape) (ShortSha $.Issue.PullRequest.MergedCommitID) ($.BaseTarget|Escape) $createdStr | Safe}}
128+
{{$.locale.Tr "repo.issues.comment_manually_pull_merged_at" (printf "<a class='ui sha' href='%[1]s'><b>%[2]s</b></a>" ($link|Escape) (ShortSha $.Issue.PullRequest.MergedCommitID)) (printf "<b>%[1]s</b>" ($.BaseTarget|Escape)) $createdStr | Safe}}
129129
{{else}}
130-
{{$.locale.Tr "repo.issues.pull_merged_at" ($link|Escape) (ShortSha $.Issue.PullRequest.MergedCommitID) ($.BaseTarget|Escape) $createdStr | Safe}}
130+
{{$.locale.Tr "repo.issues.comment_pull_merged_at" (printf "<a class='ui sha' href='%[1]s'><b>%[2]s</b></a>" ($link|Escape) (ShortSha $.Issue.PullRequest.MergedCommitID)) (printf "<b>%[1]s</b>" ($.BaseTarget|Escape)) $createdStr | Safe}}
131131
{{end}}
132132
</span>
133133
</div>

templates/repo/issue/view_content/pull.tmpl

+15-9
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@
108108
</div>
109109
</div>
110110
{{end}}
111+
{{if and .Issue.PullRequest.HasMerged (not .IsPullBranchDeletable)}}
112+
{{/* Then the merge box will not be displayed because this page already contains enough information */}}
113+
{{else}}
111114
<div class="timeline-item comment merge box">
112115
<a class="timeline-avatar text {{if .Issue.PullRequest.HasMerged}}purple
113116
{{- else if .Issue.IsClosed}}grey
@@ -131,19 +134,21 @@
131134
{{$showGeneralMergeForm := false}}
132135
<div class="ui attached merge-section segment {{if not $.LatestCommitStatus}}no-header{{end}}">
133136
{{if .Issue.PullRequest.HasMerged}}
134-
<div class="item item-section text gt-f1">
135-
<div class="item-section-left">
136-
<h3 class="gt-mb-3">{{$.locale.Tr "repo.pulls.merged_success"}}</h3>
137-
<div class="merge-section-info">
138-
{{$.locale.Tr "repo.pulls.merged_info_text" (printf "<code>%s</code>" (.HeadTarget | Escape)) | Str2html}}
137+
{{if .IsPullBranchDeletable}}
138+
<div class="item item-section text gt-f1">
139+
<div class="item-section-left">
140+
<h3 class="gt-mb-3">
141+
{{$.locale.Tr "repo.pulls.merged_success"}}
142+
</h3>
143+
<div class="merge-section-info">
144+
{{$.locale.Tr "repo.pulls.merged_info_text" (printf "<code>%s</code>" (.HeadTarget | Escape)) | Str2html}}
145+
</div>
139146
</div>
140-
</div>
141-
{{if .IsPullBranchDeletable}}
142147
<div class="item-section-right">
143148
<button class="delete-button ui button" data-url="{{.DeleteBranchLink}}">{{$.locale.Tr "repo.branch.delete_html"}}</button>
144149
</div>
145-
{{end}}
146-
</div>
150+
</div>
151+
{{end}}
147152
{{else if .Issue.IsClosed}}
148153
<div class="item item-section text gt-f1">
149154
<div class="item-section-left">
@@ -485,3 +490,4 @@
485490
</div>
486491
</div>
487492
</div>
493+
{{end}}

0 commit comments

Comments
 (0)