Parcourir la source

HUE-4393 [fb] S3 bucket should not have any file upload or file creation action

Enrico Berti il y a 9 ans
Parent
commit
c9a137887c

+ 4 - 5
apps/filebrowser/src/filebrowser/templates/listdir.mako

@@ -46,8 +46,7 @@ ${ fb_components.menubar() }
         <div class="btn-toolbar" style="display: inline; vertical-align: middle">
           <div id="ch-dropdown" class="btn-group" style="vertical-align: middle">
             <button href="#" class="btn dropdown-toggle" title="${_('Actions')}" data-toggle="dropdown"
-            data-bind="visible:
-             !inTrash(), enable: selectedFiles().length > 0">
+            data-bind="visible: !inTrash(), enable: selectedFiles().length > 0 && (!isS3() || (isS3() && !isS3Root()))">
               <i class="fa fa-cog"></i> ${_('Actions')}
               <span class="caret" style="line-height: 15px"></span>
             </button>
@@ -91,7 +90,7 @@ ${ fb_components.menubar() }
           <button class="btn fileToolbarBtn" title="${_('Restore from trash')}" data-bind="visible: inRestorableTrash(), click: restoreTrashSelected, enable: selectedFiles().length > 0 && isCurrentDirSelected().length == 0"><i class="fa fa-cloud-upload"></i> ${_('Restore')}</button>
           <!-- ko ifnot: inTrash -->
           <!-- ko if: $root.isS3 -->
-          <button class="btn fileToolbarBtn delete-link" title="${_('Delete forever')}" data-bind="enable: selectedFiles().length > 0, click: deleteSelected"><i class="fa fa-bolt"></i> ${_('Delete forever')}</button>
+          <button class="btn fileToolbarBtn delete-link" title="${_('Delete forever')}" data-bind="enable: selectedFiles().length > 0 && (!isS3() || (isS3() && !isS3Root())), click: deleteSelected"><i class="fa fa-bolt"></i> ${_('Delete forever')}</button>
           <!-- /ko -->
           <!-- ko ifnot: $root.isS3 -->
           <div id="delete-dropdown" class="btn-group" style="vertical-align: middle">
@@ -119,7 +118,7 @@ ${ fb_components.menubar() }
         <div class="btn-toolbar" style="display: inline; vertical-align: middle">
           % if show_upload_button:
           <div id="upload-dropdown" class="btn-group" style="vertical-align: middle">
-            <a href="#" class="btn upload-link dropdown-toggle" title="${_('Upload')}" data-toggle="dropdown" data-bind="visible: !inTrash()">
+            <a href="#" class="btn upload-link dropdown-toggle" title="${_('Upload')}" data-toggle="dropdown" data-bind="visible: !inTrash(), css: {'disabled': isS3() && isS3Root()}">
               <i class="fa fa-arrow-circle-o-up"></i> ${_('Upload')}
               <span class="caret"></span>
             </a>
@@ -130,7 +129,7 @@ ${ fb_components.menubar() }
           </div>
           % endif
           <div class="btn-group" style="vertical-align: middle">
-            <a href="#" data-toggle="dropdown" class="btn dropdown-toggle" data-bind="visible: !inTrash()">
+            <a href="#" data-toggle="dropdown" class="btn dropdown-toggle" data-bind="visible: !inTrash(), css: {'disabled': isS3() && isS3Root()}">
               <i class="fa fa-plus-circle"></i> ${_('New')}
               <span class="caret"></span>
             </a>

+ 18 - 12
apps/filebrowser/src/filebrowser/templates/listdir_components.mako

@@ -954,7 +954,11 @@ from django.utils.translation import ugettext as _
       });
 
       self.isS3 = ko.pureComputed(function () {
-        return self.currentPath().toLowerCase().indexOf('s3://') == 0;
+        return self.currentPath().toLowerCase().indexOf('s3://') === 0;
+      });
+
+      self.isS3Root = ko.pureComputed(function () {
+        return self.isS3() && self.currentPath().toLowerCase() === 's3://';
       });
 
       self.inTrash = ko.computed(function() {
@@ -1628,7 +1632,7 @@ from django.utils.translation import ugettext as _
         $('body').on('dragenter', function (e) {
           e.preventDefault();
 
-          if (_isExternalFile && !($("#uploadFileModal").is(":visible")) && !($("#uploadArchiveModal").is(":visible"))) {
+          if (_isExternalFile && !($("#uploadFileModal").is(":visible")) && !($("#uploadArchiveModal").is(":visible")) && (!viewModel.isS3() || (viewModel.isS3() && !viewModel.isS3Root()))) {
             showHoverMsg("${_('Drop files here to upload')}");
           }
         });
@@ -1658,7 +1662,7 @@ from django.utils.translation import ugettext as _
           try {
             _dropzone.destroy();
           }
-          catch (e) {
+          catch (exc) {
           }
           var options = {
             url: '/filebrowser/upload/file?dest=' + ops.path,
@@ -1722,17 +1726,19 @@ from django.utils.translation import ugettext as _
               }
             }
           };
-          _dropzone = new Dropzone(document.body, options);
+          if (ops.path.toLowerCase() !== 's3://') {
+            _dropzone = new Dropzone(document.body, options);
 
-          _dropzone.on('queuecomplete', function () {
+            _dropzone.on('queuecomplete', function () {
               setTimeout(function () {
-                $('#progressStatus').addClass('hide');
-                $('#progressStatusBar').addClass('hide');
-                $('#progressStatusBar div').css("width", "0");
-                viewModel.retrieveData();
-                },
-              2500);
-          });
+                    $('#progressStatus').addClass('hide');
+                    $('#progressStatusBar').addClass('hide');
+                    $('#progressStatusBar div').css("width", "0");
+                    viewModel.retrieveData();
+                  },
+                  2500);
+            });
+          }
         });
       }