diff --git a/console/src/app/modules/warn-dialog/warn-dialog.component.html b/console/src/app/modules/warn-dialog/warn-dialog.component.html index c089810b7b..5674b88c9b 100644 --- a/console/src/app/modules/warn-dialog/warn-dialog.component.html +++ b/console/src/app/modules/warn-dialog/warn-dialog.component.html @@ -1,6 +1,6 @@ -{{data.titleKey | translate}} +{{data.titleKey | translate: data.titleParam}}
-

{{data.descriptionKey | translate}}

+

{{data.descriptionKey | translate: data.descriptionParam}}

+ + + + -
diff --git a/console/src/app/pages/users/user-detail/user-detail/user-detail.component.scss b/console/src/app/pages/users/user-detail/user-detail/user-detail.component.scss index 42288edd73..d4350df012 100644 --- a/console/src/app/pages/users/user-detail/user-detail/user-detail.component.scss +++ b/console/src/app/pages/users/user-detail/user-detail/user-detail.component.scss @@ -17,6 +17,10 @@ .fill-space { flex: 1; } + + .state-button { + margin-left: .5rem; + } } .method-col { diff --git a/console/src/app/pages/users/user-detail/user-detail/user-detail.component.ts b/console/src/app/pages/users/user-detail/user-detail/user-detail.component.ts index a055b5a220..c114a76b31 100644 --- a/console/src/app/pages/users/user-detail/user-detail/user-detail.component.ts +++ b/console/src/app/pages/users/user-detail/user-detail/user-detail.component.ts @@ -1,9 +1,11 @@ import { Location } from '@angular/common'; import { Component, OnDestroy, OnInit } from '@angular/core'; +import { MatDialog } from '@angular/material/dialog'; import { ActivatedRoute } from '@angular/router'; import { TranslateService } from '@ngx-translate/core'; import { Subscription } from 'rxjs'; import { ChangeType } from 'src/app/modules/changes/changes.component'; +import { WarnDialogComponent } from 'src/app/modules/warn-dialog/warn-dialog.component'; import { Gender, MachineResponse, @@ -44,6 +46,7 @@ export class UserDetailComponent implements OnInit, OnDestroy { private toast: ToastService, public mgmtUserService: ManagementService, private _location: Location, + private dialog: MatDialog, ) { } public ngOnInit(): void { @@ -195,4 +198,29 @@ export class UserDetailComponent implements OnInit, OnDestroy { this.toast.showError(error); }); } + + public deleteUser(): void { + const dialogRef = this.dialog.open(WarnDialogComponent, { + data: { + confirmKey: 'ACTIONS.DELETE', + cancelKey: 'ACTIONS.CANCEL', + titleKey: 'USER.DIALOG.DELETE_TITLE', + descriptionParam: this.user.human ?? + this.user.machine ? { displayName: this.user.machine?.name } : { displayName: '' }, + descriptionKey: 'USER.DIALOG.DELETE_DESCRIPTION', + }, + width: '400px', + }); + + dialogRef.afterClosed().subscribe(resp => { + if (resp) { + this.mgmtUserService.DeleteUser(this.user.id).then(() => { + this.navigateBack(); + this.toast.showInfo('USER.TOAST.DELETED', true); + }).catch(error => { + this.toast.showError(error); + }); + } + }); + } } diff --git a/console/src/app/pages/users/user-list/user-list.component.html b/console/src/app/pages/users/user-list/user-list.component.html index af36116d5c..d8e2f77a77 100644 --- a/console/src/app/pages/users/user-list/user-list.component.html +++ b/console/src/app/pages/users/user-list/user-list.component.html @@ -12,7 +12,7 @@

{{ 'USER.PAGES.DESCRIPTIONMACHINE' | translate }}

diff --git a/console/src/app/pages/users/user-list/user-table/user-table.component.html b/console/src/app/pages/users/user-list/user-table/user-table.component.html index 366f0ebe23..6c673e4ee2 100644 --- a/console/src/app/pages/users/user-list/user-table/user-table.component.html +++ b/console/src/app/pages/users/user-list/user-table/user-table.component.html @@ -48,7 +48,8 @@ - {{user[userType]?.firstName}} + + {{user[userType]?.firstName}} @@ -58,7 +59,8 @@ - {{user[userType]?.lastName}} + + {{user[userType]?.lastName}} @@ -68,19 +70,22 @@ - {{user[userType]?.displayName}} + + {{user[userType]?.displayName}} {{ 'USER.MACHINE.NAME' | translate }} - {{user[userType]?.name}} + + {{user[userType]?.name}} {{ 'USER.MACHINE.DESCRIPTION' | translate }} - {{user[userType]?.description}} + + {{user[userType]?.description}} @@ -90,7 +95,8 @@ - {{user.userName}} + + {{user.userName}} @@ -100,17 +106,29 @@ - {{user[userType]?.email}} + + {{user[userType]?.email}} + {{ 'USER.DATA.STATE' | translate }} - {{ 'USER.DATA.STATE'+user.state | translate }} + + {{ 'USER.DATA.STATE'+user.state | translate }} + + + + + + + - - + = new BehaviorSubject(false); public loading$: Observable = this.loadingSubject.asObservable(); - @Input() public displayedColumns: string[] = ['select', /*'firstname', 'lastname' ,*/ 'displayName', 'username', 'email', 'state']; + @Input() public displayedColumns: string[] = ['select', 'displayName', 'username', 'email', 'state', 'actions']; @Output() public changedSelection: EventEmitter> = new EventEmitter(); UserSearchKey: any = UserSearchKey; - constructor(public translate: TranslateService, private userService: ManagementService, - private toast: ToastService) { + constructor( + public translate: TranslateService, + private userService: ManagementService, + private toast: ToastService, + private dialog: MatDialog, + ) { this.selection.changed.subscribe(() => { this.changedSelection.emit(this.selection.selected); }); @@ -129,4 +135,30 @@ export class UserTableComponent implements OnInit { this.refreshPage(); } } + + public deleteUser(user: UserView.AsObject): void { + const dialogRef = this.dialog.open(WarnDialogComponent, { + data: { + confirmKey: 'ACTIONS.DELETE', + cancelKey: 'ACTIONS.CANCEL', + titleKey: 'USER.DIALOG.DELETE_TITLE', + descriptionParam: user.human ?? user.machine ? { displayName: user.machine?.name } : { displayName: '' }, + descriptionKey: 'USER.DIALOG.DELETE_DESCRIPTION', + }, + width: '400px', + }); + + dialogRef.afterClosed().subscribe(resp => { + if (resp) { + this.userService.DeleteUser(user.id).then(() => { + setTimeout(() => { + this.refreshPage(); + }, 1000); + this.toast.showInfo('USER.TOAST.DELETED', true); + }).catch(error => { + this.toast.showError(error); + }); + } + }); + } } diff --git a/console/src/app/services/mgmt.service.ts b/console/src/app/services/mgmt.service.ts index 3eceaced66..0768dbcc56 100644 --- a/console/src/app/services/mgmt.service.ts +++ b/console/src/app/services/mgmt.service.ts @@ -643,6 +643,12 @@ export class ManagementService { return this.grpcService.mgmt.getUserByID(req); } + public DeleteUser(id: string): Promise { + const req = new UserID(); + req.setId(id); + return this.grpcService.mgmt.deleteUser(req); + } + public SearchProjectMembers( projectId: string, limit: number, diff --git a/console/src/assets/i18n/de.json b/console/src/assets/i18n/de.json index 3759fae0a4..081a8b6374 100644 --- a/console/src/assets/i18n/de.json +++ b/console/src/assets/i18n/de.json @@ -87,7 +87,12 @@ "NOUSER":"Kein Benutzer", "REACTIVATE":"Reaktivieren", "DEACTIVATE":"Deaktivieren", - "FILTER":"Filter" + "FILTER":"Filter", + "DELETE":"Benutzer löschen" + }, + "DIALOG": { + "DELETE_TITLE":"User löschen", + "DELETE_DESCRIPTION":"Sie sind im Begriff den Benutzer {{displayName}} entgültig zu löschen. Wollen Sie dies wirklich tun?" }, "TABLE":{ "DEACTIVATE":"Deaktivieren", @@ -282,7 +287,8 @@ "SELECTEDDEACTIVATED":"Selektierte Benutzer deaktiviert.", "SELECTEDKEYSDELETED":"Selektierte Schlüssel gelöscht.", "KEYADDED":"Schlüssel hinzugefügt!", - "MACHINEADDED":"Service User erstellt!" + "MACHINEADDED":"Service User erstellt!", + "DELETED":"Benutzer erfolgreich gelöscht!" }, "MEMBERSHIPS": { "TITLE":"ZITADEL Manager-Rollen", diff --git a/console/src/assets/i18n/en.json b/console/src/assets/i18n/en.json index 7e588c49b4..92b35a6b9a 100644 --- a/console/src/assets/i18n/en.json +++ b/console/src/assets/i18n/en.json @@ -87,7 +87,12 @@ "NOUSER":"No associated users.", "REACTIVATE":"Reactivate", "DEACTIVATE":"Deactivate", - "FILTER":"Filter" + "FILTER":"Filter", + "DELETE":"Delete User" + }, + "DIALOG": { + "DELETE_TITLE":"Delete User", + "DELETE_DESCRIPTION":"You are about to permanently delete the user {{displayName}}. Are you sure?" }, "TABLE":{ "DEACTIVATE":"Deactivate", @@ -282,7 +287,8 @@ "SELECTEDDEACTIVATED":"Selected users deactivated.", "SELECTEDKEYSDELETED":"Selected keys deleted.", "KEYADDED":"Key added!", - "MACHINEADDED":"Service User created!" + "MACHINEADDED":"Service User created!", + "DELETED":"User deleted successfully!" }, "MEMBERSHIPS": { "TITLE":"ZITADEL Manager Roles",