import type { FormikProps } from 'formik'; import { Field } from 'formik'; import React from 'react'; import type { IServerGroupCommand, IWizardPageComponent } from '@spinnaker/core'; import { parseNum } from '@spinnaker/core'; import { CapacitySelector } from '../capacity/CapacitySelector'; import { MinMaxDesired } from '../capacity/MinMaxDesired'; import type { IAmazonServerGroupCommand } from '../../serverGroupConfiguration.service'; export interface IServerGroupCapacityProps { formik: FormikProps; } export class ServerGroupCapacity extends React.Component implements IWizardPageComponent { public validate(values: IServerGroupCommand): { [key: string]: string } { const errors: { [key: string]: string } = {}; if ( parseNum(values.capacity.min) < 0 || parseNum(values.capacity.max) < 0 || parseNum(values.capacity.desired) < 0 ) { errors.capacity = 'Capacity min, max, and desired all have to be non-negative values.'; } const amazonValues = values as IAmazonServerGroupCommand; if ( amazonValues.targetHealthyDeployPercentage === undefined || amazonValues.targetHealthyDeployPercentage === null ) { errors.targetHealthyDeployPercentage = 'Target Healthy Deploy Percentage required.'; } return errors; } public render() { const { setFieldValue, values } = this.props.formik; return (
Consider deployment successful when{' '} {' '} percent of instances are healthy.
); } }