Przeglądaj źródła

[security] Better bulk modal and delete all acls operations

Hide save button when no groups or users are selected in a new ACL
Romain Rigaux 11 lat temu
rodzic
commit
e3f510e

+ 7 - 4
apps/security/src/security/api/hdfs.py

@@ -87,10 +87,13 @@ def update_acls(request):
   original_acls = json.loads(request.POST.get('originalAcls'))
 
   try:
-    renamed_acls = set([_get_acl_name(acl) for acl in original_acls]) - set([_get_acl_name(acl) for acl in acls]) # We need to remove ACLs that have been renamed
-    _remove_acl_names(request.fs, path, list(renamed_acls))
-    _remove_acl_entries(request.fs, path, [acl for acl in acls if acl['status'] == 'deleted'])
-    _modify_acl_entries(request.fs, path, [acl for acl in acls if acl['status'] in ('new', 'modified')])
+    if all([acl['status'] == 'deleted' for acl in acls]):
+      request.fs.remove_acl(path)
+    else:
+      renamed_acls = set([_get_acl_name(acl) for acl in original_acls]) - set([_get_acl_name(acl) for acl in acls]) # We need to remove ACLs that have been renamed
+      _remove_acl_names(request.fs, path, list(renamed_acls))
+      _remove_acl_entries(request.fs, path, [acl for acl in acls if acl['status'] == 'deleted'])
+      _modify_acl_entries(request.fs, path, [acl for acl in acls if acl['status'] in ('new', 'modified')])
   except Exception, e:
     raise PopupException(unicode(str(e.message), "utf8"))
 

+ 7 - 8
apps/security/src/security/templates/hdfs.mako

@@ -114,7 +114,6 @@ ${ layout.menubar(section='hdfs') }
                     </div>
                     <select class="user-list" data-bind="options: $root.selectableHadoopUsers, select2: { placeholder: '${ _("Select a user") }', update: $root.doAs, type: 'user'}" style="width: 120px"></select>
                     % endif
-                    <i class="fa fa-group" title="List of groups in popover for this user?"></i>
                   </div>
                   <div>
                     <a class="pointer" data-bind="click: $root.assist.collapseOthers" rel="tooltip" data-placement="right" title="${_('Close other nodes')}">
@@ -201,17 +200,11 @@ ${ layout.menubar(section='hdfs') }
 <div id="bulkActionsModal" class="modal hide fade in" role="dialog">
   <div class="modal-header">
     <a href="#" class="close" data-dismiss="modal">&times;</a>
-    <h3>${ _('Apply some bulk operations') }</h3>
+    <h3>${ _('Select a bulk operation') }</h3>
   </div>
   <div class="modal-body" style="overflow-x: hidden">
 
     <div class="row-fluid">
-      <div class="span4">
-        <h4>${ _('Path selection') }</h4>
-        <ul class="unstyled modal-panel" data-bind="foreach: $root.assist.checkedItems">
-          <li><a class="force-word-break" data-bind="attr: { href: '/filebrowser/view' + path }, text: path" target="_blank" title="${ _('Open in File Browser') }" rel="tooltip"></a></li>
-        </ul>
-      </div>
       <div class="span8">
         <div class="row-fluid">
           <div class="span4 center">
@@ -234,6 +227,12 @@ ${ layout.menubar(section='hdfs') }
           </div>
         </div>
       </div>
+      <div class="span4">
+        <h4>${ _('to apply on selection') }</h4>
+        <ul class="unstyled modal-panel" data-bind="foreach: $root.assist.checkedItems">
+          <li><a class="force-word-break" data-bind="attr: { href: '/filebrowser/view' + path }, text: path" target="_blank" title="${ _('Open in File Browser') }" rel="tooltip"></a></li>
+        </ul>
+      </div>
     </div>
 
     <div class="row-fluid" data-bind="visible: $root.assist.bulkAction() != '' && $root.assist.bulkAction() != 'delete'">

+ 14 - 13
apps/security/static/js/hdfs.ko.js

@@ -134,7 +134,8 @@ var Assist = function (vm, assist) {
   });
   self.changedRegularAcls = ko.computed(function () {
     return $.grep(self.regularAcls(), function (acl) {
-      return ['new', 'deleted', 'modified'].indexOf(acl.status()) != -1;
+      return ['new', 'deleted', 'modified'].indexOf(acl.status()) != -1 &&
+        ! (['new', 'modified'].indexOf(acl.status()) != -1 && acl.name() == ''); // Empty groups/users
     });
   });
   self.changedDefaultAcls = ko.computed(function () {
@@ -429,10 +430,10 @@ var Assist = function (vm, assist) {
             if (typeof optionalPath == "undefined") {
               self.getAcls();
             }
-          }
-        }).fail(function (xhr, textStatus, errorThrown) {
-          $(document).trigger("error", xhr.responseText);
-        });
+        }
+     }).fail(function (xhr, textStatus, errorThrown) {
+        $(document).trigger("error", xhr.responseText);
+     });
   };
 
   self.loadMore = function (what) {
@@ -495,8 +496,8 @@ var Assist = function (vm, assist) {
           $(document).trigger("updated.acls");
         }
     ).fail(function (xhr, textStatus, errorThrown) {
-          $(document).trigger("error", JSON.parse(xhr.responseText).message);
-        });
+       $(document).trigger("error", JSON.parse(xhr.responseText).message);
+    });
   }
 
   self.bulkAction = ko.observable("");
@@ -534,8 +535,8 @@ var Assist = function (vm, assist) {
           $(document).trigger("deleted.bulk.acls");
         }
     ).fail(function (xhr, textStatus, errorThrown) {
-          $(document).trigger("error", JSON.parse(xhr.responseText).message);
-        });
+      $(document).trigger("error", JSON.parse(xhr.responseText).message);
+    });
   }
 
   self.bulkAddAcls = function () {
@@ -554,8 +555,8 @@ var Assist = function (vm, assist) {
           $(document).trigger("added.bulk.acls");
         }
     ).fail(function (xhr, textStatus, errorThrown) {
-          $(document).trigger("error", JSON.parse(xhr.responseText).message);
-        });
+      $(document).trigger("error", JSON.parse(xhr.responseText).message);
+    });
   }
 
   self.bulkSyncAcls = function () {
@@ -574,8 +575,8 @@ var Assist = function (vm, assist) {
           $(document).trigger("syncd.bulk.acls");
         }
     ).fail(function (xhr, textStatus, errorThrown) {
-          $(document).trigger("error", JSON.parse(xhr.responseText).message);
-        });
+       $(document).trigger("error", JSON.parse(xhr.responseText).message);
+    });
   }
 }