Skip to content

Commit

Permalink
Fix edit profile button visibility (#4839)
Browse files Browse the repository at this point in the history
- broken as part of electron changes
- canEdit$ was incorrectly removed
  • Loading branch information
richard-cox authored Dec 16, 2020
1 parent 0413ee5 commit b95b329
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { Component } from '@angular/core';
import { Observable } from 'rxjs';
import { combineLatest, Observable } from 'rxjs';
import { map } from 'rxjs/operators';

import { ThemeService } from '../../../../../store/src/theme.service';
import { UserProfileInfo } from '../../../../../store/src/types/user-profile.types';
import { CurrentUserPermissionsService } from '../../../core/permissions/current-user-permissions.service';
import { StratosCurrentUserPermissions } from '../../../core/permissions/stratos-user-permissions.checker';
import { UserProfileService } from '../../../core/user-profile.service';
import { UserService } from '../../../core/user.service';

Expand All @@ -24,10 +26,15 @@ export class ProfileInfoComponent {
userProfileService: UserProfileService,
public userService: UserService,
public themeService: ThemeService,
private currentUserPermissionsService: CurrentUserPermissionsService,
) {
this.isError$ = userProfileService.isError$;
this.userProfile$ = userProfileService.userProfile$;

const canEdit = this.isError$.pipe(map(e => !e));
const hasEditPermissions = this.currentUserPermissionsService.can(StratosCurrentUserPermissions.EDIT_PROFILE);
this.canEdit$ = combineLatest([canEdit, hasEditPermissions]).pipe(map(([a, b]) => a && b));

this.primaryEmailAddress$ = this.userProfile$.pipe(
map((profile: UserProfileInfo) => userProfileService.getPrimaryEmailAddress(profile))
);
Expand Down

0 comments on commit b95b329

Please sign in to comment.