Browse Source

HUE-7519 [assist] Fix JS error when the sample tab can't load samples

Johan Ahlen 8 years ago
parent
commit
61b27c5

+ 1 - 2
desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

@@ -4761,8 +4761,7 @@
 
 
       var sampleErrorInsertSub = huePubSub.subscribe('sample.error.insert.click', function(popoverEntry) {
       var sampleErrorInsertSub = huePubSub.subscribe('sample.error.insert.click', function(popoverEntry) {
         var table = popoverEntry.identifierChain[popoverEntry.identifierChain.length - 1]['name'];
         var table = popoverEntry.identifierChain[popoverEntry.identifierChain.length - 1]['name'];
-        var text = "SELECT * FROM " + table + " LIMIT 100";
-
+        var text = "SELECT * FROM " + table + " LIMIT 100;";
         insertSqlAtCursor(text, -1);
         insertSqlAtCursor(text, -1);
       });
       });
 
 

+ 1 - 1
desktop/core/src/desktop/templates/context_popover.mako

@@ -439,7 +439,7 @@ from metadata.conf import has_navigator
             <div class="context-popover-flex-fill">
             <div class="context-popover-flex-fill">
                 <div class="alert">
                 <div class="alert">
                 <span data-bind="text: $parent.errorText"></span>
                 <span data-bind="text: $parent.errorText"></span>
-                <!-- ko if: $parent.enableSampleError && $parent.activeTab() === 'sample' -->
+                <!-- ko if: $parent.enableSampleError && $parents[1].activeTab() === 'sample' -->
                 <a href="javascript:void(0);" data-bind="click: function(){ huePubSub.publish('sample.error.insert.click', $data); huePubSub.publish('context.popover.hide');}">${_('Insert ')}<span data-bind="text:$parent.title"></span> ${_(' sample query')}</a> ${_('at cursor')}
                 <a href="javascript:void(0);" data-bind="click: function(){ huePubSub.publish('sample.error.insert.click', $data); huePubSub.publish('context.popover.hide');}">${_('Insert ')}<span data-bind="text:$parent.title"></span> ${_(' sample query')}</a> ${_('at cursor')}
                 <!-- /ko -->
                 <!-- /ko -->
                 </div>
                 </div>

+ 5 - 9
desktop/core/src/desktop/templates/ko_components.mako

@@ -997,21 +997,17 @@ from desktop.views import _ko
           }
           }
         });
         });
 
 
-        huePubSub.subscribe('context.popover.open.in.metastore', function () {
+        var deferredCloseIfVisible = function () {
           window.setTimeout(function () {
           window.setTimeout(function () {
             if (self.searchResultVisible()) {
             if (self.searchResultVisible()) {
               self.close();
               self.close();
             }
             }
           }, 0);
           }, 0);
-        });
+        };
 
 
-        huePubSub.subscribe('context.popover.show.in.assist', function () {
-          window.setTimeout(function () {
-            if (self.searchResultVisible()) {
-              self.close();
-            }
-          }, 0);
-        });
+        huePubSub.subscribe('context.popover.open.in.metastore', deferredCloseIfVisible);
+        huePubSub.subscribe('context.popover.show.in.assist', deferredCloseIfVisible);
+        huePubSub.subscribe('sample.error.insert.click', deferredCloseIfVisible);
 
 
         huePubSub.subscribe('draggable.text.started', function (meta) {
         huePubSub.subscribe('draggable.text.started', function (meta) {
           // We have to set the height to 0 when dragging a text, just closing the results will break the
           // We have to set the height to 0 when dragging a text, just closing the results will break the