소스 검색

[spark] Fix table metastore links

This fixes an issue were the table references were no longer identified as "hueLinks" (double click to show table in metastore manager). It was caused by the removal of "assist.firstLevelChange" in a previous commit.
Johan Ahlen 10 년 전
부모
커밋
0d9c01feaf
1개의 변경된 파일15개의 추가작업 그리고 9개의 파일을 삭제
  1. 15 9
      desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

+ 15 - 9
desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

@@ -1748,6 +1748,20 @@ ko.bindingHandlers.aceEditor = {
       onPaste(editor);
     });
 
+
+    var currentAssistTables = {};
+
+    var refreshTables = function() {
+      currentAssistTables = {};
+      self.assistHelper.fetchTables(function(data) {
+        $.each(data.tables, function(index, table) {
+          currentAssistTables[table] = true;
+        });
+      })
+    };
+    self.assistHelper.activeDatabase.subscribe(refreshTables);
+    refreshTables();
+
     ace.define("huelink", [], function (require, exports, module) {
       "use strict";
 
@@ -1811,18 +1825,10 @@ ko.bindingHandlers.aceEditor = {
 
           var token = editor.session.getTokenAt(docPos.row, docPos.column);
 
-          var currentAssistTables = [];
-
-          huePubSub.subscribe('assist.firstLevelChange', function (tables) {
-            currentAssistTables = tables;
-          });
-
           if (token) {
-            var isMetastoreLink = Object.keys(currentAssistTables).indexOf(token.value) > -1;
-
             if (token.value.indexOf("'/") == 0 && token.value.lastIndexOf("'") == token.value.length - 1 ||
                 token.value.indexOf("\"/") == 0 && token.value.lastIndexOf("\"") == token.value.length - 1 ||
-                isMetastoreLink) {
+                currentAssistTables[token.value]) {
               // add highlight for the clicked token
               var range = new AceRange(docPos.row, token.start, docPos.row, token.start + token.value.length);
               editor.session.removeMarker(this.marker);