Skip to content

Commit

Permalink
adjust some links in the UI to use the default branch
Browse files Browse the repository at this point in the history
  • Loading branch information
maximAtanasov committed Oct 5, 2020
1 parent 682f951 commit dc443a6
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 32 deletions.
9 changes: 5 additions & 4 deletions coderadar-ui/src/app/city-map/shared/effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,18 @@ import {INode} from '../interfaces/INode';
import {ICommitsGetErrorResponse} from '../interfaces/ICommitsGetErrorResponse';
import {Store} from '@ngrx/store';
import * as fromRoot from './reducers';
import {Project} from '../../model/project';

@Injectable()
export class AppEffects {

public currentProjectId: number;
public currentProject: Project;
isLoaded = false;

@Effect()
loadCommitsEffects$ = this.actions$.pipe(ofType(LOAD_COMMITS),
switchMap(
() => from(this.projectService.getCommits(this.currentProjectId, 'master'))
() => from(this.projectService.getCommits(this.currentProject.id, this.currentProject.defaultBranch))
.pipe(
map((result: any) => {
return actions.loadCommitsSuccess(result.body);
Expand All @@ -38,7 +39,7 @@ export class AppEffects {

@Effect()
loadAvailableMetricsEffects$ = this.actions$.pipe(ofType(LOAD_AVAILABLE_METRICS),
switchMap(() => from(this.projectService.getAvailableMetrics(this.currentProjectId))
switchMap(() => from(this.projectService.getAvailableMetrics(this.currentProject.id))
.pipe(
mergeMap((result: any) => {
const availableMetrics = result.body.map(
Expand Down Expand Up @@ -74,7 +75,7 @@ export class AppEffects {
map((action: IActionWithPayload<any>) => action.payload),
switchMap(
(payload) => from(this.projectService.getDeltaTree(payload.leftCommit, payload.rightCommit,
payload.metricMapping, this.currentProjectId))
payload.metricMapping, this.currentProject.id))
.pipe(
mergeMap((result: HttpResponse<INode>) => {
return [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<app-header id="header" [title]="[{location: '/dashboard', name: 'Dashboard'}, {location: '/project/' + project.id + '/master', name: appComponent.trimProjectName(project.name)}, {location: '/project/' + projectId + '/' + commitName + '/' + commitName2 + '/dependency-map', name: 'Dependency Map for ' + commitName + ' and ' + commitName2}]"></app-header>
<app-header id="header" [title]="[{location: '/dashboard', name: 'Dashboard'},
{location: '/project/' + project.id + '/' + project.defaultBranch, name: appComponent.trimProjectName(project.name)},
{location: '/project/' + projectId + '/' + commitName + '/' + commitName2 + '/dependency-map', name: 'Dependency Map for ' + commitName + ' and ' + commitName2}]"></app-header>

<mat-checkbox class="margin-left margin-right" [checked]="checkUp" (change)="onShowUpwardChanged()">Show upward Dependencies</mat-checkbox>
<mat-checkbox class="margin-left margin-right" [checked]="checkDown" (change)="onShowDownwardChanged()">Show downward Dependencies</mat-checkbox>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<app-header id="header" [title]="[{location: '/dashboard', name: 'Dashboard'}, {location: '/project/' + project.id + '/master', name: appComponent.trimProjectName(project.name)}, {location: '/project/' + project.id + '/' + commitName + '/dependency-map', name: 'Dependency Map for ' + commitName}]"></app-header>
<app-header id="header" [title]="[{location: '/dashboard', name: 'Dashboard'},
{location: '/project/' + project.id + '/' + project.defaultBranch, name: appComponent.trimProjectName(project.name)},
{location: '/project/' + project.id + '/' + commitName + '/dependency-map', name: 'Dependency Map for ' + commitName}]"></app-header>

<mat-checkbox class="margin-left margin-right" [checked]="checkUp" (change)="onShowUpwardChanged()">Show upward Dependencies</mat-checkbox>
<mat-checkbox class="margin-left margin-right" [checked]="checkDown" (change)="onShowDownwardChanged()">Show downward Dependencies</mat-checkbox>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<div class="spacer"></div>
<mat-toolbar class="md-elevation-z5" style="width: 100%" color="primary">
<span style="margin-right: 10px">
<a mat-button routerLink="/project/{{project.id}}/master" style="width: auto;">
<a mat-button routerLink="/project/{{project.id}}/{{project.defaultBranch}}" style="width: auto;">
<mat-icon style="font-size: 16pt; color: white;">arrow_back_ios</mat-icon>
<mat-label style="font-size: 20pt;">
{{appComponent.trimProjectNameToLength(project.name, 16)}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,9 @@ export class CityViewHeaderComponent implements OnInit {
}

ngOnInit() {
this.projectId = this.appEffects.currentProjectId;
this.getProject();
this.project = this.appEffects.currentProject;
}

/**
* Gets the project from the service and saves it in this.project
*/
private getProject(): void {
this.projectService.getProject(this.projectId)
.then(response => {
this.project = new Project(response.body);
})
.catch(error => {
if (error.status && error.status === FORBIDDEN) {
this.userService.refresh(() => this.getProject());
} else if (error.status && error.status === NOT_FOUND) {
this.router.navigate(['/dashboard']);
}
});
}


logout(): void {
this.userService.logout();
}
Expand Down
2 changes: 1 addition & 1 deletion coderadar-ui/src/app/view/city-view/city-view.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export class CityViewComponent implements OnInit {

ngOnInit() {
this.route.params.subscribe(params => {
this.cityEffects.currentProjectId = params.id;
this.setTitle(params.id);
});
}
Expand All @@ -31,6 +30,7 @@ export class CityViewComponent implements OnInit {
this.projectService.getProject(id)
.then(response => {
this.titleService.setTitle('Coderadar - ' + AppComponent.trimProjectName(response.body.name) + ' - 3D view');
this.cityEffects.currentProject = new Project(response.body);
})
.catch(error => {
if (error.status && error.status === FORBIDDEN) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<app-header [title]="[{location: '/dashboard', name: 'Dashboard'},
{location: '/project/' + projectId+'/master', name: project.name},
{location: '/project/' + projectId+'/' + project.defaultBranch, name: project.name},
{location: '/project/'+projectId+'/'+commitHash+'/files',
name: 'File tree for commit ' + commitHashAbbrev}]"></app-header>
<main class="bgColor">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class ListViewComponent implements OnInit, OnChanges {
this.route.params.subscribe(params => {
this.projectId = params.id;
this.selectedBranch = params.branch;
this.cityEffects.currentProjectId = this.projectId;
this.cityEffects.currentProject = this.project;
this.showCommitsInRange();
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ export class ProjectDashboardComponent implements OnInit, OnDestroy {
this.getCommits(true);
}
});
this.cityEffects.currentProjectId = this.projectId;
});
}

Expand Down Expand Up @@ -125,6 +124,7 @@ export class ProjectDashboardComponent implements OnInit, OnDestroy {
this.project = new Project(response.body.project);
this.titleService.setTitle('Coderadar - ' + AppComponent.trimProjectName(this.project.name));
this.roles = response.body.roles;
this.cityEffects.currentProject = this.project;
})
.catch(error => {
if (error.status && error.status === FORBIDDEN) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<app-header [title]="
[{location: '/dashboard', name: 'Dashboard'}, {location: '/project/' + project.id + '/master',
[{location: '/dashboard', name: 'Dashboard'}, {location: '/project/' + project.id + '/' + project.defaultBranch,
name: appComponent.trimProjectName(project.name)}, {location: '/project/' + project.id + '/commit/' + commit.hash, name: commit.hash.substring(0, 7)}]">
</app-header>

Expand Down

0 comments on commit dc443a6

Please sign in to comment.