refactor: simplify dashboard layout by removing unused navigation props and implementing a new DocumentsSidebar for better document management

This commit is contained in:
Anish Sarkar 2026-03-05 20:34:02 +05:30
parent 0cffa206ad
commit 936bd70682
11 changed files with 388 additions and 84 deletions

View file

@ -114,6 +114,9 @@ export function LayoutDataProvider({
const [isInboxSidebarOpen, setIsInboxSidebarOpen] = useState(false);
const [isInboxDocked, setIsInboxDocked] = useState(false);
// Documents sidebar state
const [isDocumentsSidebarOpen, setIsDocumentsSidebarOpen] = useState(false);
// Search space dialog state
const [isCreateSearchSpaceDialogOpen, setIsCreateSearchSpaceDialogOpen] = useState(false);
@ -301,9 +304,9 @@ export function LayoutDataProvider({
},
{
title: "Documents",
url: `/dashboard/${searchSpaceId}/documents`,
url: "#documents",
icon: SquareLibrary,
isActive: pathname?.includes("/documents"),
isActive: isDocumentsSidebarOpen,
},
{
title: "Announcements",
@ -313,7 +316,7 @@ export function LayoutDataProvider({
badge: announcementUnreadCount > 0 ? formatInboxCount(announcementUnreadCount) : undefined,
},
],
[searchSpaceId, pathname, isInboxSidebarOpen, totalUnreadCount, announcementUnreadCount]
[pathname, isInboxSidebarOpen, isDocumentsSidebarOpen, totalUnreadCount, announcementUnreadCount]
);
// Handlers
@ -411,6 +414,19 @@ export function LayoutDataProvider({
if (!prev) {
setIsAllSharedChatsSidebarOpen(false);
setIsAllPrivateChatsSidebarOpen(false);
setIsDocumentsSidebarOpen(false);
}
return !prev;
});
return;
}
// Handle documents specially - toggle sidebar instead of navigating
if (item.url === "#documents") {
setIsDocumentsSidebarOpen((prev) => {
if (!prev) {
setIsInboxSidebarOpen(false);
setIsAllSharedChatsSidebarOpen(false);
setIsAllPrivateChatsSidebarOpen(false);
}
return !prev;
});
@ -515,12 +531,14 @@ export function LayoutDataProvider({
setIsAllSharedChatsSidebarOpen(true);
setIsAllPrivateChatsSidebarOpen(false);
setIsInboxSidebarOpen(false);
setIsDocumentsSidebarOpen(false);
}, []);
const handleViewAllPrivateChats = useCallback(() => {
setIsAllPrivateChatsSidebarOpen(true);
setIsAllSharedChatsSidebarOpen(false);
setIsInboxSidebarOpen(false);
setIsDocumentsSidebarOpen(false);
}, []);
// Delete handlers
@ -651,6 +669,10 @@ export function LayoutDataProvider({
onOpenChange: setIsAllPrivateChatsSidebarOpen,
searchSpaceId,
}}
documentsPanel={{
open: isDocumentsSidebarOpen,
onOpenChange: setIsDocumentsSidebarOpen,
}}
>
{children}
</LayoutShell>