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

HUE-9292 [editor] Support autocompletion of files from the root for adl, abfs and s3a

Johan Ahlen пре 5 година
родитељ
комит
033acbb3ec
1 измењених фајлова са 21 додато и 3 уклоњено
  1. 21 3
      desktop/core/src/desktop/js/sql/autocompleteResults.js

+ 21 - 3
desktop/core/src/desktop/js/sql/autocompleteResults.js

@@ -27,6 +27,7 @@ import sqlUtils from 'sql/sqlUtils';
 import { SqlSetOptions, SqlFunctions } from 'sql/sqlFunctions';
 import { DIALECT } from 'apps/notebook2/snippet';
 import { cancelActiveRequest } from 'api/apiUtils';
+import { findBrowserConnector, getRootFilePath } from 'utils/hueConfig';
 
 const normalizedColors = HueColors.getNormalizedColors();
 
@@ -1330,13 +1331,30 @@ class AutocompleteResults {
 
       if (/^s3a:\/\//i.test(path)) {
         fetchFunction = 'fetchS3Path';
-        path = path.substring(4);
+        path = path.substring(5);
       } else if (/^adl:\/\//i.test(path)) {
         fetchFunction = 'fetchAdlsPath';
-        path = path.substring(4);
+        path = path.substring(5);
       } else if (/^abfs:\/\//i.test(path)) {
         fetchFunction = 'fetchAbfsPath';
-        path = path.substring(5);
+        path = path.substring(6);
+        if (path === '/') {
+          const connector = findBrowserConnector(connector => connector.type === 'abfs');
+          const rootPath = getRootFilePath(connector);
+          if (rootPath) {
+            pathsDeferred.resolve([
+              {
+                value: rootPath,
+                meta: 'abfs',
+                category: CATEGORIES.HDFS,
+                weightAdjust: 0,
+                popular: ko.observable(false),
+                details: null
+              }
+            ]);
+            return pathsDeferred;
+          }
+        }
       } else if (/^hdfs:\/\//i.test(path)) {
         path = path.substring(6);
       }