feat: persist parameters values in FlowSubstep (#1505)

* feat: persist parameters values in FlowSubstep

* feat: add missing import

* feat: use usePrevious hook
This commit is contained in:
kattoczko
2024-06-20 11:13:45 +02:00
committed by GitHub
parent 52994970e6
commit 017a881494

View File

@@ -5,11 +5,13 @@ import Collapse from '@mui/material/Collapse';
import ListItem from '@mui/material/ListItem';
import Button from '@mui/material/Button';
import Stack from '@mui/material/Stack';
import isEqual from 'lodash/isEqual';
import { EditorContext } from 'contexts/Editor';
import FlowSubstepTitle from 'components/FlowSubstepTitle';
import InputCreator from 'components/InputCreator';
import FilterConditions from './FilterConditions';
import { StepPropType, SubstepPropType } from 'propTypes/propTypes';
import { usePrevious } from 'hooks/usePrevious';
function FlowSubstep(props) {
const {
@@ -19,13 +21,27 @@ function FlowSubstep(props) {
onCollapse,
onSubmit,
step,
onChange,
} = props;
const prevStep = usePrevious(step);
const { name, arguments: args } = substep;
const editorContext = React.useContext(EditorContext);
const formContext = useFormContext();
const validationStatus = formContext.formState.isValid;
const onToggle = expanded ? onCollapse : onExpand;
React.useEffect(() => {
return () => {
if (!isEqual(prevStep?.parameters, formContext.getValues('parameters'))) {
onChange({
step: { ...step, parameters: formContext.getValues('parameters') },
});
}
};
}, []);
return (
<React.Fragment>
<FlowSubstepTitle