diff options
author | qwerty287 <80460567+qwerty287@users.noreply.github.com> | 2021-12-13 02:59:09 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-13 09:59:09 +0800 |
commit | c3eea2f8af599c94e49e687a80e91a14144b5ea6 (patch) | |
tree | e8253fe995d4bfec5ca1f629aac1a0981eda06fd /templates/repo/header.tmpl | |
parent | e0118b0d9b1a8fe85c0ccfbbf0df87dd57b9241a (diff) | |
download | gitea-c3eea2f8af599c94e49e687a80e91a14144b5ea6.tar.gz gitea-c3eea2f8af599c94e49e687a80e91a14144b5ea6.zip |
Improve behavior of "Fork" button (#17288)
* Improbe behaviour of fork button
* Apply suggestions from code review
* Remove old lines
* Apply suggestions
* Fix test
* Remove unnecessary or
* Update templates/repo/header.tmpl
Co-authored-by: silverwind <me@silverwind.io>
* Add comment
* Fix situation if you can't fork but don't have forks
* Fix lint
* Apply changes from #17783
* fmt
* fmt
* Apply tweaks
Co-authored by: silverwind <me@silverwind.io>
* Rm dupl css
* Fix build
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'templates/repo/header.tmpl')
-rw-r--r-- | templates/repo/header.tmpl | 49 |
1 files changed, 47 insertions, 2 deletions
diff --git a/templates/repo/header.tmpl b/templates/repo/header.tmpl index 4fb5e1941b..014623dc9a 100644 --- a/templates/repo/header.tmpl +++ b/templates/repo/header.tmpl @@ -85,10 +85,55 @@ </form> {{end}} {{if and (not .IsEmpty) ($.Permission.CanRead $.UnitTypeCode)}} - <div class="ui labeled button{{if not $.CanSignedUserFork}} tooltip disabled{{end}}"{{if and (not $.CanSignedUserFork) $.IsSigned}} data-content="{{$.i18n.Tr "repo.fork_from_self"}}" {{else if not $.IsSigned}} data-content="{{$.i18n.Tr "repo.fork_guest_user"}}"{{end}} data-position="top center" tabindex="0"> - <a class="ui compact small basic button"{{if $.CanSignedUserFork}} href="{{AppSubUrl}}/repo/fork/{{.ID}}"{{end}}> + <div class="ui labeled button + {{if or (not $.IsSigned) (and (not $.CanSignedUserFork) (eq (len $.UserAndOrgForks) 0))}} + tooltip disabled + {{end}}" + {{if not $.IsSigned}} + data-content="{{$.i18n.Tr "repo.fork_guest_user"}}" + {{else if and (not $.CanSignedUserFork) (eq (len $.UserAndOrgForks) 0)}} + data-content="{{$.i18n.Tr "repo.fork_from_self"}}" + {{end}} + data-position="top center" data-variation="tiny" tabindex="0"> + <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 eq (len $.UserAndOrgForks) 0}} + href="{{AppSubUrl}}/repo/fork/{{.ID}}" + {{else}} + data-modal="#fork-repo-modal" + {{end}} + > {{svg "octicon-repo-forked"}}{{$.i18n.Tr "repo.fork"}} </a> + <div class="ui small modal" id="fork-repo-modal"> + {{svg "octicon-x" 16 "close inside"}} + <div class="header"> + {{$.i18n.Tr "repo.already_forked" .Name}} + </div> + <div class="content tl"> + <div class="ui list"> + {{range $.UserAndOrgForks}} + <div class="ui item py-3"> + <a href="{{.Link}}"> + {{svg "octicon-repo-forked" 16 "mr-3"}}{{.FullName}} + </a> + </div> + {{end}} + </div> + {{if $.CanSignedUserFork}} + <div class="ui divider"></div> + <a href="{{AppSubUrl}}/repo/fork/{{.ID}}"> + {{$.i18n.Tr "repo.fork_to_different_account"}} + </a> + {{end}} + </div> + </div> <a class="ui basic label" href="{{.Link}}/forks"> {{CountFmt .NumForks}} </a> |