-
Notifications
You must be signed in to change notification settings - Fork 39
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
✨ Applications: Update Notification and refactors update/create modal #1207
✨ Applications: Update Notification and refactors update/create modal #1207
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #1207 +/- ##
=======================================
Coverage 44.10% 44.10%
=======================================
Files 177 177
Lines 4501 4507 +6
Branches 1007 1007
=======================================
+ Hits 1985 1988 +3
- Misses 2505 2508 +3
Partials 11 11
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
const onCreateUpdateApplicationSuccess = (response: any) => { | ||
onSaved(response); | ||
const onCreateUpdateApplicationSuccess = ( | ||
response: AxiosResponse<Application> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could use our custom useUpdateApplicationMutation & useCreateApplicationMutation hooks to 1) narrow this type to something like "appName: string" & 2) Pass the name from the mutation function variable object param to the success handler.
e.g.
export const useUpdateApplicationMutation = (
onSuccess: (appName: string) => void,
onError: (err: AxiosError) => void
) => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: ({ application }: { application: Application }) =>
updateApplication(application),
onSuccess: (_, vars) => {
onSuccess(vars.application.name);
queryClient.invalidateQueries([ApplicationsQueryKey]);
},
onError: onError,
});
};
& then in the success handler:
const onCreateUpdateApplicationSuccess = (appName: string) => {
if (application) {
pushNotification({
title: t("toastr.success.createWhat", {
type: t("terms.application"),
what: appName,
}),
variant: "success",
});
} else {
title: t("toastr.success.saveWhat", {
type: t("terms.application"),
what: appName,
}),
variant: "success",
}
onClose();
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ibolton336, generalizing this approach is, I believe out of scope of this PR, please let's discuss how we are going to do that here : #1214.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Np - we can address the missing entity name in the update notification later. However, I think it would make more sense to have two separate handlers for create / update here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ibolton336, I agree it makes sense to have separate handlers. Let me change that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See inline.
Signed-off-by: Gilles Dubreuil <[email protected]>
Signed-off-by: Gilles Dubreuil <[email protected]>
Signed-off-by: Gilles Dubreuil <[email protected]>
While resolving the related notification issues (see associated MTA-1024) this refactors create/update modal.
Includes following changes :
Partially address https://issues.redhat.com/browse/MTA-1024