Add search target check params
[oweals/peertube.git] / client / src / app / app-routing.module.ts
index 1d55b4cea2db272dac5ec2b3737a138487c39cd8..a87f4ce1babd219fe73280491451dffed623c004 100644 (file)
@@ -1,16 +1,49 @@
 import { NgModule } from '@angular/core'
-import { RouterModule, Routes } from '@angular/router'
+import { RouteReuseStrategy, RouterModule, Routes } from '@angular/router'
 
 import { PreloadSelectedModulesList } from './core'
+import { AppComponent } from '@app/app.component'
+import { CustomReuseStrategy } from '@app/core/routing/custom-reuse-strategy'
+import { MenuGuards } from '@app/core/routing/menu-guard.service'
 
 const routes: Routes = [
   {
     path: 'admin',
-    loadChildren: './+admin/admin.module#AdminModule'
+    canActivate: [ MenuGuards.close() ],
+    canDeactivate: [ MenuGuards.open() ],
+    loadChildren: () => import('./+admin/admin.module').then(m => m.AdminModule)
   },
   {
-    path: 'account',
-    loadChildren: './+account/account.module#AccountModule'
+    path: 'my-account',
+    loadChildren: () => import('./+my-account/my-account.module').then(m => m.MyAccountModule)
+  },
+  {
+    path: 'verify-account',
+    loadChildren: () => import('./+signup/+verify-account/verify-account.module').then(m => m.VerifyAccountModule)
+  },
+  {
+    path: 'accounts',
+    loadChildren: () => import('./+accounts/accounts.module').then(m => m.AccountsModule)
+  },
+  {
+    path: 'video-channels',
+    loadChildren: () => import('./+video-channels/video-channels.module').then(m => m.VideoChannelsModule)
+  },
+  {
+    path: 'about',
+    loadChildren: () => import('./+about/about.module').then(m => m.AboutModule)
+  },
+  {
+    path: 'signup',
+    loadChildren: () => import('./+signup/+register/register.module').then(m => m.RegisterModule)
+  },
+  {
+    path: '',
+    component: AppComponent // Avoid 404, app component will redirect dynamically
+  },
+  {
+    path: '**',
+    loadChildren: () => import('./+page-not-found/page-not-found.module').then(m => m.PageNotFoundModule)
   }
 ]
 
@@ -18,11 +51,15 @@ const routes: Routes = [
   imports: [
     RouterModule.forRoot(routes, {
       useHash: Boolean(history.pushState) === false,
-      preloadingStrategy: PreloadSelectedModulesList
+      scrollPositionRestoration: 'disabled',
+      preloadingStrategy: PreloadSelectedModulesList,
+      anchorScrolling: 'disabled'
     })
   ],
   providers: [
-    PreloadSelectedModulesList
+    MenuGuards.guards,
+    PreloadSelectedModulesList,
+    { provide: RouteReuseStrategy, useClass: CustomReuseStrategy }
   ],
   exports: [ RouterModule ]
 })