forked from langflow-ai/langflow
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: change downloadFolders requests to use useQuery hook (langf…
…low-ai#2920) * ✨ (sidebarComponent): Add support for downloading folders in the sidebar component to allow users to download folder data as JSON files 🔧 (sidebarComponent): Remove unused import and function related to downloading folders to clean up the codebase 📝 (use-get-download-folders): Add a new function to handle downloading folders from the API in a separate file for better code organization ♻️ (MainPage/services): Remove unused functions related to downloading and uploading flows from folders to simplify the services file and improve maintainability 🔧 (foldersStore): Remove unused import and function related to uploading flows from folders to clean up the codebase * 📝 (sideBarFolderButtons/index.tsx): add error handling logic to display error message when downloading folder fails * update error message --------- Co-authored-by: anovazzi1 <[email protected]> (cherry picked from commit 44ffe8e)
- Loading branch information
1 parent
f7128a3
commit 97b8d9c
Showing
5 changed files
with
59 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/frontend/src/controllers/API/queries/folders/use-get-download-folders.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { useMutationFunctionType } from "@/types/api"; | ||
import { api } from "../../api"; | ||
import { getURL } from "../../helpers/constants"; | ||
import { UseRequestProcessor } from "../../services/request-processor"; | ||
|
||
interface IGetDownloadFolders { | ||
folderId: string; | ||
} | ||
|
||
export const useGetDownloadFolders: useMutationFunctionType< | ||
undefined, | ||
IGetDownloadFolders | ||
> = (options?) => { | ||
const { mutate } = UseRequestProcessor(); | ||
|
||
const downloadFoldersFn = async ( | ||
data: IGetDownloadFolders, | ||
): Promise<void> => { | ||
const res = await api.get(`${getURL("FOLDERS")}/download/${data.folderId}`); | ||
return res.data; | ||
}; | ||
|
||
const mutation = mutate(["useGetFolders"], downloadFoldersFn, options); | ||
return mutation; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters