Hide 'Views' and 'Tools' drop down menu on issue search page

My objective is to hide both Views and Tools drop down lists depending upon the group. These drop down list appear on the issue search page just above the search table.

I have searched in vain all around atlassian bundled jars. Does any one has a clue in which plugin these drop down list velocity templates are located ?

2 answers

1 accepted

This widget could not be displayed.
Mizan Community Champion Nov 06, 2012

I have done something similar for Views dropdown .

You can write javascript to hide ..

refer below js

<script type="text/javascript">

function getCurrentUserName()
{
var user;
     AJS.$.ajax({
        url: "/rest/gadget/1.0/currentUser",
        type: 'get',
        dataType: 'json',
        async: false,
        success: function(data) {
            user = data.username;
        }
     });
     return user;
}

function getGroups(user)
{
var groups;
     AJS.$.ajax({
        url: "/rest/api/2.0.alpha1/user?username="+user+"&expand=groups",
        type: 'get',
        dataType: 'json',
        async: false,
        success: function(data) {
            groups = data.groups.items;
        }
     });
     return groups;
}

function isUserInGroup(user, group){
    var groups = getGroups(user);
    for (i = 0; i < groups.length; i++){
         if (groups[i].name == group){
              return true;
         }
    }
    return false;
}

var user = getCurrentUserName();
if (!isUserInGroup(user, 'jira-administrators')){
AJS.$(function(){
 AJS.$('span').each(function(){
                if(AJS.$(this).html() == 'Views')// Checks if the page is issue navigator page
                {
                 AJS.$(this).hide();
              if(AJS.$(this).html() == 'Tools')//Checks if the page is issue navigator page
            {
                 AJS.$(this).hide();
                });


                    }
            });

        }
           
        });
});

}
</script>

The new rest api url is "/rest/api/latest/user?username="+user+"&expand=groups".

Thanks a lot :)

familiar code ;)

Mizan Community Champion Nov 06, 2012

Yes its from your tutorial AJS tricks :)

Can you also precise me where I could add the same condition restricting group level visibility on tools and views drop down list located on dashboard and issue page?

Mizan Community Champion Nov 07, 2012

Do you want to hide these dropdowns where ever they appear in JIRA ?

Yes! The two buttons should be hidded in all the JIRA pages

I have added your code in each of the jsp's containing these buttons though respective div id's

/atlassian-jira/includes/navigator/table/header.jsp

/atlassian-jira/includes/panels/issue/viewissue-opsbar.jsp

However I havnt figured out yet the jsp containing the tools drop down list that appears on the dash board page.

Found out!!

This button is defined in atlassian-gadgets-dashboard-plugin- plugin !

Thanks guys for all the help.

Mizan Community Champion Nov 07, 2012

The above script should be applied using a web resource plugin or pasted Announcement banner.

There is no need to change JIRA code

This widget could not be displayed.

They are not in a plugin. The specific elements come from /atlassian-jira/includes/navigator/table/header.jsp file. If you are conditions, it will mostly go here!

Thew views themselves come from search request views. See /atlassian-jira/WEB-INF/classes/system-issueviews-plugin.xml

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in Teamwork

What teamwork quotes inspire you?

Hey everyone! My name is Natalie and I'm an editor of the Atlassian Blog and I've got a question for you: What's your favorite quote about teamwork?  We've compiled a list here, along with...

151 views 16 7
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you