浏览代码

HUE-6762 [assist] Offer right click to open table in editor

Romain Rigaux 8 年之前
父节点
当前提交
6d8666205f
共有 2 个文件被更改,包括 20 次插入2 次删除
  1. 5 2
      desktop/core/src/desktop/templates/assist.mako
  2. 15 0
      desktop/core/src/desktop/templates/hue.mako

+ 5 - 2
desktop/core/src/desktop/templates/assist.mako

@@ -94,7 +94,10 @@ from notebook.conf import get_ordered_interpreters
     <li><a href="javascript:void(0);" data-bind="click: dblClick"><i class="fa fa-fw fa-paste"></i> ${ _('Insert at cursor') }</a></li>
     <!-- /ko -->
     <!-- ko if: definition.isView || definition.isTable || definition.isDatabase -->
-    <li><a href="javascript:void(0);" data-bind="click: openInMetastore"><i class="fa fa-fw fa-table"></i> ${ _('Open in Table Browser') }</a></li>
+    <li><a href="javascript:void(0);" data-bind="click: openInMetastore"><i class="fa fa-fw fa-table"></i> ${ _('Open in Browser') }</a></li>
+    <!-- /ko -->
+    <!-- ko if: definition.isView || definition.isTable -->
+    <li><a href="javascript:void(0);" data-bind="click: function() { huePubSub.publish('query.and.watch', {'url': '/notebook/browse/' + databaseName + '/' + tableName + '/', sourceType: sourceType}); }"><i class="fa fa-fw fa-code"></i> ${ _('Open in Editor') }</a></li>
     <!-- /ko -->
     %if ENABLE_QUERY_BUILDER.get():
     <!-- ko if: definition.isColumn && $currentApp() === 'editor' -->
@@ -1630,7 +1633,7 @@ from notebook.conf import get_ordered_interpreters
             self.lastOpenPanelType(newValue.type);
             newValue.panelData.init();
           });
-          
+
           self.visiblePanel(lastFoundPanel.length === 1 ? lastFoundPanel[0] : self.availablePanels()[0]);
         });
 

+ 15 - 0
desktop/core/src/desktop/templates/hue.mako

@@ -1543,6 +1543,21 @@ ${ smart_unicode(login_modal(request).content) | n,unicode }
       $('#clearNotificationHistoryModal').modal('hide');
     });
 
+    huePubSub.subscribe('query.and.watch', function (query) {
+      $.post(query['url'], {
+        format: "json",
+        sourceType: query['sourceType']
+      },function(resp) {
+        if (resp.history_uuid) {
+          huePubSub.publish('open.editor.query', resp.history_uuid);
+        } else if (resp.message) {
+          $(document).trigger("error", resp.message);
+        }
+      }).fail(function (xhr) {
+        $(document).trigger("error", xhr.responseText);
+      });
+    });
+
     var hideJobsPanels = function (e) {
       if ($(e.target).closest('.jobs-panel').length === 0 && $(e.target).closest('.btn-toggle-jobs-panel').length === 0 && $('.jobs-panel').is(':visible')) {
         huePubSub.publish('hide.jobs.panel');