feat(settings): Added feature toggling. (TV-564)
Squashed commit of the following: commit b67cced3bd44d1673173e5fa188d776d2d097fd4 Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se> Date: Fri Sep 10 11:59:37 2021 +0200 Added feature toggling for routes and navigation
This commit is contained in:
@@ -5,13 +5,13 @@
|
||||
</a>
|
||||
</div>
|
||||
<ul class="navigation__list msfa__hide-on-print" *ngIf="user">
|
||||
<li class="navigation__item">
|
||||
<li class="navigation__item" *ngIf="myAccountVisible">
|
||||
<a routerLink="/mitt-konto" class="navigation__link">
|
||||
<msfa-icon [icon]="iconType.USER" size="l"></msfa-icon>
|
||||
<span class="navigation__text">{{ user.fullName }}</span>
|
||||
</a>
|
||||
</li>
|
||||
<li *ngIf="selectedOrganization" class="navigation__item navigation__item--without-link">
|
||||
<li *ngIf="selectedOrganization && myOrganizationVisible" class="navigation__item navigation__item--without-link">
|
||||
<msfa-icon [icon]="iconType.BUILDING" size="l"></msfa-icon>
|
||||
<span class="navigation__text">{{ selectedOrganization.name }}</span>
|
||||
</li>
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
|
||||
import { Feature } from '@msfa-enums/feature.enum';
|
||||
import { IconType } from '@msfa-enums/icon-type.enum';
|
||||
import { environment } from '@msfa-environment';
|
||||
import { Employee } from '@msfa-models/employee.model';
|
||||
import { Organization } from '@msfa-models/organization.model';
|
||||
|
||||
@@ -13,4 +15,12 @@ export class NavigationComponent {
|
||||
@Input() user: Employee;
|
||||
@Input() selectedOrganization: Organization;
|
||||
iconType = IconType;
|
||||
activeFeatures: Feature[] = environment.activeFeatures;
|
||||
|
||||
get myAccountVisible(): boolean {
|
||||
return this.activeFeatures.includes(Feature.MY_ACCOUNT);
|
||||
}
|
||||
get myOrganizationVisible(): boolean {
|
||||
return this.activeFeatures.includes(Feature.MY_ORGANIZATION);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,20 +11,20 @@
|
||||
Hem
|
||||
</a>
|
||||
</li>
|
||||
<li class="sidebar__item" *ngIf="isReceiveDeltagare">
|
||||
<li class="sidebar__item" *ngIf="avropVisible">
|
||||
<a [routerLink]="['/nya-deltagare']" [routerLinkActive]="['sidebar__link--active']" class="sidebar__link">
|
||||
<msfa-icon class="sidebar__icon" [icon]="iconType.CLIPBOARD" size="xl"></msfa-icon>
|
||||
Nya deltagare
|
||||
</a>
|
||||
</li>
|
||||
<li class="sidebar__item" *ngIf="isReportAndPlanning">
|
||||
<li class="sidebar__item" *ngIf="deltagareVisible">
|
||||
<a [routerLink]="['/deltagare']" [routerLinkActive]="['sidebar__link--active']" class="sidebar__link">
|
||||
<msfa-icon class="sidebar__icon" [icon]="iconType.SOK_KANDIDAT" size="xl"></msfa-icon>
|
||||
Deltagarlista
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li class="sidebar__item" *ngIf="isAuthAdmin">
|
||||
<li class="sidebar__item" *ngIf="adminVisible">
|
||||
<a [routerLink]="['/administration']" [routerLinkActive]="['sidebar__link--active']" class="sidebar__link">
|
||||
<msfa-icon class="sidebar__icon" [icon]="iconType.SETTINGS" size="xl"></msfa-icon>
|
||||
Administration
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
|
||||
import { Feature } from '@msfa-enums/feature.enum';
|
||||
import { IconType } from '@msfa-enums/icon-type.enum';
|
||||
import { RoleEnum } from '@msfa-enums/role.enum';
|
||||
import { environment } from '@msfa-environment';
|
||||
import { Role } from '@msfa-models/role.model';
|
||||
|
||||
@Component({
|
||||
@@ -12,14 +14,24 @@ import { Role } from '@msfa-models/role.model';
|
||||
export class SidebarComponent {
|
||||
@Input() userRoles: Role[];
|
||||
iconType = IconType;
|
||||
activeFeatures: Feature[] = environment.activeFeatures;
|
||||
|
||||
get isAuthAdmin(): boolean {
|
||||
return this.userRoles?.some(role => role.type === RoleEnum.MSFA_AuthAdmin);
|
||||
get adminVisible(): boolean {
|
||||
return (
|
||||
this.activeFeatures.includes(Feature.ADMINISTRATION) &&
|
||||
this.userRoles?.some(role => role.type === RoleEnum.MSFA_AuthAdmin)
|
||||
);
|
||||
}
|
||||
get isReceiveDeltagare(): boolean {
|
||||
return this.userRoles?.some(role => role.type === RoleEnum.MSFA_ReceiveDeltagare);
|
||||
get avropVisible(): boolean {
|
||||
return (
|
||||
this.activeFeatures.includes(Feature.AVROP) &&
|
||||
this.userRoles?.some(role => role.type === RoleEnum.MSFA_ReceiveDeltagare)
|
||||
);
|
||||
}
|
||||
get isReportAndPlanning(): boolean {
|
||||
return this.userRoles?.some(role => role.type === RoleEnum.MSFA_ReportAndPlanning);
|
||||
get deltagareVisible(): boolean {
|
||||
return (
|
||||
this.activeFeatures.includes(Feature.DELTAGARE) &&
|
||||
this.userRoles?.some(role => role.type === RoleEnum.MSFA_ReportAndPlanning)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
9
apps/mina-sidor-fa/src/app/shared/enums/feature.enum.ts
Normal file
9
apps/mina-sidor-fa/src/app/shared/enums/feature.enum.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export enum Feature {
|
||||
AVROP,
|
||||
DELTAGARE,
|
||||
ADMINISTRATION,
|
||||
MY_ACCOUNT,
|
||||
MY_ORGANIZATION,
|
||||
RELEASES,
|
||||
MOCK_LOGIN,
|
||||
}
|
||||
5
apps/mina-sidor-fa/src/app/shared/models/ciam.model.ts
Normal file
5
apps/mina-sidor-fa/src/app/shared/models/ciam.model.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export interface Ciam {
|
||||
clientId: string;
|
||||
loginUrl: string;
|
||||
logoutUrl: string;
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
import { Feature } from '@msfa-enums/feature.enum';
|
||||
|
||||
export interface Environment {
|
||||
environment: 'api' | 'local' | 'acc' | 'prod';
|
||||
clientId: string;
|
||||
@@ -8,4 +10,5 @@ export interface Environment {
|
||||
url: string;
|
||||
headers: { [key: string]: string };
|
||||
};
|
||||
activeFeatures: Feature[];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user