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

🐛 Reset wizard form after analysis run #1267

Merged
merged 1 commit into from
Aug 8, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,6 @@ export const AnalysisWizard: React.FC<IAnalysisWizard> = ({
const [stepIdReached, setStepIdReached] = React.useState(1);
const isMutating = useIsMutating();

React.useEffect(() => {
if (!currentTaskgroup) {
createTaskgroup(defaultTaskgroup);
}
}, []);

const onCreateTaskgroupSuccess = (data: Taskgroup) => {
setCurrentTaskgroup(data);
};
Expand Down Expand Up @@ -287,12 +281,22 @@ export const AnalysisWizard: React.FC<IAnalysisWizard> = ({

const isModeValid = applications.every((app) => isModeSupported(app, mode));

const handleCancel = () => {
if (currentTaskgroup && currentTaskgroup.id) {
deleteTaskgroup(currentTaskgroup.id);
}
setCurrentTaskgroup(null);
reset();
onClose();
};

const onSubmit = (fieldValues: AnalysisWizardFormValues) => {
if (currentTaskgroup) {
const taskgroup = setupTaskgroup(currentTaskgroup, fieldValues);

submitTaskgroup(taskgroup);
}
setCurrentTaskgroup(null);
reset();
onClose();
};

Expand All @@ -301,13 +305,11 @@ export const AnalysisWizard: React.FC<IAnalysisWizard> = ({
{ prevId, prevName }
) => {
if (id && stepIdReached < (id as number)) setStepIdReached(id as number);
};

const handleClose = () => {
reset();
if (currentTaskgroup && currentTaskgroup.id)
deleteTaskgroup(currentTaskgroup.id);
onClose();
if (id === StepId.SetTargets) {
if (!currentTaskgroup) {
createTaskgroup(defaultTaskgroup);
}
}
};

const analyzableApplications = useAnalyzableApplications(applications, mode);
Expand Down Expand Up @@ -410,7 +412,7 @@ export const AnalysisWizard: React.FC<IAnalysisWizard> = ({
onBack={onMove}
onSave={handleSubmit(onSubmit)}
onClose={() => {
handleClose();
handleCancel();
}}
/>
</FormProvider>
Expand Down