mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-08 22:45:51 +01:00
Merge pull request #1553 from kounoike/pr-show-commitstaus-in-commits
Show CommitStatus in commits page.
This commit is contained in:
@@ -13,7 +13,7 @@ import gitbucket.core.util.StringUtil._
|
||||
import gitbucket.core.util.SyntaxSugars._
|
||||
import gitbucket.core.util.Implicits._
|
||||
import gitbucket.core.util.Directory._
|
||||
import gitbucket.core.model.{Account, WebHook}
|
||||
import gitbucket.core.model.{Account, CommitState, CommitStatus, WebHook}
|
||||
import gitbucket.core.service.WebHookService._
|
||||
import gitbucket.core.view
|
||||
import gitbucket.core.view.helpers
|
||||
@@ -174,13 +174,24 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
||||
val (branchName, path) = repository.splitPath(multiParams("splat").head)
|
||||
val page = params.get("page").flatMap(_.toIntOpt).getOrElse(1)
|
||||
|
||||
def getStatuses(sha: String): List[CommitStatus] = {
|
||||
getCommitStatues(repository.owner, repository.name, sha)
|
||||
}
|
||||
|
||||
def getSummary(statuses: List[CommitStatus]): (CommitState, String) = {
|
||||
val stateMap = statuses.groupBy(_.state)
|
||||
val state = CommitState.combine(stateMap.keySet)
|
||||
val summary = stateMap.map{ case (keyState, states) => states.size+" "+keyState.name }.mkString(", ")
|
||||
state -> summary
|
||||
}
|
||||
|
||||
using(Git.open(getRepositoryDir(repository.owner, repository.name))){ git =>
|
||||
JGitUtil.getCommitLog(git, branchName, page, 30, path) match {
|
||||
case Right((logs, hasNext)) =>
|
||||
html.commits(if(path.isEmpty) Nil else path.split("/").toList, branchName, repository,
|
||||
logs.splitWith{ (commit1, commit2) =>
|
||||
view.helpers.date(commit1.commitTime) == view.helpers.date(commit2.commitTime)
|
||||
}, page, hasNext, hasDeveloperRole(repository.owner, repository.name, context.loginAccount))
|
||||
}, page, hasNext, hasDeveloperRole(repository.owner, repository.name, context.loginAccount), getStatuses, getSummary)
|
||||
case Left(_) => NotFound()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
commits: Seq[Seq[gitbucket.core.util.JGitUtil.CommitInfo]],
|
||||
page: Int,
|
||||
hasNext: Boolean,
|
||||
hasWritePermission: Boolean)(implicit context: gitbucket.core.controller.Context)
|
||||
hasWritePermission: Boolean,
|
||||
getStatuses: String => List[gitbucket.core.model.CommitStatus],
|
||||
getSummary: List[gitbucket.core.model.CommitStatus] => (gitbucket.core.model.CommitState, String))(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("files", repository){
|
||||
@@ -63,6 +65,30 @@
|
||||
}
|
||||
@helpers.user(commit.committerName, commit.committerEmailAddress, "username")
|
||||
<span class="muted">committed @gitbucket.core.helper.html.datetimeago(commit.commitTime)</span>
|
||||
@defining({
|
||||
val statuses = getStatuses(commit.id)
|
||||
val (summary, summaryText) = getSummary(statuses)
|
||||
(statuses, summary, summaryText)
|
||||
}){ case (statuses, summaryState, summaryText) =>
|
||||
@if(!statuses.isEmpty){
|
||||
@helpers.commitStateIcon(summaryState)
|
||||
<strong class="text-@{summaryState.name}">@helpers.commitStateText(summaryState, commit.id)</strong>
|
||||
<span class="text-@{summaryState.name}">— @summaryText checks</span>
|
||||
<a href="#" class="toggle-check">Show all checks</a>
|
||||
<div style="display: none;">
|
||||
@statuses.map{ status =>
|
||||
<div class="build-status-item">
|
||||
<span class="build-status-icon text-@{status.state.name}">@helpers.commitStateIcon(status.state)</span>
|
||||
<strong>@status.context</strong>
|
||||
@status.description.map { desc => <span class="muted">— @desc</span> }
|
||||
<span>
|
||||
@status.targetUrl.map { url => — <a href="@url">Details</a> }
|
||||
</span>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -86,5 +112,20 @@
|
||||
}
|
||||
</ul>
|
||||
</nav>
|
||||
<script>
|
||||
$(function () {
|
||||
$('.toggle-check').click(function(){
|
||||
var div = $(this).next('div');
|
||||
console.log(div);
|
||||
if(div.is(':visible')){
|
||||
$(this).text('Show all checks');
|
||||
}else{
|
||||
$(this).text('Hide all checks');
|
||||
}
|
||||
div.toggle();
|
||||
return false;
|
||||
});
|
||||
})
|
||||
</script>
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user