AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
fix(frontend): show sub-folders when navigating inside a folder (#12316)
Abhimanyu Yadav0cd9c0d87a43
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/components/LibraryAgentList/LibraryAgentList.tsx b/autogpt_platform/frontend/src/app/(platform)/library/components/LibraryAgentList/LibraryAgentList.tsxindex 906b7cf0eb..18d564870e 100644--- a/autogpt_platform/frontend/src/app/(platform)/library/components/LibraryAgentList/LibraryAgentList.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/library/components/LibraryAgentList/LibraryAgentList.tsx@@ -7,7 +7,6 @@ import { LibraryActionSubHeader } from "../LibraryActionSubHeader/LibraryActionSimport { LibraryAgentCard } from "../LibraryAgentCard/LibraryAgentCard";import { LibraryFolder } from "../LibraryFolder/LibraryFolder";import { LibrarySubSection } from "../LibrarySubSection/LibrarySubSection";-import { Button } from "@/components/atoms/Button/Button";import { ArrowLeftIcon, HeartIcon } from "@phosphor-icons/react";import { Text } from "@/components/atoms/Text/Text";import { Tab } from "../LibraryTabs/LibraryTabs";@@ -136,22 +135,21 @@ export function LibraryAgentList({<div>{selectedFolderId && (<div className="mb-4 flex items-center gap-2">- <Button- variant="ghost"- size="small"+ <button+ type="button"onClick={() => onFolderSelect(null)}- className="gap-1 text-zinc-500 hover:text-zinc-900"+ className="inline-flex items-center gap-1 text-sm text-zinc-500 hover:text-zinc-900"><ArrowLeftIcon className="h-4 w-4" />My Library- </Button>+ </button>{currentFolder && (<>- <Text variant="small" className="text-zinc-400">+ <Text variant="body" className="text-zinc-400">/</Text>- <Text variant="h4" className="text-zinc-700">- {currentFolder.icon} {currentFolder.name}+ <Text variant="large" className="text-zinc-700">+ {currentFolder.name}</Text></>)}diff --git a/autogpt_platform/frontend/src/app/(platform)/library/components/LibraryAgentList/useLibraryAgentList.ts b/autogpt_platform/frontend/src/app/(platform)/library/components/LibraryAgentList/useLibraryAgentList.tsindex 2304a13e3e..b20410464a 100644--- a/autogpt_platform/frontend/src/app/(platform)/library/components/LibraryAgentList/useLibraryAgentList.ts+++ b/autogpt_platform/frontend/src/app/(platform)/library/components/LibraryAgentList/useLibraryAgentList.ts@@ -4,6 +4,7 @@ import { useGetV2ListLibraryAgentsInfinite } from "@/app/api/__generated__/endpoimport { getGetV2ListLibraryAgentsQueryKey } from "@/app/api/__generated__/endpoints/library/library";import {useGetV2ListLibraryFolders,+ useGetV2GetFolder,usePostV2BulkMoveAgents,getGetV2ListLibraryFoldersQueryKey,} from "@/app/api/__generated__/endpoints/folders/folders";@@ -106,9 +107,12 @@ export function useLibraryAgentList({fetchNextPage: fetchNextPage,};- const { data: rawFoldersData } = useGetV2ListLibraryFolders(undefined, {- query: { select: okData },- });+ const { data: rawFoldersData } = useGetV2ListLibraryFolders(+ { parent_id: selectedFolderId ?? undefined },+ {+ query: { select: okData },+ },+ );const foldersData = searchTerm ? undefined : rawFoldersData;@@ -185,11 +189,15 @@ export function useLibraryAgentList({});}- const currentFolder = selectedFolderId- ? foldersData?.folders.find((f) => f.id === selectedFolderId)- : null;+ const { data: currentFolderData } = useGetV2GetFolder(+ selectedFolderId ?? "",+ {+ query: { select: okData, enabled: !!selectedFolderId },+ },+ );+ const currentFolder = selectedFolderId ? currentFolderData : null;- const showFolders = !isFavoritesTab && !selectedFolderId;+ const showFolders = !isFavoritesTab;function handleFolderDeleted() {if (selectedFolderId === deletingFolder?.id) {