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