소스 검색

HUE-3829 [sentry] Preset the privilege to the selected one when creating from browse section

Enrico Berti 9 년 전
부모
커밋
176874c
1개의 변경된 파일24개의 추가작업 그리고 7개의 파일을 삭제
  1. 24 7
      apps/security/src/security/static/security/js/sentry.ko.js

+ 24 - 7
apps/security/src/security/static/security/js/sentry.ko.js

@@ -92,12 +92,25 @@ var Privilege = function (vm, privilege) {
   self.showAdvanced = ko.observable(false);
   self.path = ko.computed({
     read: function () {
-      var path = $.map(self.authorizables(), function(authorizable) {
-        if (authorizable.name_() !== ''){
-          return authorizable.name_();
-        }
-      }).join(".");
-      return path;
+      if (vm.component() == 'solr') {
+        return $.map(self.authorizables(), function (authorizable) {
+          if (authorizable.name_() !== '') {
+            if (authorizable.type() === 'COLLECTION') {
+              return 'collections.' + authorizable.name_();
+            }
+            else {
+              return 'configs.' + authorizable.name_();
+            }
+          }
+        }).join("");
+      }
+      else {
+        return $.map(self.authorizables(), function (authorizable) {
+          if (authorizable.name_() !== '') {
+            return authorizable.name_();
+          }
+        }).join(".");
+      }
     },
     write: function (value) {
       var _parts = value.split(".");
@@ -246,7 +259,11 @@ var Role = function (vm, role) {
   }
 
   self.addPrivilege = function () {
-    self.privileges.push(new Privilege(vm, {'serverName': vm.assist.server(), 'status': 'new', 'editing': true}));
+    var privilege = new Privilege(vm, {'serverName': vm.assist.server(), 'status': 'new', 'editing': true});
+    if (vm.assist.path()) {
+      privilege.path(vm.assist.path());
+    }
+    self.privileges.push(privilege);
   }
 
   self.resetGroups = function () {