This repository has been archived by the owner on Apr 12, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(repository): #1579 display build history for each PR on new page
- Loading branch information
1 parent
cf84ee2
commit f344c41
Showing
8 changed files
with
189 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Angular modules | ||
import { Injectable } from '@angular/core'; | ||
import { ActivatedRouteSnapshot, Resolve, Router } from '@angular/router'; | ||
|
||
// 3rd party | ||
import { of, Observable } from 'rxjs'; | ||
import { catchError, take } from 'rxjs/operators'; | ||
|
||
// Dashboard hub model and services | ||
import { RepositoryService } from '@core/services/index.service'; | ||
import { PullRequestStatusModel } from '@shared/models/index.model'; | ||
|
||
@Injectable({ | ||
providedIn: 'root', | ||
}) | ||
export class StatusResolver implements Resolve<PullRequestStatusModel> { | ||
|
||
/** | ||
* Life cycle method | ||
* @param respositoryService RepositoryService | ||
* @param router Router | ||
*/ | ||
constructor( | ||
private respositoryService: RepositoryService, | ||
private router: Router | ||
) { } | ||
|
||
resolve(route: ActivatedRouteSnapshot): Observable<PullRequestStatusModel> { | ||
return this.respositoryService.getPullRequestStatusByUid(route.params.repoUid, route.params.pullRequestUid) | ||
.pipe( | ||
take(1), | ||
catchError(() => { | ||
this.router.navigate(['/projects', route.params.projectUid]); | ||
|
||
return of(new PullRequestStatusModel()); | ||
}) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
web/src/app/projects/build-history/build-history.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<div class="build-history" *ngIf="status"> | ||
<div class="build-history__header" fxLayout="row" fxLayoutAlign="start center"> | ||
<div fxLayout="row" fxLayoutAlign="space-between center" fxLayoutGap="5px"> | ||
<a [routerLink]="['/projects', projectUid]" *ngIf="!isSmallScreen"> Project ></a> | ||
<a [routerLink]="['/projects', projectUid, repoUid]" *ngIf="!isSmallScreen"> Pull Request ></a> | ||
<span>Build History</span> | ||
</div> | ||
</div> | ||
<mat-card class="build-history__card"> | ||
<mat-card-header> | ||
<div class="build-history__card__header"> | ||
<mat-icon svgIcon="request_white"></mat-icon> | ||
</div> | ||
<mat-card-title class="build-history__card__title"> | ||
Build History | ||
</mat-card-title> | ||
<mat-card-subtitle class="build-history__card__title__subtitle"> | ||
You have {{ status.historic.length }} total builds | ||
</mat-card-subtitle> | ||
</mat-card-header> | ||
<mat-card-content class="build-history__card__content"> | ||
<table mat-table [dataSource]="status.historic" class="build-history__card__content__table"> | ||
<ng-container matColumnDef="commitId"> | ||
<th mat-header-cell *matHeaderCellDef>Commit Id</th> | ||
<td mat-cell *matCellDef="let element"> {{ element.commitId }} </td> | ||
</ng-container> | ||
|
||
<ng-container matColumnDef="time"> | ||
<th mat-header-cell *matHeaderCellDef>Time</th> | ||
<td mat-cell *matCellDef="let element"> {{ element.buildTimes[0].time }} seconds </td> | ||
</ng-container> | ||
|
||
<tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: true"></tr> | ||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> | ||
</table> | ||
</mat-card-content> | ||
</mat-card> | ||
</div> |
42 changes: 42 additions & 0 deletions
42
web/src/app/projects/build-history/build-history.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
@import "../../../assets/scss/variable"; | ||
@import "../../../assets/scss/mixin.scss"; | ||
|
||
.build-history { | ||
@include pageContainer; | ||
|
||
&__header { | ||
@include pageHeader; | ||
} | ||
|
||
&__card { | ||
@include cardContainer; | ||
|
||
&__header { | ||
@include header-icon; | ||
background-color: $purple-color; | ||
box-shadow: 0px 3px 6px $purple-shadow; | ||
} | ||
|
||
&__title { | ||
@include title; | ||
|
||
&__subtitle { | ||
@include subtitle; | ||
} | ||
} | ||
|
||
&__content { | ||
padding: 0; | ||
display: block; | ||
overflow: auto; | ||
max-height: 60vh; | ||
|
||
@include tableContainer; | ||
|
||
&__table { | ||
width: 100%; | ||
padding: 0 2px; | ||
} | ||
} | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
web/src/app/projects/build-history/build-history.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Core modules | ||
import { Component, OnInit } from '@angular/core'; | ||
import { ActivatedRoute } from '@angular/router'; | ||
|
||
// DashboardHub services | ||
import { PullRequestStatusModel } from '@app/shared/models/index.model'; | ||
|
||
@Component({ | ||
selector: 'dashboard-build-history', | ||
templateUrl: './build-history.component.html', | ||
styleUrls: ['./build-history.component.scss'], | ||
}) | ||
export class BuildHistoryComponent implements OnInit { | ||
|
||
public projectUid: string; | ||
public repoUid: string; | ||
public pullRequestUid: string; | ||
public historic: []; | ||
public displayedColumns: string[] = ['commitId', 'time']; | ||
public status: PullRequestStatusModel; | ||
|
||
/** | ||
* Life cycle method | ||
* @param route ActivateRoute | ||
*/ | ||
constructor( | ||
private route: ActivatedRoute | ||
) { } | ||
|
||
/** | ||
* Captured pull request status information from status resolver route | ||
*/ | ||
ngOnInit(): void { | ||
this.projectUid = this.route.snapshot.paramMap.get('projectUid'); | ||
this.repoUid = this.route.snapshot.paramMap.get('repoUid'); | ||
this.route.data.subscribe((data: { status: PullRequestStatusModel }) => this.status = data.status); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters