Merge pull request #2005 from gitbucket/fork-button
Move Fork button to the header
commit d322f772e8dfe434b15f8aab15fc7dbee0bec92a
2 parents 9830392 + e578f95
@Naoki Takezoe Naoki Takezoe authored on 25 Jun 2018
GitHub committed on 25 Jun 2018
Showing 3 changed files
View
38
src/main/twirl/gitbucket/core/helper/forkrepository.scala.html
@(repository: gitbucket.core.service.RepositoryService.RepositoryInfo,
groupAndPerm: Seq[(String, Boolean)])(implicit context: gitbucket.core.controller.Context)
@import gitbucket.core.view.helpers
<h2 class="facebox-header">Where should we fork this repository?</h2>
<h2 class="facebox-header">
Where should we fork this repository?
<a class="btn btn-default btn-sm" href="@helpers.url(repository)/network/members">Show forks</a>
</h2>
<form action="@helpers.url(repository)/fork" id="fork" method="post">
<div class="content">
<div class="block">
@helpers.avatar(context.loginAccount.get.userName, 24) <a href="javascript:void(0);" class="js-fork-owner-select-target">@@@context.loginAccount.get.userName</a>
</div>
@for((groupName, isManager) <- groupAndPerm) {
@if(isManager) {
<div class="block js-fork-owner-select-target">
@helpers.avatar(groupName, 24) <a href="javascript:void(0);" class="js-fork-owner-select-target">@@@groupName</a>
</div>
} else {
<div class="block" title="You don't have permission to fork here.">
@helpers.avatar(groupName, 24) <span class="muted">@@@groupName</span>
</div>
}
<div class="block">
@helpers.avatar(context.loginAccount.get.userName, 24) <a href="javascript:void(0);" class="js-fork-owner-select-target">@@@context.loginAccount.get.userName</a>
</div>
@for((groupName, isManager) <- groupAndPerm) {
@if(isManager) {
<div class="block js-fork-owner-select-target">
@helpers.avatar(groupName, 24) <a href="javascript:void(0);" class="js-fork-owner-select-target">@@@groupName</a>
</div>
} else {
<div class="block" title="You don't have permission to fork here.">
@helpers.avatar(groupName, 24) <span class="muted">@@@groupName</span>
</div>
}
</div>
}
<input id="account" name="account" type="hidden" />
</form>
View
32
src/main/twirl/gitbucket/core/menu.scala.html
@repository.repository.options.externalWikiUrl.map { externalWikiUrl =>
@menuitem(externalWikiUrl, "wiki", "Wiki", "book")
}
}
@if(repository.repository.options.allowFork) {
@menuitem("/network/members", "fork", "Forks", "repo-forked", repository.forkedCount)
}
@if(context.loginAccount.isDefined && (context.loginAccount.get.isAdmin || repository.managers.contains(context.loginAccount.get.userName))){
@menuitem("/settings", "settings", "Settings", "gear")
}
@gitbucket.core.plugin.PluginRegistry().getRepositoryMenus.map { menu =>
<div class="pull-right">
@gitbucket.core.plugin.PluginRegistry().getRepositoryHeaders.map { repositoryHeaderComponent =>
@repositoryHeaderComponent(repository, context)
}
@if(repository.repository.options.allowFork) {
@if(context.loginAccount.isEmpty){
<a class="btn btn-default btn-sm" href="@context.path/signin?redirect=@helpers.urlEncode(s"${context.path}/${repository.owner}/${repository.name}")">
<span class="strong"><i class="octicon octicon-repo-forked"></i>Fork</span><span class="muted">: @repository.forkedCount</span>
</a>
} else {
<a class="btn btn-default btn-sm" href="@context.path/@repository.owner/@repository.name/fork" rel="facebox">
<span class="strong"><i class="octicon octicon-repo-forked"></i>Fork</span><span class="muted">: @repository.forkedCount</span>
</a>
}
}
<form id="fork-form" method="post" action="@context.path/@repository.owner/@repository.name/fork" style="display: none;">
<input type="hidden" name="account" value="@context.loginAccount.get.userName"/>
</form>
</div>
@gitbucket.core.helper.html.repositoryicon(repository, true)
<a href="@helpers.url(repository.owner)">@repository.owner</a> / <a href="@helpers.url(repository)" class="strong">@repository.name</a>
 
</div>
@body
</div>
</div>
<script>
$(function(){
$('a[rel*=facebox]').facebox({
'loadingImage': '@helpers.assets("/vendors/facebox/loading.gif")',
'closeImage': '@helpers.assets("/vendors/facebox/closelabel.png")'
});
 
$(document).on("click", ".js-fork-owner-select-target", function() {
var account = $(this).text().replace("@@", "");
$("#account").val(account);
$("#fork").submit();
});
});
</script>
 
 
View
55
src/main/twirl/gitbucket/core/repo/forked.scala.html
repository: gitbucket.core.service.RepositoryService.RepositoryInfo)(implicit context: gitbucket.core.controller.Context)
@import gitbucket.core.view.helpers
@gitbucket.core.html.main(s"${repository.owner}/${repository.name}", Some(repository)) {
@gitbucket.core.html.menu("fork", repository){
<h1 class="body-title">
Forked repositories
@if(context.loginAccount.isEmpty){
<a href="@context.path/signin?redirect=@helpers.urlEncode(s"${context.path}/${repository.owner}/${repository.name}")" class="btn btn-success">Fork</a>
} else {
@if(groupNames.isEmpty) {
<a id="fork-link" href="javascript:void(0);" class="btn btn-success">Fork</a>
} else {
<a href="@context.path/@repository.owner/@repository.name/fork" class="btn btn-success" rel="facebox">Fork</a>
}
}
</h1>
@if(context.loginAccount.isDefined && groupNames.isEmpty){
<form id="fork-form" method="post" action="@context.path/@repository.owner/@repository.name/fork" style="display: none;">
<input type="hidden" name="account" value="@context.loginAccount.get.userName"/>
</form>
}
<h1 class="body-title">Forked repositories</h1>
<div class="block">
@if(originRepository.isDefined){
@helpers.avatarLink(originRepository.get.owner, 20)
<span@if(repository.owner == originRepository.get.owner){ class="highlight"}>
</div>
}
}
}
<script>
$(function(){
$('a[rel*=facebox]').facebox({
'loadingImage': '@helpers.assets("/vendors/facebox/loading.gif")',
'closeImage': '@helpers.assets("/vendors/facebox/closelabel.png")'
});
$(document).on("click", ".js-fork-owner-select-target", function() {
var account = $(this).text().replace("@@", "");
$("#account").val(account);
$("#fork").submit();
});
 
@if(context.loginAccount.isDefined){
$(document).on("click", "a#fork-link", function(e) {
e.preventDefault();
$('#fork-form').submit();
});
}
});
</script>