fix(striker-ui): disable add network when limit(s) reached

main
Tsu-ba-me 2 years ago
parent 7a66b1417c
commit a02e1a76fb
  1. 6
      striker-ui/components/IconButton/IconButton.tsx
  2. 10
      striker-ui/components/NetworkInitForm.tsx

@ -2,11 +2,13 @@ import { FC } from 'react';
import { import {
IconButton as MUIIconButton, IconButton as MUIIconButton,
IconButtonProps as MUIIconButtonProps, IconButtonProps as MUIIconButtonProps,
inputClasses as muiInputClasses,
} from '@mui/material'; } from '@mui/material';
import { import {
BLACK, BLACK,
BORDER_RADIUS, BORDER_RADIUS,
DISABLED,
GREY, GREY,
TEXT, TEXT,
} from '../../lib/consts/DEFAULT_THEME'; } from '../../lib/consts/DEFAULT_THEME';
@ -30,6 +32,10 @@ const IconButton: FC<IconButtonProps> = ({
backgroundColor: TEXT, backgroundColor: TEXT,
}, },
[`&.${muiInputClasses.disabled}`]: {
backgroundColor: DISABLED,
},
...sx, ...sx,
}, },
}} }}

@ -410,7 +410,15 @@ const NetworkInitForm: FC = () => {
justifyContent: 'center', justifyContent: 'center',
}} }}
> >
<IconButton onClick={createNetwork}> <IconButton
disabled={
networkInputs.length >= networkInterfaces.length ||
Object.values(networkInterfaceInputMap).every(
({ isApplied }) => isApplied,
)
}
onClick={createNetwork}
>
<MUIAddIcon /> <MUIAddIcon />
</IconButton> </IconButton>
</MUIBox> </MUIBox>

Loading…
Cancel
Save