Skip to content

Commit

Permalink
Added Dialog window after deleting user + modified tests accordingly (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcelfrueh authored Dec 14, 2023
1 parent dcdea28 commit 5eecd02
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 6 deletions.
1 change: 1 addition & 0 deletions ui/cypress/support/utils/UserUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,6 @@ export class UserUtils {
this.goToUserConfiguration();

cy.dataCy('user-delete-btn-' + user.name).click();
cy.dataCy('confirm-delete').click();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<
Expand All @@ -47,6 +52,7 @@ export abstract class AbstractSecurityPrincipalConfig<
protected userService: UserService,
protected userAdminService: UserAdminService,
protected dialogService: DialogService,
private dialog: MatDialog,
) {}

ngOnInit(): void {
Expand Down Expand Up @@ -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();
});
}
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -41,6 +46,7 @@ export class SecurityUserGroupConfigComponent implements OnInit {
constructor(
private userGroupService: UserGroupService,
private dialogService: DialogService,
private dialog: MatDialog,
) {}

ngOnInit(): void {
Expand All @@ -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();
});
}
});
}

Expand Down

0 comments on commit 5eecd02

Please sign in to comment.