Skip to content

Commit

Permalink
Frontend: Don't allow -ve values for numReplicas
Browse files Browse the repository at this point in the history
  • Loading branch information
ashu8912 committed Jul 3, 2024
1 parent b057039 commit 836bd9b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions frontend/src/components/common/Resource/ScaleButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ function ScaleDialog(props: ScaleDialogProps) {
<Fab
size="small"
color="primary"
onClick={() => setNumReplicas(numReplicas => numReplicas - 1)}
onClick={() =>
setNumReplicas(numReplicas => (numReplicas <= 0 ? 0 : numReplicas - 1))
}
aria-label={t('translation|Decrement')}
>
<Icon icon="mdi:minus" width="22px" />
Expand All @@ -172,7 +174,11 @@ function ScaleDialog(props: ScaleDialogProps) {
type="number"
value={numReplicas}
sx={{ marginLeft: '6px', marginRight: '6px' }}
onChange={e => setNumReplicas(Number(e.target.value))}
onChange={e =>
Number(e.target.value) <= 0
? setNumReplicas(0)
: setNumReplicas(Number(e.target.value))
}
aria-labelledby={desiredNumReplicasLabel}
inputProps={{
min: 0,
Expand Down

0 comments on commit 836bd9b

Please sign in to comment.