mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-23 05:45:34 +03:00
0ea021c8c9
For small, personal self-hosted instances with no user signups, the fork button is just a noise. This patch allows disabling them like stars can be disabled too. Disabling forks does not only remove the buttons from the web UI, it also disables the routes that could be used to create forks. Fixes #2441. Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
50 lines
1.7 KiB
Go HTML Template
50 lines
1.7 KiB
Go HTML Template
{{if and (not .IsEmpty) ($.Permission.CanRead $.UnitTypeCode)}}
|
|
<div class="ui labeled button
|
|
{{if or (not $.IsSigned) (and (not $.CanSignedUserFork) (not $.UserAndOrgForks))}}
|
|
disabled
|
|
{{end}}"
|
|
{{if not $.IsSigned}}
|
|
data-tooltip-content="{{ctx.Locale.Tr "repo.fork_guest_user"}}"
|
|
{{else if and (not $.CanSignedUserFork) (not $.UserAndOrgForks)}}
|
|
data-tooltip-content="{{ctx.Locale.Tr "repo.fork_from_self"}}"
|
|
{{end}}
|
|
>
|
|
<a class="ui compact{{if $.ShowForkModal}} show-modal{{end}} small basic button"
|
|
{{if not $.CanSignedUserFork}}
|
|
{{if gt (len $.UserAndOrgForks) 1}}
|
|
data-modal="#fork-repo-modal"
|
|
{{else if eq (len $.UserAndOrgForks) 1}}
|
|
href="{{AppSubUrl}}/{{(index $.UserAndOrgForks 0).FullName}}"
|
|
{{/*else is not required here, because the button shouldn't link to any site if you can't create a fork*/}}
|
|
{{end}}
|
|
{{else if not $.UserAndOrgForks}}
|
|
href="{{$.RepoLink}}/fork"
|
|
{{else}}
|
|
data-modal="#fork-repo-modal"
|
|
{{end}}
|
|
>
|
|
{{svg "octicon-repo-forked"}}<span class="text">{{ctx.Locale.Tr "repo.fork"}}</span>
|
|
</a>
|
|
<div class="ui small modal" id="fork-repo-modal">
|
|
<div class="header">
|
|
{{ctx.Locale.Tr "repo.already_forked" .Name}}
|
|
</div>
|
|
<div class="content gt-text-left">
|
|
<div class="ui list">
|
|
{{range $.UserAndOrgForks}}
|
|
<div class="ui item gt-py-3">
|
|
<a href="{{.Link}}">{{svg "octicon-repo-forked" 16 "gt-mr-3"}}{{.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>
|
|
<a class="ui basic label" href="{{.Link}}/forks">
|
|
{{CountFmt .NumForks}}
|
|
</a>
|
|
</div>
|
|
{{end}}
|