ソースを参照

HUE-4550 [fb] Fix file chooser for S3 after S3A migration

Enrico Berti 9 年 前
コミット
6ea74a9

+ 10 - 7
apps/beeswax/src/beeswax/templates/import_wizard_choose_file.mako

@@ -262,16 +262,10 @@ ${ assist.assistPanel() }
       $(".fileChooserBtn").click(function (e) {
         e.preventDefault();
         var _destination = $(this).attr("data-filechooser-destination");
-        var initialLoadValue = $('#id_load_data').val();
         function handleChoice(filePath){
           $("input[name='" + _destination + "']").val(filePath);
           $("#chooseFile").modal("hide");
-          if (filePath.toLowerCase().indexOf('s3') === 0){
-            $('#id_load_data').val('EXTERNAL').trigger('change').find('option[value="IMPORT"]').attr('disabled', 'disabled');
-          }
-          else {
-            $('#id_load_data').val(initialLoadValue).trigger('change').find('option[value="IMPORT"]').removeAttr('disabled');
-          }
+          $('.pathChooser').trigger('change');
         }
         $("#filechooser").jHueFileChooser({
           initialPath: $("input[name='" + _destination + "']").val(),
@@ -291,6 +285,15 @@ ${ assist.assistPanel() }
           $("#fileWillBeMoved").hide();
         }
       });
+      $('.pathChooser').change(function () {
+        var initialLoadValue = $('#id_load_data').val();
+        if ($(this).val().toLowerCase().indexOf('s3') === 0) {
+          $('#id_load_data').val('EXTERNAL').trigger('change').find('option[value="IMPORT"]').attr('disabled', 'disabled');
+        }
+        else {
+          $('#id_load_data').val(initialLoadValue).trigger('change').find('option[value="IMPORT"]').removeAttr('disabled');
+        }
+      });
       $("#step2").click(function (e) {
         e.preventDefault();
         $("input[name='submit_file']").click();

+ 6 - 6
desktop/core/src/desktop/static/desktop/js/jquery.filechooser.js

@@ -99,7 +99,7 @@
     }
 
     var initialPath = $.trim(self.options.initialPath);
-    if (initialPath && initialPath.toLowerCase().indexOf('s3') > -1 && $(self.element).data('fs').indexOf('s3') > -1) {
+    if (initialPath && initialPath.toLowerCase().indexOf('s3a') > -1 && $(self.element).data('fs').indexOf('s3') > -1) {
       self.options.fsSelected = 's3';
     }
 
@@ -147,10 +147,10 @@
           self.options.fsSelected = fs;
           var storedPath = $.totalStorage(STORAGE_PREFIX + self.options.user + self.options.fsSelected);
           if (storedPath !== null) {
-            if (fs === 's3a' && storedPath.toLowerCase().indexOf('s3a') === -1) {
+            if (fs === 's3' && storedPath.toLowerCase().indexOf('s3') === -1) {
               self.navigateTo('S3A://');
             }
-            else if (fs !== 's3a' && storedPath.toLowerCase().indexOf('s3a') > -1) {
+            else if (fs !== 's3' && storedPath.toLowerCase().indexOf('s3') > -1) {
               self.navigateTo('');
             }
             else {
@@ -158,7 +158,7 @@
             }
           }
           else {
-            self.navigateTo(fs === 's3a' ? 'S3A://' : '');
+            self.navigateTo(fs === 's3' ? 'S3A://' : '');
           }
         });
         $li.appendTo($ul);
@@ -375,7 +375,7 @@
         _parent.options.onError();
       }
       if (e.status === 404 || e.status === 500) {
-        _parent.navigateTo(_parent.options.errorRedirectPath != "" ? _parent.options.errorRedirectPath : (_parent.options.fsSelected === 's3a' ? 'S3A://' : '/?default_to_home'));
+        _parent.navigateTo(_parent.options.errorRedirectPath != "" ? _parent.options.errorRedirectPath : (_parent.options.fsSelected === 's3' ? 'S3A://' : '/?default_to_home'));
       }
       else {
         console.error(e);
@@ -425,7 +425,7 @@
     $.post('/filebrowser/api/get_filesystems', function (data) {
       var initialPath = $.trim(self.options.initialPath);
       if (data && data.status == 0) {
-        if (initialPath && initialPath.toLowerCase().indexOf('s3') > -1 && data.filesystems['s3']) {
+        if (initialPath && initialPath.toLowerCase().indexOf('s3a') > -1 && data.filesystems['s3']) {
           self.options.fsSelected = 's3';
         }
         self.setFileSystems(data.filesystems);