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:
@@ -1,11 +1,14 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { ExtraOptions, RouterModule, Routes } from '@angular/router';
|
||||
import { Feature } from '@msfa-enums/feature.enum';
|
||||
import { RoleEnum } from '@msfa-enums/role.enum';
|
||||
import { environment } from '@msfa-environment';
|
||||
import { AuthGuard } from '@msfa-guards/auth.guard';
|
||||
import { OrganizationGuard } from '@msfa-guards/organization.guard';
|
||||
import { RoleGuard } from '@msfa-guards/role.guard';
|
||||
|
||||
const activeFeatures: Feature[] = environment.activeFeatures;
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
@@ -13,24 +16,6 @@ const routes: Routes = [
|
||||
loadChildren: () => import('./pages/start/start.module').then(m => m.StartModule),
|
||||
canActivate: [AuthGuard, OrganizationGuard],
|
||||
},
|
||||
{
|
||||
path: 'administration',
|
||||
data: { title: 'Administration', expectedRole: RoleEnum.MSFA_AuthAdmin },
|
||||
loadChildren: () => import('./pages/administration/administration.module').then(m => m.AdministrationModule),
|
||||
canActivate: [AuthGuard, OrganizationGuard, RoleGuard],
|
||||
},
|
||||
{
|
||||
path: 'deltagare',
|
||||
data: { title: 'Deltagare', expectedRole: RoleEnum.MSFA_ReportAndPlanning },
|
||||
loadChildren: () => import('./pages/deltagare/deltagare.module').then(m => m.DeltagareModule),
|
||||
canActivate: [AuthGuard, OrganizationGuard, RoleGuard],
|
||||
},
|
||||
{
|
||||
path: 'nya-deltagare',
|
||||
data: { title: 'Nya deltagare', expectedRole: RoleEnum.MSFA_ReceiveDeltagare },
|
||||
loadChildren: () => import('./pages/avrop/avrop.module').then(m => m.AvropModule),
|
||||
canActivate: [AuthGuard, OrganizationGuard, RoleGuard],
|
||||
},
|
||||
{
|
||||
path: 'logga-ut',
|
||||
data: { title: 'Logga ut' },
|
||||
@@ -44,12 +29,6 @@ const routes: Routes = [
|
||||
import('./pages/organization-picker/organization-picker.module').then(m => m.OrganizationPickerModule),
|
||||
canActivate: [AuthGuard],
|
||||
},
|
||||
{
|
||||
path: 'mitt-konto',
|
||||
data: { title: 'Mitt konto' },
|
||||
loadChildren: () => import('./pages/my-account/my-account.module').then(m => m.MyAccountModule),
|
||||
canActivate: [AuthGuard, OrganizationGuard],
|
||||
},
|
||||
{
|
||||
path: 'obehorig',
|
||||
data: { title: 'Saknar behörighet' },
|
||||
@@ -58,21 +37,59 @@ const routes: Routes = [
|
||||
},
|
||||
];
|
||||
|
||||
if (!environment.production) {
|
||||
routes.push(
|
||||
{
|
||||
path: 'mock-login',
|
||||
data: { title: 'Mock login' },
|
||||
loadChildren: () => import('./pages/mock-login/mock-login.module').then(m => m.MockLoginModule),
|
||||
},
|
||||
{
|
||||
path: 'releases',
|
||||
data: { title: 'Releaser' },
|
||||
loadChildren: () => import('./pages/releases/releases.module').then(m => m.ReleasesModule),
|
||||
canActivate: [AuthGuard],
|
||||
}
|
||||
);
|
||||
}
|
||||
activeFeatures.forEach(feature => {
|
||||
switch (feature) {
|
||||
case Feature.ADMINISTRATION:
|
||||
routes.push({
|
||||
path: 'administration',
|
||||
data: { title: 'Administration', expectedRole: RoleEnum.MSFA_AuthAdmin },
|
||||
loadChildren: () => import('./pages/administration/administration.module').then(m => m.AdministrationModule),
|
||||
canActivate: [AuthGuard, OrganizationGuard, RoleGuard],
|
||||
});
|
||||
break;
|
||||
case Feature.AVROP:
|
||||
routes.push({
|
||||
path: 'nya-deltagare',
|
||||
data: { title: 'Nya deltagare', expectedRole: RoleEnum.MSFA_ReceiveDeltagare },
|
||||
loadChildren: () => import('./pages/avrop/avrop.module').then(m => m.AvropModule),
|
||||
canActivate: [AuthGuard, OrganizationGuard, RoleGuard],
|
||||
});
|
||||
break;
|
||||
case Feature.DELTAGARE:
|
||||
routes.push({
|
||||
path: 'deltagare',
|
||||
data: { title: 'Deltagare', expectedRole: RoleEnum.MSFA_ReportAndPlanning },
|
||||
loadChildren: () => import('./pages/deltagare/deltagare.module').then(m => m.DeltagareModule),
|
||||
canActivate: [AuthGuard, OrganizationGuard, RoleGuard],
|
||||
});
|
||||
break;
|
||||
case Feature.MY_ACCOUNT:
|
||||
routes.push({
|
||||
path: 'mitt-konto',
|
||||
data: { title: 'Mitt konto' },
|
||||
loadChildren: () => import('./pages/my-account/my-account.module').then(m => m.MyAccountModule),
|
||||
canActivate: [AuthGuard, OrganizationGuard],
|
||||
});
|
||||
break;
|
||||
case Feature.RELEASES:
|
||||
routes.push({
|
||||
path: 'releases',
|
||||
data: { title: 'Releaser' },
|
||||
loadChildren: () => import('./pages/releases/releases.module').then(m => m.ReleasesModule),
|
||||
canActivate: [AuthGuard],
|
||||
});
|
||||
break;
|
||||
case Feature.MOCK_LOGIN:
|
||||
routes.push({
|
||||
path: 'mock-login',
|
||||
data: { title: 'Mock login' },
|
||||
loadChildren: () => import('./pages/mock-login/mock-login.module').then(m => m.MockLoginModule),
|
||||
});
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
routes.push({
|
||||
path: '**',
|
||||
|
||||
Reference in New Issue
Block a user