Skip to content

Commit

Permalink
Handle endpoint types that do no support connect (#3596)
Browse files Browse the repository at this point in the history
- Also add space between failed register message and details
  • Loading branch information
richard-cox authored and nwmac committed Jun 5, 2019
1 parent 212abca commit f610905
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AfterContentInit, Component, ViewChild } from '@angular/core';
import { AfterContentInit, Component, Input, ViewChild } from '@angular/core';
import { NgForm, NgModel } from '@angular/forms';
import { ActivatedRoute } from '@angular/router';
import { Store } from '@ngrx/store';
Expand Down Expand Up @@ -28,6 +28,8 @@ import { getEndpointType, getFullEndpointApiUrl } from '../../endpoint-helpers';
})
export class CreateEndpointCfStep1Component implements IStepperStep, AfterContentInit {

@Input() finalStep: boolean;

existingEndpoints: Observable<{
names: string[],
urls: string[],
Expand Down Expand Up @@ -111,10 +113,11 @@ export class CreateEndpointCfStep1Component implements IStepperStep, AfterConten
if (!result.error) {
this.store.dispatch(new ShowSnackBar(`Successfully registered '${this.nameField.value}'`));
}
const success = !result.error;
return {
success: !result.error,
redirect: false,
message: !result.error ? '' : result.message,
success,
redirect: success && this.finalStep,
message: success ? '' : result.message,
data
};
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ <h1>Register a new Endpoint</h1>

<app-steppers cancel="/endpoints">
<app-step [title]="'Register'" [valid]="step1.validate | async" [onNext]="step1.onNext" [nextButtonText]="'Register'">
<app-create-endpoint-cf-step-1 #step1></app-create-endpoint-cf-step-1>
<app-create-endpoint-cf-step-1 #step1 [finalStep]="!showConnectStep"></app-create-endpoint-cf-step-1>
</app-step>
<app-step [title]="'Connect (Optional)'" [valid]="connect.doConnect ? connect.valid : true" [onNext]="connect.onNext"
[onEnter]="connect.onEnter" [disablePrevious]="true" [hideCloseButton]="true"
<app-step *ngIf="showConnectStep" [title]="'Connect (Optional)'" [valid]="connect.doConnect ? connect.valid : true"
[onNext]="connect.onNext" [onEnter]="connect.onEnter" [disablePrevious]="true" [hideCloseButton]="true"
[finishButtonText]="connect.doConnect ? 'Connect' : 'Finish'">
<app-create-endpoint-connect #connect></app-create-endpoint-connect>
</app-step>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
import { Component } from '@angular/core';
import { ActivatedRoute } from '@angular/router';

import { getIdFromRoute } from '../../cloud-foundry/cf.helpers';
import { getEndpointType } from '../endpoint-helpers';

@Component({
selector: 'app-create-endpoint',
templateUrl: './create-endpoint.component.html',
styleUrls: ['./create-endpoint.component.scss']
})
export class CreateEndpointComponent {

showConnectStep: boolean;

constructor(activatedRoute: ActivatedRoute) {
const epType = getIdFromRoute(activatedRoute, 'type');
const epSubType = getIdFromRoute(activatedRoute, 'subtype');
const endpoint = getEndpointType(epType, epSubType);
this.showConnectStep = !endpoint.doesNotSupportConnect ? endpoint.authTypes && !!endpoint.authTypes.length : false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export class EndpointsEffect {
private processRegisterError(e: HttpErrorResponse): string {
let message = 'There was a problem creating the endpoint. ' +
`Please ensure the endpoint address is correct and try again` +
`${e.error.error ? '(' + e.error.error + ').' : '.'}`;
`${e.error.error ? ' (' + e.error.error + ').' : '.'}`;
if (e.status === 403) {
message = `${e.error.error}. Please check \"Skip SSL validation for the endpoint\" if the certificate issuer is trusted"`;
}
Expand Down

0 comments on commit f610905

Please sign in to comment.