Skip to content

Commit 0bc1294

Browse files
da-Kaiwxiaoguang
andauthored
Print PR-Title into tooltip for actions (#35579)
This PR updates the tooltip for Pull-Request triggered runs to show the PR title instead of the PR number. --- I dont remember PR numbers, so having the title in the tooltip makes it much easier to recognize the right one 😊 Current <img width="290" height="88" alt="Screenshot 2025-10-03 231547" src="https://github.com/user-attachments/assets/dd8d264d-933f-4fb1-a945-82b172f95861" /> After <img width="301" height="91" alt="Screenshot 2025-10-03 224628" src="https://github.com/user-attachments/assets/74c9809a-c09a-4804-bb27-79058a99238b" /> --------- Co-authored-by: wxiaoguang <[email protected]>
1 parent 03fce8f commit 0bc1294

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

models/actions/run.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,15 @@ func (run *ActionRun) PrettyRef() string {
102102
return refName.ShortName()
103103
}
104104

105+
// RefTooltip return a tooltop of run's ref. For pull request, it's the title of the PR, otherwise it's the ShortName.
106+
func (run *ActionRun) RefTooltip() string {
107+
payload, err := run.GetPullRequestEventPayload()
108+
if err == nil && payload != nil && payload.PullRequest != nil {
109+
return payload.PullRequest.Title
110+
}
111+
return git.RefName(run.Ref).ShortName()
112+
}
113+
105114
// LoadAttributes load Repo TriggerUser if not loaded
106115
func (run *ActionRun) LoadAttributes(ctx context.Context) error {
107116
if run == nil {

templates/repo/actions/runs_list.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
</div>
2929
<div class="flex-item-trailing">
3030
{{if $run.IsRefDeleted}}
31-
<span class="ui label run-list-ref gt-ellipsis tw-line-through" data-tooltip-content="{{$run.PrettyRef}}">{{$run.PrettyRef}}</span>
31+
<span class="ui label run-list-ref gt-ellipsis tw-line-through" data-tooltip-content="{{$run.RefTooltip}}">{{$run.PrettyRef}}</span>
3232
{{else}}
33-
<a class="ui label run-list-ref gt-ellipsis" href="{{$run.RefLink}}" data-tooltip-content="{{$run.PrettyRef}}">{{$run.PrettyRef}}</a>
33+
<a class="ui label run-list-ref gt-ellipsis" href="{{$run.RefLink}}" data-tooltip-content="{{$run.RefTooltip}}">{{$run.PrettyRef}}</a>
3434
{{end}}
3535
<div class="run-list-item-right">
3636
<div class="run-list-meta">{{svg "octicon-calendar" 16}}{{DateUtils.TimeSince $run.Updated}}</div>

0 commit comments

Comments
 (0)