Skip to content

Commit

Permalink
fix: add feature toggle route guard for 'punchout' routes (#527)
Browse files Browse the repository at this point in the history
- separate PunchoutRoutingModule and PunchoutAccountRoutingModule (rule of one)
  • Loading branch information
shauke committed Feb 10, 2021
1 parent eeddc76 commit 7d27960
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';

const routes: Routes = [
{
path: '',
loadChildren: () =>
import('./account-punchout/account-punchout-page.module').then(m => m.AccountPunchoutPageModule),
},
{
path: 'create',
loadChildren: () =>
import('./account-punchout-create/account-punchout-create-page.module').then(
m => m.AccountPunchoutCreatePageModule
),
},
{
path: ':PunchoutLogin',
loadChildren: () =>
import('./account-punchout-details/account-punchout-details-page.module').then(
m => m.AccountPunchoutDetailsPageModule
),
},
];

@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class PunchoutAccountRoutingModule {}
39 changes: 8 additions & 31 deletions src/app/extensions/punchout/pages/punchout-routing.module.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,19 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';

const routes: Routes = [
{ path: 'punchout', loadChildren: () => import('./punchout/punchout-page.module').then(m => m.PunchoutPageModule) },
];

@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class PunchoutRoutingModule {}
import { FeatureToggleGuard } from 'ish-core/feature-toggle.module';

// tslint:disable-next-line: project-structure
const accountRoutes: Routes = [
{
path: '',
loadChildren: () =>
import('./account-punchout/account-punchout-page.module').then(m => m.AccountPunchoutPageModule),
},
{
path: 'create',
loadChildren: () =>
import('./account-punchout-create/account-punchout-create-page.module').then(
m => m.AccountPunchoutCreatePageModule
),
},
const routes: Routes = [
{
path: ':PunchoutLogin',
loadChildren: () =>
import('./account-punchout-details/account-punchout-details-page.module').then(
m => m.AccountPunchoutDetailsPageModule
),
path: 'punchout',
canActivate: [FeatureToggleGuard],
data: { feature: 'punchout' },
loadChildren: () => import('./punchout/punchout-page.module').then(m => m.PunchoutPageModule),
},
];

@NgModule({
imports: [RouterModule.forChild(accountRoutes)],
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
// tslint:disable-next-line: project-structure
export class AccountPunchoutRoutingModule {}
export class PunchoutRoutingModule {}
14 changes: 11 additions & 3 deletions src/app/pages/account/account-page.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';

import { AuthorizationToggleGuard } from 'ish-core/authorization-toggle.module';
import { FeatureToggleGuard } from 'ish-core/feature-toggle.module';
import { SharedModule } from 'ish-shared/shared.module';

import { AccountOverviewPageModule } from '../account-overview/account-overview-page.module';
Expand Down Expand Up @@ -84,10 +85,17 @@ const accountPageRoutes: Routes = [
},
{
path: 'punchout',
data: { breadcrumbData: [{ key: 'account.punchout.link' }], permission: 'APP_B2B_MANAGE_PUNCHOUT' },
canActivate: [AuthorizationToggleGuard],
canActivate: [FeatureToggleGuard, AuthorizationToggleGuard],
data: {
feature: 'punchout',
permission: 'APP_B2B_MANAGE_PUNCHOUT',
breadcrumbData: [{ key: 'account.punchout.link' }],
},
loadChildren: () =>
import('../../extensions/punchout/pages/punchout-routing.module').then(m => m.AccountPunchoutRoutingModule),
import('../../extensions/punchout/pages/punchout-account-routing.module').then(
m => m.PunchoutAccountRoutingModule
),

},
],
},
Expand Down

0 comments on commit 7d27960

Please sign in to comment.