Преглед изворни кода

[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 пре 11 година
родитељ
комит
0d9c01f
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);
       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) {
     ace.define("huelink", [], function (require, exports, module) {
       "use strict";
       "use strict";
 
 
@@ -1811,18 +1825,10 @@ ko.bindingHandlers.aceEditor = {
 
 
           var token = editor.session.getTokenAt(docPos.row, docPos.column);
           var token = editor.session.getTokenAt(docPos.row, docPos.column);
 
 
-          var currentAssistTables = [];
-
-          huePubSub.subscribe('assist.firstLevelChange', function (tables) {
-            currentAssistTables = tables;
-          });
-
           if (token) {
           if (token) {
-            var isMetastoreLink = Object.keys(currentAssistTables).indexOf(token.value) > -1;
-
             if (token.value.indexOf("'/") == 0 && token.value.lastIndexOf("'") == token.value.length - 1 ||
             if (token.value.indexOf("'/") == 0 && token.value.lastIndexOf("'") == token.value.length - 1 ||
                 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
               // add highlight for the clicked token
               var range = new AceRange(docPos.row, token.start, docPos.row, token.start + token.value.length);
               var range = new AceRange(docPos.row, token.start, docPos.row, token.start + token.value.length);
               editor.session.removeMarker(this.marker);
               editor.session.removeMarker(this.marker);