-
Notifications
You must be signed in to change notification settings - Fork 397
[ui-core] add put and path methods in api utils and useSaveData hook #4199
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
base: master
Are you sure you want to change the base?
Conversation
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.
Pull Request Overview
This pull request adds support for PUT and PATCH HTTP methods to the existing API utilities and useSaveData hook, expanding beyond the original POST-only functionality. The backend has started supporting these additional HTTP methods, and this change provides the frontend infrastructure to utilize them.
- Adds
put
andpatch
functions to the API utilities following the same pattern as the existingpost
function - Extends the
useSaveData
hook to support method selection via anHttpMethod
enum - Maintains backward compatibility by defaulting to POST method when no method is specified
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
desktop/core/src/desktop/js/api/utils.ts |
Implements put and patch functions with the same structure as existing post function |
desktop/core/src/desktop/js/utils/hooks/useSaveData/useSaveData.ts |
Adds HTTP method selection capability and refactors to support multiple request methods |
desktop/core/src/desktop/js/utils/hooks/useSaveData/useSaveData.test.tsx |
Adds comprehensive test coverage for the new HTTP method functionality |
@@ -264,6 +264,86 @@ export const get = <T, U = unknown, E = AxiosError<DefaultApiResponse>>( | |||
}); | |||
}); | |||
|
|||
export const put = <T, U = unknown, E = AxiosError>( |
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 put
and patch
functions are nearly identical to the existing post
function with only the HTTP method differing. Consider extracting the common logic into a shared helper function to reduce code duplication and improve maintainability.
Copilot uses AI. Check for mistakes.
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 agree with this comment. make sure we don't break the existing functionality as it is heavily used.
✅ Test files were modified. Ensure that the tests cover all relevant changes. ✅ |
What changes were proposed in this pull request?
How was this patch tested?
Please review Hue Contributing Guide before opening a pull request.