Skip to content

Commit

Permalink
Add chart link in charts table, refresh endpoints status on sync (#490)
Browse files Browse the repository at this point in the history
* Add link to chart in chart list table view
-

* Refresh endpoints after sync request is sent

* Fix unit tests
  • Loading branch information
richard-cox committed Sep 17, 2020
1 parent c049909 commit 29ee2f9
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';

import { ChartsService } from '../monocular/shared/services/charts.service';
import { createMonocularProviders } from '../monocular/stratos-monocular-providers.helpers';
import { getMonocularEndpoint } from '../monocular/stratos-monocular.helper';


@Component({
Expand All @@ -19,7 +19,10 @@ export class MonocularChartViewComponent implements OnInit {

public title = '';

constructor(private route: ActivatedRoute) { }
constructor(
private route: ActivatedRoute,
private chartService: ChartsService
) { }

public ngOnInit() {

Expand All @@ -34,7 +37,7 @@ export class MonocularChartViewComponent implements OnInit {

if (!!parts.version) {
breadcrumbs.push(
{ value: this.title, routerLink: `/monocular/charts/${getMonocularEndpoint(this.route)}/${parts.repo}/${parts.chartName}` }
{ value: this.title, routerLink: this.chartService.getChartSummaryRoute(parts.repo, parts.chartName, null, this.route) }
);
this.title = parts.version;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Store } from '@ngrx/store';
import { of } from 'rxjs';
import { map } from 'rxjs/operators';
import { catchError, first, map } from 'rxjs/operators';

import { IListAction } from '../../../../core/src/shared/components/list/list.component.types';
import { AppState } from '../../../../store/src/app-state';
Expand All @@ -10,6 +10,7 @@ import {
StratosCatalogEntity,
} from '../../../../store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity';
import { StratosEndpointExtensionDefinition } from '../../../../store/src/entity-catalog/entity-catalog.types';
import { stratosEntityCatalog } from '../../../../store/src/stratos-entity-catalog';
import { EndpointModel } from '../../../../store/src/types/endpoint.types';
import { IFavoriteMetadata } from '../../../../store/src/types/user-favorites.types';
import { helmEntityCatalog } from './helm-entity-catalog';
Expand Down Expand Up @@ -57,7 +58,16 @@ export function generateHelmEntities(): StratosBaseCatalogEntity[] {
authTypes: [],
endpointListActions: (store: Store<AppState>): IListAction<EndpointModel>[] => {
return [{
action: (item: EndpointModel) => helmEntityCatalog.chart.api.synchronise(item),
action: (item: EndpointModel) => {
helmEntityCatalog.chart.api.synchronise(item).pipe(
catchError(() => null), // Be super safe to ensure we pass the first filter
first()
).subscribe(res => {
if (res != null) {
stratosEntityCatalog.endpoint.api.getAll();
}
});
},
label: 'Synchronize',
description: '',
createVisible: row => row.pipe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { ListView } from '../../../../../store/src/actions/list.actions';
import { AppState } from '../../../../../store/src/app-state';
import { defaultHelmKubeListPageSize } from '../../kubernetes/list-types/kube-helm-list-types';
import { HELM_ENDPOINT_TYPE } from '../helm-entity-factory';
import { ChartsService } from '../monocular/shared/services/charts.service';
import { MonocularChart } from '../store/helm.types';
import { MonocularChartCardComponent } from './monocular-chart-card/monocular-chart-card.component';
import { MonocularChartsDataSource } from './monocular-charts-data-source';
Expand All @@ -29,7 +30,14 @@ export class MonocularChartsListConfig implements IListConfig<MonocularChart> {
{
columnId: 'name', headerCell: () => 'Name',
cellDefinition: {
getValue: (row) => row.name,
getValue: row => row.name,
getLink: row => this.chartsService.getChartSummaryRoute(
row.attributes.repo.name,
row.name,
null,
null,
row
),
},
sort: {
type: 'sort',
Expand Down Expand Up @@ -81,6 +89,7 @@ export class MonocularChartsListConfig implements IListConfig<MonocularChart> {
store: Store<AppState>,
private endpointsService: EndpointsService,
private route: ActivatedRoute,
private chartsService: ChartsService
) {

this.initialised = endpointsService.endpoints$.pipe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';

import { PanelComponent } from '../../panel/panel.component';
import { MockChartService } from '../../shared/services/chart.service.mock';
import { ChartsService } from '../../shared/services/charts.service';
import { ChartDetailsVersionsComponent } from './chart-details-versions.component';

/* tslint:disable:no-unused-variable */
describe('ChartDetailsVersionsComponent', () => {
let component: ChartDetailsVersionsComponent;
let fixture: ComponentFixture<ChartDetailsVersionsComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ChartDetailsVersionsComponent, PanelComponent],
imports: [RouterTestingModule]
imports: [RouterTestingModule],
providers: [{ provide: ChartsService, useValue: new MockChartService() },]
})
.compileComponents();
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ActivatedRoute } from '@angular/router';

import { ChartAttributes } from '../../shared/models/chart';
import { ChartVersion } from '../../shared/models/chart-version';
import { getMonocularEndpoint } from '../../stratos-monocular.helper';
import { ChartsService } from '../../shared/services/charts.service';

@Component({
selector: 'app-chart-details-versions',
Expand All @@ -15,11 +15,14 @@ export class ChartDetailsVersionsComponent {
@Input() currentVersion: ChartVersion;
showAllVersions: boolean;

constructor(private route: ActivatedRoute) { }
constructor(
private route: ActivatedRoute,
private chartService: ChartsService
) { }

goToVersionUrl(version: ChartVersion): string {
const chart: ChartAttributes = version.relationships.chart.data;
return `/monocular/charts/${getMonocularEndpoint(this.route)}/${chart.repo.name}/${chart.name}/${version.attributes.version}`;
return this.chartService.getChartSummaryRoute(chart.repo.name, chart.name, version.attributes.version, this.route);
}

isSelected(version: ChartVersion): boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Component, OnInit } from '@angular/core';

import { Chart } from '../shared/models/chart';
import { ChartsService } from '../shared/services/charts.service';
import { getMonocularEndpoint } from '../stratos-monocular.helper';

@Component({
selector: 'app-chart-item',
Expand All @@ -27,11 +26,7 @@ export class ChartItemComponent implements OnInit {
}

goToDetailUrl(): string {
return `/monocular/charts/${getMonocularEndpoint(null, this.chart)}/${this.chart.attributes.repo.name}/${this.chart.attributes
.name}`;
return this.chartsService.getChartSummaryRoute(this.chart.attributes.repo.name, this.chart.attributes.name, null, null, this.chart);
}

goToRepoUrl(): string {
return `/monocular/charts/${getMonocularEndpoint(null, this.chart)}/${this.chart.attributes.repo.name}`;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ export class ChartsService {
}
}

getChartSummaryRoute(repoName: string, chartName: string, version?: string, route?: ActivatedRoute, chart?: Chart): string {
return `/monocular/charts/${getMonocularEndpoint(route, chart)}/${repoName}/${chartName}${version ? `/${version}` : ''}`;
}

/**
* Store the charts in the cache
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { HelmBaseTestModules } from '../../helm-testing.module';
import { MockChartService } from '../../monocular/shared/services/chart.service.mock';
import { ChartsService } from '../../monocular/shared/services/charts.service';
import { CatalogTabComponent } from './catalog-tab.component';

describe('CatalogTabComponent', () => {
Expand All @@ -12,7 +14,8 @@ describe('CatalogTabComponent', () => {
imports: [
...HelmBaseTestModules
],
declarations: [CatalogTabComponent]
declarations: [CatalogTabComponent],
providers: [{ provide: ChartsService, useValue: new MockChartService() },]
})
.compileComponents();
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class CreateReleaseComponent implements OnInit, OnDestroy {
private chartsService: ChartsService,
) {
const chart = this.route.snapshot.params as HelmChartReference;
this.cancelUrl = `/monocular/charts/${getMonocularEndpoint(this.route)}/${chart.repo}/${chart.name}/${chart.version}`;
this.cancelUrl = this.chartsService.getChartSummaryRoute(chart.repo, chart.name, chart.version, this.route);
this.chart = chart;

this.config = {
Expand Down

0 comments on commit 29ee2f9

Please sign in to comment.