Pārlūkot izejas kodu

HUE-8066 [editor] Open query result in dashboard opens in importer

Romain Rigaux 7 gadi atpakaļ
vecāks
revīzija
e5d0c77

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

@@ -196,7 +196,7 @@ except ImportError, e:
         </li>
         % if ENABLE_SQL_INDEXER.get():
         <li>
-          <a class="download" href="javascript:void(0)" data-bind="click: function() { saveTarget('search-index'); savePath('__hue__'); trySaveResults(); }" title="${ _('Visually explore the result') }">
+          <a class="download" href="javascript:void(0)" data-bind="click: function() { saveTarget('dashboard'); trySaveResults(); }" title="${ _('Visually explore the result') }">
             <!-- ko template: { name: 'app-icon-template', data: { icon: 'dashboard' } } --><!-- /ko --> ${ _('Dashboard') }
           </a>
         </li>
@@ -355,7 +355,7 @@ except ImportError, e:
         });
 
         self.isValidDestination = ko.pureComputed(function () {
-          return self.savePath() !== '' && (self.saveTarget() != 'hive-table' || /^([a-zA-Z0-9_]+\.)?[a-zA-Z0-9_]*$/.test(self.savePath()));
+          return self.savePath() !== '' && (self.saveTarget() != 'hive-table' || /^([a-zA-Z0-9_]+\.)?[a-zA-Z0-9_]*$/.test(self.savePath())) || self.saveTarget() == 'dashboard';
         });
 
         self.clipboardClass = ko.pureComputed(function () {
@@ -419,6 +419,9 @@ except ImportError, e:
                 } else if (self.saveTarget() == 'search-index') {
                   $(self.saveResultsModalId).modal('hide');
                   huePubSub.publish('open.importer.query', resp);
+                } else if (self.saveTarget() == 'dashboard') {
+                  $(self.saveResultsModalId).modal('hide');
+                  huePubSub.publish('open.link', resp.watch_url);
                 } else if (resp.history_uuid) {
                   $(self.saveResultsModalId).modal('hide');
                   huePubSub.publish('notebook.task.submitted', resp.history_uuid);

+ 2 - 2
desktop/libs/notebook/src/notebook/api.py

@@ -705,12 +705,12 @@ def export_result(request):
       'operationText': 'User %s exported to HDFS directory: %s' % (request.user.username, destination),
       'allowed': True
     }
-  elif data_format == 'search-index':
+  elif data_format in ('search-index', 'dashboard'):
     # Open the result in the Dashboard via a SQL sub-query or the Import wizard (quick vs scalable)
     if is_embedded:
       notebook_id = notebook['id'] or request.GET.get('editor', request.GET.get('notebook'))
 
-      if destination == '__hue__':
+      if data_format == 'dashboard':
         engine = notebook['type'].replace('query-', '')
         response['watch_url'] = reverse('dashboard:browse', kwargs={'name': notebook_id}) + '?source=query&engine=%(engine)s' % {'engine': engine}
         response['status'] = 0