Bläddra i källkod

HUE-7683 [assist] Add 'Open in assist' functionality for the right assist items

Enrico Berti 8 år sedan
förälder
incheckning
c02e8b4

+ 38 - 27
desktop/core/src/desktop/templates/assist.mako

@@ -1193,35 +1193,40 @@ from desktop.views import _ko
           }
         };
 
-        if (!options.isSolr) {
-          huePubSub.subscribe('assist.db.highlight', function (location) {
-            huePubSub.publish('left.assist.show');
+        huePubSub.subscribe('assist.db.highlight', function (location) {
+          huePubSub.publish('left.assist.show');
+          if (location.sourceType === 'solr') {
+            huePubSub.publish('assist.show.solr');
+          }
+          else {
             huePubSub.publish('assist.show.sql');
-            huePubSub.publish('context.popover.hide');
-            window.setTimeout(function () {
-              var foundSource;
-              $.each(self.sources(), function (idx, source) {
-                if (source.sourceType === location.sourceType) {
-                  foundSource = source;
-                  return false;
-                }
-              });
-              if (foundSource) {
-                var whenLoaded = function () {
-                  if (self.selectedSource() !== foundSource) {
-                    self.selectedSource(foundSource);
-                  }
-                  foundSource.highlightInside(location.path);
-                };
-                if (foundSource.hasEntries()) {
-                  whenLoaded();
-                } else {
-                  foundSource.initDatabases(whenLoaded);
+          }
+          huePubSub.publish('context.popover.hide');
+          window.setTimeout(function () {
+            var foundSource;
+            $.each(self.sources(), function (idx, source) {
+              if (source.sourceType === location.sourceType) {
+                foundSource = source;
+                return false;
+              }
+            });
+            if (foundSource) {
+              var whenLoaded = function () {
+                if (self.selectedSource() !== foundSource) {
+                  self.selectedSource(foundSource);
                 }
+                foundSource.highlightInside(location.path);
+              };
+              if (foundSource.hasEntries()) {
+                whenLoaded();
+              } else {
+                foundSource.initDatabases(whenLoaded);
               }
-            }, 0);
-          });
+            }
+          }, 0);
+        });
 
+        if (!options.isSolr) {
           huePubSub.subscribe('assist.set.database', function (databaseDef) {
             if (!databaseDef.source || !self.sourceIndex[databaseDef.source]) {
               return;
@@ -1919,7 +1924,7 @@ from desktop.views import _ko
               }
 
               if (appConfig['browser'] && appConfig['browser']['interpreter_names'].indexOf('indexes') != -1) {
-                panels.push(new AssistInnerPanel({
+                var solrPanel = new AssistInnerPanel({
                   panelData: new AssistDbPanel($.extend({
                     apiHelper: self.apiHelper,
                     i18n: i18nCollections,
@@ -1930,7 +1935,13 @@ from desktop.views import _ko
                   type: 'solr',
                   icon: 'fa-search-plus',
                   minHeight: 75
-                }));
+                });
+                panels.push(solrPanel);
+                huePubSub.subscribe('assist.show.solr', function () {
+                  if (self.visiblePanel() !== solrPanel) {
+                    self.visiblePanel(solrPanel);
+                  }
+                });
               }
 
               if (appConfig['browser'] && appConfig['browser']['interpreter_names'].indexOf('hbase') != -1) {

+ 18 - 1
desktop/core/src/desktop/templates/ko_components/ko_context_popover.mako

@@ -1231,6 +1231,23 @@ from metadata.conf import has_navigator
           }
         ];
         self.activeTab = ko.observable('terms');
+
+        self.apiHelper.identifierChainToPath({
+          sourceType: 'solr',
+          identifierChain: data.identifierChain,
+          defaultDatabase: 'default'
+        }, function (path) {
+          var showInAssistPubSub = huePubSub.subscribe('context.popover.show.in.assist', function () {
+            huePubSub.publish('assist.db.highlight', {
+              sourceType: 'solr',
+              path: path
+            });
+          });
+          self.disposals.push(function () {
+            showInAssistPubSub.remove();
+          })
+        });
+
       }
 
       CollectionContextTabs.prototype.loadTerms = function () {
@@ -1537,7 +1554,7 @@ from metadata.conf import has_navigator
         self.isDocument = params.data.type.toLowerCase() === 'hue';
         self.isCollection = params.data.type === 'collection';
 
-        self.showInAssistEnabled = (typeof params.showInAssistEnabled !== 'undefined' ? params.showInAssistEnabled : true) && (self.isDocument || self.isDatabase || self.isTable || self.isColumn);
+        self.showInAssistEnabled = (typeof params.showInAssistEnabled !== 'undefined' ? params.showInAssistEnabled : true) && (self.isDocument || self.isDatabase || self.isTable || self.isColumn || self.isCollection);
         self.openInDashboardEnabled = self.isTable || self.isView || self.isDatabase;
         self.openInTableBrowserEnabled = self.isTable || self.isView || self.isDatabase;
         self.replaceEditorContentEnabled = self.isHdfs;

+ 1 - 1
desktop/libs/indexer/src/indexer/templates/indexes.mako

@@ -807,7 +807,7 @@ ${ assist.assistPanel() }
               ko.mapping.toJS(field)
             ]
           },
-          showInAssistEnabled: false,
+          showInAssistEnabled: true,
           orientation: 'right',
           pinEnabled: false,
           source: {