Updated version that doesn't break SUDO or HBAC. The third level nesting in the tabs set is only used for this kind of navigation now, but should be used for Action panel shortly.
From 2371a5b82d7f3184445bcbba32ca516747bb9c6e Mon Sep 17 00:00:00 2001
From: Adam Young <ayo...@redhat.com>
Date: Fri, 19 Nov 2010 15:57:40 -0500
Subject: [PATCH] top nav index
 allows links between differnt top level tabs by calculating the index of the top level tab for the target tab.

---
 install/static/associate.js |   15 +++++++++++----
 install/static/webui.js     |   27 ++++++++++++++++++++++++++-
 install/static/widget.js    |   14 +++++++-------
 3 files changed, 44 insertions(+), 12 deletions(-)

diff --git a/install/static/associate.js b/install/static/associate.js
index f0239a44e12670f5399d9dd30c99a5e553a2aba0..913b36449d117e6c53734102ef0eb26f22c5f182 100644
--- a/install/static/associate.js
+++ b/install/static/associate.js
@@ -247,12 +247,15 @@ function ipa_association_widget(spec) {
 
     that.create = function(container) {
 
-        that.member_attribute = ipa_get_member_attribute(that.entity_name, that.other_entity);
+        that.member_attribute = ipa_get_member_attribute(
+            that.entity_name, that.other_entity);
 
         that.create_column({
-            'name': that.member_attribute + '_' + that.other_entity,
-            'label': IPA.metadata[that.other_entity].label,
-            'primary_key': true
+            name: that.member_attribute + '_' + that.other_entity,
+            other_entity :  that.other_entity,
+            label: IPA.metadata[that.other_entity].label,
+            primary_key: true,
+            link: true
         });
 
         that.superior_create(container);
@@ -472,6 +475,10 @@ function ipa_association_facet(spec) {
         that.table.refresh();
     };
 
+    //TODO find out why this is needed
+    that.refresh = function(){
+    }
+
     return that;
 }
 
diff --git a/install/static/webui.js b/install/static/webui.js
index 17c08d8f46e4e943ee7033e038e5e2bf69e69ace..3b3646ca7a9290cf10e177494de57010eac226e1 100644
--- a/install/static/webui.js
+++ b/install/static/webui.js
@@ -54,6 +54,30 @@ var self_serv_tab_set =
             {name:'user', label:'Users', setup:ipa_entity_setup}]}];
 
 
+IPA.tab_state = function(entity_name){
+
+    var state = {};
+
+    for (var top_tab_index = 0;
+         top_tab_index < IPA.tab_set.length;
+         top_tab_index += 1){
+        var top_tab =  IPA.tab_set[top_tab_index];
+        for (var subtab_index = 0;
+             subtab_index < top_tab.children.length;
+             subtab_index += 1){
+            if((top_tab.children[subtab_index].name) &&
+               (top_tab.children[subtab_index].name === entity_name)){
+                state.navigation =  top_tab_index;
+                state[top_tab.name] =  subtab_index;
+                return state;
+            }
+        }
+    }
+}
+
+
+
+
 
 
 /* main (document onready event handler) */
@@ -78,9 +102,10 @@ $(function() {
 
         if (whoami.hasOwnProperty('memberof_rolegroup') &&
             whoami.memberof_rolegroup.length > 0){
+            IPA.tab_set = admin_tab_set;
             nav_create(admin_tab_set, navigation, 'tabs');
-
         } else {
+            IPA.tab_set = self_serv_tab_set;
             nav_create(self_serv_tab_set, navigation, 'tabs');
 
             var state = {'user-pkey':IPA.whoami_pkey ,
diff --git a/install/static/widget.js b/install/static/widget.js
index 060f258eb0a516fe11069ed7f55e83b5deb37112..c2184c64685d3bcd519710ffa015fcac64efefdf 100755
--- a/install/static/widget.js
+++ b/install/static/widget.js
@@ -421,6 +421,7 @@ function ipa_button_widget(spec) {
     return that;
 }
 
+
 function ipa_column_widget(spec) {
 
     spec = spec || {};
@@ -431,6 +432,7 @@ function ipa_column_widget(spec) {
     that.primary_key = spec.primary_key;
     that.setup = spec.setup || setup;
     that.link = spec.link;
+    that.other_entity = spec.other_entity;
 
     function setup(container, name, value, record) {
 
@@ -445,13 +447,11 @@ function ipa_column_widget(spec) {
                 'html': value,
                 'click': function (value) {
                     return function() {
-                        var state = {};
-                        state[that.entity_name + '-facet'] = 'details';
-                        state[that.entity_name + '-pkey'] = value;
-                        //Before this will work, we need to set the tab one level up
-                        //for example:
-                        //state['identity'] = 0;
-                        //but we have no way of getting the index.
+                        var target_entity = that.other_entity ||
+                            that.entity_name;
+                        var state = IPA.tab_state(target_entity);
+                        state[target_entity + '-facet'] = 'details';
+                        state[target_entity + '-pkey'] = value;
 
                         $.bbq.pushState(state);
                         return false;
-- 
1.7.2.3

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to