Skip to content

Commit

Permalink
marketplace: cf endpoint on card when multiple cf connected
Browse files Browse the repository at this point in the history
When multiple CF were connected the user could end up with multiple services
with the same name without being able to identify the source of that.

Now when multiple CF endpoints are connected a CF endpoint is shown on
each service card so the user can identify where it comes from.

Signed-off-by: Vítor Avelino <vavelino@suse.com>
  • Loading branch information
Vítor Avelino committed May 2, 2019
1 parent 98ec379 commit 571dc55
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<ng-container *ngIf="service?.multipleConnectedEndpoints$ | async">
<a [routerLink]="service?.getCfURL()">{{ service?.getCfName() | async }}</a> /
<a [routerLink]="service?.getCfURL()">{{ service?.getCfName() | async }}</a>
<span *ngIf="service?.getOrgName() | async"> / </span>
</ng-container>
<a [routerLink]="service?.getOrgURL()">{{ service?.getOrgName() | async}}</a> /
<a [routerLink]="service?.getSpaceURL()" [queryParams]="spaceBreadCrumbs">{{ service?.getSpaceName() | async}}</a>
<ng-container *ngIf="service?.getOrgName() | async">
<a [routerLink]="service?.getOrgURL()">{{ service?.getOrgName() | async}}</a>
<span *ngIf="service?.getSpaceName() | async"> / </span>
</ng-container>
<ng-container *ngIf="service?.getSpaceName() | async">
<a [routerLink]="service?.getSpaceURL()" [queryParams]="spaceBreadCrumbs">{{ service?.getSpaceName() | async}}</a>
</ng-container>
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ import { RouterTestingModule } from '@angular/router/testing';

import { createBasicStoreModule } from '../../../../test-framework/store-test-helper';
import { CfOrgSpaceLinksComponent } from './cf-org-space-links.component';
import { of } from 'rxjs';
import { CfOrgSpaceLabelService } from '../../services/cf-org-space-label.service';


describe('CfOrgSpaceLinksComponent', () => {
fdescribe('CfOrgSpaceLinksComponent', () => {
let component: CfOrgSpaceLinksComponent;
let fixture: ComponentFixture<CfOrgSpaceLinksComponent>;
let service;

beforeEach(async(() => {
TestBed.configureTestingModule({
Expand All @@ -21,12 +24,45 @@ describe('CfOrgSpaceLinksComponent', () => {
}));

beforeEach(() => {
service = jasmine.createSpyObj<CfOrgSpaceLabelService>('CfOrgSpaceLabelService', [
'getCfName',
'getCfURL',
'getOrgName',
'getOrgURL',
'getSpaceName',
'getSpaceURL'
]);
service.multipleConnectedEndpoints$ = of(false);
service.getCfName.and.returnValue(of('CfName'));
service.getCfURL.and.returnValue(['/cf/path']);
service.getOrgName.and.returnValue(of('OrgName'));
service.getOrgURL.and.returnValue(['/org/path']);
service.getSpaceName.and.returnValue(of('SpaceName'));
service.getSpaceURL.and.returnValue(['/space/path']);
fixture = TestBed.createComponent(CfOrgSpaceLinksComponent);
component = fixture.componentInstance;
component.service = service;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});

it('should render only org and space', () => {
const element: HTMLElement = fixture.nativeElement;
expect(element.textContent).toEqual('OrgName / SpaceName');
});

describe('with multiple endpoints', () => {
beforeEach(() => {
service.multipleConnectedEndpoints$ = of(true);
fixture.detectChanges();
});

it('should render cf if multiple', () => {
const element: HTMLElement = fixture.nativeElement;
expect(element.textContent).toEqual('CfName / OrgName / SpaceName');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@
<app-meta-card-key>Provider</app-meta-card-key>
<app-meta-card-value>{{ extraInfo?.providerDisplayName }}</app-meta-card-value>
</app-meta-card-item>
<app-meta-card-item *ngIf="cfOrgSpace.multipleConnectedEndpoints$ | async">
<app-meta-card-key>CF Endpoint</app-meta-card-key>
<app-meta-card-value>
<app-cf-org-space-links [service]="cfOrgSpace" [spaceBreadCrumbs]="getSpaceBreadcrumbs()">
</app-cf-org-space-links>
</app-meta-card-value>
</app-meta-card-item>
<app-meta-card-item customStyle="column">
<app-meta-card-key>Tags</app-meta-card-key>
<app-meta-card-value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { CardCell } from '../../../list.types';
import { APIResource } from '../../../../../../../../store/src/types/api.types';
import { AppState } from '../../../../../../../../store/src/app-state';
import { RouterNav } from '../../../../../../../../store/src/actions/router.actions';
import { CfOrgSpaceLabelService } from '../../../../../services/cf-org-space-label.service';

export interface ServiceTag {
value: string;
Expand All @@ -20,8 +21,11 @@ export interface ServiceTag {
styleUrls: ['./cf-service-card.component.scss']
})
export class CfServiceCardComponent extends CardCell<APIResource<IService>> {

serviceEntity: APIResource<IService>;
cfOrgSpace: CfOrgSpaceLabelService;
extraInfo: IServiceExtra;
tags: AppChip<ServiceTag>[] = [];

@Input() disableCardClick = false;

@Input('row')
Expand All @@ -40,12 +44,13 @@ export class CfServiceCardComponent extends CardCell<APIResource<IService>> {
hideClearButton$: observableOf(true)
});
});

if (!this.cfOrgSpace) {
this.cfOrgSpace = new CfOrgSpaceLabelService(this.store, this.serviceEntity.entity.cfGuid);
}
}
}


extraInfo: IServiceExtra;
tags: AppChip<ServiceTag>[] = [];
constructor(private store: Store<AppState>) {
super();
}
Expand All @@ -57,7 +62,6 @@ export class CfServiceCardComponent extends CardCell<APIResource<IService>> {
return this.serviceEntity.entity.label;
}


hasDocumentationUrl() {
return !!(this.getDocumentationUrl());
}
Expand All @@ -68,10 +72,13 @@ export class CfServiceCardComponent extends CardCell<APIResource<IService>> {
hasSupportUrl() {
return !!(this.getSupportUrl());
}

getSupportUrl() {
return this.extraInfo && this.extraInfo.supportUrl;
}

getSpaceBreadcrumbs = () => ({ breadcrumbs: 'services-wall' });

goToServiceInstances = () =>
this.store.dispatch(new RouterNav({
path: ['marketplace', this.serviceEntity.entity.cfGuid, this.serviceEntity.metadata.guid]
Expand Down

0 comments on commit 571dc55

Please sign in to comment.