mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-08 22:45:51 +01:00
(refs #584) Fix the activity of commenting to pull request.
This commit is contained in:
@@ -57,7 +57,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
||||
oldLineNumber: Option[Int],
|
||||
newLineNumber: Option[Int],
|
||||
content: String,
|
||||
pullRequest: Boolean
|
||||
issueId: Option[Int]
|
||||
)
|
||||
|
||||
val editorForm = mapping(
|
||||
@@ -83,7 +83,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
||||
"oldLineNumber" -> trim(label("Old line number", optional(number()))),
|
||||
"newLineNumber" -> trim(label("New line number", optional(number()))),
|
||||
"content" -> trim(label("Content", text(required))),
|
||||
"pullRequest" -> trim(label("In pull request", boolean()))
|
||||
"issueId" -> trim(label("Issue Id", optional(number())))
|
||||
)(CommentForm.apply)
|
||||
|
||||
/**
|
||||
@@ -247,20 +247,23 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
||||
post("/:owner/:repository/commit/:id/comment/new", commentForm)(readableUsersOnly { (form, repository) =>
|
||||
val id = params("id")
|
||||
createCommitComment(repository.owner, repository.name, id, context.loginAccount.get.userName, form.content,
|
||||
form.fileName, form.oldLineNumber, form.newLineNumber, form.pullRequest)
|
||||
recordCommentCommitActivity(repository.owner, repository.name, context.loginAccount.get.userName, id, form.content)
|
||||
form.fileName, form.oldLineNumber, form.newLineNumber, form.issueId.isDefined)
|
||||
if (form.issueId.isDefined)
|
||||
recordCommentPullRequestActivity(repository.owner, repository.name, context.loginAccount.get.userName, form.issueId.get, form.content)
|
||||
else
|
||||
recordCommentCommitActivity(repository.owner, repository.name, context.loginAccount.get.userName, id, form.content)
|
||||
redirect(s"/${repository.owner}/${repository.name}/commit/${id}")
|
||||
})
|
||||
|
||||
ajaxGet("/:owner/:repository/commit/:id/comment/_form")(readableUsersOnly { repository =>
|
||||
val id = params("id")
|
||||
val fileName = params.get("fileName")
|
||||
val oldLineNumber = params.get("oldLineNumber") flatMap {b => Some(b.toInt)}
|
||||
val newLineNumber = params.get("newLineNumber") flatMap {b => Some(b.toInt)}
|
||||
val pullRequest = params.get("pullRequest")
|
||||
val oldLineNumber = params.get("oldLineNumber") map (_.toInt)
|
||||
val newLineNumber = params.get("newLineNumber") map (_.toInt)
|
||||
val issueId = params.get("issueId") map (_.toInt)
|
||||
repo.html.commentform(
|
||||
commitId = id,
|
||||
fileName, oldLineNumber, newLineNumber, pullRequest.map(_.toBoolean).getOrElse(false),
|
||||
fileName, oldLineNumber, newLineNumber, issueId,
|
||||
hasWritePermission = hasWritePermission(repository.owner, repository.name, context.loginAccount),
|
||||
repository = repository
|
||||
)
|
||||
@@ -269,8 +272,11 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
||||
ajaxPost("/:owner/:repository/commit/:id/comment/_data/new", commentForm)(readableUsersOnly { (form, repository) =>
|
||||
val id = params("id")
|
||||
val commentId = createCommitComment(repository.owner, repository.name, id, context.loginAccount.get.userName,
|
||||
form.content, form.fileName, form.oldLineNumber, form.newLineNumber, form.pullRequest)
|
||||
recordCommentCommitActivity(repository.owner, repository.name, context.loginAccount.get.userName, id, form.content)
|
||||
form.content, form.fileName, form.oldLineNumber, form.newLineNumber, form.issueId.isDefined)
|
||||
if (form.issueId.isDefined)
|
||||
recordCommentPullRequestActivity(repository.owner, repository.name, context.loginAccount.get.userName, form.issueId.get, form.content)
|
||||
else
|
||||
recordCommentCommitActivity(repository.owner, repository.name, context.loginAccount.get.userName, id, form.content)
|
||||
helper.html.commitcomment(getCommitComment(repository.owner, repository.name, commentId.toString).get,
|
||||
hasWritePermission(repository.owner, repository.name, context.loginAccount), repository)
|
||||
})
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
newCommitId: Option[String],
|
||||
oldCommitId: Option[String],
|
||||
showIndex: Boolean,
|
||||
pullRequest: Boolean,
|
||||
issueId: Option[Int],
|
||||
hasWritePermission: Boolean,
|
||||
showLineNotes: Boolean)(implicit context: app.Context)
|
||||
@import context._
|
||||
@@ -157,7 +157,7 @@ $(function(){
|
||||
fileName = $(this).closest('.table-bordered').attr('fileName'),
|
||||
oldLineNumber = $(this).closest('.newline').prev('.oldline').text(),
|
||||
newLineNumber = $(this).closest('.newline').clone().children().remove().end().text(),
|
||||
url = '@url(repository)/commit/' + commitId + '/comment/_form?fileName=' + fileName + '&pullRequest=@pullRequest';
|
||||
url = '@url(repository)/commit/' + commitId + '/comment/_form?fileName=' + fileName @if(issueId.isDefined){+ '&issueId=@issueId.get'}
|
||||
if (!isNaN(oldLineNumber) && oldLineNumber != null && oldLineNumber !== '') {
|
||||
url += ('&oldLineNumber=' + oldLineNumber)
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@
|
||||
</table>
|
||||
} else {
|
||||
@pulls.html.commits(commits, Some(comments), repository)
|
||||
@helper.html.diff(diffs, repository, Some(commitId), Some(sourceId), true, false, hasWritePermission, false)
|
||||
@helper.html.diff(diffs, repository, Some(commitId), Some(sourceId), true, None, hasWritePermission, false)
|
||||
<p>Showing you all comments on commits in this comparison.</p>
|
||||
@issues.html.commentlist(None, comments, hasWritePermission, repository, None)
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@
|
||||
@pulls.html.commits(dayByDayCommits, Some(comments), repository)
|
||||
</div>
|
||||
<div class="tab-pane" id="files">
|
||||
@helper.html.diff(diffs, repository, Some(commits.head.id), Some(commits.last.id), true, true, hasWritePermission, true)
|
||||
@helper.html.diff(diffs, repository, Some(commits.head.id), Some(commits.last.id), true, Some(pullreq.issueId), hasWritePermission, true)
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
fileName: Option[String] = None,
|
||||
oldLineNumber: Option[Int] = None,
|
||||
newLineNumber: Option[Int] = None,
|
||||
pullRequest: Boolean,
|
||||
issueId: Option[Int] = None,
|
||||
hasWritePermission: Boolean,
|
||||
repository: service.RepositoryService.RepositoryInfo)(implicit context: app.Context)
|
||||
@import context._
|
||||
@@ -29,7 +29,7 @@
|
||||
<input type="submit" class="btn btn-success" formaction="@url(repository)/commit/@commitId/comment/new" value="Comment on this commit"/>
|
||||
</div>
|
||||
}
|
||||
<input type="hidden" name="pullRequest" value="@pullRequest">
|
||||
@if(issueId.isDefined){<input type="hidden" name="issueId" value="@issueId.get">}
|
||||
@if(fileName.isDefined){<input type="hidden" name="fileName" value="@fileName.get">}
|
||||
@if(oldLineNumber.isDefined){<input type="hidden" name="oldLineNumber" value="@oldLineNumber.get">}
|
||||
@if(newLineNumber.isDefined){<input type="hidden" name="newLineNumber" value="@newLineNumber.get">}
|
||||
|
||||
@@ -83,14 +83,14 @@
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@helper.html.diff(diffs, repository, Some(commit.id), oldCommitId, true, false, hasWritePermission, true)
|
||||
@helper.html.diff(diffs, repository, Some(commit.id), oldCommitId, true, None, hasWritePermission, true)
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" id="show-notes"> Show line notes below
|
||||
</label>
|
||||
<div id="comment-list">
|
||||
@issues.html.commentlist(None, comments, hasWritePermission, repository, None)
|
||||
</div>
|
||||
@commentform(commitId = commitId, pullRequest = false, hasWritePermission = hasWritePermission, repository = repository)
|
||||
@commentform(commitId = commitId, hasWritePermission = hasWritePermission, repository = repository)
|
||||
}
|
||||
}
|
||||
<script>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
@helper.html.diff(diffs, repository, None, None, false, false, false, false)
|
||||
@helper.html.diff(diffs, repository, None, None, false, None, false, false)
|
||||
@if(hasWritePermission){
|
||||
<div>
|
||||
@if(pageName.isDefined){
|
||||
|
||||
Reference in New Issue
Block a user