1
1
mirror of https://github.com/go-gitea/gitea.git synced 2026-05-07 12:56:39 +02:00
Files
silverwind 6da8027446 Fix inconsistent disabled styling on logged-out repo header buttons (#37406)
Make the watch, star, and fork buttons in the repo header consistent for
logged-out users:

- Apply the same look to all three buttons (number labels
included), instead of only the action button being grayed.
- Clicking any of them while logged out now leads to the login page
(with a redirect back) instead of being inert.
- Split the per-button markup out of `header.tmpl` into a dedicated
`templates/repo/header/` folder (`fork.tmpl`, `star.tmpl`,
`watch.tmpl`).

---------

Co-authored-by: Claude (Opus 4.7) <noreply@anthropic.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2026-04-27 17:33:10 +00:00

48 lines
1.5 KiB
Go HTML Template

{{$canNotForkOwn := and $.IsSigned (not $.CanSignedUserFork) (not $.UserAndOrgForks)}}
<div class="ui labeled button"
{{if not $.IsSigned}}
data-tooltip-content="{{ctx.Locale.Tr "repo.fork_guest_user"}}"
{{else if $canNotForkOwn}}
data-tooltip-content="{{ctx.Locale.Tr "repo.fork_from_self"}}"
{{end}}
>
<a role="button" class="ui compact small basic button {{if $.ShowForkModal}}show-modal{{end}}"
{{if not $.IsSigned}}
href="{{AppSubUrl}}/user/login"
{{else if $.ShowForkModal}}{{/* see backend comment for this logic */}}
href="#" data-modal="#fork-repo-modal"
{{else if eq (len $.UserAndOrgForks) 1}}
href="{{AppSubUrl}}/{{(index $.UserAndOrgForks 0).FullName}}"
{{else if $canNotForkOwn}}
href="#"
{{else}}
href="{{$.RepoLink}}/fork"
{{end}}
>
{{svg "octicon-repo-forked"}}<span class="text not-mobile">{{ctx.Locale.Tr "repo.fork"}}</span>
</a>
<a class="ui basic label" href="{{$.Repository.Link}}/forks">
{{CountFmt $.Repository.NumForks}}
</a>
</div>
{{if $.ShowForkModal}}
<div class="ui small modal" id="fork-repo-modal">
<div class="header">
{{ctx.Locale.Tr "repo.already_forked" $.Repository.Name}}
</div>
<div class="content">
<div class="ui relaxed list">
{{range $.UserAndOrgForks}}
<div class="item">
<a class="flex-text-block" href="{{.Link}}">{{svg "octicon-repo-forked"}}{{.FullName}}</a>
</div>
{{end}}
</div>
{{if $.CanSignedUserFork}}
<div class="divider"></div>
<a href="{{$.RepoLink}}/fork">{{ctx.Locale.Tr "repo.fork_to_different_account"}}</a>
{{end}}
</div>
</div>
{{end}}