Browse Source

HUE-6245 [cluster] Do not show the dropdown when no extra clusters are configured

Romain Rigaux 8 years ago
parent
commit
fa52178c88
2 changed files with 16 additions and 16 deletions
  1. 13 13
      desktop/core/src/desktop/conf.py
  2. 3 3
      desktop/core/src/desktop/templates/hue.mako

+ 13 - 13
desktop/core/src/desktop/conf.py

@@ -1342,21 +1342,21 @@ IS_HUE_4 = Config( # To remove in Hue 5
 
 def get_clusters():
   if CLUSTERS.get():
-    clusters = CLUSTERS.get()
+    cluster_config = CLUSTERS.get()
+    clusters = OrderedDict([
+      (i, {
+        'name': i,
+        'type': cluster_config[i].TYPE.get(),
+        'interfaces': [{'name': i, 'type': cluster_config[i].TYPE.get(), 'interface': interface} for interface in cluster_config[i].INTERFACES.get()]
+      }) for i in cluster_config]
+    )
   else:
-    clusters = []
-
-  cl = OrderedDict([
-    (i, {
-      'name': i,
-      'type': clusters[i].TYPE.get(),
-      'interfaces': [{'name': i, 'type': clusters[i].TYPE.get(), 'interface': interface} for interface in clusters[i].INTERFACES.get()]
-    }) for i in clusters]
-  )
+    clusters = OrderedDict([('Default', {'name': 'Default', 'type': 'ini', 'interfaces': []})])
 
-  cl['Data Eng']['interfaces'].append({'name': 'Data Eng', 'type': 'dataeng', 'interface': 'c1'})
-  cl['Data Eng']['interfaces'].append({'name': 'Data Eng', 'type': 'dataeng', 'interface': 'c2'})
-  return cl
+  if 'Data Eng' in clusters:
+    clusters['Data Eng']['interfaces'].append({'name': 'Data Eng', 'type': 'dataeng', 'interface': 'c1'})
+    clusters['Data Eng']['interfaces'].append({'name': 'Data Eng', 'type': 'dataeng', 'interface': 'c2'})
+  return clusters
 
 
 CLUSTERS = UnspecifiedConfigSection(

+ 3 - 3
desktop/core/src/desktop/templates/hue.mako

@@ -154,8 +154,8 @@ ${ hueIcons.symbols() }
 
       <div class="top-nav-middle">
 
-        <!-- ko if: cluster.clusters().length > 0 -->
-        <div class="btn-group pull-right">
+        <!-- ko if: cluster.clusters().length > 1 -->
+        <div class="btn-group pull-right" style="display: none;" data-bind="visible: cluster.clusters().length > 1">
           <button class="btn" data-bind="text: cluster.cluster().name() + (cluster.cluster().interface ? ' ' + cluster.cluster().interface() : '')"></button>
           <button class="btn dropdown-toggle" data-toggle="dropdown">
             <span class="caret"></span>
@@ -1182,7 +1182,7 @@ ${ smart_unicode(login_modal(request).content) | n,unicode }
           self.apiHelper = ApiHelper.getInstance();
 
           self.clusters = ko.mapping.fromJS(${ clusters_config_json | n,unicode });
-          self.cluster = ko.observable(self.clusters().length > 0 ? self.clusters()[${ default_cluster_index }] : null);
+          self.cluster = ko.observable(self.clusters().length > 0 ? self.clusters()[${ default_cluster_index }] : self.clusters()[0]);
           self.cluster.subscribe(function(newValue) {
             new ClusterConfig({'cluster': ko.mapping.toJSON(newValue)});
           });