0
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-07-04 22:57:34 -04:00

Adds tooltip on branch commit counts (#34869)

Adds a tooltip to the commit counts when comparing branches, making it
easier for novice users to understand what the numbers mean.

Fixes #34867.

---------

Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
Aaron Meese 2025-07-01 07:14:32 -04:00 committed by GitHub
parent 90f96c301e
commit 35f0b5a3ec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 3 deletions

View File

@ -2769,6 +2769,8 @@ branch.new_branch_from = Create new branch from "%s"
branch.renamed = Branch %s was renamed to %s.
branch.rename_default_or_protected_branch_error = Only admins can rename default or protected branches.
branch.rename_protected_branch_failed = This branch is protected by glob-based protection rules.
branch.commits_divergence_from = Commits divergence: %[1]d behind and %[2]d ahead of %[3]s
branch.commits_no_divergence = The same as branch %[1]s
tag.create_tag = Create tag %s
tag.create_tag_operation = Create tag

View File

@ -107,8 +107,14 @@
{{end}}
</td>
<td class="two wide ui">
{{if and (not .DBBranch.IsDeleted) $.DefaultBranchBranch}}
<div class="commit-divergence">
{{if and (not .DBBranch.IsDeleted) $.DefaultBranchBranch}}
{{$tooltipDivergence := ""}}
{{if or .CommitsBehind .CommitsAhead}}
{{$tooltipDivergence = ctx.Locale.Tr "repo.branch.commits_divergence_from" .CommitsBehind .CommitsAhead $.DefaultBranchBranch.DBBranch.Name}}
{{else}}
{{$tooltipDivergence = ctx.Locale.Tr "repo.branch.commits_no_divergence" $.DefaultBranchBranch.DBBranch.Name}}
{{end}}
<div class="commit-divergence" data-tooltip-content="{{$tooltipDivergence}}">
<div class="bar-group">
<div class="count count-behind">{{.CommitsBehind}}</div>
{{/* old code bears 0/0.0 = NaN output, so it might output invalid "width: NaNpx", it just works and doesn't caues any problem. */}}
@ -119,7 +125,7 @@
<div class="bar bar-ahead" style="width: {{Eval 100 "*" .CommitsAhead "/" "(" .CommitsBehind "+" .CommitsAhead "+" 0.0 ")"}}%"></div>
</div>
</div>
{{end}}
{{end}}
</td>
<td class="two wide tw-text-right">
{{if not .LatestPullRequest}}