This might be my favorite patch name yet.

This patch depends on admiyo-0221-2
From 12cb82c6cfa037d90c2caf61d902f0bd21d264b4 Mon Sep 17 00:00:00 2001
From: Adam Young <ayo...@redhat.com>
Date: Fri, 22 Apr 2011 14:31:12 -0400
Subject: [PATCH] Removed entities that are, for some reason, invalid.

---
 install/ui/dns.js        |    4 ++++
 install/ui/entity.js     |    4 ++++
 install/ui/ipa.js        |   11 ++++++++---
 install/ui/navigation.js |    9 ++++++---
 install/ui/webui.js      |    7 +------
 5 files changed, 23 insertions(+), 12 deletions(-)

diff --git a/install/ui/dns.js b/install/ui/dns.js
index 1b38e73d1c0316ae1c6932aef038d47f61a77c84..f52a06429a23c7352cdb78bff744ca7843c072b0 100644
--- a/install/ui/dns.js
+++ b/install/ui/dns.js
@@ -26,6 +26,10 @@
 /* DNS */
 IPA.entity_factories.dnszone = function() {
 
+    if (!IPA.dns_enabled){
+        throw "DNS not enabled on server";
+    }
+
     return  IPA.entity_builder().
         entity('dnszone').
         search_facet({
diff --git a/install/ui/entity.js b/install/ui/entity.js
index f45cf33299b9f70bb3a851b232c2290b4e18f7ea..edd50ce707a5c0d09c6b2dc2965871c3e77ca38a 100644
--- a/install/ui/entity.js
+++ b/install/ui/entity.js
@@ -590,6 +590,10 @@ IPA.entity_builder = function(){
             spec = { name: param  };
         }
         spec.metadata = spec.metadata || IPA.metadata.objects[spec.name];
+        if (!spec.metadata){
+            throw "Entity not supported by server.";
+        }
+
         entity = factory(spec);
         return that;
     };
diff --git a/install/ui/ipa.js b/install/ui/ipa.js
index 2b224689fc236269c5657855b94b846b94115d83..60b27633addc2251e319706e0273f4e5bf265cac 100644
--- a/install/ui/ipa.js
+++ b/install/ui/ipa.js
@@ -144,9 +144,14 @@ var IPA = ( function () {
         var name ;
         for (name in that.entity_factories){
             factory = that.entity_factories[name];
-            var entity = factory();
-            add_entity(entity);
-            entity.init();
+            try{
+                var entity = factory();
+                add_entity(entity);
+                entity.init();
+            }catch(e){
+                /*exceptions  thrown by builder just mean that entities
+                  are not to be registered. */
+            }
         }
     };
 
diff --git a/install/ui/navigation.js b/install/ui/navigation.js
index 931e5e828c68af6ee890563af1f417c50b5b9c1a..786a5a972ff30b7ee197f398909d3f4a1ad18a1a 100644
--- a/install/ui/navigation.js
+++ b/install/ui/navigation.js
@@ -72,7 +72,7 @@ IPA.nav = {
         var ul = $('<ul/>');
         container.append(ul);
 
-        for (var i = 0; i < nls.length; ++i) {
+        for (var i = 0; i < nls.length; i += 1) {
             var tab = nls[i];
             if (tab.entity){
                 tab.name = tab.entity;
@@ -81,6 +81,11 @@ IPA.nav = {
             var label = tab.name;
             if (tab.entity) {
                 var entity = IPA.get_entity(tab.entity);
+                if (!entity){
+                    nls.splice(i,1);
+                    i -= 1;
+                    continue;
+                }
                 label = entity.label;
                 tab.entity = entity;
             }
@@ -169,7 +174,5 @@ IPA.tab_state = function(entity_name,tab){
             return state;
         }
     }
-    //should never be reached.
-    alert('tab state cannot be caluclated.Application error');
     return null;
 };
diff --git a/install/ui/webui.js b/install/ui/webui.js
index cc842f84d4453dc420d547e5614d9734d951eb69..02fe918a0992598b0a25da98ac3a5345dbff63ff 100644
--- a/install/ui/webui.js
+++ b/install/ui/webui.js
@@ -37,6 +37,7 @@ IPA.admin_tab_set = function () {
             {entity:'service'}
         ]},
         {name:'policy', label: IPA.messages.tabs.policy, children:[
+            {entity:'dnszone'},
             {name:'hbac', label: IPA.messages.tabs.hbac ,
              children:[
                  {entity:'hbacrule'},
@@ -66,12 +67,6 @@ IPA.admin_tab_set = function () {
             {entity:'config'}
         ]}];
 
-    if (IPA.dns_enabled){
-        tabset[1].children.unshift(
-            {entity:'dnszone'}
-        );
-    }
-
     return tabset;
 };
 
-- 
1.7.4.4

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

Reply via email to