-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: folder fetching, folder sidebar and fix various issues (#3344)
* Removed unused code * Separated folder sidebar from common sidebar * Removed useOnFileDrop from common sidebar * Added folderSidebarComponent that fetches the folders * Added useOnFileDrop and SIdebarFoldersButton * Make auth context not get folders * Make delete folder refetch get folders * Make folder mutations refetch the getFolder * Create getFolder query * Removed unused functions from useFolderStore * Make isLoading from application depend only on flows * Make main page not refetch folders * Change types of folders store * removed getFolders refetch on duplicateFolders * Added loading from query into ComponentsComponent * Made the flow page get the flows and types if they're not available * Made the loading be the isLoading only * Removed unused function * Make cards appear even if it didnt load * Removed setLoading of various pages * Fixed loading happening every time the flow changes * Added skeleton instead of loading on folders * Added routing to contain folderId on both flows and initial page * remove redirect of useFileDrop * remove folderid getting from state * removed setAllFlows * chore: Remove unused variables and functions in useDuplicateFlows hook * Added refetch of folders when the flow is deleted or added * Changed redirectToLastLocation to redirect to last folder also * Added upload flow to folder tanstack and refetched folders on upload * Added loading of current folder on display of empty component * Removed refetching folder on file drop * Removed unused code * Fixed add new flow from header not redirecting correctly * Fixed unused code * Added undefined on setting current flow as empty * Added disable top bar and make it be displayed on the top of an empty folder * Fixed select all checked when deleting all flows
- Loading branch information
1 parent
1d8a24e
commit 7658954
Showing
44 changed files
with
540 additions
and
657 deletions.
There are no files selected for viewing
321 changes: 155 additions & 166 deletions
321
...components/sideBarFolderButtons/index.tsx → ...components/sideBarFolderButtons/index.tsx
Large diffs are not rendered by default.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
...frontend/src/components/folderSidebarComponent/components/sidebarFolderSkeleton/index.tsx
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,10 @@ | ||
import { Skeleton } from "@/components/ui/skeleton"; | ||
|
||
export function SidebarFolderSkeleton() { | ||
return ( | ||
<div className="flex h-10 w-full shrink-0 animate-pulse cursor-pointer items-center gap-4 rounded-md border bg-background px-4 opacity-100 lg:min-w-full"> | ||
<Skeleton className="h-3 w-4 rounded-full" /> | ||
<Skeleton className="h-3 w-[40%]" /> | ||
</div> | ||
); | ||
} |
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
38 changes: 38 additions & 0 deletions
38
src/frontend/src/components/folderSidebarComponent/index.tsx
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,38 @@ | ||
import { useGetFoldersQuery } from "@/controllers/API/queries/folders/use-get-folders"; | ||
import { useLocation } from "react-router-dom"; | ||
import { FolderType } from "../../pages/MainPage/entities"; | ||
import { cn } from "../../utils/utils"; | ||
import HorizontalScrollFadeComponent from "../horizontalScrollFadeComponent"; | ||
import SideBarFoldersButtonsComponent from "./components/sideBarFolderButtons"; | ||
|
||
type SidebarNavProps = { | ||
handleChangeFolder?: (id: string) => void; | ||
handleDeleteFolder?: (item: FolderType) => void; | ||
className?: string; | ||
}; | ||
|
||
export default function FolderSidebarNav({ | ||
className, | ||
handleChangeFolder, | ||
handleDeleteFolder, | ||
...props | ||
}: SidebarNavProps) { | ||
const location = useLocation(); | ||
const pathname = location.pathname; | ||
|
||
const { data: folders, isPending } = useGetFoldersQuery(); | ||
|
||
return ( | ||
<nav className={cn(className)} {...props}> | ||
<HorizontalScrollFadeComponent> | ||
<SideBarFoldersButtonsComponent | ||
loading={isPending || !folders} | ||
pathname={pathname} | ||
handleChangeFolder={handleChangeFolder} | ||
handleDeleteFolder={handleDeleteFolder} | ||
folders={folders} | ||
/> | ||
</HorizontalScrollFadeComponent> | ||
</nav> | ||
); | ||
} |
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
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
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
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
30 changes: 30 additions & 0 deletions
30
src/frontend/src/controllers/API/queries/folders/use-get-folder.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,30 @@ | ||
import { FolderType } from "@/pages/MainPage/entities"; | ||
import { useQueryFunctionType } from "@/types/api"; | ||
import { api } from "../../api"; | ||
import { getURL } from "../../helpers/constants"; | ||
import { UseRequestProcessor } from "../../services/request-processor"; | ||
|
||
interface IGetFolder { | ||
id: string; | ||
} | ||
|
||
export const useGetFolderQuery: useQueryFunctionType<IGetFolder, FolderType> = ( | ||
params, | ||
options, | ||
) => { | ||
const { query } = UseRequestProcessor(); | ||
|
||
const getFolderFn = async (): Promise<FolderType> => { | ||
const res = await api.get(`${getURL("FOLDERS")}/${params.id}`); | ||
const data = res.data; | ||
|
||
return data; | ||
}; | ||
|
||
const queryResult = query( | ||
["useGetFolder", { id: params.id }], | ||
getFolderFn, | ||
options, | ||
); | ||
return queryResult; | ||
}; |
Oops, something went wrong.