Browse Source

HUE-8330 [assist] Fix broken namespace refresh

Johan Ahlen 7 years ago
parent
commit
558088a633

+ 6 - 6
desktop/core/src/desktop/static/desktop/js/assist/assistDbSource.js

@@ -116,11 +116,11 @@ var AssistDbSource = (function () {
     self.loadedDeferred.done(callback);
     self.loadedDeferred.done(callback);
   };
   };
 
 
-  AssistDbSource.prototype.loadNamespaces = function () {
+  AssistDbSource.prototype.loadNamespaces = function (refresh) {
     var self = this;
     var self = this;
     self.loading(true);
     self.loading(true);
 
 
-    return ContextCatalog.getNamespaces({ sourceType: self.sourceType }).done(function (context) {
+    return ContextCatalog.getNamespaces({ sourceType: self.sourceType, clearCache: refresh }).done(function (context) {
       var assistNamespaces = [];
       var assistNamespaces = [];
       var activeNamespace;
       var activeNamespace;
       var activeCompute;
       var activeCompute;
@@ -146,12 +146,12 @@ var AssistDbSource = (function () {
         assistNamespaces.push(assistNamespace);
         assistNamespaces.push(assistNamespace);
       });
       });
       self.namespaces(assistNamespaces);
       self.namespaces(assistNamespaces);
-      if (activeNamespace) {
+      if (!refresh && activeNamespace) {
         self.selectedNamespace(activeNamespace);
         self.selectedNamespace(activeNamespace);
-      } else if (assistNamespaces.length) {
+      } else if (!refresh && assistNamespaces.length) {
         self.selectedNamespace(assistNamespaces[0]);
         self.selectedNamespace(assistNamespaces[0]);
       }
       }
-      if (activeCompute) {
+      if (!refresh && activeCompute) {
         self.selectedNamespace().compute(activeCompute);
         self.selectedNamespace().compute(activeCompute);
       }
       }
     }).fail(function () {
     }).fail(function () {
@@ -200,7 +200,7 @@ var AssistDbSource = (function () {
 
 
   AssistDbSource.prototype.triggerRefresh = function (data, event) {
   AssistDbSource.prototype.triggerRefresh = function (data, event) {
     var self = this;
     var self = this;
-    ContextCatalog.getNamespaces({ sourceType: self.sourceType, clearCache: true });
+    self.loadNamespaces(true);
   };
   };
 
 
   return AssistDbSource;
   return AssistDbSource;

+ 2 - 1
desktop/core/src/desktop/static/desktop/js/contextCatalog.js

@@ -110,11 +110,12 @@ var ContextCatalog = (function () {
       var fetchNamespaces = function () {
       var fetchNamespaces = function () {
         ApiHelper.getInstance().fetchContextNamespaces(options).done(function (namespaces) {
         ApiHelper.getInstance().fetchContextNamespaces(options).done(function (namespaces) {
           if (namespaces[options.sourceType]) {
           if (namespaces[options.sourceType]) {
+            var dynamic = namespaces.dynamicClusters;
             var namespaces = namespaces[options.sourceType];
             var namespaces = namespaces[options.sourceType];
             if (namespaces) {
             if (namespaces) {
               self.namespaces[options.sourceType] = { namespaces: namespaces.filter(function (namespace) {
               self.namespaces[options.sourceType] = { namespaces: namespaces.filter(function (namespace) {
                 return namespace.name; // Only include namespaces with a name.
                 return namespace.name; // Only include namespaces with a name.
-              }), dynamic: namespaces.hasMultiCluster };
+              }), dynamic: dynamic };
               deferred.resolve(self.namespaces[options.sourceType]);
               deferred.resolve(self.namespaces[options.sourceType]);
               if (notifyForRefresh) {
               if (notifyForRefresh) {
                 huePubSub.publish('context.catalog.namespaces.refreshed', options.sourceType);
                 huePubSub.publish('context.catalog.namespaces.refreshed', options.sourceType);