Skip to content

Commit

Permalink
Merge pull request #1128 from eclipse-tractusx/feature/#832-enable-po…
Browse files Browse the repository at this point in the history
…licy-management

chore(policy): 832 layout feedback
  • Loading branch information
ds-mwesener authored Jun 28, 2024
2 parents 2a504a9 + cabd707 commit 4df9128
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export class PoliciesComponent {
ctrlKeyState: boolean = false;
deselectPartTrigger$ = new Subject<Policy[]>();
selectedPoliciesInfoLabel: string = 'pageAdmin.policyManagement.selectedPolicies';
isDefaultSelected: boolean;

constructor(public readonly policyFacade: PoliciesFacade, private readonly router: Router, private readonly toastService: ToastService, public dialog: MatDialog, private readonly roleService: RoleService) {
window.addEventListener('keydown', (event) => {
Expand Down Expand Up @@ -85,6 +86,8 @@ export class PoliciesComponent {
multiSelection(selectedPolicies: Policy[]) {
this.selectedPoliciesInfoLabel = selectedPolicies.length === 1 ? 'pageAdmin.policyManagement.selectedPolicy' : 'pageAdmin.policyManagement.selectedPolicies';
this.selectedPolicies = selectedPolicies;
this.isDefaultSelected = this.selectedPolicies.filter(policy => policy?.policyId === 'default-policy').length > 0;
console.log(this.isDefaultSelected);
}

openDetailedView(selectedPolicy: Record<string, unknown>) {
Expand All @@ -105,21 +108,22 @@ export class PoliciesComponent {

dialogRef.afterClosed().subscribe(confirmation => {
if (confirmation) {
this.deletePolicies();
this.deletePolicies(this.isDefaultSelected);
this.deselectPartTrigger$.next(this.selectedPolicies);
}
});
}


deletePolicies() {
deletePolicies(isDefaultSelected?: boolean) {
this.policyFacade.deletePolicies(this.selectedPolicies).subscribe({
next: value => {
this.toastService.success('pageAdmin.policyManagement.deleteSuccess');
this.policyFacade.setPolicies();
},
error: err => {
this.toastService.error('pageAdmin.policyManagement.deleteError');
const errorMessage = isDefaultSelected === true ? 'pageAdmin.policyManagement.deleteErrorDefault' : 'pageAdmin.policyManagement.deleteError';
this.toastService.error(errorMessage);
},
});
}
Expand Down
1 change: 1 addition & 0 deletions frontend/src/assets/locales/de/page.admin.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"policyManagement" : "Richtlinienverwaltung",
"deleteSuccess" : "Selektierte Richtlinien wurden erfolgreich gelöscht.",
"deleteError" : "Fehler bei der Löschung der selektierten Richtlinien.",
"deleteErrorDefault" : "Fehler: Das Löschen der Standardrichtlinie namens 'default-policy' ist nicht erlaubt.",
"confirm" : "Bestätigen",
"policyDeletion" : "Löschen bestätigen",
"deletionText" : "Möchten sie die selektierten Richtlinien löschen?",
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/assets/locales/en/page.admin.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"policyManagement" : "Policy management",
"deleteSuccess" : "Successfully deleted the selected policies.",
"deleteError" : "Error while deleting the selected policies.",
"deleteErrorDefault" : "Error: Deleting the default policy is not permitted.",
"confirm" : "Confirm",
"policyDeletion" : "Confirm deletion",
"deletionText" : "Do you want to delete the selected policies?",
Expand Down Expand Up @@ -95,7 +96,9 @@
"bpnsHint" : "Please provide a list of BPNs separated by comma",
"bpnHint" : "Please provide a BPN",
"savePolicy" : "Save policy",
"addConstraint" : "Add constraint"
"addConstraint" : "Add constraint",
"selectedPolicy" : "{{count}} Policy selected for this page.",
"selectedPolicies" : "{{count}} Policies selected for this page."

}
}
Expand Down

0 comments on commit 4df9128

Please sign in to comment.