mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-02 03:26:06 +01:00
Add visibility of Labels/Priority/Milestone/Assignee changes in an issue. closes #1855
This commit is contained in:
@@ -6,17 +6,22 @@ The details are saved at `ISSUE_COMMENT` table.
|
||||
To determine if it was any operation, you see the `ACTION` column.
|
||||
And in the case of some actions, `CONTENT` column value contains additional information.
|
||||
|
||||
|ACTION |CONTENT |
|
||||
|---------------|-----------------|
|
||||
|comment |comment |
|
||||
|close_comment |comment |
|
||||
|reopen_comment |comment |
|
||||
|close |"Close" |
|
||||
|reopen |"Reopen" |
|
||||
|commit |comment commitId |
|
||||
|merge |comment |
|
||||
|delete_branch |branchName |
|
||||
|refer |issueId:title |
|
||||
|ACTION |CONTENT |
|
||||
|-------------------|------------------------|
|
||||
|comment |comment |
|
||||
|close_comment |comment |
|
||||
|reopen_comment |comment |
|
||||
|close |"Close" |
|
||||
|reopen |"Reopen" |
|
||||
|commit |comment commitId |
|
||||
|merge |comment |
|
||||
|delete_branch |branchName |
|
||||
|refer |issueId:title |
|
||||
|add_label |labelName |
|
||||
|delete_label |labelName |
|
||||
|change_priority |oldPriority:priority |
|
||||
|change_milestone|oldMilestone:milestone|
|
||||
|assign |oldAssigned:assigned |
|
||||
|
||||
### comment
|
||||
|
||||
@@ -54,3 +59,23 @@ Therefore, this comment is not displayed, and not counted as a comment.
|
||||
|
||||
This value is saved when other issue or issue comment contains reference to the issue like `#issueId`.
|
||||
At the same time, store id and title of the referrer issue as `id:title`.
|
||||
|
||||
### add_label
|
||||
|
||||
This value is saved when users have added the label.
|
||||
|
||||
### delete_label
|
||||
|
||||
This value is saved when users have deleted the label.
|
||||
|
||||
### change_priority
|
||||
|
||||
This value is saved when users have changed the priority.
|
||||
|
||||
### change_milestone
|
||||
|
||||
This value is saved when users have changed the milestone.
|
||||
|
||||
### assign
|
||||
|
||||
This value is saved when users have assign issue/PR to user or remove the assign.
|
||||
|
||||
@@ -8,7 +8,7 @@ import gitbucket.core.service.IssuesService._
|
||||
|
||||
class DashboardController extends DashboardControllerBase
|
||||
with IssuesService with PullRequestService with RepositoryService with AccountService with CommitsService
|
||||
with UsersAuthenticator
|
||||
with LabelsService with PrioritiesService with MilestonesService with UsersAuthenticator
|
||||
|
||||
trait DashboardControllerBase extends ControllerBase {
|
||||
self: IssuesService with PullRequestService with RepositoryService with AccountService
|
||||
|
||||
@@ -271,25 +271,25 @@ trait IssuesControllerBase extends ControllerBase {
|
||||
|
||||
ajaxPost("/:owner/:repository/issues/:id/label/new")(writableUsersOnly { repository =>
|
||||
defining(params("id").toInt){ issueId =>
|
||||
registerIssueLabel(repository.owner, repository.name, issueId, params("labelId").toInt)
|
||||
registerIssueLabel(repository.owner, repository.name, issueId, params("labelId").toInt, true)
|
||||
html.labellist(getIssueLabels(repository.owner, repository.name, issueId))
|
||||
}
|
||||
})
|
||||
|
||||
ajaxPost("/:owner/:repository/issues/:id/label/delete")(writableUsersOnly { repository =>
|
||||
defining(params("id").toInt){ issueId =>
|
||||
deleteIssueLabel(repository.owner, repository.name, issueId, params("labelId").toInt)
|
||||
deleteIssueLabel(repository.owner, repository.name, issueId, params("labelId").toInt, true)
|
||||
html.labellist(getIssueLabels(repository.owner, repository.name, issueId))
|
||||
}
|
||||
})
|
||||
|
||||
ajaxPost("/:owner/:repository/issues/:id/assign")(writableUsersOnly { repository =>
|
||||
updateAssignedUserName(repository.owner, repository.name, params("id").toInt, assignedUserName("assignedUserName"))
|
||||
updateAssignedUserName(repository.owner, repository.name, params("id").toInt, assignedUserName("assignedUserName"), true)
|
||||
Ok("updated")
|
||||
})
|
||||
|
||||
ajaxPost("/:owner/:repository/issues/:id/milestone")(writableUsersOnly { repository =>
|
||||
updateMilestoneId(repository.owner, repository.name, params("id").toInt, milestoneId("milestoneId"))
|
||||
updateMilestoneId(repository.owner, repository.name, params("id").toInt, milestoneId("milestoneId"), true)
|
||||
milestoneId("milestoneId").map { milestoneId =>
|
||||
getMilestonesWithIssueCount(repository.owner, repository.name)
|
||||
.find(_._1.milestoneId == milestoneId).map { case (_, openCount, closeCount) =>
|
||||
@@ -299,7 +299,8 @@ trait IssuesControllerBase extends ControllerBase {
|
||||
})
|
||||
|
||||
ajaxPost("/:owner/:repository/issues/:id/priority")(writableUsersOnly { repository =>
|
||||
updatePriorityId(repository.owner, repository.name, params("id").toInt, priorityId("priorityId"))
|
||||
val priority = priorityId("priorityId")
|
||||
updatePriorityId(repository.owner, repository.name, params("id").toInt, priority, true)
|
||||
Ok("updated")
|
||||
})
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package gitbucket.core.controller
|
||||
|
||||
import gitbucket.core.issues.labels.html
|
||||
import gitbucket.core.service.{RepositoryService, AccountService, IssuesService, LabelsService}
|
||||
import gitbucket.core.service.{RepositoryService, AccountService, IssuesService, LabelsService, MilestonesService, PrioritiesService}
|
||||
import gitbucket.core.util.{ReferrerAuthenticator, WritableUsersAuthenticator}
|
||||
import gitbucket.core.util.Implicits._
|
||||
import gitbucket.core.util.SyntaxSugars._
|
||||
@@ -10,8 +10,9 @@ import org.scalatra.i18n.Messages
|
||||
import org.scalatra.Ok
|
||||
|
||||
class LabelsController extends LabelsControllerBase
|
||||
with LabelsService with IssuesService with RepositoryService with AccountService
|
||||
with ReferrerAuthenticator with WritableUsersAuthenticator
|
||||
with IssuesService with RepositoryService with AccountService
|
||||
with LabelsService with PrioritiesService with MilestonesService
|
||||
with ReferrerAuthenticator with WritableUsersAuthenticator
|
||||
|
||||
trait LabelsControllerBase extends ControllerBase {
|
||||
self: LabelsService with IssuesService with RepositoryService
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package gitbucket.core.controller
|
||||
|
||||
import gitbucket.core.issues.priorities.html
|
||||
import gitbucket.core.service.{RepositoryService, AccountService, IssuesService, PrioritiesService}
|
||||
import gitbucket.core.service.{RepositoryService, AccountService, IssuesService, LabelsService, MilestonesService, PrioritiesService}
|
||||
import gitbucket.core.util.{ReferrerAuthenticator, WritableUsersAuthenticator}
|
||||
import gitbucket.core.util.Implicits._
|
||||
import gitbucket.core.util.SyntaxSugars._
|
||||
@@ -10,8 +10,9 @@ import org.scalatra.i18n.Messages
|
||||
import org.scalatra.Ok
|
||||
|
||||
class PrioritiesController extends PrioritiesControllerBase
|
||||
with PrioritiesService with IssuesService with RepositoryService with AccountService
|
||||
with ReferrerAuthenticator with WritableUsersAuthenticator
|
||||
with IssuesService with RepositoryService with AccountService
|
||||
with LabelsService with PrioritiesService with MilestonesService
|
||||
with ReferrerAuthenticator with WritableUsersAuthenticator
|
||||
|
||||
trait PrioritiesControllerBase extends ControllerBase {
|
||||
self: PrioritiesService with IssuesService with RepositoryService
|
||||
|
||||
@@ -4,6 +4,7 @@ import gitbucket.core.util.JGitUtil.CommitInfo
|
||||
import gitbucket.core.util.StringUtil._
|
||||
import gitbucket.core.util.Implicits._
|
||||
import gitbucket.core.util.SyntaxSugars._
|
||||
import gitbucket.core.controller.Context
|
||||
import gitbucket.core.model.{Issue, PullRequest, IssueComment, IssueLabel, Label, Account, Repository, CommitState, Role}
|
||||
import gitbucket.core.model.Profile._
|
||||
import gitbucket.core.model.Profile.profile._
|
||||
@@ -11,7 +12,7 @@ import gitbucket.core.model.Profile.profile.blockingApi._
|
||||
import gitbucket.core.model.Profile.dateColumnType
|
||||
|
||||
trait IssuesService {
|
||||
self: AccountService with RepositoryService =>
|
||||
self: AccountService with RepositoryService with LabelsService with PrioritiesService with MilestonesService =>
|
||||
import IssuesService._
|
||||
|
||||
def getIssue(owner: String, repository: String, issueId: String)(implicit s: Session) =
|
||||
@@ -321,11 +322,35 @@ trait IssuesService {
|
||||
} get
|
||||
}
|
||||
|
||||
def registerIssueLabel(owner: String, repository: String, issueId: Int, labelId: Int)(implicit s: Session): Int = {
|
||||
def registerIssueLabel(owner: String, repository: String, issueId: Int, labelId: Int, insertComment: Boolean = false)(implicit context: Context, s: Session): Int = {
|
||||
if (insertComment) {
|
||||
IssueComments insert IssueComment(
|
||||
userName = owner,
|
||||
repositoryName = repository,
|
||||
issueId = issueId,
|
||||
action = "add_label",
|
||||
commentedUserName = context.loginAccount.map(_.userName).getOrElse("Unknown user"),
|
||||
content = getLabel(owner, repository, labelId).map(_.labelName).getOrElse("Unknown label"),
|
||||
registeredDate = currentDate,
|
||||
updatedDate = currentDate
|
||||
)
|
||||
}
|
||||
IssueLabels insert IssueLabel(owner, repository, issueId, labelId)
|
||||
}
|
||||
|
||||
def deleteIssueLabel(owner: String, repository: String, issueId: Int, labelId: Int)(implicit s: Session): Int = {
|
||||
def deleteIssueLabel(owner: String, repository: String, issueId: Int, labelId: Int, insertComment: Boolean = false)(implicit context: Context, s: Session): Int = {
|
||||
if (insertComment) {
|
||||
IssueComments insert IssueComment(
|
||||
userName = owner,
|
||||
repositoryName = repository,
|
||||
issueId = issueId,
|
||||
action = "delete_label",
|
||||
commentedUserName = context.loginAccount.map(_.userName).getOrElse("Unknown user"),
|
||||
content = getLabel(owner, repository, labelId).map(_.labelName).getOrElse("Unknown label"),
|
||||
registeredDate = currentDate,
|
||||
updatedDate = currentDate
|
||||
)
|
||||
}
|
||||
IssueLabels filter(_.byPrimaryKey(owner, repository, issueId, labelId)) delete
|
||||
}
|
||||
|
||||
@@ -350,15 +375,57 @@ trait IssuesService {
|
||||
.update(title, content, currentDate)
|
||||
}
|
||||
|
||||
def updateAssignedUserName(owner: String, repository: String, issueId: Int, assignedUserName: Option[String])(implicit s: Session): Int = {
|
||||
def updateAssignedUserName(owner: String, repository: String, issueId: Int, assignedUserName: Option[String], insertComment: Boolean = false)(implicit context: Context, s: Session): Int = {
|
||||
if (insertComment) {
|
||||
val oldAssigned = getIssue(owner, repository, s"${issueId}").get.assignedUserName.getOrElse("Not assigned")
|
||||
val assigned = assignedUserName.getOrElse("Not assigned")
|
||||
IssueComments insert IssueComment(
|
||||
userName = owner,
|
||||
repositoryName = repository,
|
||||
issueId = issueId,
|
||||
action = "assign",
|
||||
commentedUserName = context.loginAccount.map(_.userName).getOrElse("Unknown user"),
|
||||
content = s"${oldAssigned}:${assigned}",
|
||||
registeredDate = currentDate,
|
||||
updatedDate = currentDate
|
||||
)
|
||||
}
|
||||
Issues.filter(_.byPrimaryKey(owner, repository, issueId)).map(t => (t.assignedUserName?, t.updatedDate)).update(assignedUserName, currentDate)
|
||||
}
|
||||
|
||||
def updateMilestoneId(owner: String, repository: String, issueId: Int, milestoneId: Option[Int])(implicit s: Session): Int = {
|
||||
def updateMilestoneId(owner: String, repository: String, issueId: Int, milestoneId: Option[Int], insertComment: Boolean = false)(implicit context: Context, s: Session): Int = {
|
||||
if (insertComment) {
|
||||
val oldMilestoneName = getIssue(owner, repository, s"${issueId}").get.milestoneId.map(getMilestone(owner, repository, _).map(_.title).getOrElse("Unknown milestone")).getOrElse("No milestone")
|
||||
val milestoneName = milestoneId.map(getMilestone(owner, repository, _).map(_.title).getOrElse("Unknown milestone")).getOrElse("No milestone")
|
||||
IssueComments insert IssueComment(
|
||||
userName = owner,
|
||||
repositoryName = repository,
|
||||
issueId = issueId,
|
||||
action = "change_milestone",
|
||||
commentedUserName = context.loginAccount.map(_.userName).getOrElse("Unknown user"),
|
||||
content = s"${oldMilestoneName}:${milestoneName}",
|
||||
registeredDate = currentDate,
|
||||
updatedDate = currentDate
|
||||
)
|
||||
}
|
||||
Issues.filter(_.byPrimaryKey(owner, repository, issueId)).map(t => (t.milestoneId?, t.updatedDate)).update(milestoneId, currentDate)
|
||||
}
|
||||
|
||||
def updatePriorityId(owner: String, repository: String, issueId: Int, priorityId: Option[Int])(implicit s: Session): Int = {
|
||||
def updatePriorityId(owner: String, repository: String, issueId: Int, priorityId: Option[Int], insertComment: Boolean = false)(implicit context: Context, s: Session): Int = {
|
||||
if (insertComment) {
|
||||
val oldPriorityName = getIssue(owner, repository, s"${issueId}").get.priorityId.map(getPriority(owner, repository, _).map(_.priorityName).getOrElse("Unknown priority")).getOrElse("No priority")
|
||||
val priorityName = priorityId.map(getPriority(owner, repository, _).map(_.priorityName).getOrElse("Unknown priority")).getOrElse("No priority")
|
||||
IssueComments insert IssueComment(
|
||||
userName = owner,
|
||||
repositoryName = repository,
|
||||
issueId = issueId,
|
||||
action = "change_priority",
|
||||
commentedUserName = context.loginAccount.map(_.userName).getOrElse("Unknown user"),
|
||||
content = s"${oldPriorityName}:${priorityName}",
|
||||
registeredDate = currentDate,
|
||||
updatedDate = currentDate
|
||||
)
|
||||
}
|
||||
Issues.filter(_.byPrimaryKey(owner, repository, issueId)).map(t => (t.priorityId?, t.updatedDate)).update(priorityId, currentDate)
|
||||
}
|
||||
|
||||
|
||||
@@ -185,7 +185,8 @@ import scala.collection.JavaConverters._
|
||||
class CommitLogHook(owner: String, repository: String, pusher: String, baseUrl: String, sshUrl: Option[String])
|
||||
extends PostReceiveHook with PreReceiveHook
|
||||
with RepositoryService with AccountService with IssuesService with ActivityService with PullRequestService with WebHookService
|
||||
with WebHookPullRequestService with CommitsService {
|
||||
with LabelsService with PrioritiesService with MilestonesService
|
||||
with WebHookPullRequestService with CommitsService {
|
||||
|
||||
private val logger = LoggerFactory.getLogger(classOf[CommitLogHook])
|
||||
private var existIds: Seq[String] = Nil
|
||||
|
||||
@@ -34,32 +34,185 @@
|
||||
|
||||
@comments.map {
|
||||
case comment: gitbucket.core.model.IssueComment => {
|
||||
@if(comment.action != "close" && comment.action != "reopen" && comment.action != "delete_branch"
|
||||
&& comment.action != "commit" && comment.action != "refer"){
|
||||
<div class="panel panel-default issue-comment-box" id="comment-@comment.commentId">
|
||||
<div class="panel-heading">
|
||||
@helpers.avatar(comment.commentedUserName, 20)
|
||||
@helpers.user(comment.commentedUserName, styleClass="username strong")
|
||||
<span class="muted">
|
||||
@if(comment.action == "comment"){
|
||||
commented
|
||||
} else {
|
||||
referenced the @issueOrPullRequest()
|
||||
}
|
||||
<a href="#comment-@comment.commentId">
|
||||
@comment.action match {
|
||||
case "close" => {
|
||||
}
|
||||
case "commit" => {
|
||||
@defining({
|
||||
val (content, id) = " ([a-f0-9]{40})$".r.findFirstMatchIn(comment.content)
|
||||
.map(m => (m.before.toString -> Some(m.group(1))))
|
||||
.getOrElse(comment.content -> None)
|
||||
val head = content.take(100).takeWhile(_ != '\n')
|
||||
(id, head, if(head == content){ None }else{ Some(content.drop(head.length).dropWhile(_ == '\n')) }.filter(_.nonEmpty))
|
||||
}){ case (commitId, head, rest) =>
|
||||
<div class="discussion-item discussion-item-commit">
|
||||
<div class="discussion-item-header">
|
||||
<span class="discussion-item-icon"><i class="octicon octicon-bookmark"></i></span>
|
||||
@helpers.avatar(comment.commentedUserName, 16)
|
||||
@helpers.user(comment.commentedUserName, styleClass="username strong")
|
||||
added a commit that referenced this @issueOrPullRequest()
|
||||
@gitbucket.core.helper.html.datetimeago(comment.registeredDate)
|
||||
</a>
|
||||
</span>
|
||||
@if(comment.action != "commit" && comment.action != "merge" && comment.action != "refer"
|
||||
&& (isManageable || context.loginAccount.map(_.userName == comment.commentedUserName).getOrElse(false))){
|
||||
<span class="pull-right">
|
||||
<a href="#" data-comment-id="@comment.commentId"><i class="octicon octicon-pencil" aria-label="Edit"></i></a>
|
||||
<a href="#" data-comment-id="@comment.commentId"><i class="octicon octicon-x" aria-label="Remove"></i></a>
|
||||
</span>
|
||||
}
|
||||
</div>
|
||||
<div style="discussion-item-content">
|
||||
@commitId.map{ id =>
|
||||
<span class="pull-right"><a href="@context.path/@repository.owner/@repository.name/commit/@id" class="monospace">@id.substring(0, 7)</a></span>
|
||||
}
|
||||
<span class="discussion-item-content-head"><i class="octicon octicon-git-commit"></i></span>
|
||||
@helpers.link(head, repository)
|
||||
@rest.map{ content =>
|
||||
<a href="javascript:void(0)" class="omit" onclick="$(this.parentNode).find('.discussion-item-content-text').toggle()">...</a>
|
||||
<pre class="reset discussion-item-content-text" style="display:none">@helpers.link(content, repository)</pre>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-body issue-content markdown-body" id="commentContent-@comment.commentId">
|
||||
@helpers.markdown(
|
||||
}
|
||||
}
|
||||
case "refer" => {
|
||||
<div class="discussion-item discussion-item-refer">
|
||||
<div class="discussion-item-header">
|
||||
<span class="discussion-item-icon"><i class="octicon octicon-bookmark"></i></span>
|
||||
@helpers.avatar(comment.commentedUserName, 16)
|
||||
@helpers.user(comment.commentedUserName, styleClass="username strong")
|
||||
referenced the @issueOrPullRequest()
|
||||
@gitbucket.core.helper.html.datetimeago(comment.registeredDate)
|
||||
</div>
|
||||
<div style="discussion-item-content">
|
||||
@defining(comment.content.split(":")){ case Array(issueId, rest @ _*) =>
|
||||
<strong>@helpers.issueLink(repository, issueId.toInt): @rest.mkString(":")</strong>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
case "merge" => {
|
||||
<div class="discussion-item discussion-item-merge">
|
||||
<div class="discussion-item-header">
|
||||
<span class="discussion-item-icon"><i class="octicon octicon-git-merge"></i></span>
|
||||
@helpers.avatar(comment.commentedUserName, 16)
|
||||
@helpers.user(comment.commentedUserName, styleClass="username strong")
|
||||
merged commit
|
||||
<code>@pullreq.map(_.commitIdTo.substring(0, 7))</code> into
|
||||
@if(pullreq.get.requestUserName == repository.owner){
|
||||
<code>@pullreq.map(_.branch)</code> from <code>@pullreq.map(_.requestBranch)</code>
|
||||
} else {
|
||||
<code>@pullreq.map(_.userName):@pullreq.map(_.branch)</code> from <code>@pullreq.map(_.requestUserName):@pullreq.map(_.requestBranch)</code>
|
||||
}
|
||||
@gitbucket.core.helper.html.datetimeago(comment.registeredDate)
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
case "close" | "close_comment" => {
|
||||
<div class="discussion-item discussion-item-close">
|
||||
<div class="discussion-item-header">
|
||||
<span class="discussion-item-icon"><i class="octicon octicon-circle-slash"></i></span>
|
||||
@helpers.avatar(comment.commentedUserName, 16)
|
||||
@helpers.user(comment.commentedUserName, styleClass="username strong")
|
||||
closed this @issueOrPullRequest()
|
||||
@gitbucket.core.helper.html.datetimeago(comment.registeredDate)
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
case "reopen" | "reopen_comment" => {
|
||||
<div class="discussion-item discussion-item-reopen">
|
||||
<div class="discussion-item-header">
|
||||
<span class="discussion-item-icon"><i class="octicon octicon-primitive-dot"></i></span>
|
||||
@helpers.avatar(comment.commentedUserName, 16)
|
||||
@helpers.user(comment.commentedUserName, styleClass="username strong")
|
||||
reopened the @issueOrPullRequest()
|
||||
@gitbucket.core.helper.html.datetimeago(comment.registeredDate)
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
case "delete_branch" => {
|
||||
<div class="discussion-item discussion-item-delete_branch">
|
||||
<div class="discussion-item-header">
|
||||
<span class="discussion-item-icon"><i class="octicon octicon-git-branch"></i></span>
|
||||
@helpers.avatar(comment.commentedUserName, 16)
|
||||
@helpers.user(comment.commentedUserName, styleClass="username strong")
|
||||
deleted the <code>@pullreq.map(_.requestBranch)</code> branch
|
||||
@gitbucket.core.helper.html.datetimeago(comment.registeredDate)
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
case "add_label" => {
|
||||
<div class="discussion-item discussion-item-add-label">
|
||||
<div class="discussion-item-header">
|
||||
<span class="discussion-item-icon"><i class="octicon octicon-tag"></i></span>
|
||||
@helpers.avatar(comment.commentedUserName, 16)
|
||||
@helpers.user(comment.commentedUserName, styleClass="username strong")
|
||||
add the <code>@comment.content</code> label
|
||||
@gitbucket.core.helper.html.datetimeago(comment.registeredDate)
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
case "delete_label" => {
|
||||
<div class="discussion-item discussion-item-delete-label">
|
||||
<div class="discussion-item-header">
|
||||
<span class="discussion-item-icon"><i class="octicon octicon-tag"></i></span>
|
||||
@helpers.avatar(comment.commentedUserName, 16)
|
||||
@helpers.user(comment.commentedUserName, styleClass="username strong")
|
||||
removed the <code>@comment.content</code> label
|
||||
@gitbucket.core.helper.html.datetimeago(comment.registeredDate)
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
case "change_priority" => {
|
||||
<div class="discussion-item discussion-item-change-priority">
|
||||
<div class="discussion-item-header">
|
||||
<span class="discussion-item-icon"><i class="octicon octicon-flame"></i></span>
|
||||
@helpers.avatar(comment.commentedUserName, 16)
|
||||
@helpers.user(comment.commentedUserName, styleClass="username strong")
|
||||
change priority from <code>@comment.content.split(":")(0)</code> to <code>@comment.content.split(":")(1)</code>
|
||||
@gitbucket.core.helper.html.datetimeago(comment.registeredDate)
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
case "change_milestone" => {
|
||||
<div class="discussion-item discussion-item-change-milestone">
|
||||
<div class="discussion-item-header">
|
||||
<span class="discussion-item-icon"><i class="octicon octicon-milestone"></i></span>
|
||||
@helpers.avatar(comment.commentedUserName, 16)
|
||||
@helpers.user(comment.commentedUserName, styleClass="username strong")
|
||||
change milestone from <code>@comment.content.split(":")(0)</code> to <code>@comment.content.split(":")(1)</code>
|
||||
@gitbucket.core.helper.html.datetimeago(comment.registeredDate)
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
case "assign" => {
|
||||
<div class="discussion-item discussion-item-assign">
|
||||
<div class="discussion-item-header">
|
||||
<span class="discussion-item-icon"><i class="octicon octicon-person"></i></span>
|
||||
@helpers.avatar(comment.commentedUserName, 16)
|
||||
@helpers.user(comment.commentedUserName, styleClass="username strong")
|
||||
change assignee from <code>@comment.content.split(":")(0)</code> to <code>@comment.content.split(":")(1)</code>
|
||||
@gitbucket.core.helper.html.datetimeago(comment.registeredDate)
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
case _ => {
|
||||
<div class="panel panel-default issue-comment-box" id="comment-@comment.commentId">
|
||||
<div class="panel-heading">
|
||||
@helpers.avatar(comment.commentedUserName, 20)
|
||||
@helpers.user(comment.commentedUserName, styleClass="username strong")
|
||||
<span class="muted">
|
||||
@if(comment.action == "comment"){
|
||||
commented
|
||||
} else {
|
||||
referenced the @issueOrPullRequest()
|
||||
}
|
||||
<a href="#comment-@comment.commentId">
|
||||
@gitbucket.core.helper.html.datetimeago(comment.registeredDate)
|
||||
</a>
|
||||
</span>
|
||||
@if(comment.action != "commit" && comment.action != "merge" && comment.action != "refer"
|
||||
&& (isManageable || context.loginAccount.map(_.userName == comment.commentedUserName).getOrElse(false))){
|
||||
<span class="pull-right">
|
||||
<a href="#" data-comment-id="@comment.commentId"><i class="octicon octicon-pencil" aria-label="Edit"></i></a>
|
||||
<a href="#" data-comment-id="@comment.commentId"><i class="octicon octicon-x" aria-label="Remove"></i></a>
|
||||
</span>
|
||||
}
|
||||
</div>
|
||||
<div class="panel-body issue-content markdown-body" id="commentContent-@comment.commentId">
|
||||
@helpers.markdown(
|
||||
markdown = comment.content,
|
||||
repository = repository,
|
||||
enableWikiLink = false,
|
||||
@@ -67,106 +220,11 @@
|
||||
enableLineBreaks = true,
|
||||
enableTaskList = true,
|
||||
hasWritePermission = isManageable
|
||||
)
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
@if(comment.action == "commit"){
|
||||
@defining({
|
||||
val (content, id) = " ([a-f0-9]{40})$".r.findFirstMatchIn(comment.content)
|
||||
.map(m => (m.before.toString -> Some(m.group(1))))
|
||||
.getOrElse(comment.content -> None)
|
||||
val head = content.take(100).takeWhile(_ != '\n')
|
||||
(id, head, if(head == content){ None }else{ Some(content.drop(head.length).dropWhile(_ == '\n')) }.filter(_.nonEmpty))
|
||||
}){ case (commitId, head, rest) =>
|
||||
<div class="discussion-item discussion-item-commit">
|
||||
<div class="discussion-item-header">
|
||||
<span class="discussion-item-icon"><i class="octicon octicon-bookmark"></i></span>
|
||||
@helpers.avatar(comment.commentedUserName, 16)
|
||||
@helpers.user(comment.commentedUserName, styleClass="username strong")
|
||||
added a commit that referenced this @issueOrPullRequest()
|
||||
@gitbucket.core.helper.html.datetimeago(comment.registeredDate)
|
||||
</div>
|
||||
<div style="discussion-item-content">
|
||||
@commitId.map{ id =>
|
||||
<span class="pull-right"><a href="@context.path/@repository.owner/@repository.name/commit/@id" class="monospace">@id.substring(0, 7)</a></span>
|
||||
}
|
||||
<span class="discussion-item-content-head"><i class="octicon octicon-git-commit"></i></span>
|
||||
@helpers.link(head, repository)
|
||||
@rest.map{ content =>
|
||||
<a href="javascript:void(0)" class="omit" onclick="$(this.parentNode).find('.discussion-item-content-text').toggle()">...</a>
|
||||
<pre class="reset discussion-item-content-text" style="display:none">@helpers.link(content, repository)</pre>
|
||||
}
|
||||
)
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
@if(comment.action == "refer"){
|
||||
<div class="discussion-item discussion-item-refer">
|
||||
<div class="discussion-item-header">
|
||||
<span class="discussion-item-icon"><i class="octicon octicon-bookmark"></i></span>
|
||||
@helpers.avatar(comment.commentedUserName, 16)
|
||||
@helpers.user(comment.commentedUserName, styleClass="username strong")
|
||||
referenced the @issueOrPullRequest()
|
||||
@gitbucket.core.helper.html.datetimeago(comment.registeredDate)
|
||||
</div>
|
||||
<div style="discussion-item-content">
|
||||
@defining(comment.content.split(":")){ case Array(issueId, rest @ _*) =>
|
||||
<strong>@helpers.issueLink(repository, issueId.toInt): @rest.mkString(":")</strong>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
@if(comment.action == "merge"){
|
||||
<div class="discussion-item discussion-item-merge">
|
||||
<div class="discussion-item-header">
|
||||
<span class="discussion-item-icon"><i class="octicon octicon-git-merge"></i></span>
|
||||
@helpers.avatar(comment.commentedUserName, 16)
|
||||
@helpers.user(comment.commentedUserName, styleClass="username strong")
|
||||
merged commit
|
||||
<code>@pullreq.map(_.commitIdTo.substring(0, 7))</code> into
|
||||
@if(pullreq.get.requestUserName == repository.owner){
|
||||
<code>@pullreq.map(_.branch)</code> from <code>@pullreq.map(_.requestBranch)</code>
|
||||
} else {
|
||||
<code>@pullreq.map(_.userName):@pullreq.map(_.branch)</code> from <code>@pullreq.map(_.requestUserName):@pullreq.map(_.requestBranch)</code>
|
||||
}
|
||||
@gitbucket.core.helper.html.datetimeago(comment.registeredDate)
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
@if(comment.action == "close" || comment.action == "close_comment"){
|
||||
<div class="discussion-item discussion-item-close">
|
||||
<div class="discussion-item-header">
|
||||
<span class="discussion-item-icon"><i class="octicon octicon-circle-slash"></i></span>
|
||||
@helpers.avatar(comment.commentedUserName, 16)
|
||||
@helpers.user(comment.commentedUserName, styleClass="username strong")
|
||||
closed this @issueOrPullRequest()
|
||||
@gitbucket.core.helper.html.datetimeago(comment.registeredDate)
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
@if(comment.action == "reopen" || comment.action == "reopen_comment"){
|
||||
<div class="discussion-item discussion-item-reopen">
|
||||
<div class="discussion-item-header">
|
||||
<span class="discussion-item-icon"><i class="octicon octicon-primitive-dot"></i></span>
|
||||
@helpers.avatar(comment.commentedUserName, 16)
|
||||
@helpers.user(comment.commentedUserName, styleClass="username strong")
|
||||
reopened the @issueOrPullRequest()
|
||||
@gitbucket.core.helper.html.datetimeago(comment.registeredDate)
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
@if(comment.action == "delete_branch"){
|
||||
<div class="discussion-item discussion-item-delete_branch">
|
||||
<div class="discussion-item-header">
|
||||
<span class="discussion-item-icon"><i class="octicon octicon-git-branch"></i></span>
|
||||
@helpers.avatar(comment.commentedUserName, 16)
|
||||
@helpers.user(comment.commentedUserName, styleClass="username strong")
|
||||
deleted the <code>@pullreq.map(_.requestBranch)</code> branch
|
||||
@gitbucket.core.helper.html.datetimeago(comment.registeredDate)
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
case comment: CommitComment => {
|
||||
@gitbucket.core.helper.html.commitcomment(comment, isManageable, repository, pullreq.map(_.commitIdTo))
|
||||
|
||||
Reference in New Issue
Block a user