From d3011ae166fc9ce1f1212314034c48fc0869dd58 Mon Sep 17 00:00:00 2001 From: mdelez <60604010+mdelez@users.noreply.github.com> Date: Thu, 28 Jul 2022 08:45:48 +0200 Subject: [PATCH] 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 --- src/app/app-routing.module.ts | 6 +----- .../action/login-form/login-form.component.ts | 4 ++-- src/app/main/status/status.component.spec.ts | 15 ++++++++++++++- src/app/project/project.component.ts | 2 +- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 102e6a46ee..6faeadead7 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -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, diff --git a/src/app/main/action/login-form/login-form.component.ts b/src/app/main/action/login-form/login-form.component.ts index d2c18f413b..07f2538300 100644 --- a/src/app/main/action/login-form/login-form.component.ts +++ b/src/app/main/action/login-form/login-form.component.ts @@ -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) => { @@ -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(['/']) ); } }); diff --git a/src/app/main/status/status.component.spec.ts b/src/app/main/status/status.component.spec.ts index 76be25ea3b..96301a7ee3 100644 --- a/src/app/main/status/status.component.spec.ts +++ b/src/app/main/status/status.component.spec.ts @@ -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 diff --git a/src/app/project/project.component.ts b/src/app/project/project.component.ts index fc6ffba4d2..7015ac04c1 100644 --- a/src/app/project/project.component.ts +++ b/src/app/project/project.component.ts @@ -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 }); } /**