Skip to content

Commit

Permalink
Add form alert
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewbaldwin44 committed Oct 3, 2024
1 parent 832d192 commit fe71f63
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions locust/webui/src/components/SwarmForm/SwarmForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import {
Accordion,
AccordionDetails,
AccordionSummary,
Alert,
Box,
Button,
Container,
TextField,
Typography,
} from '@mui/material';
import { AlertColor } from '@mui/material/Alert';
import { connect } from 'react-redux';

import Form from 'components/Form/Form';
Expand Down Expand Up @@ -46,7 +48,13 @@ interface ISwarmForm
| 'showUserclassPicker'
| 'spawnRate'
| 'numUsers'
> {}
> {
alert?: {
level?: AlertColor;
message: string;
};
isDisabled?: boolean;
}

function SwarmForm({
availableShapeClasses,
Expand All @@ -60,6 +68,8 @@ function SwarmForm({
setSwarm,
showUserclassPicker,
spawnRate,
alert,
isDisabled = false,
}: ISwarmForm) {
const [startSwarm] = useStartSwarmMutation();
const [selectedUserClasses, setSelectedUserClasses] = useState(availableUserClasses);
Expand Down Expand Up @@ -143,7 +153,8 @@ function SwarmForm({
</AccordionDetails>
</Accordion>
{!isEmpty(extraOptions) && <CustomParameters extraOptions={extraOptions} />}
<Button size='large' type='submit' variant='contained'>
{alert && <Alert severity={alert.level || 'info'}>{alert.message}</Alert>}
<Button disabled={isDisabled} size='large' type='submit' variant='contained'>
Start
</Button>
</Box>
Expand Down

0 comments on commit fe71f63

Please sign in to comment.