Hi community,
I am using the "Hide system or plugin UI element" from ScriptRunner Add-On to hide a Link in the UI and it works to hide it for all members of the project.
Is it possible to change the condition so that the link is only hidden for the members of some project roles? I have not found any way to access the roles or the current user yet.
Thanks
Bastian
It would be like this
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRoleManager
def project = jiraHelper.project?.key
String roleName = "Administrators"
if (project != null) {
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
ProjectRoleManager projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager);
def projectRole = projectRoleManager.getProjectRole(roleName)
return projectRoleManager.isUserInProjectRole(user, projectRole, issue.getProjectObject())
}
return false
Hi @Alexey Matveev,
thank you very much for this quick response.
I had to change the line:
return projectRoleManager.isUserInProjectRole(user, projectRole, issue.getProjectObject())
to
return projectRoleManager.isUserInProjectRole(user, projectRole, jiraHelper.project)
because there is not always an issue selected, but now it works great.
Best regards
Bastian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Alexey Matveev
Hey Alexey, I know this an older post, but I'm unsure of where to put the actual project key that I want this code displayed for. There are many projects on our server and I don't want to mess with their setups.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Alexey Matveev ,
Could you please tell how to modify your suggested code to have some operations visible for two or three different project roles instead of just "Administrators"? Like visible for project roles "Administartors" and "Service Desk Team".
Many thanks! :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try this solution for more than one role:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRoleManager
import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.user.util.UserManager
def project = jiraHelper.project?.key
if (project != null) {
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
ProjectRoleManager projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager);
def projectRoleAdmin = projectRoleManager.getProjectRole("Administrators")
def projectRoleSDT = projectRoleManager.getProjectRole("Service Desk Team")
Boolean isAdmin = projectRoleManager.isUserInProjectRole(user, projectRoleAdmin, jiraHelper.project);
Boolean isSDT = projectRoleManager.isUserInProjectRole(user, projectRoleSDT, jiraHelper.project);
if(isAdmin || isSDT){
return true;
}
}
return false
Best regards,
Artiom
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is it possible to Hide UI element for a particular status?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi all,
Could you help me please to hide voters from mentioned project in Jira ?
I have tried to hide voters with same code, but it isn't working.
Maybe I am using not correct module ?
I tried this modules
com.atlassian.jira.plugin.system.issueoprations:vote-issue,
com.atlassian.jira.plugin.system.issueoprations:view-voters,
com.atlassian.jira.plugin.system.issueoprations:unvote-issue
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.