Skip to content

Commit

Permalink
SHIBUI-1165 Fixed issue with deleting self
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Feb 12, 2019
1 parent 806f729 commit 64a056e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
8 changes: 6 additions & 2 deletions ui/src/app/admin/component/user-management.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@
<td>{{ user.firstName }} {{ user.lastName }}</td>
<td>{{ user.emailAddress }}</td>
<td>
<select [name]="user.username" [ngModel]="user.role" class="form-control" (change)="setUserRole(user, $event.target.value)">
<select [name]="user.username"
[ngModel]="user.role"
class="form-control"
(change)="setUserRole(user, $event.target.value)"
[disabled]="currentUser.username === user.username">
<option *ngFor="let role of roles$ | async" [value]="role">{{ role }}</option>
</select>
</td>
<td>
<button class="btn btn-link" (click)="deleteUser(user.username)">
<button class="btn btn-link" (click)="deleteUser(user.username)" *ngIf="!(currentUser.username === user.username)">
<span class="sr-only" translate="label.delete-user">
Delete User
</span>
Expand Down
11 changes: 7 additions & 4 deletions ui/src/app/admin/component/user-management.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, ChangeDetectionStrategy, OnInit } from '@angular/core';
import { Component, ChangeDetectionStrategy, OnInit, OnDestroy } from '@angular/core';
import { Store } from '@ngrx/store';
import { Observable, Subscription } from 'rxjs';

Expand All @@ -18,7 +18,7 @@ import { map } from 'rxjs/operators';
templateUrl: './user-management.component.html',
styleUrls: []
})
export class UserManagementComponent implements OnInit {
export class UserManagementComponent implements OnInit, OnDestroy {

users$: Observable<Admin[]>;
currentUser: Admin;
Expand All @@ -32,15 +32,18 @@ export class UserManagementComponent implements OnInit {
protected modal: NgbModal
) {
this.roles$ = this.store.select(fromCore.getUserRoles);
let user$ = this.store.select(fromCore.getUser);
this.userSub = user$.subscribe(u => this.currentUser = u);
}

ngOnInit(): void {
this.users$ = this.store.select(fromAdmin.getAllConfiguredAdmins);
this.hasUsers$ = this.users$.pipe(map(userList => userList.length > 0));
this.users$ = this.store.select(fromAdmin.getAllAdmins);
let user$ = this.store.select(fromCore.getUser);
}

this.userSub = user$.subscribe(u => this.currentUser = u);
ngOnDestroy(): void {
this.userSub.unsubscribe();
}

setUserRole(user: Admin, change: string): void {
Expand Down

0 comments on commit 64a056e

Please sign in to comment.