Skip to content

Adding ViewQueue path to Routes is error prone #26

@Jan-PeterRichterCG

Description

@Jan-PeterRichterCG

Category: enhancement

Severity: High

Description of issue / expected enhacement /Comments
The instruction how to add the ViewQueue path to Routes in https://github.com/devonfw/devonfw-tutorial-sources/wiki/build-devon4ng-application#generating-viewqueue is error prone:

After that, we are going to include the component in the app-routing.module.ts adding also the guard, only allowing users that are VISITOR to see the component.

....
const appRoutes: Routes = [
  ....
  { path: 'ViewQueue', component: ViewQueueComponent,
  canActivate: [AuthGuardService]},  // Redirect if url path is /ViewQueue, check if canActivate() with the AuthGuardService.
  ....
];
....

Problem: If you add the line at the end of the array then the added path has no effect - the '**' default path is evaluated before the newly added path at the end and always wins.
This leads to a situation where you cannot reach the ViewQueueComponent. For an unexperienced developer it is hard to identify the reason for this. He/she (like me) may think the reason is a malfunction in the AuthGuardService that - for some reason - doesn't return true...

So, it would be helpful to explicitly show where the additional path shall be inserted:

const appRoutes: Routes = [
  { path: 'FormLogin', component: FormLoginComponent},               // Redirect if url path is /access.
  { path: 'Register', component: RegisterComponent},               // Redirect if url path is /Register.
  { path: 'ViewQueue', component: ViewQueueComponent, 
   canActivate: [AuthGuardService]},   // Redirect if url path is /ViewQueue, check if canActivate() with the AuthGuardService.
  { path: '**', redirectTo: '/FormLogin', pathMatch: 'full' },  // Redirect if url path do not match with any other route.
 ];

Your environment - windows/Linux, Devonfw version , component
irrelevant

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions