Skip to content

Instantly share code, notes, and snippets.

@mrueegg
Created March 9, 2017 17:18
Show Gist options
  • Save mrueegg/f84bb952d77c80b3228fe1c3ff011884 to your computer and use it in GitHub Desktop.
Save mrueegg/f84bb952d77c80b3228fe1c3ff011884 to your computer and use it in GitHub Desktop.
Bitbucket Server condition in Scala to only display a button if open tasks exist
import java.util.{Map => JMap}
import ch.mibex.crossproduct.api.OpenTasksCounter
import com.atlassian.bitbucket.pull.PullRequest
import com.atlassian.plugin.web.Condition
class HasOpenTasksCondition(openTasksCounter: OpenTasksCounter[PullRequest]) extends Condition {
override def init(context: JMap[String, String]): Unit = {}
override def shouldDisplay(context: JMap[String, AnyRef]): Boolean = context.get("pullRequest") match {
case pullRequest: PullRequest => openTasksCounter.countOpenTasks(pullRequest) > 0
case _ => false
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment