浏览代码

HUE-3884 [editor] Opening a query from saved query tab should not switch to the history tab

Enrico Berti 9 年之前
父节点
当前提交
6c97925f53

+ 8 - 3
desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

@@ -1653,7 +1653,7 @@
       }
     };
 
-    self.loadNotebook = function (notebook) {
+    self.loadNotebook = function (notebook, queryTab) {
       if (self.checkStatusTimeout != null) {
         clearTimeout(self.checkStatusTimeout);
         self.checkStatusTimeout = null;
@@ -1674,11 +1674,16 @@
         if (notebook.snippets()[0].result.data().length > 0) {
           $(document).trigger("redrawResults");
         }
+        else {
+          if (queryTab){
+            notebook.snippets()[0].currentQueryTab(queryTab);
+          }
+        }
       }
       self.selectedNotebook(notebook);
     };
 
-    self.openNotebook = function (uuid) {
+    self.openNotebook = function (uuid, queryTab) {
       $.get('/desktop/api2/doc/', {
         uuid: uuid,
         data: true,
@@ -1687,7 +1692,7 @@
         data.data.dependents = data.dependents;
         data.data.can_write = data.user_perms.can_write;
         var notebook = data.data;
-        self.loadNotebook(notebook);
+        self.loadNotebook(notebook, queryTab);
         hueUtils.changeURL('/notebook/editor?editor=' + data.document.id);
       });
     };

+ 1 - 1
desktop/libs/notebook/src/notebook/templates/editor_components.mako

@@ -1132,7 +1132,7 @@ ${ hueIcons.symbols() }
               </tr>
             </thead>
             <tbody data-bind="foreach: queries">
-            <tr data-bind="click: function() { if (uuid != $root.selectedNotebook().uuid()) { $root.openNotebook(uuid); } }, css: { 'highlight': uuid == $root.selectedNotebook().uuid(), 'pointer': uuid != $root.selectedNotebook().uuid() }">
+            <tr data-bind="click: function() { if (uuid != $root.selectedNotebook().uuid()) { $root.openNotebook(uuid, 'savedQueries'); } }, css: { 'highlight': uuid == $root.selectedNotebook().uuid(), 'pointer': uuid != $root.selectedNotebook().uuid() }">
               <td style="width: 16%"><span data-bind="ellipsis: {data: name, length: 30}"></span></td>
               <td style="width: 50%; white-space: normal"><span data-bind="text: description"></span></td>
               <td style="width: 18%"><span data-bind="text: owner"></span></td>