Fix presentation of branch list

This commit is contained in:
Naoki Takezoe
2016-05-30 09:05:01 +09:00
parent ecbe7228b9
commit 2b730ef180
2 changed files with 67 additions and 64 deletions

View File

@@ -13,74 +13,75 @@
</thead>
<tbody>
@branchInfo.map { case (branch, prs, isProtected) =>
<tr><td style="padding: 12px;">
<div class="branch-action">
@branch.mergeInfo.map{ info =>
@prs.map{ case (pull, issue) =>
<a href="@url(repository)/pull/@issue.issueId" title="@issue.title">#@issue.issueId</a>
@if(issue.closed) {
@if(info.isMerged){
<a href="@url(repository)/pull/@issue.issueId" title="@issue.title" class="label label-info">Merged</a>
}else{
<a href="@url(repository)/pull/@issue.issueId" title="@issue.title" class="label label-important">Closed</a>
}
} else {
<a href="@url(repository)/pull/@issue.issueId" title="@issue.title" class="label label-success">Open</a>
}
}.getOrElse{
@if(context.loginAccount.isDefined){
<a href="@url(repository)/compare/@{repository.repository.parentUserName.map { parent =>
urlEncode(parent) + ":" + encodeRefName(repository.repository.defaultBranch)
}.getOrElse {
encodeRefName(repository.repository.defaultBranch)
}}...@{encodeRefName(branch.name)}?expand=1" class="btn btn-success">New Pull Request</a>
} else {
<a href="@url(repository)/compare/@{repository.repository.parentUserName.map { parent =>
urlEncode(parent) + ":" + encodeRefName(repository.repository.defaultBranch)
}.getOrElse {
encodeRefName(repository.repository.defaultBranch)
}}...@{encodeRefName(branch.name)}" class="btn btn-success">Compare</a>
}
}
@if(hasWritePermission){
<span style="margin-left: 8px;">
@if(prs.map(!_._2.closed).getOrElse(false)){
<a class="disabled" data-toggle="tooltip" title="You cant delete this branch because it has an open pull request"><i class="octicon octicon-trashcan"></i></a>
} else {
@if(isProtected){
<a class="disabled" data-toggle="tooltip" title="You cant delete a protected branch."><i class="octicon octicon-trashcan"></i></a>
} else {
<a href="@url(repository)/delete/@encodeRefName(branch.name)" class="delete-branch" data-name="@branch.name" @if(info.isMerged){ data-toggle="tooltip" title="this branch is merged" }><i class="octicon octicon-trashcan @if(info.isMerged){warning} else {danger}"></i></a>
}
}
</span>
}
}
</div>
<div class="branch-details">
@if(isProtected){ <span class="octicon octicon-shield" title="This branch is protected"></span> }
<a href="@url(repository)/tree/@encodeRefName(branch.name)" class="branch-name">@branch.name</a>
<span class="branch-meta">
<span>Updated @helper.html.datetimeago(branch.commitTime, false)
by <span>@user(branch.committerName, branch.committerEmailAddress, "muted-link")</span>
</span>
</span>
</div>
<div class="branch-a-b-count">
@if(branch.mergeInfo.isEmpty){
<span class="badge">Default</span>
}else{
<tr>
<td style="padding: 12px;">
<div class="branch-action">
@branch.mergeInfo.map{ info =>
<div data-toggle="tooltip" title="@info.ahead commits ahead, @info.behind commits behind @repository.repository.defaultBranch">
<div class="a-b-count-widget">
<div class="count-half"><div class="count-value">@info.ahead</div></div>
<div class="count-half"><div class="count-value">@info.behind</div></div>
@prs.map{ case (pull, issue) =>
<a href="@url(repository)/pull/@issue.issueId" title="@issue.title">#@issue.issueId</a>
@if(issue.closed) {
@if(info.isMerged){
<a href="@url(repository)/pull/@issue.issueId" title="@issue.title" class="label label-info">Merged</a>
} else {
<a href="@url(repository)/pull/@issue.issueId" title="@issue.title" class="label label-important">Closed</a>
}
} else {
<a href="@url(repository)/pull/@issue.issueId" title="@issue.title" class="label label-success">Open</a>
}
}.getOrElse{
@if(context.loginAccount.isDefined){
<a href="@url(repository)/compare/@{repository.repository.parentUserName.map { parent =>
urlEncode(parent) + ":" + encodeRefName(repository.repository.defaultBranch)
}.getOrElse {
encodeRefName(repository.repository.defaultBranch)
}}...@{encodeRefName(branch.name)}?expand=1" class="btn btn-success">New Pull Request</a>
} else {
<a href="@url(repository)/compare/@{repository.repository.parentUserName.map { parent =>
urlEncode(parent) + ":" + encodeRefName(repository.repository.defaultBranch)
}.getOrElse {
encodeRefName(repository.repository.defaultBranch)
}}...@{encodeRefName(branch.name)}" class="btn btn-success">Compare</a>
}
}
@if(hasWritePermission){
<span style="margin-left: 8px;">
@if(prs.map(!_._2.closed).getOrElse(false)){
<a class="disabled" data-toggle="tooltip" title="You cant delete this branch because it has an open pull request"><i class="octicon octicon-trashcan"></i></a>
} else {
@if(isProtected){
<a class="disabled" data-toggle="tooltip" title="You cant delete a protected branch."><i class="octicon octicon-trashcan"></i></a>
} else {
<a href="@url(repository)/delete/@encodeRefName(branch.name)" class="delete-branch" data-name="@branch.name" @if(info.isMerged){ data-toggle="tooltip" title="this branch is merged" }><i class="octicon octicon-trashcan @if(info.isMerged){warning} else {danger}"></i></a>
}
}
</span>
}
}
</div>
<div class="branch-details">
@if(isProtected){ <span class="octicon octicon-shield" title="This branch is protected"></span> }
<a href="@url(repository)/tree/@encodeRefName(branch.name)" class="branch-name">@branch.name</a>
<span class="branch-meta">
<span>Updated @helper.html.datetimeago(branch.commitTime, false)
by <span>@user(branch.committerName, branch.committerEmailAddress, "muted-link")</span>
</span>
</span>
</div>
<div class="branch-a-b-count">
@if(branch.mergeInfo.isEmpty){
<span class="badge">Default</span>
} else {
@branch.mergeInfo.map{ info =>
<div data-toggle="tooltip" title="@info.ahead commits ahead, @info.behind commits behind @repository.repository.defaultBranch">
<div class="a-b-count-widget">
<div class="count-half"><div class="count-value">@info.ahead</div></div>
<div class="count-half"><div class="count-value">@info.behind</div></div>
</div>
</div>
</div>
}
}
}
</div>
</div>
</td>
</tr>
}
</table>

View File

@@ -833,6 +833,7 @@ a.issue-title {
font-size: 120%;
}
/*
.label-success {
background-color: #6cc644;
}
@@ -840,6 +841,7 @@ a.issue-title {
.label-important {
background-color: #bd2c00;
}
*/
ul.label-list {
list-style-type: none;