Mark sidebar list item when it is selected

We’ve added a web item to the sidebar navigation in Jira in our add-on. It works fine apart from the fact that when it is selected it is not marked (that is the background color is not changed). When selecting one of Jira’s pre-existing web items in the list it is marked with the class ‘aui-nav-selected’ added to the list element. I would have thought that this behavior should work “out of the box” but that does not seem to be the case. Does anyone know if there is anything in particular that needs to be done to fix this?

The web item looks something like this in our atlassian-plugin.xml:

<web-item key="foo-item" name="Foo Item" section="jira.project.sidebar.plugins.navigation" weight="900">
   <label key="foo.item" />
   <icon height="16" width="16"> {Link to icon} </icon>
   <link linkId="foo_view"> /projects/$pathEncodedProjectKey?selectedItem=com.atlassian.jira.jira-projects-plugin:foo-page </link>
   <conditions type="AND"> {Conditions} </conditions>
</web-item>

Hi,

I resolved same situation with changing naming rules.

<web-item key="foo-item" name="Foo Item" section="jira.project.sidebar.plugins.navigation" weight="900">
   <link linkId="foo_view">/projects/$pathEncodedProjectKey?selectedItem=com.atlassian.jira.jira-projects-plugin:foo-item</link>
</web-item>

I hope this will be help.

3 Likes

I have the same problem. Can you please explain in more detail what you mean? The web-item key needs to be used when creating the URL?

Yes.
It seems that the web-item key “foo-item” needs to match the link-url “xxx:foo-item”, but I could not find any documentation about it.
It works fine on my JIRA 7.4.0.

1 Like

Thanks for the help! Unfortunately it still won’t work for me so there is probably something more that I need to change.

It worked for me very well. Please see below all places where I used “sidebar-item”. Maybe you can paste your full atlassian-plugin.xml as well and we all together have a look.

<web-item key="sidebar-item" name="JIRA Project Role Sidebar Item" 
	section="jira.project.sidebar.plugins.navigation" weight="101">
    <link linkId="projectroletab-link">/projects/$pathEncodedProjectKey?selectedItem=${project.groupId}.${project.artifactId}:sidebar-item</link>
    <param name="iconClass" value="aui-icon-large aui-iconfont-group"/>
</web-item>	
<web-panel key="projectroletab-webpanel" location="${project.groupId}.${project.artifactId}:sidebar-item">
    <context-provider class="jira.plugin.projectroletab.ProjectRoleContextProviderForSidebarPanel"/>
	<resource name="view" type="velocity" location="templates/projectrolepanel.vm"/>
</web-panel>
1 Like

Hi again!

Sorry for my slow response here. I just tried it out again and my issue was with the url in the link. When I changed it to the same form as your link it all worked. Thanks guys for your excellent help!

1 Like