Skip to content
This repository has been archived by the owner on Jul 16, 2021. It is now read-only.

ui: limit shown chart versions to latest 5 #312

Merged
merged 2 commits into from
Jul 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
<div class="versions">
<h1>Chart Versions</h1>
<div class="version" *ngFor="let version of versions">
<div class="version" *ngFor="let version of shownVersions(versions)">
<span class='number' [class.selected]="isSelected(version)">
<a [href]="goToVersionUrl(version)" [routerLink]="goToVersionUrl(version)">
{{ version.attributes.version }}</a>
</span> -
<span class='creation-date'>{{ version.attributes.created | date: 'MMM d, y' }}</span>
</div>
<div class="more-link" *ngIf="showMoreLink()">
<a (click)="setShowAllVersions()">show all...</a>
</div>
</div>
<div class="app-version" *ngIf="currentVersion && currentVersion.attributes.app_version">
<h1>Application Version</h1>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
h1 {
margin-top: 0;
}
.more-link {
margin-top: .5em;
}
}

.version {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { ChartAttributes } from '../../shared/models/chart';
export class ChartDetailsVersionsComponent implements OnInit {
@Input() versions: ChartVersion[]
@Input() currentVersion: ChartVersion
showAllVersions: boolean
constructor() { }

ngOnInit() { }
Expand All @@ -22,4 +23,19 @@ export class ChartDetailsVersionsComponent implements OnInit {
isSelected(version: ChartVersion): boolean {
return version.attributes.version == this.currentVersion.attributes.version;
}

showMoreLink(): boolean {
return this.versions && this.versions.length > 5 && !this.showAllVersions;
}

setShowAllVersions() {
this.showAllVersions = true;
}

shownVersions(versions: ChartVersion[]): ChartVersion[] {
if (this.versions) {
return this.showAllVersions ? this.versions : this.versions.slice(0, 5);
}
return [];
}
}