Skip to content
Permalink
Browse files
refactor(routing): home button should direct to overview page (DEV-1152
…) (#779)

* refactor(routing): home button now leads to overview page

* test(status): make tests more stable by mocking the linkify pipe
  • Loading branch information
mdelez committed Jul 28, 2022
1 parent 9885cfb commit d3011ae166fc9ce1f1212314034c48fc0869dd58
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
@@ -33,7 +33,7 @@ import { ResultsComponent } from './workspace/results/results.component';
const routes: Routes = [
{
path: '',
component: MainComponent
component: OverviewComponent
},
{
path: 'help',
@@ -43,10 +43,6 @@ const routes: Routes = [
path: 'login',
component: LoginFormComponent
},
{
path: 'overview',
component: OverviewComponent
},
{
path: 'dashboard',
component: DashboardComponent,
@@ -163,7 +163,7 @@ export class LoginFormComponent implements OnInit, AfterViewInit {
this.returnUrl = this._route.snapshot.queryParams['returnUrl'];
if (this.returnUrl) {
this._router.navigate([this.returnUrl]);
} else if (this._route.snapshot.url.length && this._route.snapshot.url[0].path === 'login') { // if user is on /login
} else if (!this._route.snapshot.url.length || (this._route.snapshot.url.length && this._route.snapshot.url[0].path === 'login')) { // if user is on "/" or "/login"
const username = this.session.user.name;
this._dspApiConnection.admin.usersEndpoint.getUserByUsername(username).subscribe(
(userResponse: ApiResponseData<UserResponse>) => {
@@ -174,7 +174,7 @@ export class LoginFormComponent implements OnInit, AfterViewInit {
);
} else { // if user is a member of multiple projects, redirect them to the overview
this._router.navigateByUrl('/refresh', { skipLocationChange: true }).then(
() => this._router.navigate(['/overview'])
() => this._router.navigate(['/'])
);
}
});
@@ -1,4 +1,4 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { Component, OnInit, Pipe, PipeTransform, ViewChild } from '@angular/core';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { MatDialogRef } from '@angular/material/dialog';
import { MatIconModule } from '@angular/material/icon';
@@ -11,6 +11,19 @@ import { HttpStatusMsg } from 'src/assets/http/statusMsg';
import { DspApiConnectionToken } from '../declarations/dsp-api-tokens';
import { StatusComponent } from './status.component';


/**
* mocked linkify pipe from main/pipes.
*/
@Pipe({ name: 'appLinkify' })
class MockPipe implements PipeTransform {
transform(value: string): string {
// do stuff here, if you want
return value;
}
}


/**
* test host component to simulate parent component.
* dsp specific http status message
@@ -226,7 +226,7 @@ export class ProjectComponent implements OnInit {
* go to overview page
*/
goToOverview() {
this._router.navigate(['/overview'], { relativeTo: this._route });
this._router.navigate(['/'], { relativeTo: this._route });
}

/**

0 comments on commit d3011ae

Please sign in to comment.