Skip to content

[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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ramprasadagarwal
Copy link
Collaborator

What changes were proposed in this pull request?

  • Backend has started supporting PUT and PATCH methods in APIs.
  • Adding the methods in api util and in useSaveData hook

How was this patch tested?

  • Added tests

Please review Hue Contributing Guide before opening a pull request.

@ramprasadagarwal ramprasadagarwal self-assigned this Jul 22, 2025
@Copilot Copilot AI review requested due to automatic review settings July 22, 2025 10:25
Copy link
Contributor

@Copilot Copilot AI left a 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 and patch functions to the API utilities following the same pattern as the existing post function
  • Extends the useSaveData hook to support method selection via an HttpMethod 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>(
Copy link
Preview

Copilot AI Jul 22, 2025

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.

Copy link
Collaborator

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.

Copy link

✅ Test files were modified. Ensure that the tests cover all relevant changes. ✅

Copy link

UI Code Coverage Report

Lines Statements Branches Functions
Coverage: 33%
39.44% (30819/78127) 31.17% (14349/46028) 24.7% (2215/8967)

Copy link

Coverage

Backend Code Coverage Report •
FileStmtsMissCoverMissing
TOTAL547002741349% 
report-only-changed-files is enabled. No files were changed during this commit :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants