Add a button to show forked repos to the fork account select dialog

This commit is contained in:
Naoki Takezoe
2018-06-25 19:42:57 +09:00
parent 79a7df254e
commit e578f9548b
3 changed files with 45 additions and 57 deletions

View File

@@ -76,10 +76,19 @@
@repositoryHeaderComponent(repository, context)
}
@if(repository.repository.options.allowFork) {
<a class="btn btn-default btn-sm" href="@helpers.url(repository)/network/members">
<span class="strong"><i class="octicon octicon-repo-forked"></i>Fork</span><span class="muted">: @repository.forkedCount</span>
</a>
@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>
@@ -97,4 +106,19 @@
@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>