diff --git a/src/main/scala/app/RepositoryViewerController.scala b/src/main/scala/app/RepositoryViewerController.scala index 2a313c0..8c83f2c 100644 --- a/src/main/scala/app/RepositoryViewerController.scala +++ b/src/main/scala/app/RepositoryViewerController.scala @@ -57,7 +57,7 @@ oldLineNumber: Option[Int], newLineNumber: Option[Int], content: String, - pullRequest: Boolean + issueId: Option[Int] ) val editorForm = mapping( @@ -83,7 +83,7 @@ "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 @@ 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 @@ 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) }) diff --git a/src/main/twirl/helper/diff.scala.html b/src/main/twirl/helper/diff.scala.html index 1fb4e9a..db06b04 100644 --- a/src/main/twirl/helper/diff.scala.html +++ b/src/main/twirl/helper/diff.scala.html @@ -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 @@ 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) } diff --git a/src/main/twirl/pulls/compare.scala.html b/src/main/twirl/pulls/compare.scala.html index b3ec768..b3f2483 100644 --- a/src/main/twirl/pulls/compare.scala.html +++ b/src/main/twirl/pulls/compare.scala.html @@ -83,7 +83,7 @@ } 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)
Showing you all comments on commits in this comparison.
@issues.html.commentlist(None, comments, hasWritePermission, repository, None) } diff --git a/src/main/twirl/pulls/pullreq.scala.html b/src/main/twirl/pulls/pullreq.scala.html index 3d66d8c..f6c3abf 100644 --- a/src/main/twirl/pulls/pullreq.scala.html +++ b/src/main/twirl/pulls/pullreq.scala.html @@ -77,7 +77,7 @@ @pulls.html.commits(dayByDayCommits, Some(comments), repository)