diff --git a/src/main/scala/gitbucket/core/controller/PrioritiesController.scala b/src/main/scala/gitbucket/core/controller/PrioritiesController.scala index ab24b59..e0e010a 100644 --- a/src/main/scala/gitbucket/core/controller/PrioritiesController.scala +++ b/src/main/scala/gitbucket/core/controller/PrioritiesController.scala @@ -16,11 +16,11 @@ self: PrioritiesService with IssuesService with RepositoryService with ReferrerAuthenticator with WritableUsersAuthenticator => - case class PriorityForm(priorityName: String, description: String, color: String) + case class PriorityForm(priorityName: String, description: Option[String], color: String) val priorityForm = mapping( "priorityName" -> trim(label("Priority name", text(required, priorityName, uniquePriorityName, maxlength(100)))), - "description" -> trim(label("Description", text(maxlength(255)))), + "description" -> trim(label("Description", optional(text(maxlength(255))))), "priorityColor" -> trim(label("Color", text(required, color))) )(PriorityForm.apply) diff --git a/src/main/scala/gitbucket/core/service/PrioritiesService.scala b/src/main/scala/gitbucket/core/service/PrioritiesService.scala index fa4e405..cafff4b 100644 --- a/src/main/scala/gitbucket/core/service/PrioritiesService.scala +++ b/src/main/scala/gitbucket/core/service/PrioritiesService.scala @@ -16,7 +16,7 @@ def getPriority(owner: String, repository: String, priorityName: String)(implicit s: Session): Option[Priority] = Priorities.filter(_.byPriority(owner, repository, priorityName)).firstOption - def createPriority(owner: String, repository: String, priorityName: String, description: String, color: String)(implicit s: Session): Int = { + def createPriority(owner: String, repository: String, priorityName: String, description: Option[String], color: String)(implicit s: Session): Int = { val ordering = Priorities.filter(_.byRepository(owner, repository)) .list .map(p => p.ordering) @@ -28,18 +28,18 @@ userName = owner, repositoryName = repository, priorityName = priorityName, - description = StringUtil.emptyToNone(description), + description = description, isDefault = false, ordering = ordering, color = color ) } - def updatePriority(owner: String, repository: String, priorityId: Int, priorityName: String, description: String, color: String) + def updatePriority(owner: String, repository: String, priorityId: Int, priorityName: String, description: Option[String], color: String) (implicit s: Session): Unit = Priorities.filter(_.byPrimaryKey(owner, repository, priorityId)) .map(t => (t.priorityName, t.description.?, t.color)) - .update(priorityName, StringUtil.emptyToNone(description), color) + .update(priorityName, description, color) def reorderPriorities(owner: String, repository: String, order: Map[Int, Int]) (implicit s: Session): Unit = { diff --git a/src/main/scala/gitbucket/core/service/RepositoryCreationService.scala b/src/main/scala/gitbucket/core/service/RepositoryCreationService.scala index 97df82d..2aa4196 100644 --- a/src/main/scala/gitbucket/core/service/RepositoryCreationService.scala +++ b/src/main/scala/gitbucket/core/service/RepositoryCreationService.scala @@ -78,11 +78,11 @@ } def insertDefaultPriorities(userName: String, repositoryName: String)(implicit s: Session): Unit = { - createPriority(userName, repositoryName, "highest", "All defects at this priority must be fixed before any public product is delivered.", "fc2929") - createPriority(userName, repositoryName, "very high", "Issues must be addressed before a final product is delivered.", "fc5629") - createPriority(userName, repositoryName, "high", "Issues should be addressed before a final product is delivered. If the issue cannot be resolved before delivery, it should be prioritized for the next release.", "fc9629") - createPriority(userName, repositoryName, "important", "Issues can be shipped with a final product, but should be reviewed before the next release.", "fccd29") - createPriority(userName, repositoryName, "default", "Default.", "acacac") + createPriority(userName, repositoryName, "highest", Some("All defects at this priority must be fixed before any public product is delivered."), "fc2929") + createPriority(userName, repositoryName, "very high", Some("Issues must be addressed before a final product is delivered."), "fc5629") + createPriority(userName, repositoryName, "high", Some("Issues should be addressed before a final product is delivered. If the issue cannot be resolved before delivery, it should be prioritized for the next release."), "fc9629") + createPriority(userName, repositoryName, "important", Some("Issues can be shipped with a final product, but should be reviewed before the next release."), "fccd29") + createPriority(userName, repositoryName, "default", Some("Default."), "acacac") setDefaultPriority(userName, repositoryName, getPriority(userName, repositoryName, "default").map(_.priorityId)) } diff --git a/src/main/scala/gitbucket/core/util/StringUtil.scala b/src/main/scala/gitbucket/core/util/StringUtil.scala index 2b0bb6c..908fd25 100644 --- a/src/main/scala/gitbucket/core/util/StringUtil.scala +++ b/src/main/scala/gitbucket/core/util/StringUtil.scala @@ -136,6 +136,4 @@ // } // b.toString // } - - def emptyToNone(str: String): Option[String] = Option(str).map(_.trim).flatMap(s => if (s.isEmpty) None else Some(s)); }