Monday, March 12, 2012

How to hide TFS web access tabs

Hi folks,

I was tasked to hide Source and Build tabs in TFS 2010 Web Access. I started to find out if TFS has any security groups that prevent users to view source or build tabs but with no luck!. TFS doesn't have security permissions to grant/hide tabs in TFS web application. To tackle this i wrote a javascript function which hides those tabs. After looking in the TFS web application in IIS i found that i can write this Javascript in "Content.master" Master page file for TFS web.

Just add this script in the header of Content.master file:


<script type="text/javascript">

window.onload = function() {

      // Search for the top navigation menu.

      var x= document.getElementById('ctl00_pghd_mainTabs');
       // Search for rows in this table.
       for(var i=0;i<x.rows.length;i++)
       {
                // only remove tabs in the first row. 
                        if(i==0)
                                {
                                  // Remove Source tab.                
                                  x.rows[i].cells[3].style.display='none'; 
                                  // Remove Build tab.
                                  x.rows[i].cells[4].style.display='none';          
                                }         
       }

                
}
</script>




To download the updated content.master file:


Also, To prevent any web users not to view any of source or build pages, Go to IIS and do the following:
1) Open TFS web site in IIS.
2) Expand tfs and then UI folder.
3) Select Build folder.
4) Double click on Authentication and disable Windows and Anonymous access to this folder.
5) Do the same for Scc folder which has all source tab pages.

With these 2 steps, we added security on the folder level in addition to hide Build and Source tabs.



Hope this helps!

UPDATE 03/13/2011: This workaround works after installing TFS SP1.