소스 검색

HUE-2356 [sentry] Refresh on tree resets the unexpand the selection

Fixed refresh tree for Hive
Removed blue shield creation and refresh tree on create/delete/update role
Enrico Berti 11 년 전
부모
커밋
528316825f
2개의 변경된 파일10개의 추가작업 그리고 14개의 파일을 삭제
  1. 2 2
      apps/security/src/security/templates/hive.mako
  2. 8 12
      apps/security/static/js/hive.ko.js

+ 2 - 2
apps/security/src/security/templates/hive.mako

@@ -216,7 +216,7 @@ ${ layout.menubar(section='hive') }
                 <h4 style="margin-top: 4px" data-bind="visible: $root.assist.privileges().length > 0 && ! $root.isLoadingPrivileges()">${ _('Privileges') } &nbsp;</h4>
                 <div data-bind="visible: $root.assist.privileges().length == 0 && ! $root.isLoadingPrivileges()">
                   <div class="span10 offset1 center" style="cursor: pointer" data-bind="click: function(){ if ($root.is_sentry_admin) { $root.showCreateRole(true); $('#createRoleModal').modal('show'); } }">
-                    <i class="fa fa-plus-circle waiting"></i>
+                    <i data-bind="visible: $root.is_sentry_admin" class="fa fa-plus-circle waiting"></i>
                     <h1 class="emptyMessage">
                       ${ _('No privileges found for the selected item') }<br/>
                       <a class="pointer" data-bind="visible: $root.is_sentry_admin">${ _('Click here to add a new role') }</a>
@@ -239,7 +239,7 @@ ${ layout.menubar(section='hive') }
         <div class="card-body">
           <h1 class="muted" data-bind="visible: $root.isLoadingRoles()"><i class="fa fa-spinner fa-spin"></i></h1>
           <div class="span10 offset1 center" style="cursor: pointer" data-bind="visible: $root.roles().length == 0 && ! $root.isLoadingRoles(), click: function(){ if ($root.is_sentry_admin) { $root.showCreateRole(true); $('#createRoleModal').modal('show'); } }">
-            <i class="fa fa-plus-circle waiting"></i>
+            <i data-bind="visible: $root.is_sentry_admin" class="fa fa-plus-circle waiting"></i>
             <h1 class="emptyMessage">
               ${ _('There are currently no roles defined') }<br/>
               <a class="pointer" data-bind="visible: $root.is_sentry_admin">${ _('Click here to add one') }</a>

+ 8 - 12
apps/security/static/js/hive.ko.js

@@ -246,7 +246,7 @@ var Role = function (vm, role) {
         var role = new Role(vm, data.role);
         role.showPrivileges(true);
         vm.originalRoles.unshift(role);
-        vm.assist.refreshTree();
+        vm.list_sentry_privileges_by_authorizable();
         $(document).trigger("created.role");
       } else {
         $(document).trigger("error", data.message);
@@ -264,7 +264,7 @@ var Role = function (vm, role) {
       if (data.status == 0) {
         $(document).trigger("info", data.message);
         vm.showCreateRole(false);
-        vm.assist.refreshTree();
+        vm.list_sentry_privileges_by_authorizable();
         $(document).trigger("created.role");
       } else {
         $(document).trigger("error", data.message);
@@ -281,7 +281,7 @@ var Role = function (vm, role) {
     }, function (data) {
       if (data.status == 0) {
         vm.removeRole(role.name());
-        vm.assist.refreshTree();
+        vm.list_sentry_privileges_by_authorizable();
         $(document).trigger("removed.role");
       } else {
         $(document).trigger("error", data.message);
@@ -528,14 +528,19 @@ var Assist = function (vm, initial) {
             if (self.treeAdditionalData[path].loaded) {
               self.fetchHivePath(path, function () {
                 self.updatePathProperty(self.growingTree(), path, "isExpanded", self.treeAdditionalData[path].expanded);
+                var _withTable = false;
                 Object.keys(self.treeAdditionalData).forEach(function (ipath) {
                   if (ipath.split(".").length == 2 && ipath.split(".")[0] == path) {
                     self.fetchHivePath(ipath, function () {
+                      _withTable = true;
                       self.updatePathProperty(self.growingTree(), ipath, "isExpanded", self.treeAdditionalData[ipath].expanded);
                       self.loadData(self.growingTree());
                     });
                   }
                 });
+                if (! _withTable){
+                  self.loadData(self.growingTree());
+                }
               });
             }
           }
@@ -1035,9 +1040,6 @@ var HiveViewModel = function (initial) {
     	if (data.status == 0) {
           var _privileges = [];
           $.each(data.privileges, function (index, item) {
-            if (item.table != ""){
-              self.assist.updatePathProperty(self.assist.growingTree(), item.database + "." + item.table, "withPrivileges", true);
-            }
             if (typeof skipList == "undefined" || (skipList != null && typeof skipList == "Boolean" && !skipList)){
               var _role = null;
               self.assist.roles().forEach(function (role) {
@@ -1100,9 +1102,6 @@ var HiveViewModel = function (initial) {
       'recursive': false
     }, function (data) {
       if (data.status == 0) {
-        ko.utils.arrayForEach(self.assist.checkedItems(), function (item) {
-          self.assist.updatePathProperty(self.assist.growingTree(), item.path, "withPrivileges", false);
-        });
         if (norefresh == undefined) {
           self.list_sentry_privileges_by_authorizable(); // Refresh
           $(document).trigger("deleted.bulk.privileges");
@@ -1125,9 +1124,6 @@ var HiveViewModel = function (initial) {
       'recursive': false
     }, function (data) {
       if (data.status == 0) {
-        ko.utils.arrayForEach(self.assist.checkedItems(), function (item) {
-          self.assist.updatePathProperty(self.assist.growingTree(), item.path, "withPrivileges", true);
-        });
         self.list_sentry_privileges_by_authorizable(); // Refresh
         $(document).trigger("added.bulk.privileges");
       } else {