Created
September 28, 2016 11:22
-
-
Save jechlin/cf096c1da6ad5b5e44a8a803bd6fcaa5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 com.atlassian.jira.bc.project.ProjectAction | |
import com.atlassian.jira.component.ComponentAccessor | |
import com.atlassian.jira.user.UserProjectHistoryManager | |
import com.atlassian.jira.util.I18nHelper | |
import com.atlassian.jira.util.velocity.VelocityRequestContextFactory | |
import com.atlassian.plugin.web.api.model.WebFragmentBuilder | |
def historyManager = ComponentAccessor.getComponent(UserProjectHistoryManager) | |
def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser | |
if (user) { | |
def historyItems = historyManager.getProjectHistoryWithPermissionChecks(ProjectAction.VIEW_ISSUES, user) | |
def velocityRequestContextFactory = ComponentAccessor.getComponent(VelocityRequestContextFactory) | |
def requestContext = velocityRequestContextFactory.getJiraVelocityRequestContext() | |
def baseUrl = requestContext.getBaseUrl() | |
def beanFactory = ComponentAccessor.getComponent(I18nHelper.BeanFactory) | |
def i18n = beanFactory.getInstance(user) | |
return historyItems.findAll { project -> | |
project.projectCategory?.name == "CAT1" // modify project category name to suit | |
}.collect { project -> | |
String iconUrl = null | |
if (project.getAvatar()) | |
{ | |
def avatar = project.getAvatar() | |
iconUrl = baseUrl + "/secure/projectavatar?pid=" + project.id + "&avatarId=" + avatar.id + "&size=small" | |
} | |
new WebFragmentBuilder(50). | |
id("project-cat-web-item-${project.key.toLowerCase()}"). | |
label(project.name + " (" + project.key + ")"). | |
title(i18n.getText("tooltip.browseproject.specified", project.name)). | |
styleClass(""). | |
addParam("iconUrl", iconUrl). | |
webItem(""). | |
url(baseUrl + "/browse/" + project.key). | |
build() | |
} | |
} | |
[] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment