Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only show + icon when we have at least one connected CF #3211

Merged
merged 5 commits into from
Nov 22, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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,10 +1,12 @@
<app-page-header [endpointIds$]="cfIds$">
<h1>Services</h1>
<div class="page-header-right">
<ng-container *appUserPermission="canCreateServiceInstance">
<button mat-icon-button [routerLink]="'/services/new/'">
<mat-icon>add</mat-icon>
</button>
<ng-container *ngIf="(haveConnectedCf$ | async)">
<ng-container *appUserPermission="canCreateServiceInstance">
<button mat-icon-button [routerLink]="'/services/new/'">
<mat-icon>add</mat-icon>
</button>
</ng-container>
</ng-container>
</div>
</app-page-header>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ import { serviceInstancesSchemaKey } from '../../../store/helpers/entity-factory
]
})
export class ServicesWallComponent implements OnDestroy {

public haveConnectedCf$: Observable<boolean>;

canCreateServiceInstance: CurrentUserPermissions;
initCfOrgSpaceService: Subscription;
cfIds$: Observable<string[]>;
Expand All @@ -46,6 +49,11 @@ export class ServicesWallComponent implements OnDestroy {
this.cfOrgSpaceService,
serviceInstancesSchemaKey,
'all').subscribe();

this.haveConnectedCf$ = cloudFoundryService.cFEndpoints$.pipe(
map(endpoints => endpoints.map(endpoint => endpoint.connectionStatus === 'connected')),
map(connected => connected.reduce((a, v) => a || v, false))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like !!connected.find(isConnected => isConnected) would be more efficient.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or even just !!endpoints.find(endpoint => endpoint.connectionStatus === 'connected'))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah - I just used what we had in the CF page - but can have a look at simplifying

);
}

ngOnDestroy(): void {
Expand Down