CEC-4499: add bulk update configs support (#357)

* add taskRunner util

* add bulk update config flow
This commit is contained in:
Tristan Timblin
2023-06-14 13:53:32 -04:00
committed by GitHub
parent a68c00b4ad
commit de1a5dcd2d
11 changed files with 621 additions and 7 deletions

View File

@@ -0,0 +1,92 @@
import React from "react";
import {
Button,
Checkbox,
Dialog,
DialogTitle,
DialogContentText,
DialogActions,
DialogContent,
FormGroup,
FormControlLabel,
} from '@material-ui/core';
const TransformModal = ({
open,
close,
title,
body,
data,
setData,
submit
}) => {
const handleClick = () => {
close();
submit();
};
const handleChange = (key) => {
setData((data) => {
const {[key]: toChange, ...rest} = data;
toChange.value = !toChange.value;
return {
[key]: toChange,
...rest
};
});
}
return (
<Dialog
open={open}
onClose={close}
>
<DialogTitle id="alert-dialog-title">
{title}
</DialogTitle>
<DialogContent>
{body && <DialogContentText>
{body}
</DialogContentText>}
<FormGroup>
{Object.entries(data).map((([key, value]) => {
switch (value.type) {
case "boolean":
return (
<FormControlLabel
key={key}
label={value.label}
control={
<Checkbox
checked={data[key].value}
onChange={() => handleChange(key)}
/>
}
/>
)
default:
return <></>;
}
}))}
</FormGroup>
</DialogContent>
<DialogActions>
<Button
onClick={close}
>
Cancel
</Button>
<Button
variant="contained"
color="secondary"
onClick={handleClick}
autoFocus
>
Submit
</Button>
</DialogActions>
</Dialog>
);
}
export default TransformModal;