You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by me...@apache.org on 2020/04/14 11:59:04 UTC

[ranger] 03/03: RANGER-2765 : Correct permissions are not getting loaded for entity-label in Atlas service

This is an automated email from the ASF dual-hosted git repository.

mehul pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ranger.git

commit 7dac4e178b94c949da7c727fb2e749b50d933bb5
Author: Nitin Galave <ni...@apache.org>
AuthorDate: Thu Apr 2 14:34:09 2020 +0530

    RANGER-2765 : Correct permissions are not getting loaded for entity-label in Atlas service
    
    Signed-off-by: Mehul Parikh <me...@apache.org>
---
 .../scripts/views/policies/PermissionList.js       | 41 ++++++++++++++--------
 .../scripts/views/policies/RangerPolicyForm.js     |  6 ++--
 2 files changed, 30 insertions(+), 17 deletions(-)

diff --git a/security-admin/src/main/webapp/scripts/views/policies/PermissionList.js b/security-admin/src/main/webapp/scripts/views/policies/PermissionList.js
index 4d9cd7d..cf5aff9 100644
--- a/security-admin/src/main/webapp/scripts/views/policies/PermissionList.js
+++ b/security-admin/src/main/webapp/scripts/views/policies/PermissionList.js
@@ -413,23 +413,36 @@ define(function(require) {
 	        return accessTypeByResource;
 		},
 		//if parent isValidLeaf is false than check child isvalidLeaf
-		childRscDef:function(resChild , rscName){
-			var childResourcs = _.filter(resChild, function(m){ 
+		childRscDef:function(resChild , rscName, rscDef){
+			var childResourcs = _.filter(resChild, function(m){
 				return m.parent == rscName 
 			});
-			var rscDef , someVal;
-			someVal = _.some(childResourcs,function(obj){
-//				help of this we separate specified(selected) child resource from all childResourcs 
-				var $html = $('[data-name="field-'+obj.name+'"]');
-				if($html.length > 0){
-					rscName = obj.name;
-					rscDef = obj;
-					return true;
+			if(!_.isEmpty(childResourcs)){
+				var someVal;
+				someVal = _.some(childResourcs,function(obj){
+				//help of this we separate specified(selected) child resource from all childResourcs
+					var $html = $('[data-name="field-'+obj.name+'"]');
+					if($html.length > 0){
+						rscName = obj.name;
+						rscDef = obj;
+						return true;
+					}
+				});
+				if(!someVal){
+					rscDef = childResourcs[0];
+					rscName = childResourcs[0].name;
+				}
+			}
+			// resource-node have isValidLeaf is true and resource have child node then render that child node permission
+			if(rscDef && rscDef.isValidLeaf && !this.model.has('editMode')) {
+				var hasChiled = _.filter(resChild, function(m){
+					return m.parent == rscName
+				});
+				if(!_.isEmpty(hasChiled)) {
+					rscDef = hasChiled[0];
+					rscName = hasChiled[0].name;
+					this.childRscDef(resChild , rscName, rscDef);
 				}
-			});
-			if(!someVal){
-				rscDef = childResourcs[0];
-				rscName = childResourcs[0].name;
 			}
 			return  ((rscDef.isValidLeaf) ? _.findWhere(resChild, {'name':rscName }) : this.childRscDef(resChild , rscName))
 		},
diff --git a/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyForm.js b/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyForm.js
index e2bd6ed..f0b687f 100644
--- a/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyForm.js
+++ b/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyForm.js
@@ -487,9 +487,9 @@ define(function(require){
 	                	var resorceFieldName = _.pick(this.schema ,this.selectedFields[key]);
 	                	if(resorceFieldName[this.selectedFields[key]].sameLevelOpts && _.contains(resorceFieldName[this.selectedFields[key]].sameLevelOpts , 'none') 
 	                			&& formDiv.find(selector).find('select').val() != 'none' && onChangeOfSameLevelType){
-//	                		change trigger and set value to none
-	                		$(rsrc).find('select').val("none").trigger('change',"onChangeResources");
-	                	}
+						//change trigger and set value to selected node
+							$(rsrc).find('select').val($(rsrc).find('select option:nth-child(1)').text()).trigger('change',"onChangeResources");
+		                }
 	                }else{
 	                    if($(rsrc).find('select').val() == 'none'){
 	                    		$(rsrc).find('input[data-js="resource"]').select2('disable');