I add Additional menu ( in picture)
I want to add condition.
For Example
There are 2 Groups in jira User Management.
One is A Group, the others is B Group.
A group can see Additional menu.
And B group don't see Extra Additional menu.
How can I control condition?
This is XML code written by me.
<web-item key="effort_input" name="Effort Input" section="system.user.options/system" i18n-name-key="webfragments.user.options.item.effort.input" weight="50">
<label key="Effort Input" />
<tooltip key="tooltip.Effort Input" />
<link linkId="KPI_Dashboard">/kpi/jsp/effort/effortList.jsp</link>
<condition class="com.atlassian.jira.plugin.webfragment.conditions.UserLoggedInCondition" />
</web-item>
I add web-item.
but Can I Where to control ?
Community moderators have prevented the ability to post new answers.
Sooji, You need to write another condition in your <web-item> module. And in that condition class you have to restrict for the group whom you dont want to show.
For example: If th group name is 'Effort Group' then
In atlassina-plugin.xml:
<condition class="packagename.classname">
<param name="group">Effort Group</param></condition>
And in java:
public class @classname@ extends AbstractJiraCondition{
private String group;
@Override
public void init(Map params) throws PluginParseException {
this.group=(String)params.get("group");
super.init(params);
}
//If the user is not in 'Effort Group', it returns false
@Override
public boolean shouldDisplay(User user, JiraHelper arg1) {
if(user!=null && this.group!=null){
return user.inGroup(this.group);
}
return false;
}
}
Hi rambabu patina ·
I want to know where to add source that you told me.
I confused which source do I modify
"atlassina-plugin.xml" is "system-user-nav-bar-sections.xml" ?
What you said is this?
but I don't know where is java file
Please tell me the location of files.
Thank you
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sooji, The atlassian-plugin.xml file will be available in the location <your plugin source>\src\main\resources. And for the java file you can create new file in your <your plugin source>\src\main\java. While creation you need to define the package name for that class then you can use the class name with this package in atlassin-plugin.xml.
And "atlassina-plugin.xml" and "system-user-nav-bar-sections.xml" are different files.
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I had a very similar problem but with confluence. Just wanted to share my solution.
Starting with the code from rambabu patina and updating to non-deprecated classes I got:
package %package name%; import java.util.Map; import com.atlassian.confluence.plugin.descriptor.web.WebInterfaceContext; import com.atlassian.confluence.plugin.descriptor.web.conditions.BaseConfluenceCondition; import com.atlassian.plugin.PluginParseException; import com.atlassian.sal.api.user.UserManager; public class userHasGroup extends BaseConfluenceCondition{ private String group; private UserManager userManager; public userHasGroup(UserManager userManager){ this.userManager = userManager; } @Override public void init(Map params) throws PluginParseException { this.group=(String)params.get("group"); super.init(params); } @Override public boolean shouldDisplay(WebInterfaceContext context) { if(userManager.getRemoteUserKey()!=null && this.group!=null){ return userManager.isUserInGroup(userManager.getRemoteUserKey(), this.group); } return false; } }
My atlassian-plugin.xml looks similar to this (just adding web resources like css or js files)
<web-resource key="forwarder-resources" name="forwarder-resources Resources"> <dependency>com.atlassian.auiplugin:ajs</dependency> <resource type="download" name="improvedsearch.js" location="improvedsearch.js"/> <resource type="download" name="skel.js" location="/assets/js/skel.min.js"/> <resource type="download" name="util.js" location="/assets/js/util.js"/> <resource type="download" name="main.js" location="/assets/js/main.js"/> <resource type="download" name="main.css" location="/assets/css/main.css"/> <!-- add group condition --> <condition class="%package name%.userHasGroup"> <param name="group">%%%the groupname a user has to hve%%%</param> </condition> <context>atl.general</context> </web-resource>
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.