Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Fix helm endpoint link #4777

Merged
merged 5 commits into from
Nov 23, 2020
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
Expand Up @@ -61,7 +61,7 @@ export class CardCfRecentAppsComponent implements OnInit {
if (!this.allApps$) {
this.allApps$ = this.appsPagObs.entities$;
this.loading$ = this.appsPagObs.fetchingEntities$;
this.hasEntities$ = this.appsPagObs.hasEntities$
this.hasEntities$ = this.appsPagObs.hasEntities$;
} else {
this.hasEntities$ = of(true);
}
Expand All @@ -84,7 +84,7 @@ export class CardCfRecentAppsComponent implements OnInit {
}

private fetchAppStats(recentApps: APIResource<IApp>[]) {
if(!this.noStats) {
if (!this.noStats) {
recentApps.forEach(app => {
if (app.entity.state === 'STARTED') {
cfEntityCatalog.appStats.api.getMultiple(app.metadata.guid, this.endpoint);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ export class CompactAppCardComponent implements OnInit {

) { }
ngOnInit() {
if(this.activeRouteCfOrgSpace) {
if (this.activeRouteCfOrgSpace) {
this.bcType = this.setBreadcrumbType(this.activeRouteCfOrgSpace);
if (!this.endpoint) {
this.endpoint = this.activeRouteCfOrgSpace.cfGuid;
}
}

if (!this.app) {
return
return;
}

const initState = this.appStateService.get(this.app.entity, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,18 @@ import { ITileConfig } from './../../../../../core/src/shared/components/tile/ti
})
export class CFHomeCardComponent implements HomePageEndpointCard {

_layout: HomePageCardLayout;
pLayout: HomePageCardLayout;

get layout(): HomePageCardLayout {
return this._layout;
return this.pLayout;
}

@Input() set layout(value: HomePageCardLayout) {
if (value) {
this._layout = value;
this.pLayout = value;
}
this.updateLayout();
};
}

@Input() set endpoint(value: EndpointModel) {
this.guid = value.guid;
Expand Down Expand Up @@ -89,7 +89,7 @@ export class CFHomeCardComponent implements HomePageEndpointCard {
appDeploySourceTypes: ApplicationDeploySourceTypes,
) {
// Set a default layout
this._layout = new HomePageCardLayout(1, 1);
this.pLayout = new HomePageCardLayout(1, 1);

// Get source types for if we are showing tiles to deploy an application
this.sourceTypes = appDeploySourceTypes.getTypes();
Expand All @@ -110,7 +110,7 @@ export class CFHomeCardComponent implements HomePageEndpointCard {
if (tile) {
const query = {
[BASE_REDIRECT_QUERY]: `applications/new/${this.guid}`,
[AUTO_SELECT_CF_URL_PARAM]:this.guid
[AUTO_SELECT_CF_URL_PARAM]: this.guid
};
if (tile.data.subType) {
query[AUTO_SELECT_DEPLOY_TYPE_URL_PARAM] = tile.data.subType;
Expand All @@ -126,7 +126,7 @@ export class CFHomeCardComponent implements HomePageEndpointCard {
this.appCount$ = CloudFoundryEndpointService.fetchAppCount(this.store, this.pmf, this.guid);
this.orgCount$ = CloudFoundryEndpointService.fetchOrgCount(this.store, this.pmf, this.guid);

this.appLink = () => goToAppWall(this.store, this.guid);;
this.appLink = () => goToAppWall(this.store, this.guid);

const appsPagObs = cfEntityCatalog.application.store.getPaginationService(this.guid);

Expand Down Expand Up @@ -192,8 +192,6 @@ export class CFHomeCardComponent implements HomePageEndpointCard {
}

private restrictApps(apps: APIResource<IApp>[]): APIResource<IApp>[] {
return !apps ? [] :[...apps.sort(appDataSort).slice(0, this.recentAppsRows)];
return !apps ? [] : [...apps.sort(appDataSort).slice(0, this.recentAppsRows)];
}

}

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<button mat-icon-button (click)="show = !show" [attr.aria-label]="'Hide password'" [attr.aria-pressed]="!show"
<button tabindex="-1" mat-icon-button (click)="show = !show" [attr.aria-label]="'Hide password'" [attr.aria-pressed]="!show"
type="button">
<mat-icon>{{!show ? 'visibility_off' : 'visibility'}}</mat-icon>
</button>
5 changes: 2 additions & 3 deletions src/frontend/packages/core/src/features/home/home.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export abstract class HomePageEndpointCard {
}

export interface LinkMetadata {
favs: IHydrationResults[],
shortcuts: HomeCardShortcut[]
favs: IHydrationResults[];
shortcuts: HomeCardShortcut[];
}

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class FavoritesSidePanelComponent implements PreviewableComponent {
name: string;

setProps(props: { [key: string]: any; }): void {
this.favorites$ = props.favorites$
this.favorites$ = props.favorites$;
this.name = props.endpoint.name;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('HomePageEndpointCardComponent', () => {

afterEach(() => {
component.ngOnDestroy();
})
});

it('should create', () => {
expect(component).toBeTruthy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,22 @@ const MAX_LINKS = 5;
})
export class HomePageEndpointCardComponent implements OnInit, OnDestroy, AfterViewInit {

@ViewChild('customCard', {read:ViewContainerRef}) customCard: ViewContainerRef;
@ViewChild('customCard', {read: ViewContainerRef}) customCard: ViewContainerRef;

@Input() endpoint: EndpointModel;

_layout: HomePageCardLayout;
pLayout: HomePageCardLayout;

get layout(): HomePageCardLayout {
return this._layout;
return this.pLayout;
}

@Input() set layout(value: HomePageCardLayout) {
if (value) {
this._layout = value;
this.pLayout = value;
}
this.updateLayout();
};
}

@Output() loaded = new EventEmitter<HomePageEndpointCardComponent>();

Expand Down Expand Up @@ -102,7 +102,7 @@ export class HomePageEndpointCardComponent implements OnInit, OnDestroy, AfterVi

ngAfterViewInit() {
// Dynamically load the component for the Home Card for this endopoint
const endpointEntity = entityCatalog.getEndpoint(this.endpoint.cnsi_type, this.endpoint.sub_type)
const endpointEntity = entityCatalog.getEndpoint(this.endpoint.cnsi_type, this.endpoint.sub_type);
if (endpointEntity && endpointEntity.definition.homeCard && endpointEntity.definition.homeCard.component) {
this.createCard(endpointEntity);
} else {
Expand All @@ -116,7 +116,7 @@ export class HomePageEndpointCardComponent implements OnInit, OnDestroy, AfterVi
map(f => f.map(item => this.userFavoriteManager.mapToHydrated(item)))
);

this.entity = entityCatalog.getEndpoint(this.endpoint.cnsi_type, this.endpoint.sub_type)
this.entity = entityCatalog.getEndpoint(this.endpoint.cnsi_type, this.endpoint.sub_type);
if (this.entity) {
this.definition = this.entity.definition;
this.favorite = this.favoritesConfigMapper.getFavoriteEndpointFromEntity(this.endpoint);
Expand Down Expand Up @@ -187,7 +187,7 @@ export class HomePageEndpointCardComponent implements OnInit, OnDestroy, AfterVi
public updateLayout() {
this.layout$.next(this.layout);
if (this.ref && this.ref.instance) {
this.ref.instance.layout = this._layout;
this.ref.instance.layout = this.pLayout;
}
}

Expand All @@ -196,7 +196,7 @@ export class HomePageEndpointCardComponent implements OnInit, OnDestroy, AfterVi
const component = await endpointEntity.definition.homeCard.component(this.compiler, this.injector);
this.ref = this.customCard.createComponent(component);
this.ref.instance.endpoint = this.endpoint;
this.ref.instance.layout = this._layout;
this.ref.instance.layout = this.pLayout;
this.loadCardIfReady();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export class HomePageComponent implements AfterViewInit, OnInit, OnDestroy {
).subscribe(id => {
const selected = this.layouts.find(hpcl => hpcl && hpcl.id === id) || this.layouts[0];
this.onChangeLayout(selected);
})
});
}

ngOnInit() {
Expand Down Expand Up @@ -152,10 +152,10 @@ export class HomePageComponent implements AfterViewInit, OnInit, OnDestroy {
} else {
remaining.push(index);
}
};
}
this.processCardsToLoad();
this.notLoadedCardIndices = remaining;
})
});
}

processCardsToLoad() {
Expand Down Expand Up @@ -184,7 +184,7 @@ export class HomePageComponent implements AfterViewInit, OnInit, OnDestroy {

setCardsToLoad(cards: any[]) {
this.notLoadedCardIndices = [];
for(let i=0;i< cards.length; i++) {
for (let i = 0; i < cards.length; i++) {
this.notLoadedCardIndices.push(i);
}
setTimeout(() => this.checkCardsInView(), 1);
Expand Down Expand Up @@ -263,7 +263,7 @@ export class HomePageComponent implements AfterViewInit, OnInit, OnDestroy {
processed[ep.guid] = true;
result.push(ep);
}
})
});

// Filter out the disconnected ones
return result.filter(ep => ep.connectionStatus === 'connected');
Expand All @@ -277,7 +277,7 @@ export class HomePageComponent implements AfterViewInit, OnInit, OnDestroy {
return !!defn.definition.homeCard;
})),
map(eps => {
switch(eps.length) {
switch (eps.length) {
case 1:
return this.getLayout(1, 1);
case 2:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export class LoginPageComponent implements OnInit, OnDestroy {
this.subscription.unsubscribe(); // Ensure to unsub otherwise GoToState gets caught in loop
}
if (this.redirect) {
this.store.dispatch(new RouterNav({ path: [this.redirect.path], query: this.redirect.queryParams || {} }));
this.store.dispatch(new RouterNav({ path: [decodeURI(this.redirect.path)], query: this.redirect.queryParams || {} }));
} else {
this.store.dispatch(new RouterNav({ path: ['/'] }, null));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export function generateHelmEntities(): StratosBaseCatalogEntity[] {
function generateEndpointEntity(endpointDefinition: StratosEndpointExtensionDefinition) {
helmEntityCatalog.endpoint = new StratosCatalogEndpointEntity(
endpointDefinition,
metadata => `/monocular/charts`,
(metadata) => `/monocular/charts/${metadata.name}`,
);
return helmEntityCatalog.endpoint;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ export class MonocularChartsDataSource extends ListDataSource<MonocularChart> {
{ type: 'filter', field: 'name' },
(entities: MonocularChart[], paginationState: PaginationEntityState) => {
const repository = paginationState.clientPagination.filter.items.repository;
return repository ? entities.filter(e => repository === e.attributes.repo.name) : entities;
const isHub = repository === 'Artifact Hub';
if (!repository) {
return entities;
} else if (isHub) {
return entities.filter(e => !!e.monocularEndpointId);
} else {
return entities.filter(e => repository === e.attributes.repo.name);
}
}
]
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ActivatedRoute } from '@angular/router';

import { HelmBaseTestModules } from '../../helm-testing.module';
import { MockChartService } from '../../monocular/shared/services/chart.service.mock';
Expand All @@ -15,7 +16,13 @@ describe('CatalogTabComponent', () => {
...HelmBaseTestModules
],
declarations: [CatalogTabComponent],
providers: [{ provide: ChartsService, useValue: new MockChartService() }]
providers: [
{ provide: ChartsService, useValue: new MockChartService() },
{ provide: ActivatedRoute, useValue: {
snapshot: { params: {}, queryParams: {} }
}
}
]
})
.compileComponents();
}));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Component } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Store } from '@ngrx/store';
import { BehaviorSubject, combineLatest, Observable } from 'rxjs';
import { distinctUntilChanged, filter, first, map, startWith } from 'rxjs/operators';
Expand Down Expand Up @@ -38,8 +39,7 @@ export class CatalogTabComponent {
public collapsed = true;
public hide = true;

constructor(private store: Store<AppState>) {

constructor(private store: Store<AppState>, private activatedRoute: ActivatedRoute) {
// Determine the starting state of the filter by repo section
stratosEntityCatalog.endpoint.store.getAll.getPaginationService().entities$.pipe(
filter(entities => !!entities),
Expand Down Expand Up @@ -92,7 +92,12 @@ export class CatalogTabComponent {
helmEntityCatalog.chart.store.getPaginationMonitor().pagination$.pipe(
first()
).subscribe(pagination => {
this.filteredRepo = pagination.clientPagination?.filter?.items?.[REPO_FILTER_NAME];
const { repo } = this.activatedRoute.snapshot.params;
if (repo && repo.length > 0) {
this.filterCharts(repo);
} else {
this.filteredRepo = pagination.clientPagination?.filter?.items?.[REPO_FILTER_NAME];
}
});
}

Expand All @@ -101,7 +106,6 @@ export class CatalogTabComponent {
*/
public filterCharts(repoName: string) {
this.filteredRepo = repoName;

helmEntityCatalog.chart.store.getPaginationMonitor().pagination$.pipe(first()).subscribe(pagination => {
const action = helmEntityCatalog.chart.actions.getMultiple();
this.store.dispatch(new SetClientFilter(action, action.paginationKey, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ export class KubernetesHomeCardComponent implements OnInit {

@Input() endpoint: EndpointModel;

_layout: HomePageCardLayout;
pLayout: HomePageCardLayout;

get layout(): HomePageCardLayout {
return this._layout;
return this.pLayout;
}

@Input() set layout(value: HomePageCardLayout) {
if (value) {
this._layout = value;
this.pLayout = value;
}
};
}

public shortcuts: HomeCardShortcut[];

Expand Down
4 changes: 2 additions & 2 deletions src/frontend/packages/store/src/user-favorite-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ export class UserFavoriteManager {
if (f.endpointId === endpointID && f.entityId) {
result.push(f);
}
})
});
return result;
})
)
);
}

public getEndpointIDFromFavoriteID(id: string): string {
Expand Down