Skip to content

Commit

Permalink
refactor(routing): home button should direct to overview page (DEV-1152
Browse files Browse the repository at this point in the history
…) (#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 d3011ae
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
6 changes: 1 addition & 5 deletions src/app/app-routing.module.ts
Expand Up @@ -33,7 +33,7 @@ import { ResultsComponent } from './workspace/results/results.component';
const routes: Routes = [
{
path: '',
component: MainComponent
component: OverviewComponent
},
{
path: 'help',
Expand All @@ -43,10 +43,6 @@ const routes: Routes = [
path: 'login',
component: LoginFormComponent
},
{
path: 'overview',
component: OverviewComponent
},
{
path: 'dashboard',
component: DashboardComponent,
Expand Down
4 changes: 2 additions & 2 deletions src/app/main/action/login-form/login-form.component.ts
Expand Up @@ -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>) => {
Expand All @@ -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(['/'])
);
}
});
Expand Down
15 changes: 14 additions & 1 deletion 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';
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/app/project/project.component.ts
Expand Up @@ -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 });
}

/**
Expand Down

0 comments on commit d3011ae

Please sign in to comment.