Browse Source

HUE-5518 [fb] Bubble up errors from forbidden actions

Romain Rigaux 9 years ago
parent
commit
340cfae

+ 28 - 2
apps/filebrowser/src/filebrowser/templates/listdir_components.mako

@@ -767,6 +767,10 @@ from django.utils.translation import ugettext as _
             keyboard:true,
             show:true
           });
+        },
+        error: function (xhr, textStatus, errorThrown) {
+          $(document).trigger("error", xhr.responseText);
+          resetPrimaryButtonsStatus();
         }
       });
     };
@@ -1317,9 +1321,7 @@ from django.utils.translation import ugettext as _
 
         if (!isMoveOnSelf){
           hiddenFields($("#moveForm"), "src_path", paths);
-
           $("#moveForm").attr("action", "/filebrowser/move?next=${url('filebrowser.views.view', path='')}" + self.currentPath());
-
           $('#moveForm').ajaxForm({
             dataType:  'json',
             success: function() {
@@ -1451,6 +1453,10 @@ from django.utils.translation import ugettext as _
             success: function() {
               $("#changeOwnerModal").modal('hide');
               self.retrieveData();
+            },
+            error: function (xhr, textStatus, errorThrown) {
+              $(document).trigger("error", xhr.responseText);
+              resetPrimaryButtonsStatus();
             }
           });
         }
@@ -1481,6 +1487,10 @@ from django.utils.translation import ugettext as _
             success: function() {
               $("#changePermissionModal").modal('hide');
               self.retrieveData();
+            },
+            error: function (xhr, textStatus, errorThrown) {
+              $(document).trigger("error", xhr.responseText);
+              resetPrimaryButtonsStatus();
             }
           });
 
@@ -1522,6 +1532,10 @@ from django.utils.translation import ugettext as _
           success: function() {
             $("#deleteModal").modal('hide');
             self.retrieveData();
+          },
+          error: function(xhr, textStatus, errorThrown) {
+            $(document).trigger("error", xhr.responseText);
+            resetPrimaryButtonsStatus();
           }
         });
       };
@@ -1598,6 +1612,10 @@ from django.utils.translation import ugettext as _
           success: function() {
             $("#createDirectoryModal").modal('hide');
             self.retrieveData();
+          },
+          error: function (xhr, textStatus, errorThrown) {
+            $(document).trigger("error", xhr.responseText);
+            resetPrimaryButtonsStatus();
           }
         });
         return false;
@@ -1624,6 +1642,10 @@ from django.utils.translation import ugettext as _
           success: function() {
             $("#createFileModal").modal('hide');
             self.retrieveData();
+          },
+          error: function (xhr, textStatus, errorThrown) {
+            $(document).trigger("error", xhr.responseText);
+            resetPrimaryButtonsStatus();
           }
         });
         return false;
@@ -1650,6 +1672,10 @@ from django.utils.translation import ugettext as _
           success: function() {
             $("#restoreTrashModal").modal('hide');
             self.retrieveData();
+          },
+          error: function(xhr, textStatus, errorThrown) {
+            $(document).trigger("error", xhr.responseText);
+            resetPrimaryButtonsStatus();
           }
         });
       };

+ 8 - 1
desktop/core/src/desktop/templates/common_footer.mako

@@ -54,7 +54,14 @@ ${ smart_unicode(login_modal(request).content) | n,unicode }
     $(document).ajaxComplete(function (event, xhr, settings) {
       var whiteListURLs = [
         'filebrowser/copy?next=',
-        'filebrowser/move?next='
+        'filebrowser/move?next=',
+        'filebrowser/touch?next=',
+        'filebrowser/mkdir?next=',
+        'filebrowser/rmtree',
+        'filebrowser/chown?next=',
+        'filebrowser/chmod?next=',
+        'filebrowser/rename?next=',
+        'filebrowser/trash',
       ];
       var whiteListed = false;
       whiteListURLs.forEach(function(url){