It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage
Highlighted

Disable Tab based on security group script disabling for everyone

Hi all

 

I would like to disable a tab for everyone but a specific security group but for some reason it's not seeing my condition and just disabling it for everyone

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRoleManager

// Get the current user
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def groupManager = ComponentAccessor.getGroupManager()

if (ComponentAccessor.getGroupManager().getGroupsForUser(currentUser)?.find { it.name != "Jira Service Desk Time Log" })
{
disableTab(1)
}

 

1 comment

Hi @Steve_Letch ,

I not sure that condition is well.

it.name != "Jira Service Desk Time Log"

If user have a lots group it return true for all groups!="Jira.."

Try some like next:

if (!ComponentAccessor.getGroupManager().getGroupsForUser(currentUser)?.find { it.name == "Jira Service Desk Time Log" })


B.R.

See I want to hide it from all users except that group so I need it to be a != unless you can think of a better way

May I clarify?

someA = [a,b,c,d,f]

someB = [a,b,c,f]

someC = [a,b]

I suppose we want exclude 'd'. We should return 'true' for someB and someC.

1. return true only for someA:

if ( some.find{ it == 'd'} )
someA - true (can find 'd')

someB - false (cannot find 'd')

someC - false(cannot find 'd')

2. Inverse result:

if ( ! some.find{ it == 'd'} )
someA - false (can find 'd')

someB - true (cannot find 'd')

someC - true (cannot find 'd')

B.R.

Comment

Log in or Sign up to comment
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you