diff --git a/apps/mina-sidor-fa/src/app/app-routing.module.ts b/apps/mina-sidor-fa/src/app/app-routing.module.ts index 5a54fc0..1b20e68 100644 --- a/apps/mina-sidor-fa/src/app/app-routing.module.ts +++ b/apps/mina-sidor-fa/src/app/app-routing.module.ts @@ -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: '**', diff --git a/apps/mina-sidor-fa/src/app/shared/components/layout/components/navigation/navigation.component.html b/apps/mina-sidor-fa/src/app/shared/components/layout/components/navigation/navigation.component.html index 30f85fb..3c5fef6 100644 --- a/apps/mina-sidor-fa/src/app/shared/components/layout/components/navigation/navigation.component.html +++ b/apps/mina-sidor-fa/src/app/shared/components/layout/components/navigation/navigation.component.html @@ -5,13 +5,13 @@