Skip to content

Commit

Permalink
Fixes duplicate isolation policy addition (#256)
Browse files Browse the repository at this point in the history
  • Loading branch information
vishal-j authored Jan 13, 2017
1 parent 6c54e61 commit 152f370
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 125 deletions.
13 changes: 4 additions & 9 deletions app/applicationgroups/isolationpolicydirective.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export class IsolationPolicySelectionComponent implements OnChanges {

incomingRules:any[] = [];
outgoingRules:any[] = [];
selectedPolicies:any[] = []; // To Store policies selected by user to display
isolationPolicies:any[] = []; // To Get all isolation policies of tenant
isolationPolicySearchText:string = '';

Expand Down Expand Up @@ -77,9 +76,11 @@ export class IsolationPolicySelectionComponent implements OnChanges {
var component = this;
var currentPolicyName = policyName;

if (currentPolicyName !== undefined && _.includes(component.selectedPolicies, currentPolicyName) == false) {
if (currentPolicyName !== undefined && _.includes(component.applicationgroup.policies, currentPolicyName) == false) {
//To display selected policies
component.selectedPolicies.push(currentPolicyName);
//To be added to application group and saved to the server
component.applicationgroup.policies
.push(currentPolicyName);

//To display rules of selected policies
component.rulesModel.getIncomingRules(currentPolicyName, component.applicationgroup.tenantName)
Expand All @@ -91,19 +92,13 @@ export class IsolationPolicySelectionComponent implements OnChanges {
Array.prototype.push.apply(component.outgoingRules, rules);
});

//To be added to application group and saved to the server
component.applicationgroup.policies
.push(currentPolicyName);
}
};

/**
* Remove policy from application group
*/
removeIsolationPolicy(policyName) {
_.remove(this.selectedPolicies, function (policy) {
return policy === policyName;
});
_.remove(this.applicationgroup.policies, function (policy) {
return policy === policyName;
});
Expand Down
16 changes: 6 additions & 10 deletions app/main.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -2509,7 +2509,8 @@ webpackJsonp([2],[
if (value == null) {
return value === undefined ? undefinedTag : nullTag;
}
return (symToStringTag && symToStringTag in Object(value))
value = Object(value);
return (symToStringTag && symToStringTag in value)
? getRawTag(value)
: objectToString(value);
}
Expand Down Expand Up @@ -7953,7 +7954,6 @@ webpackJsonp([2],[
this.rulesModel = rulesModel;
this.incomingRules = [];
this.outgoingRules = [];
this.selectedPolicies = []; // To Store policies selected by user to display
this.isolationPolicies = []; // To Get all isolation policies of tenant
this.isolationPolicySearchText = '';
}
Expand Down Expand Up @@ -8004,9 +8004,11 @@ webpackJsonp([2],[
IsolationPolicySelectionComponent.prototype.addIsolationPolicy = function (policyName) {
var component = this;
var currentPolicyName = policyName;
if (currentPolicyName !== undefined && _.includes(component.selectedPolicies, currentPolicyName) == false) {
if (currentPolicyName !== undefined && _.includes(component.applicationgroup.policies, currentPolicyName) == false) {
//To display selected policies
component.selectedPolicies.push(currentPolicyName);
//To be added to application group and saved to the server
component.applicationgroup.policies
.push(currentPolicyName);
//To display rules of selected policies
component.rulesModel.getIncomingRules(currentPolicyName, component.applicationgroup.tenantName)
.then(function (rules) {
Expand All @@ -8016,19 +8018,13 @@ webpackJsonp([2],[
.then(function (rules) {
Array.prototype.push.apply(component.outgoingRules, rules);
});
//To be added to application group and saved to the server
component.applicationgroup.policies
.push(currentPolicyName);
}
};
;
/**
* Remove policy from application group
*/
IsolationPolicySelectionComponent.prototype.removeIsolationPolicy = function (policyName) {
_.remove(this.selectedPolicies, function (policy) {
return policy === policyName;
});
_.remove(this.applicationgroup.policies, function (policy) {
return policy === policyName;
});
Expand Down
Loading

0 comments on commit 152f370

Please sign in to comment.