diff --git a/src/main/resources/update/2_7.sql b/src/main/resources/update/2_7.sql index 89a7df9..6fa0684 100644 --- a/src/main/resources/update/2_7.sql +++ b/src/main/resources/update/2_7.sql @@ -10,7 +10,7 @@ NEW_LINE_NUMBER INT, REGISTERED_DATE TIMESTAMP NOT NULL, UPDATED_DATE TIMESTAMP NOT NULL, - IS_IN_PR BOOLEAN NOT NULL + PULL_REQUEST BOOLEAN NOT NULL ); ALTER TABLE COMMIT_COMMENT ADD CONSTRAINT IDX_COMMIT_COMMENT_PK PRIMARY KEY (COMMENT_ID); diff --git a/src/main/scala/app/RepositoryViewerController.scala b/src/main/scala/app/RepositoryViewerController.scala index b4dab83..2a313c0 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, - isInPR: Boolean + pullRequest: Boolean ) val editorForm = mapping( @@ -79,11 +79,11 @@ )(DeleteForm.apply) val commentForm = mapping( - "fileName" -> trim(label("Filename", optional(text()))), + "fileName" -> trim(label("Filename", optional(text()))), "oldLineNumber" -> trim(label("Old line number", optional(number()))), "newLineNumber" -> trim(label("New line number", optional(number()))), - "content" -> trim(label("Content", text(required))), - "isInPR" -> trim(label("Is in PR", boolean())) + "content" -> trim(label("Content", text(required))), + "pullRequest" -> trim(label("In pull request", boolean())) )(CommentForm.apply) /** @@ -247,20 +247,20 @@ 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.isInPR) + form.fileName, form.oldLineNumber, form.newLineNumber, form.pullRequest) 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 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 isInPR = params.get("isInPR") + val pullRequest = params.get("pullRequest") repo.html.commentform( commitId = id, - fileName, oldLineNumber, newLineNumber, isInPR.map(_.toBoolean).getOrElse(false), + fileName, oldLineNumber, newLineNumber, pullRequest.map(_.toBoolean).getOrElse(false), hasWritePermission = hasWritePermission(repository.owner, repository.name, context.loginAccount), repository = repository ) @@ -269,7 +269,7 @@ 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.isInPR) + form.content, form.fileName, form.oldLineNumber, form.newLineNumber, form.pullRequest) 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/scala/model/Comment.scala b/src/main/scala/model/Comment.scala index 66146d0..9569871 100644 --- a/src/main/scala/model/Comment.scala +++ b/src/main/scala/model/Comment.scala @@ -55,8 +55,8 @@ val newLine = column[Option[Int]]("NEW_LINE_NUMBER") val registeredDate = column[java.util.Date]("REGISTERED_DATE") val updatedDate = column[java.util.Date]("UPDATED_DATE") - val isInPR = column[Boolean]("IS_IN_PR") - def * = (userName, repositoryName, commitId, commentId, commentedUserName, content, fileName, oldLine, newLine, registeredDate, updatedDate, isInPR) <> (CommitComment.tupled, CommitComment.unapply) + val pullRequest = column[Boolean]("PULL_REQUEST") + def * = (userName, repositoryName, commitId, commentId, commentedUserName, content, fileName, oldLine, newLine, registeredDate, updatedDate, pullRequest) <> (CommitComment.tupled, CommitComment.unapply) def byPrimaryKey(commentId: Int) = this.commentId === commentId.bind } @@ -74,5 +74,5 @@ newLine: Option[Int], registeredDate: java.util.Date, updatedDate: java.util.Date, - isInPR: Boolean + pullRequest: Boolean ) extends Comment diff --git a/src/main/scala/service/CommitsService.scala b/src/main/scala/service/CommitsService.scala index 60d8645..6f70e3c 100644 --- a/src/main/scala/service/CommitsService.scala +++ b/src/main/scala/service/CommitsService.scala @@ -12,9 +12,9 @@ trait CommitsService { - def getCommitComments(owner: String, repository: String, commitId: String, isInPR: Boolean)(implicit s: Session) = + def getCommitComments(owner: String, repository: String, commitId: String, pullRequest: Boolean)(implicit s: Session) = CommitComments filter { - t => t.byCommit(owner, repository, commitId) && (t.isInPR === isInPR || isInPR) + t => t.byCommit(owner, repository, commitId) && (t.pullRequest === pullRequest || pullRequest) } list def getCommitComment(owner: String, repository: String, commentId: String)(implicit s: Session) = @@ -26,7 +26,7 @@ None def createCommitComment(owner: String, repository: String, commitId: String, loginUser: String, - content: String, fileName: Option[String], oldLine: Option[Int], newLine: Option[Int], isInPR: Boolean)(implicit s: Session): Int = + content: String, fileName: Option[String], oldLine: Option[Int], newLine: Option[Int], pullRequest: Boolean)(implicit s: Session): Int = CommitComments.autoInc insert CommitComment( userName = owner, repositoryName = repository, @@ -38,7 +38,7 @@ newLine = newLine, registeredDate = currentDate, updatedDate = currentDate, - isInPR = isInPR) + pullRequest = pullRequest) def updateCommitComment(commentId: Int, content: String)(implicit s: Session) = CommitComments diff --git a/src/main/twirl/helper/commitcomment.scala.html b/src/main/twirl/helper/commitcomment.scala.html index 81c5b82..537b21c 100644 --- a/src/main/twirl/helper/commitcomment.scala.html +++ b/src/main/twirl/helper/commitcomment.scala.html @@ -1,7 +1,7 @@ @(comment: model.CommitComment, -hasWritePermission: Boolean, -repository: service.RepositoryService.RepositoryInfo, -latestCommitId: Option[String] = None)(implicit context: app.Context) + hasWritePermission: Boolean, + repository: service.RepositoryService.RepositoryInfo, + latestCommitId: Option[String] = None)(implicit context: app.Context) @import context._ @import view.helpers._
@@ -11,7 +11,7 @@ @user(comment.commentedUserName, styleClass="username strong") commented - @if(comment.isInPR){ + @if(comment.pullRequest){ on this Pull Request }else{ @if(comment.fileName.isDefined){ diff --git a/src/main/twirl/helper/diff.scala.html b/src/main/twirl/helper/diff.scala.html index 23cc5a1..1fb4e9a 100644 --- a/src/main/twirl/helper/diff.scala.html +++ b/src/main/twirl/helper/diff.scala.html @@ -1,11 +1,11 @@ @(diffs: Seq[util.JGitUtil.DiffInfo], - repository: service.RepositoryService.RepositoryInfo, - newCommitId: Option[String], - oldCommitId: Option[String], - showIndex: Boolean, - isInPR: Boolean, - hasWritePermission: Boolean, - showLineNotes: Boolean)(implicit context: app.Context) + repository: service.RepositoryService.RepositoryInfo, + newCommitId: Option[String], + oldCommitId: Option[String], + showIndex: Boolean, + pullRequest: Boolean, + hasWritePermission: Boolean, + showLineNotes: Boolean)(implicit context: app.Context) @import context._ @import view.helpers._ @import org.eclipse.jgit.diff.DiffEntry.ChangeType @@ -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 + '&isInPR=@isInPR'; + url = '@url(repository)/commit/' + commitId + '/comment/_form?fileName=' + fileName + '&pullRequest=@pullRequest'; if (!isNaN(oldLineNumber) && oldLineNumber != null && oldLineNumber !== '') { url += ('&oldLineNumber=' + oldLineNumber) } diff --git a/src/main/twirl/pulls/commits.scala.html b/src/main/twirl/pulls/commits.scala.html index 7cf9659..2d729b5 100644 --- a/src/main/twirl/pulls/commits.scala.html +++ b/src/main/twirl/pulls/commits.scala.html @@ -21,7 +21,7 @@ @comments.get.flatMap @{ case comment: model.CommitComment => Some(comment) case other => None - }.count(t => t.commitId == commit.id && !t.isInPR) + }.count(t => t.commitId == commit.id && !t.pullRequest) } diff --git a/src/main/twirl/repo/commentform.scala.html b/src/main/twirl/repo/commentform.scala.html index f019b4b..d9935bb 100644 --- a/src/main/twirl/repo/commentform.scala.html +++ b/src/main/twirl/repo/commentform.scala.html @@ -2,7 +2,7 @@ fileName: Option[String] = None, oldLineNumber: Option[Int] = None, newLineNumber: Option[Int] = None, - isInPR: Boolean, + pullRequest: Boolean, hasWritePermission: Boolean, repository: service.RepositoryService.RepositoryInfo)(implicit context: app.Context) @import context._ @@ -29,7 +29,7 @@
} - + @if(fileName.isDefined){} @if(oldLineNumber.isDefined){} @if(newLineNumber.isDefined){} diff --git a/src/main/twirl/repo/commit.scala.html b/src/main/twirl/repo/commit.scala.html index e0ca4f2..c0568e6 100644 --- a/src/main/twirl/repo/commit.scala.html +++ b/src/main/twirl/repo/commit.scala.html @@ -90,7 +90,7 @@
@issues.html.commentlist(None, comments, hasWritePermission, repository, None)
- @commentform(commitId = commitId, isInPR = false, hasWritePermission = hasWritePermission, repository = repository) + @commentform(commitId = commitId, pullRequest = false, hasWritePermission = hasWritePermission, repository = repository) } }