Created
March 9, 2017 17:18
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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