From c53831037cbe388d961420e87b036b1caf6cf723 Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Thu, 30 Sep 2010 15:37:33 -0500 Subject: Refactoring navigation.js. The navigation.js has been modified to make it more abstract, i.e. unaware of entity facets. The nav_update_tabs() has been modified such that it activates and updates the tabs based on the current state stored in the URL. The facets are now handled in entity.js. The ipa_entity_setup() has been modified to update the facets based on the current state and cached state. The navigation.js also has been modified to be more class-like. The nav_create() has been modified to store the tab configuration and the tab container in internal variables nav_tabs_lists and nav_container. The nav_update_tabs() now can be called without any parameters. Functions nav_push_state(), nav_get_state(), and nav_remove_state() have been added to wrap BBQ API. This is to allow unit tests to replace them with mockup functions to remove dependency on BBQ. --- install/static/webui.js | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'install/static/webui.js') diff --git a/install/static/webui.js b/install/static/webui.js index ac28412d..fa37bcdd 100644 --- a/install/static/webui.js +++ b/install/static/webui.js @@ -30,7 +30,7 @@ var admin_tab_set = [ {name:'host', label:'Hosts', setup: ipa_entity_setup}, {name:'hostgroup', label:'Hostgroups', setup: ipa_entity_setup}, {name:'netgroup', label:'Netgroups', setup: ipa_entity_setup}, - {name:'service', label:'Services', setup: ipa_entity_setup}, + {name:'service', label:'Services', setup: ipa_entity_setup} ]}, {name:'policy', label:'POLICY', setup: unimplemented_tab}, {name:'config', label:'CONFIG', children: [ @@ -38,16 +38,11 @@ var admin_tab_set = [ ]} ]; - - - -var self_serv_tabs_lists = +var self_serv_tab_set = [ { name:'identity', label:'IDENTITY', children: [ {name:'user', label:'Users', setup:ipa_entity_setup}]}]; -var nav_tabs_lists; - /* main (document onready event handler) */ $(function() { @@ -61,11 +56,15 @@ $(function() { $('#loggedinas').find('strong').text(whoami.krbprincipalname[0]); $('#loggedinas a').fragment( {'user-facet':'details', 'user-pkey':whoami_pkey},2); + + var navigation = $('#navigation'); + if (whoami.hasOwnProperty('memberof_rolegroup') && whoami.memberof_rolegroup.length > 0){ - nav_tabs_lists = admin_tab_set; + nav_create(admin_tab_set, navigation, 'tabs'); + }else{ - nav_tabs_lists = self_serv_tab_set; + nav_create(self_serv_tab_set, navigation, 'tabs'); var state = {'user-pkey':whoami_pkey , 'user-facet': jQuery.bbq.getState('user-facet') || @@ -73,8 +72,6 @@ $(function() { $.bbq.pushState(state); } - var navigation = $('#navigation'); - nav_create(nav_tabs_lists, navigation, 'tabs'); $('#login_header').html(ipa_messages.login.header); }else{ @@ -98,8 +95,7 @@ $(function() { /* main loop (hashchange event handler) */ function window_hashchange(evt) { - var navigation = $('#navigation'); - nav_update_tabs(nav_tabs_lists, navigation); + nav_update_tabs(); } /* builder function for unimplemented tab content */ -- cgit