Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webui Add Form Alert #2922

Merged
merged 1 commit into from
Oct 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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