feat(ui): add model update for success/failure handling

This commit is contained in:
psychedelicious 2023-07-14 17:35:45 +10:00
parent d8437d3036
commit 48a8bd4985
2 changed files with 48 additions and 42 deletions

View File

@ -74,27 +74,30 @@ export default function CheckpointModelEdit(props: CheckpointModelEditProps) {
model_name: retrievedModel.model_name,
body: values,
};
updateMainModel(responseBody);
if (error) {
dispatch(
addToast(
makeToast({
title: t('modelManager.modelUpdateFailed'),
status: 'success',
})
)
);
}
dispatch(
addToast(
makeToast({
title: t('modelManager.modelUpdated'),
status: 'success',
})
)
);
updateMainModel(responseBody)
.unwrap()
.then((payload) => {
checkpointEditForm.setValues(payload as CheckpointModelConfig);
dispatch(
addToast(
makeToast({
title: t('modelManager.modelUpdated'),
status: 'success',
})
)
);
})
.catch((error) => {
checkpointEditForm.reset();
dispatch(
addToast(
makeToast({
title: t('modelManager.modelUpdateFailed'),
status: 'error',
})
)
);
});
};
return modelToEdit ? (

View File

@ -71,27 +71,30 @@ export default function DiffusersModelEdit(props: DiffusersModelEditProps) {
model_name: retrievedModel.model_name,
body: values,
};
updateMainModel(responseBody);
if (error) {
dispatch(
addToast(
makeToast({
title: t('modelManager.modelUpdateFailed'),
status: 'error',
})
)
);
}
dispatch(
addToast(
makeToast({
title: t('modelManager.modelUpdated'),
status: 'success',
})
)
);
updateMainModel(responseBody)
.unwrap()
.then((payload) => {
diffusersEditForm.setValues(payload as DiffusersModelConfig);
dispatch(
addToast(
makeToast({
title: t('modelManager.modelUpdated'),
status: 'success',
})
)
);
})
.catch((error) => {
diffusersEditForm.reset();
dispatch(
addToast(
makeToast({
title: t('modelManager.modelUpdateFailed'),
status: 'error',
})
)
);
});
};
return modelToEdit ? (