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

saslam November 5, 2012

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

1 vote
Answer accepted
Mizan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 6, 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>

saslam November 6, 2012

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

Thanks a lot :)

Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 6, 2012

familiar code ;)

Mizan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 6, 2012

Yes its from your tutorial AJS tricks :)

saslam November 6, 2012

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
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 7, 2012

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

saslam November 7, 2012

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.

saslam November 7, 2012

Found out!!

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

Thanks guys for all the help.

Mizan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 7, 2012

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

There is no need to change JIRA code

0 votes
Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 6, 2012

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
TAGS
AUG Leaders

Atlassian Community Events