-
Notifications
You must be signed in to change notification settings - Fork 43
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
✨ BusinessServices: Update Notification and refactors update/create modal and queries #1210
✨ BusinessServices: Update Notification and refactors update/create modal and queries #1210
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #1210 +/- ##
==========================================
- Coverage 44.10% 44.02% -0.08%
==========================================
Files 177 177
Lines 4501 4511 +10
Branches 1007 1007
==========================================
+ Hits 1985 1986 +1
- Misses 2505 2514 +9
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. |
): Promise<BusinessService> => axios.delete(`${BUSINESS_SERVICES}/${id}`); | ||
|
||
export const createBusinessService = ( | ||
obj: New<BusinessService> |
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 would like to see a more descriptive param name 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, the entire rest.ts file is using obj as parameter for passing the payload.
I don't see the gain to explicitly name the payload but that might be opinionated.
And if we do that then we're going to be inconsistent across the file.
onClose(); | ||
}; | ||
|
||
const onUpdateBusinessServiceSuccess = ( |
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.
We should be using a combined success handler here like we are for applications. Or at least we should agree on a style and be consistent across slices of the app.
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.
The Applications case is actually more an exception.
To have combined success handlers for both create/edit means both needs to provide the name of the modified resource which I believe is out of scope. To discuss the matter, please seee #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.
Thx. I read the issue but I still don't see why the application handler is a special case. Maybe it would just be easier to move the on create / on update success handlers to their own functions for the applications? Just for consistency.
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,
you're right, the Application isn't a special case, I confused it with the MigrationTargets where we have to pass the reference to scroll down the page.
So revisiting this, we want to be consistent and have separate handlers, I'm changing the handlers in #1207.
We might eventually revisit that, consistently of course, or not once we decide to pass along the object name to the save/edit.
}; | ||
|
||
export const useUpdateBusinessServiceMutation = ( | ||
onSuccess: (res: any) => void, |
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.
onSuccess: (res: any) => void, | |
onSuccess: (businessServiceName: string) => void, |
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, all queries are using res
as parameter for onSuccess().
Therefore I don't see the value of such change and the gain in the meaning.
I'm not necessarily against it meanwhile if we decide such change then we'd have to make it consistent across the all queries.
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 - My main gripe here was the use of the 'any' type. Seems like since we are working on tech debt, it would be a good time to address. And by narrowing what we are passing from the response ( we aren't using the entire response), we can reduce complexity in the handlers which are using this param up the chain.
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, you had a good point with the any
type.
This isn't the case anymore as there is no need to pass anything for now (see update) until we eventually address that later if we decide to pass object name to update queries.
onSuccess: (res) => { | ||
onSuccess(res); |
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.
onSuccess: (res) => { | |
onSuccess(res); | |
onSuccess: (_, vars) => { | |
onSuccess(vars.businessService.name); |
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.
This seems to be out of scope, please see why here #1214 to following-up.
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 don't mind not doing this. Just seemed like an easy solution that would help standardize notifications with more info.
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 but I would like to have an agreed overall approach to address this across the board.
client/src/app/pages/controls/business-services/business-services.tsx
Outdated
Show resolved
Hide resolved
@@ -35,7 +35,7 @@ export interface FormValues { | |||
} | |||
|
|||
export interface BusinessServiceFormProps { | |||
businessService?: BusinessService; | |||
businessService: BusinessService | null; |
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.
This seems to go against what we have done across the app for optional props. Having the prop be undefined makes sense as it is omitted for new businessServices & doesn't need to be explicitly set.
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 thought about that but this isn't an optional prop anymore as it was before.
The Form requires the businessService
prop.
The modal state value provides either the object value itself or null:
const businessServiceToUpdate =
createUpdateModalState !== "create" ? createUpdateModalState : null;
Signed-off-by: Gilles Dubreuil <gdubreui@redhat.com>
Signed-off-by: Gilles Dubreuil <gdubreui@redhat.com>
Signed-off-by: Gilles Dubreuil <gdubreui@redhat.com>
While resolving the related notification issues (see associated MTA-1024) this also refactors create/update modal and tries to bring more consistency.
Includes following changes :
Partially address https://issues.redhat.com/browse/MTA-1024