Browse Source

HUE-8325 [editor] Add the correct protocol type for the file context popover replace in editor action

Johan Ahlen 7 years ago
parent
commit
29b811df90

+ 4 - 1
desktop/core/src/desktop/static/desktop/js/assist/assistStorageEntry.js

@@ -45,6 +45,7 @@ var AssistStorageEntry = (function () {
    * @param {string} options.definition.name
    * @param {string} options.definition.name
    * @param {string} options.definition.type (file, dir)
    * @param {string} options.definition.type (file, dir)
    * @param {string} options.type - The storage type ('adls', 'hdfs', 's3')
    * @param {string} options.type - The storage type ('adls', 'hdfs', 's3')
+   * @param {string} [options.originalType] - The original storage type ('adl', 's3a')
    * @param {AssistStorageEntry} options.parent
    * @param {AssistStorageEntry} options.parent
    * @param {ApiHelper} options.apiHelper
    * @param {ApiHelper} options.apiHelper
    * @constructor
    * @constructor
@@ -52,6 +53,7 @@ var AssistStorageEntry = (function () {
   function AssistStorageEntry (options) {
   function AssistStorageEntry (options) {
     var self = this;
     var self = this;
     self.type = options.type;
     self.type = options.type;
+    self.originalType = options.originalType;
     self.definition = options.definition;
     self.definition = options.definition;
     self.apiHelper = options.apiHelper;
     self.apiHelper = options.apiHelper;
     self.parent = options.parent;
     self.parent = options.parent;
@@ -339,10 +341,11 @@ var AssistStorageEntry = (function () {
     var typeMatch = path.match(/^([^:]+):\/(\/.*)\/?/i);
     var typeMatch = path.match(/^([^:]+):\/(\/.*)\/?/i);
     var type = typeMatch ? typeMatch[1] : (type || 'hdfs');
     var type = typeMatch ? typeMatch[1] : (type || 'hdfs');
     type = type.replace(/s3.*/i, 's3');
     type = type.replace(/s3.*/i, 's3');
-    type = type.replace(/adl.*/i, 'adls');
+    type = type.replace(/adl.*/i, 'adls')
 
 
     var rootEntry = new AssistStorageEntry({
     var rootEntry = new AssistStorageEntry({
       type: type.toLowerCase(),
       type: type.toLowerCase(),
+      originalType: typeMatch && typeMatch[1],
       definition: {
       definition: {
         name: '/',
         name: '/',
         type: 'dir'
         type: 'dir'

+ 2 - 1
desktop/core/src/desktop/templates/ko_components/ko_context_popover.mako

@@ -797,9 +797,10 @@ from metadata.conf import has_navigator
       };
       };
 
 
       StorageContext.prototype.replaceInEditor = function (entry, storageContext) {
       StorageContext.prototype.replaceInEditor = function (entry, storageContext) {
+        var text = entry.originalType ? entry.originalType + ':/' + entry.path : entry.path;
         huePubSub.publish('ace.replace', {
         huePubSub.publish('ace.replace', {
           location: storageContext.editorLocation,
           location: storageContext.editorLocation,
-          text: entry.path
+          text: text
         });
         });
         huePubSub.publish('context.popover.hide');
         huePubSub.publish('context.popover.hide');
       };
       };