mirror of
https://github.com/gitbucket/gitbucket.git
synced 2026-02-10 16:47:01 +01:00
Update issue link presentation
This commit is contained in:
@@ -3,23 +3,23 @@ package gitbucket.core.view
|
||||
import gitbucket.core.controller.Context
|
||||
import gitbucket.core.service.{RepositoryService, RequestCache}
|
||||
import gitbucket.core.util.Implicits.RichString
|
||||
import gitbucket.core.util.StringUtil
|
||||
|
||||
trait LinkConverter { self: RequestCache =>
|
||||
|
||||
/**
|
||||
* Creates a link to the issue or the pull request from the issue id.
|
||||
*/
|
||||
protected def createIssueLink(repository: RepositoryService.RepositoryInfo, issueId: Int)(
|
||||
protected def createIssueLink(repository: RepositoryService.RepositoryInfo, issueId: Int, title: String)(
|
||||
implicit context: Context
|
||||
): String = {
|
||||
val userName = repository.repository.userName
|
||||
val repositoryName = repository.repository.repositoryName
|
||||
|
||||
getIssue(userName, repositoryName, issueId.toString) match {
|
||||
case Some(issue) if (issue.isPullRequest) =>
|
||||
s"""<a href="${context.path}/${userName}/${repositoryName}/pull/${issueId}">Pull #${issueId}</a>"""
|
||||
case Some(_) =>
|
||||
s"""<a href="${context.path}/${userName}/${repositoryName}/issues/${issueId}">Issue #${issueId}</a>"""
|
||||
case Some(issue) =>
|
||||
s"""<a href="${context.path}/${userName}/${repositoryName}/${if (issue.isPullRequest) "pull" else "issues"}/${issueId}"><strong>${StringUtil
|
||||
.escapeHtml(title)}</strong> #${issueId}</a>"""
|
||||
case None =>
|
||||
s"Unknown #${issueId}"
|
||||
}
|
||||
|
||||
@@ -156,8 +156,10 @@ object helpers extends AvatarImageProvider with LinkConverter with RequestCache
|
||||
/**
|
||||
* Creates a link to the issue or the pull request from the issue id.
|
||||
*/
|
||||
def issueLink(repository: RepositoryService.RepositoryInfo, issueId: Int)(implicit context: Context): Html = {
|
||||
Html(createIssueLink(repository, issueId))
|
||||
def issueLink(repository: RepositoryService.RepositoryInfo, issueId: Int, title: String)(
|
||||
implicit context: Context
|
||||
): Html = {
|
||||
Html(createIssueLink(repository, issueId, title))
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -112,7 +112,7 @@
|
||||
</div>
|
||||
<div style="discussion-item-content">
|
||||
@defining(comment.content.split(":")){ case Array(issueId, rest @ _*) =>
|
||||
<strong>@helpers.issueLink(repository, issueId.toInt): @rest.mkString(":")</strong>
|
||||
@helpers.issueLink(repository, issueId.toInt, rest.mkString(":"))
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user