import type { FormikProps } from 'formik'; import React from 'react'; import { FormikFormField, NumberInput, SelectInput, TextInput } from '@spinnaker/core'; import type { IAmazonClassicLoadBalancerUpsertCommand } from '../../../domain'; export interface IHealthCheckProps { formik: FormikProps; } export class HealthCheck extends React.Component { public requiresHealthCheckPath(): boolean { const { values } = this.props.formik; return values.healthCheckProtocol && values.healthCheckProtocol.indexOf('HTTP') === 0; } private healthCheckPathChanged = (value: string) => { if (value && value.indexOf('/') !== 0) { this.props.formik.setFieldValue('healthCheckPath', `/${value}`); } }; public render() { return (
Ping
Protocol Port {this.requiresHealthCheckPath() && Path}
} /> } /> {this.requiresHealthCheckPath() && ( } required={true} onChange={this.healthCheckPathChanged} /> )}
); } }