Skip to content

Commit bc6cf26

Browse files
author
William Hou
committed
correct validation math in ui
1 parent cd3336f commit bc6cf26

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

SingularityUI/app/components/common/modalButtons/ScaleModal.jsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,14 @@ class ScaleModal extends Component {
100100
{
101101
name: 'largeScaleDownAcknowledged',
102102
type: FormModal.INPUT_TYPES.BOOLEAN,
103-
label: 'Explciit acknowledgement of large (>=10) scale down',
103+
label: 'Explciit acknowledgement of large scale down (less than -10 or 1/2 of previous)',
104104
defaultValue: false,
105-
dependsOnFormState: data => (this.props.currentInstances - data.instances) >= 10,
105+
dependsOnFormState: data => {
106+
const scaleDownExceedsAbsoluteMax = (this.props.currentInstances - data.instances) > 10;
107+
const scaleDownExceedsRelativeMax = (this.props.currentInstances > 10) && (data.instances < (this.props.currentInstances / 2));
108+
// window.config flag in case the numbers change at some point
109+
return scaleDownExceedsAbsoluteMax || scaleDownExceedsRelativeMax || window.config.largeScaleDownAcknowledged;
110+
},
106111
}
107112
]}>
108113
<p>Scaling request:</p>

0 commit comments

Comments
 (0)