Explorar o código

[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 %!s(int64=10) %!d(string=hai) anos
pai
achega
0d9c01f
Modificáronse 1 ficheiros con 15 adicións e 9 borrados
  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);