From 5eecd0224cc86b96795b75e6c63117691f22b642 Mon Sep 17 00:00:00 2001 From: Marcelfrueh <78954450+Marcelfrueh@users.noreply.github.com> Date: Thu, 14 Dec 2023 15:32:53 +0100 Subject: [PATCH] Added Dialog window after deleting user + modified tests accordingly (#2307) --- ui/cypress/support/utils/UserUtils.ts | 1 + .../abstract-security-principal-config.ts | 28 +++++++++++++++++-- .../user-group-configuration.component.ts | 26 +++++++++++++++-- 3 files changed, 49 insertions(+), 6 deletions(-) diff --git a/ui/cypress/support/utils/UserUtils.ts b/ui/cypress/support/utils/UserUtils.ts index fb505aa81a..9db82d6410 100644 --- a/ui/cypress/support/utils/UserUtils.ts +++ b/ui/cypress/support/utils/UserUtils.ts @@ -66,5 +66,6 @@ export class UserUtils { this.goToUserConfiguration(); cy.dataCy('user-delete-btn-' + user.name).click(); + cy.dataCy('confirm-delete').click(); } } diff --git a/ui/src/app/configuration/security-configuration/abstract-security-principal-config.ts b/ui/src/app/configuration/security-configuration/abstract-security-principal-config.ts index 998f9e8e1f..b3f639b301 100644 --- a/ui/src/app/configuration/security-configuration/abstract-security-principal-config.ts +++ b/ui/src/app/configuration/security-configuration/abstract-security-principal-config.ts @@ -27,8 +27,13 @@ import { UserService, } from '@streampipes/platform-services'; import { Observable } from 'rxjs'; -import { DialogService, PanelType } from '@streampipes/shared-ui'; +import { + ConfirmDialogComponent, + DialogService, + PanelType, +} from '@streampipes/shared-ui'; import { EditUserDialogComponent } from './edit-user-dialog/edit-user-dialog.component'; +import { MatDialog } from '@angular/material/dialog'; @Directive() export abstract class AbstractSecurityPrincipalConfig< @@ -47,6 +52,7 @@ export abstract class AbstractSecurityPrincipalConfig< protected userService: UserService, protected userAdminService: UserAdminService, protected dialogService: DialogService, + private dialog: MatDialog, ) {} ngOnInit(): void { @@ -86,8 +92,24 @@ export abstract class AbstractSecurityPrincipalConfig< } deleteUser(account: UserAccount | ServiceAccount) { - this.userService.deleteUser(account.principalId).subscribe(() => { - this.load(); + const dialogRef = this.dialog.open(ConfirmDialogComponent, { + width: '500px', + data: { + title: 'Are you sure you want to delete this account?', + subtitle: 'This action cannot be reversed!', + cancelTitle: 'Cancel', + okTitle: 'Delete User', + confirmAndCancel: true, + }, + }); + dialogRef.afterClosed().subscribe(result => { + if (result) { + this.userService + .deleteUser(account.principalId) + .subscribe(() => { + this.load(); + }); + } }); } diff --git a/ui/src/app/configuration/security-configuration/user-group-configuration/user-group-configuration.component.ts b/ui/src/app/configuration/security-configuration/user-group-configuration/user-group-configuration.component.ts index d4f23cf61e..ef32d235d1 100644 --- a/ui/src/app/configuration/security-configuration/user-group-configuration/user-group-configuration.component.ts +++ b/ui/src/app/configuration/security-configuration/user-group-configuration/user-group-configuration.component.ts @@ -21,8 +21,13 @@ import { Group, UserGroupService } from '@streampipes/platform-services'; import { MatPaginator } from '@angular/material/paginator'; import { MatSort } from '@angular/material/sort'; import { MatTableDataSource } from '@angular/material/table'; -import { DialogService, PanelType } from '@streampipes/shared-ui'; +import { + ConfirmDialogComponent, + DialogService, + PanelType, +} from '@streampipes/shared-ui'; import { EditGroupDialogComponent } from '../edit-group-dialog/edit-group-dialog.component'; +import { MatDialog } from '@angular/material/dialog'; @Component({ selector: 'sp-security-user-group-config', @@ -41,6 +46,7 @@ export class SecurityUserGroupConfigComponent implements OnInit { constructor( private userGroupService: UserGroupService, private dialogService: DialogService, + private dialog: MatDialog, ) {} ngOnInit(): void { @@ -60,8 +66,22 @@ export class SecurityUserGroupConfigComponent implements OnInit { } deleteGroup(group: Group) { - this.userGroupService.deleteGroup(group).subscribe(response => { - this.loadAllGroups(); + const dialogRef = this.dialog.open(ConfirmDialogComponent, { + width: '500px', + data: { + title: 'Are you sure you want to delete this group?', + subtitle: 'This action cannot be reversed!', + cancelTitle: 'Cancel', + okTitle: 'Delete Group', + confirmAndCancel: true, + }, + }); + dialogRef.afterClosed().subscribe(result => { + if (result) { + this.userGroupService.deleteGroup(group).subscribe(response => { + this.loadAllGroups(); + }); + } }); }