瀏覽代碼

HUE-7864 [assist] Open top search document folders in the assist instead of home

Johan Ahlen 7 年之前
父節點
當前提交
b08af6459f

+ 18 - 11
desktop/core/src/desktop/static/desktop/js/document/hueFileEntry.js

@@ -261,7 +261,7 @@ var HueFileEntry = (function () {
 
   HueFileEntry.prototype.highlightInside = function (uuid) {
     var self = this;
-    self.typeFilter(self.availableTypeFilters()[0]);
+    self.typeFilter(DOCUMENT_TYPES[0]);
     var foundEntry;
     self.entries().forEach(function (entry) {
       entry.highlight(false);
@@ -270,16 +270,23 @@ var HueFileEntry = (function () {
       }
     });
     if (foundEntry) {
-      window.setTimeout(function () {
-        huePubSub.subscribeOnce('assist.db.scrollToComplete', function () {
-          foundEntry.highlight(true);
-          // Timeout is for animation effect
-          window.setTimeout(function () {
-            foundEntry.highlight(false);
-          }, 1800);
-        });
-        huePubSub.publish('assist.db.scrollTo', foundEntry);
-      }, 0);
+      if (foundEntry.definition().type === 'directory') {
+        self.activeEntry(foundEntry);
+        if (!foundEntry.entries().length) {
+          foundEntry.load();
+        }
+      } else {
+        window.setTimeout(function () {
+          huePubSub.subscribeOnce('assist.db.scrollToComplete', function () {
+            foundEntry.highlight(true);
+            // Timeout is for animation effect
+            window.setTimeout(function () {
+              foundEntry.highlight(false);
+            }, 1800);
+          });
+          huePubSub.publish('assist.db.scrollTo', foundEntry);
+        }, 0);
+      }
     }
   };
 

+ 5 - 0
desktop/core/src/desktop/templates/ko_components/ko_context_popover.mako

@@ -369,7 +369,12 @@ from metadata.conf import has_navigator
   <script type="text/html" id="generic-document-context-template">
     <div style="width:100%; text-align: center; margin-top: 30px; font-size: 100px; color: #787878;" data-bind="template: { name: 'document-icon-template', data: { document: { isDirectory: type === 'directory', definition: function() { return $data } } } }"></div>
     <div style="width: 100%; margin-top: 20px; text-align:center">
+      <!-- ko if: type === 'directory' -->
+      <a style="font-size: 20px;" href="javscript:void(0)" data-bind="text: name, publish: 'context.popover.show.in.assist'"></a>
+      <!-- /ko -->
+      <!-- ko if: type !== 'directory' -->
       <a style="font-size: 20px;" href="javscript:void(0)" data-bind="text: name, hueLink: link, click: function () { $parents[1].close(); }"></a>
+      <!-- /ko -->
       <br/>
       <span data-bind="text: HUE_I18n.documentType[type] || type"></span>
       <!-- ko if: description -->

+ 5 - 1
desktop/core/src/desktop/templates/ko_components/ko_global_search.mako

@@ -266,7 +266,11 @@ from desktop.views import _ko
         if (['database', 'table', 'field', 'view'].indexOf(selectedResult.type) !== -1) {
           huePubSub.publish('context.popover.show.in.assist');
         } else if (selectedResult.type === 'document') {
-          huePubSub.publish('open.link', '/hue' + selectedResult.data.link);
+          if (selectedResult.data.doc_type === 'directory') {
+            huePubSub.publish('context.popover.show.in.assist');
+          } else {
+            huePubSub.publish('open.link', '/hue' + selectedResult.data.link);
+          }
         } else if (selectedResult.type === 'hueApp' && selectedResult.data.interpreter && selectedResult.data.interpreter.page) {
           huePubSub.publish('open.link', selectedResult.data.interpreter.page);
         } else if (selectedResult.type === 'hueApp' && selectedResult.data.app && selectedResult.data.app.page) {