RED-2877: Account screen permissions

This commit is contained in:
Adina Țeudan 2021-11-25 15:10:02 +02:00
parent fb63499183
commit 9bbf7d211e
4 changed files with 9 additions and 3 deletions

View File

@ -34,7 +34,7 @@ export class BaseScreenComponent {
{
name: _('top-bar.navigation-items.my-account.children.account'),
routerLink: '/main/account',
show: this.currentUser.isUser,
show: true,
action: this.appStateService.reset,
showDot: () => false,
},

View File

@ -14,7 +14,6 @@ const routes = [
canActivate: [CompositeRouteGuard],
data: {
routeGuards: [AuthGuard, RedRoleGuard, AppStateGuard],
requiredRoles: ['RED_USER'],
},
loadChildren: () => import('./screens/user-profile/user-profile.module').then(m => m.UserProfileModule),
},
@ -24,6 +23,7 @@ const routes = [
canActivate: [CompositeRouteGuard],
data: {
routeGuards: [AuthGuard, RedRoleGuard, AppStateGuard],
requiredRoles: ['RED_USER'],
},
loadChildren: () => import('./screens/notifications/notifications.module').then(m => m.NotificationsModule),
},

View File

@ -1,6 +1,7 @@
<iqser-side-nav [title]="'account-settings' | translate">
<ng-container *ngFor="let item of items">
<div [routerLinkActiveOptions]="{ exact: false }" [routerLink]="'../' + item.screen" class="item" routerLinkActive="active">
<div *ngIf="!item.hideIf"
[routerLinkActiveOptions]="{ exact: false }" [routerLink]="'../' + item.screen" class="item" routerLinkActive="active">
{{ item.label | translate }}
</div>
</ng-container>

View File

@ -1,9 +1,11 @@
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { UserService } from '@services/user.service';
interface NavItem {
readonly label: string;
readonly screen: string;
readonly hideIf?: boolean;
}
@Component({
@ -21,6 +23,9 @@ export class AccountSideNavComponent {
{
screen: 'notifications',
label: _('notifications'),
hideIf: !this._userService.currentUser.isUser,
},
];
constructor(private readonly _userService: UserService) {}
}