Skip to content

Commit

Permalink
#931: show "remove member" button only if the okrUser has role OkrCha…
Browse files Browse the repository at this point in the history
…mpion
  • Loading branch information
clean-coder committed Jul 29, 2024
1 parent 28c1c52 commit 818e3aa
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ <h2>
[currentTeams$]="currentUserTeams$.asObservable()"
(addUserTeam)="addTeamMembership($event, userRef)"
></app-add-user-team>
<app-delete-user [user]="userRef"></app-delete-user>
<div *ngIf="hasOkrUserRoleOkrChampion()">
<app-delete-user [user]="userRef"></app-delete-user>
</div>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export class MemberDetailComponent implements OnInit, OnDestroy {
@ViewChild(MatTable) table!: MatTable<User[]>;

user: User | undefined;
okrUser: User | undefined;
teams: Team[] = [];
currentUserTeams$ = new BehaviorSubject<UserTeam[]>([]);
selectedUserIsLoggedInUser: boolean = false;
Expand All @@ -40,6 +41,16 @@ export class MemberDetailComponent implements OnInit, OnDestroy {
private readonly dialog: MatDialog,
) {}
ngOnInit(): void {
this.loadSelectedUser();
this.loadOkrUser();
}

ngOnDestroy(): void {
this.unsubscribe$.next();
this.unsubscribe$.complete();
}

private loadSelectedUser() {
this.route.paramMap
.pipe(
takeUntil(this.unsubscribe$),
Expand All @@ -51,9 +62,19 @@ export class MemberDetailComponent implements OnInit, OnDestroy {
.subscribe();
}

ngOnDestroy(): void {
this.unsubscribe$.next();
this.unsubscribe$.complete();
private loadOkrUser() {
this.userService
.getOrInitCurrentUser()
.pipe(
takeUntil(this.unsubscribe$),
tap((user) => (this.okrUser = user)),
)
.subscribe();
}

public hasOkrUserRoleOkrChampion() {
if (this.okrUser == undefined) return false;
return this.okrUser.isOkrChampion;
}

private loadUser(userId: number) {
Expand Down

0 comments on commit 818e3aa

Please sign in to comment.