11import * as React from 'react' ;
2- import { FormGroup , Popover , Icon , Flex , FlexItem } from '@patternfly/react-core' ;
3- import { OutlinedQuestionCircleIcon } from '@patternfly/react-icons' ;
2+ import {
3+ FormGroup ,
4+ Popover ,
5+ Icon ,
6+ Flex ,
7+ FlexItem ,
8+ FormHelperText ,
9+ HelperText ,
10+ HelperTextItem ,
11+ } from '@patternfly/react-core' ;
12+ import { OutlinedQuestionCircleIcon , ExclamationTriangleIcon } from '@patternfly/react-icons' ;
413import NumberInputWrapper from '#~/components/NumberInputWrapper' ;
514import { normalizeBetween } from '#~/utilities/utils' ;
615
@@ -27,6 +36,7 @@ const ReplicaFormGroup: React.FC<ReplicaSectionProps> = ({
2736 onMaxChange,
2837} ) => {
2938 const maxLimit = showMinMax ? upperLimit : maxValue ;
39+ const maxLessThanMin = ! showMinMax && maxValue < value ;
3040
3141 return (
3242 < FormGroup
@@ -87,16 +97,32 @@ const ReplicaFormGroup: React.FC<ReplicaSectionProps> = ({
8797 data-testid = "max-replicas"
8898 >
8999 < NumberInputWrapper
90- min = { value }
100+ min = { lowerLimit }
91101 max = { upperLimit }
92102 value = { maxValue }
103+ validated = { maxLessThanMin ? 'warning' : 'default' }
104+ minusBtnProps = { { isDisabled : maxValue <= value } }
105+ onBlur = { ( ) => {
106+ if ( maxValue < value ) {
107+ onMaxChange ( value ) ;
108+ }
109+ } }
93110 onChange = { ( val ) => {
94111 const newSize = val === undefined ? 0 : Number ( val ) ;
95- if ( ! Number . isNaN ( newSize ) && newSize <= upperLimit && newSize >= value ) {
96- onMaxChange ( normalizeBetween ( newSize , value , upperLimit ) ) ;
112+ if ( ! Number . isNaN ( newSize ) && newSize <= upperLimit ) {
113+ onMaxChange ( normalizeBetween ( newSize , lowerLimit , upperLimit ) ) ;
97114 }
98115 } }
99116 />
117+ { maxLessThanMin && (
118+ < FormHelperText >
119+ < HelperText >
120+ < HelperTextItem icon = { < ExclamationTriangleIcon /> } variant = "warning" >
121+ Maximum replicas must be greater than or equal to minimum replicas.
122+ </ HelperTextItem >
123+ </ HelperText >
124+ </ FormHelperText >
125+ ) }
100126 </ FormGroup >
101127 </ FlexItem >
102128 ) }
0 commit comments