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(); + }); + } }); }