瀏覽代碼

HUE-7558 [assist] Update the context menu for the collections items

Enrico Berti 8 年之前
父節點
當前提交
16609e8

+ 41 - 2
desktop/core/src/desktop/static/desktop/js/assist/assistDbEntry.js

@@ -501,9 +501,14 @@ var AssistDbEntry = (function () {
     }
   };
 
-  AssistDbEntry.prototype.explore = function () {
+  AssistDbEntry.prototype.explore = function (isSolr) {
     var self = this;
-    huePubSub.publish('open.link', '/hue/dashboard/browse/' + self.getDatabaseName() + '.' + self.getTableName() + '?engine=' + self.assistDbSource.sourceType);
+    if (isSolr) {
+      huePubSub.publish('open.link', '/hue/dashboard/browse/' + self.definition.name);
+    }
+    else {
+      huePubSub.publish('open.link', '/hue/dashboard/browse/' + self.getDatabaseName() + '.' + self.getTableName() + '?engine=' + self.assistDbSource.sourceType);
+    }
   };
 
   AssistDbEntry.prototype.openInMetastore = function () {
@@ -524,6 +529,40 @@ var AssistDbEntry = (function () {
     }
   };
 
+  AssistDbEntry.prototype.openInIndexer = function () {
+    var definitionName = this.definition.name;
+    if (IS_NEW_INDEXER_ENABLED) {
+      if (IS_HUE_4) {
+        huePubSub.publish('open.link', '/indexer/indexes/' + definitionName);
+      }
+      else {
+        window.open('/indexer/indexes/' + definitionName);
+      }
+    }
+    else {
+      var hash = '#edit/' + definitionName;
+      if (IS_HUE_4) {
+        if (window.location.pathname.startsWith('/hue/indexer') && !window.location.pathname.startsWith('/hue/indexer/importer')) {
+          window.location.hash = hash;
+        }
+        else {
+          huePubSub.subscribeOnce('app.gained.focus', function (app) {
+            if (app === 'indexes') {
+              window.setTimeout(function () {
+                window.location.hash = hash;
+              }, 0)
+            }
+          });
+          huePubSub.publish('open.link', '/indexer');
+        }
+      }
+      else {
+        window.open('/indexer/' + hash);
+      }
+    }
+  };
+
+
   AssistDbEntry.prototype.toggleOpen = function () {
     var self = this;
     self.open(!self.open());

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

@@ -87,33 +87,48 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, get_ord
 
   <script type="text/html" id="sql-context-items">
     <!-- ko if: typeof definition !== 'undefined' -->
-    <li><a href="javascript:void(0);" data-bind="click: function (data) { showContextPopover(data, { target: $parentContext.$contextSourceElement }, { left: 4, top: 2 }); }"><i class="fa fa-fw fa-info"></i> ${ _('Show details') }</a></li>
-    <!-- ko if: !definition.isDatabase && $currentApp() === 'editor' -->
-    <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 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>
-    % if HAS_SQL_ENABLED.get():
-    <li>
-      <a href="javascript: void(0);" data-bind="click: explore">
-        <!-- ko template: { name: 'app-icon-template', data: { icon: 'dashboard' } } --><!-- /ko --> ${ _('Open in Dashboard') }
-      </a>
-    </li>
-    % endif
-    <!-- /ko -->
-    %if ENABLE_QUERY_BUILDER.get():
-    <!-- ko if: definition.isColumn && $currentApp() === 'editor' -->
-    <li class="divider"></li>
-    <!-- ko template: { name: 'query-builder-context-items' } --><!-- /ko -->
-    <!-- /ko -->
-    %endif
+      <!-- ko if: sourceType === 'solr' -->
+        <!-- ko if: definition.isColumn -->
+        <li><a href="javascript:void(0);" data-bind="click: function (data) { showContextPopover(data, { target: $parentContext.$contextSourceElement }, { left: 4, top: 2 }); }"><i class="fa fa-fw fa-info"></i> ${ _('Show details') }</a></li>
+        <!-- /ko -->
+        <!-- ko if: definition.isView || definition.isTable -->
+        <li><a href="javascript:void(0);" data-bind="click: openInIndexer"><i class="fa fa-fw fa-table"></i> ${ _('Open in Browser') }</a></li>
+        <li>
+          <a href="javascript: void(0);" data-bind="click: function() { explore(true); }">
+            <!-- ko template: { name: 'app-icon-template', data: { icon: 'dashboard' } } --><!-- /ko --> ${ _('Open in Dashboard') }
+          </a>
+        </li>
+        <!-- /ko -->
+      <!-- /ko -->
+      <!-- ko ifnot: sourceType === 'solr' -->
+        <li><a href="javascript:void(0);" data-bind="click: function (data) { showContextPopover(data, { target: $parentContext.$contextSourceElement }, { left: 4, top: 2 }); }"><i class="fa fa-fw fa-info"></i> ${ _('Show details') }</a></li>
+        <!-- ko if: !definition.isDatabase && $currentApp() === 'editor' -->
+        <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 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>
+        % if HAS_SQL_ENABLED.get():
+        <li>
+          <a href="javascript: void(0);" data-bind="click: function() { explore(false); }">
+            <!-- ko template: { name: 'app-icon-template', data: { icon: 'dashboard' } } --><!-- /ko --> ${ _('Open in Dashboard') }
+          </a>
+        </li>
+        % endif
+        <!-- /ko -->
+        %if ENABLE_QUERY_BUILDER.get():
+        <!-- ko if: definition.isColumn && $currentApp() === 'editor' -->
+        <li class="divider"></li>
+        <!-- ko template: { name: 'query-builder-context-items' } --><!-- /ko -->
+        <!-- /ko -->
+        %endif
+      <!-- /ko -->
     <!-- /ko -->
   </script>
 

+ 6 - 1
desktop/core/src/desktop/templates/common_header_footer_components.mako

@@ -21,7 +21,7 @@ from desktop import conf
 from desktop.lib.i18n import smart_unicode
 
 from beeswax.conf import LIST_PARTITIONS_LIMIT
-
+from indexer.conf import ENABLE_NEW_INDEXER
 from metadata.conf import has_optimizer, OPTIMIZER
 %>
 
@@ -31,6 +31,11 @@ from metadata.conf import has_optimizer, OPTIMIZER
     var LOGGED_USERNAME = '${ user.username }';
     var IS_S3_ENABLED = '${ is_s3_enabled }' === 'True';
     var HAS_OPTIMIZER = '${ has_optimizer() }' === 'True';
+    %if hasattr(ENABLE_NEW_INDEXER, 'get') and ENABLE_NEW_INDEXER.get():
+    var IS_NEW_INDEXER_ENABLED = true;
+    %else:
+    var IS_NEW_INDEXER_ENABLED = false;
+    %endif
 
     %if request and request.COOKIES and request.COOKIES.get('csrftoken','')!='':
     window.CSRF_TOKEN = '${request.COOKIES.get('csrftoken')}';