浏览代码

HUE-8629 [assist] Customise the assist icons for streams

Johan Ahlen 7 年之前
父节点
当前提交
3e630b0be3

+ 18 - 9
desktop/core/src/desktop/static/desktop/js/assist/assistDbEntry.js

@@ -52,8 +52,21 @@ var AssistDbEntry = (function () {
 
     self.hasErrors = ko.observable(false);
 
+    self.iconClass = '';
+    if (!self.navigationSettings.rightAssist) {
+      if (self.sourceType === 'solr') {
+        self.iconClass = 'fa-search';
+      } else if (self.sourceType === 'kafka') {
+        self.iconClass = 'fa-sitemap';
+      } else if (self.catalogEntry.isView()) {
+        self.iconClass = 'fa-eye';
+      } else {
+        self.iconClass = 'fa-table';
+      }
+    }
+
     self.open.subscribe(function(newValue) {
-      if (newValue && self.entries().length == 0) {
+      if (newValue && self.entries().length === 0) {
         self.loadEntries();
       }
     });
@@ -431,18 +444,15 @@ var AssistDbEntry = (function () {
     if (IS_NEW_INDEXER_ENABLED) {
       if (IS_HUE_4) {
         huePubSub.publish('open.link', '/indexer/indexes/' + definitionName);
-      }
-      else {
+      } else {
         window.open('/indexer/indexes/' + definitionName);
       }
-    }
-    else {
+    } 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 {
+        } else {
           huePubSub.subscribeOnce('app.gained.focus', function (app) {
             if (app === 'indexes') {
               window.setTimeout(function () {
@@ -452,8 +462,7 @@ var AssistDbEntry = (function () {
           });
           huePubSub.publish('open.link', '/indexer');
         }
-      }
-      else {
+      } else {
         window.open('/indexer/' + hash);
       }
     }

+ 1 - 1
desktop/core/src/desktop/templates/assist.mako

@@ -209,7 +209,7 @@ from desktop.views import _ko
         <a class="inactive-action" href="javascript:void(0)" data-bind="visible: navigationSettings.openItem, click: openItem"><i class="fa fa-long-arrow-right" title="${_('Open')}"></i></a>
       </div>
       <a class="assist-entry assist-table-link" href="javascript:void(0)" data-bind="click: toggleOpen, attr: {'title': catalogEntry.getTitle(true) }, draggableText: { text: editorText,  meta: {'type': 'sql', 'isView': catalogEntry.isView(), 'table': tableName, 'database': databaseName} }">
-        <i class="fa fa-fw fa-table muted valign-middle" data-bind="css: { 'fa-eye': catalogEntry.isView() && !navigationSettings.rightAssist, 'fa-table': catalogEntry.isTable() && sourceType !== 'solr' && !navigationSettings.rightAssist, 'fa-search': sourceType === 'solr' }"></i>
+        <i class="fa fa-fw muted valign-middle" data-bind="css: iconClass"></i>
         <span class="highlightable" data-bind="text: catalogEntry.getDisplayName(navigationSettings.rightAssist), css: { 'highlight': highlight }"></span>
       </a>
       <div class="center assist-spinner" data-bind="visible: loading() && open()"><i class="fa fa-spinner fa-spin"></i></div>