ソースを参照

HUE-4402 [fb] S3 copy action is not using the picker and fails

Enrico Berti 9 年 前
コミット
e67693a66b

+ 6 - 4
apps/filebrowser/src/filebrowser/templates/listdir_components.mako

@@ -1193,10 +1193,11 @@ from django.utils.translation import ugettext as _
               $("#moveHdfsTree").remove();
               $("<div>").attr("id", "moveHdfsTree").appendTo($("#moveModal .modal-body"));
               $("#moveHdfsTree").jHueHdfsTree({
-                home: "/user/${ user }",
+                home: viewModel.isS3() ? "" : "/user/${ user }",
+                isS3: viewModel.isS3(),
                 initialPath: viewModel.currentPath(),
                 onPathChange: function (path) {
-                  $("#moveDestination").val((path.indexOf("/") == 0 ? "" : "/") + path);
+                  $("#moveDestination").val((viewModel.isS3() ? "" : (path.indexOf("/") == 0 ? "" : "/")) + path);
                   $("#moveNameRequiredAlert").hide();
                 }
               });
@@ -1229,10 +1230,11 @@ from django.utils.translation import ugettext as _
           $("#copyHdfsTree").remove();
           $("<div>").attr("id", "copyHdfsTree").appendTo($("#copyModal .modal-body"));
           $("#copyHdfsTree").jHueHdfsTree({
-            home: "/user/${ user }",
+            home: viewModel.isS3() ? "" : "/user/${ user }",
+            isS3: viewModel.isS3(),
             initialPath: viewModel.currentPath(),
             onPathChange: function(path){
-              $("#copyDestination").val((path.indexOf("/") == 0 ? "" : "/") + path);
+              $("#copyDestination").val((viewModel.isS3() ? "" : (path.indexOf("/") == 0 ? "" : "/")) + path);
               $("#copyNameRequiredAlert").hide();
             }
           });

+ 20 - 6
desktop/core/src/desktop/static/desktop/js/jquery.hdfstree.js

@@ -32,6 +32,7 @@
       defaults = {
         home: "",
         initialPath: "/",
+        isS3: false,
         onPathChange: function () {
         },
         createFolder: true,
@@ -156,7 +157,12 @@
 
       if (options.paths != null && options.paths.length > 0) {
         var shiftedPath = options.paths.shift();
-        currentPath = (shiftedPath != "" ? shiftedPath : "/");
+        if (_this.options.isS3){
+          currentPath = shiftedPath;
+        }
+        else {
+          currentPath = (shiftedPath != "" ? shiftedPath : "/");
+        }
       }
       else {
         currentPath = (options.leaf != null ? options.leaf : "/");
@@ -165,7 +171,8 @@
       $.getJSON(autocompleteUrl + "?pagesize=1000&format=json", function (data) {
         _currentFiles = [];
         if (data.error == null) {
-          var _dataPathForCurrent = currentPath != "" ? removeLeadingSlash(currentPath) : "__JHUEHDFSTREE__ROOT__";
+          var filteredCurrentPath = _this.options.isS3 ? currentPath.substr(5) : currentPath;
+          var _dataPathForCurrent = filteredCurrentPath != "" ? removeLeadingSlash(filteredCurrentPath) : "__JHUEHDFSTREE__ROOT__";
           _el.find("[data-path='" + escapeSingleQuote(_dataPathForCurrent) + "']").attr("data-loaded", true);
           _el.find("[data-path='" + escapeSingleQuote(_dataPathForCurrent) + "']").siblings("a").find(".fa-folder-o").removeClass("fa-folder-o").addClass("fa-folder-open-o");
           _tree.find("a").removeClass("selected");
@@ -177,10 +184,11 @@
           $(data.files).each(function (cnt, item) {
             if (item.name != "." && item.name != ".." && item.type == "dir") {
               var _path = item.path;
-              var _escapedPath = escapeSingleQuote(_path);
+              var filteredPath = _this.options.isS3 ? _path.substr(5) : _path;
+              var _escapedPath = escapeSingleQuote(filteredPath);
               if (_el.find("[data-path='" + removeLeadingSlash(_escapedPath) + "']").length == 0) {
                 var _li = $("<li>").html('<a class="pointer"><i class="fa fa-folder-o"></i> ' + item.name + '</a><ul class="content unstyled" data-path="' + removeLeadingSlash(_escapedPath) + '" data-loaded="false"></ul>');
-                var _destination = _path.substr(0, _path.lastIndexOf("/"));
+                var _destination = filteredPath.substr(0, filteredPath.lastIndexOf("/"));
                 if (_destination == "") {
                   _destination = "__JHUEHDFSTREE__ROOT__";
                 }
@@ -210,8 +218,9 @@
             }
           });
           if (_this.options.createFolder) {
+            var filteredCurrentPath = _this.options.isS3 ? currentPath.substr(5) : currentPath;
             var _createFolderLi = $("<li>").html('<a class="pointer"><i class="fa fa-plus-square-o"></i> ' + _this.options.labels.CREATE_FOLDER + '</a>');
-            _createFolderLi.appendTo(_el.find("[data-path='" + removeLeadingSlash(escapeSingleQuote(currentPath)) + "']"));
+            _createFolderLi.appendTo(_el.find("[data-path='" + removeLeadingSlash(escapeSingleQuote(filteredCurrentPath)) + "']"));
 
             var _createFolderDetails = $("<form>").css("margin-top", "10px").addClass("form-inline");
             _createFolderDetails.hide();
@@ -245,7 +254,7 @@
               });
 
             });
-            _createFolderDetails.appendTo(_el.find("[data-path='" + removeLeadingSlash(escapeSingleQuote(currentPath)) + "']"));
+            _createFolderDetails.appendTo(_el.find("[data-path='" + removeLeadingSlash(escapeSingleQuote(filteredCurrentPath)) + "']"));
 
             _createFolderLi.find("a").on("click", function () {
               _createFolderDetails.slideDown();
@@ -275,6 +284,11 @@
       _paths.push(_this.options.initialPath);
     }
 
+    if (_this.options.isS3){
+      _paths.shift();
+      _paths[0] = 's3://';
+    }
+
     showHdfsLeaf({
       paths: _paths
     });