You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by ga...@apache.org on 2016/03/31 08:24:29 UTC

incubator-ranger git commit: RANGER-876 : Policy UI updates to make deny & exception policy items optional

Repository: incubator-ranger
Updated Branches:
  refs/heads/master 9264dd006 -> a50fcf116


RANGER-876 : Policy UI updates to make deny & exception policy items optional

Signed-off-by: Gautam Borad <ga...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/incubator-ranger/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ranger/commit/a50fcf11
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ranger/tree/a50fcf11
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ranger/diff/a50fcf11

Branch: refs/heads/master
Commit: a50fcf1167cf0ef12da908c10c987b75e823ece2
Parents: 9264dd0
Author: Mehul Parikh <me...@freestoneinfotech.com>
Authored: Tue Mar 22 11:50:59 2016 +0530
Committer: Gautam Borad <ga...@apache.org>
Committed: Thu Mar 31 11:54:09 2016 +0530

----------------------------------------------------------------------
 .../scripts/views/policies/RangerPolicyForm.js  | 100 ++++++++-----
 .../policies/RangerPolicyForm_tmpl.html         | 147 ++++++++++---------
 2 files changed, 135 insertions(+), 112 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/a50fcf11/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyForm.js
----------------------------------------------------------------------
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 f32ffbc..8518765 100644
--- a/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyForm.js
+++ b/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyForm.js
@@ -81,7 +81,10 @@ define(function(require){
 			});
 			this.on('policyForm:parentChildHideShow',this.renderParentChildHideShow);
 		},
-
+		ui : {
+			'denyConditionItems' : '[data-js="denyConditionItems"]',
+			'allowExcludePerm' : '[data-js="allowExcludePerm"]',
+		},
 		/** fields for the form
 		*/
 		fields: ['name', 'description', 'isEnabled', 'isAuditEnabled'],
@@ -200,8 +203,23 @@ define(function(require){
 		},
 		/** all custom field rendering */
 		renderCustomFields: function(){
-			var that = this;
-			var accessType = this.rangerServiceDefModel.get('accessTypes').filter(function(val) { return val !== null; });
+			var that = this,
+				accessType = this.rangerServiceDefModel.get('accessTypes').filter(function(val) { return val !== null; }),
+				serviceDefOptions = this.rangerServiceDefModel.get('options'),
+				enableDenyAndExceptionsInPolicies = false;
+			//By default hide the PolicyItems for all component except tag component
+			if((!_.isUndefined(serviceDefOptions) && !_.isUndefined(serviceDefOptions.enableDenyAndExceptionsInPolicies))){
+				enableDenyAndExceptionsInPolicies = $.parseJSON(serviceDefOptions.enableDenyAndExceptionsInPolicies);
+			} else {
+				if(this.rangerServiceDefModel.get('name') == XAEnums.ServiceType.SERVICE_TAG.label){
+					enableDenyAndExceptionsInPolicies = true;
+				}		
+			}
+			if( !enableDenyAndExceptionsInPolicies ){
+				this.$el.find(this.ui.allowExcludePerm).hide();
+				this.$el.find(this.ui.denyConditionItems).remove();
+			} 
+	
 			this.userList = new VXUserList();
 			var params = {sortBy : 'name', isVisible : XAEnums.VisibilityStatus.STATUS_VISIBLE.value};
 			this.userList.setPageSize(100,{fetch:false});
@@ -216,42 +234,46 @@ define(function(require){
 					cache :true,
 					data : params
 				}).done(function(){
-					that.$('[data-customfields="groupPerms"]').html(new PermissionList({
-						collection : that.formInputList,
-						groupList  : that.groupList,
-						userList   : that.userList,
-						model 	   : that.model,
-						accessTypes: accessType,
-						headerTitle: "",
-						rangerServiceDefModel : that.rangerServiceDefModel
-						}).render().el);
-						that.$('[data-customfields="groupPermsAllowExclude"]').html(new PermissionList({
-						collection : that.formInputAllowExceptionList,
-						groupList  : that.groupList,
-						userList   : that.userList,
-						model 	   : that.model,
-						accessTypes: accessType,
-						headerTitle: "",
-						rangerServiceDefModel : that.rangerServiceDefModel
-						}).render().el);
-						that.$('[data-customfields="groupPermsDeny"]').html(new PermissionList({
-						collection : that.formInputDenyList,
-						groupList  : that.groupList,
-						userList   : that.userList,
-						model 	   : that.model,
-						accessTypes: accessType,
-						headerTitle: "Deny",
-						rangerServiceDefModel : that.rangerServiceDefModel
-						}).render().el);
-						that.$('[data-customfields="groupPermsDenyExclude"]').html(new PermissionList({
-						collection : that.formInputDenyExceptionList,
-						groupList  : that.groupList,
-						userList   : that.userList,
-						model 	   : that.model,
-						accessTypes: accessType,
-						headerTitle: "Deny",
-						rangerServiceDefModel : that.rangerServiceDefModel
-					}).render().el);
+						that.$('[data-customfields="groupPerms"]').html(new PermissionList({
+							collection : that.formInputList,
+							groupList  : that.groupList,
+							userList   : that.userList,
+							model 	   : that.model,
+							accessTypes: accessType,
+							headerTitle: "",
+							rangerServiceDefModel : that.rangerServiceDefModel
+							}).render().el);
+						
+						if( enableDenyAndExceptionsInPolicies ){
+							that.$('[data-customfields="groupPermsAllowExclude"]').html(new PermissionList({
+								collection : that.formInputAllowExceptionList,
+								groupList  : that.groupList,
+								userList   : that.userList,
+								model 	   : that.model,
+								accessTypes: accessType,
+								headerTitle: "",
+								rangerServiceDefModel : that.rangerServiceDefModel
+								}).render().el);
+						
+							that.$('[data-customfields="groupPermsDeny"]').html(new PermissionList({
+								collection : that.formInputDenyList,
+								groupList  : that.groupList,
+								userList   : that.userList,
+								model 	   : that.model,
+								accessTypes: accessType,
+								headerTitle: "Deny",
+								rangerServiceDefModel : that.rangerServiceDefModel
+							}).render().el);
+							that.$('[data-customfields="groupPermsDenyExclude"]').html(new PermissionList({
+								collection : that.formInputDenyExceptionList,
+								groupList  : that.groupList,
+								userList   : that.userList,
+								model 	   : that.model,
+								accessTypes: accessType,
+								headerTitle: "Deny",
+								rangerServiceDefModel : that.rangerServiceDefModel
+							}).render().el);
+					}
 			});
 
 		},

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/a50fcf11/security-admin/src/main/webapp/templates/policies/RangerPolicyForm_tmpl.html
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/templates/policies/RangerPolicyForm_tmpl.html b/security-admin/src/main/webapp/templates/policies/RangerPolicyForm_tmpl.html
index 9b56bca..9e31b0d 100644
--- a/security-admin/src/main/webapp/templates/policies/RangerPolicyForm_tmpl.html
+++ b/security-admin/src/main/webapp/templates/policies/RangerPolicyForm_tmpl.html
@@ -1,92 +1,93 @@
-{{!-- 
-  Licensed to the Apache Software Foundation (ASF) under one or more
-  contributor license agreements.  See the NOTICE file distributed with
-  this work for additional information regarding copyright ownership.
-  The ASF licenses this file to You under the Apache License, Version 2.0
-  (the "License"); you may not use this file except in compliance with
-  the License.  You may obtain a copy of the License at
+{{!-- Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership. The
+ASF licenses this file to You under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance with the
+License. You may obtain a copy of the License at
 
-      http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing, software
-  distributed under the License is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
---}}
+http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable
+law or agreed to in writing, software distributed under the License is
+distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the specific
+language governing permissions and limitations under the License. --}}
 <form class="form-horizontal">
 	<fieldset>
-		<p class="formHeader">
-			Policy Details : 
-		</p>
+		<p class="formHeader">Policy Details :</p>
 		{{#if id}}
-			<div class="control-group field-id">
-				<label class="control-label" for="c1836_id">Policy ID</label>
-				<div class="controls"><label class="label label-ranger" style="margin-top: 5px; margin-left: 9px;">{{id}}</label></div>
+		<div class="control-group field-id">
+			<label class="control-label" for="c1836_id">Policy ID</label>
+			<div class="controls">
+				<label class="label label-ranger"
+					style="margin-top: 5px; margin-left: 9px;">{{id}}</label>
 			</div>
-		{{/if}}
-		<b data-fieldsets class="policy-form"></b>
+		</div>
+		{{/if}} <b data-fieldsets class="policy-form"></b>
 	</fieldset>
-	 <fieldset>
-		<p class="wrap-header bold formHeader">
- 			Allow Conditions :	
- 			<span class="label label-yellow pull-right" ></span>
- 		</p> &nbsp;
- 		<div class=" wrap position-relative">
+	<fieldset>
+			<p class="wrap-header bold formHeader">
+				Allow Conditions : <span class="label label-yellow pull-right"></span>
+			</p>
+			&nbsp;
+			<div class=" wrap position-relative">
 
-		<div class="" data-customfields="groupPerms">
-			<div class="control-group">
-				<label class="control-label">{{tt 'lbl.permissions'}}</label>
-				<div class="controls">
-					<img src="images/loading.gif" style=" margin-left: 4%; margin-top: 1%;" />
-				</div>
-			</div>		
-		</div>
-		<div class="form-indent-right">
-			<p class="wrap-header reportSearchHeader">
-				Exclude from Allow Conditions :	
-			</p> &nbsp;
-			<div class="wrap position-relative" >
-		
-				<div class="" data-customfields="groupPermsAllowExclude">
-					<div class="control-group" style="margin-left: -100px;">
-						<label class="control-label">Exclude :</label>
+				<div class="" data-customfields="groupPerms">
+					<div class="control-group">
+						<label class="control-label">{{tt 'lbl.permissions'}}</label>
 						<div class="controls">
-							<img src="images/loading.gif" style=" margin-left: 4%; margin-top: 1%;" />
+							<img src="images/loading.gif"
+								style="margin-left: 4%; margin-top: 1%;" />
 						</div>
-					</div>		
+					</div>
 				</div>
-			</div>
-		</div>
-		</div>
+				<div class="form-indent-right" data-js="allowExcludePerm">
+					<p class="wrap-header reportSearchHeader ">Exclude from Allow
+						Conditions :</p>
+					&nbsp;
+					<div class="wrap position-relative">
 
-		<p class="wrap-header bold formHeader">
-			Deny Conditions :	
-		</p> &nbsp;
-		<div class="wrap position-relative" >
-			<div class="" data-customfields="groupPermsDeny">
-				<div class="control-group">
-					<label class="control-label">{{tt 'lbl.permissions'}}</label>
-					<div class="controls">
-						<img src="images/loading.gif" style=" margin-left: 4%; margin-top: 1%;" />
+						<div class="" data-customfields="groupPermsAllowExclude">
+							<div class="control-group" style="margin-left: -100px;">
+								<label class="control-label">Exclude :</label>
+								<div class="controls">
+									<img src="images/loading.gif"
+										style="margin-left: 4%; margin-top: 1%;" />
+								</div>
+							</div>
+						</div>
 					</div>
-				</div>		
+				</div>
 			</div>
-		<div class="form-indent-right">
-			<p class="wrap-header reportSearchHeader">
-				Exclude from Deny Conditions :	
-			</p> &nbsp;
-			<div class="wrap position-relative" >
-				<div class="" data-customfields="groupPermsDenyExclude">
-					<div class="control-group">
-						<label class="control-label">Exclude :</label>
-						<div class="controls">
-							<img src="images/loading.gif" style=" margin-left: 4%; margin-top: 1%;" />
+			<div data-js="denyConditionItems">
+				<p class="wrap-header bold formHeader">Deny Conditions :</p>
+				&nbsp;
+				<div class="wrap position-relative">
+					<div class="" data-customfields="groupPermsDeny">
+						<div class="control-group">
+							<label class="control-label">{{tt 'lbl.permissions'}}</label>
+							<div class="controls">
+								<img src="images/loading.gif"
+									style="margin-left: 4%; margin-top: 1%;" />
+							</div>
 						</div>
-					</div>		
+					</div>
+					<div class="form-indent-right">
+						<p class="wrap-header reportSearchHeader">Exclude from Deny
+							Conditions :</p>
+						&nbsp;
+						<div class="wrap position-relative">
+							<div class="" data-customfields="groupPermsDenyExclude">
+								<div class="control-group">
+									<label class="control-label">Exclude :</label>
+									<div class="controls">
+										<img src="images/loading.gif"
+											style="margin-left: 4%; margin-top: 1%;" />
+									</div>
+								</div>
+							</div>
+						</div>
+					</div>
 				</div>
 			</div>
-			</div>
 	</fieldset>
 </form>