mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-26 23:51:14 +02:00
feat(sidebar): add onChatsClick handler to sidebar components for improved navigation
This commit is contained in:
parent
a466fdcf5d
commit
8aaf9cadbe
4 changed files with 31 additions and 1 deletions
|
|
@ -631,6 +631,9 @@ export function LayoutDataProvider({
|
|||
const isArtifactsPage = pathname?.endsWith("/artifacts") === true;
|
||||
const isPlaygroundPage = pathname?.includes("/playground") === true;
|
||||
const isAllChatsPage = pathname?.endsWith("/chats") === true;
|
||||
const handleChatsClick = useCallback(() => {
|
||||
router.push(`/dashboard/${workspaceId}/chats`);
|
||||
}, [router, workspaceId]);
|
||||
const handleViewAllChats = useCallback(() => {
|
||||
router.push(
|
||||
isAllChatsPage ? `/dashboard/${workspaceId}/new-chat` : `/dashboard/${workspaceId}/chats`
|
||||
|
|
@ -671,6 +674,7 @@ export function LayoutDataProvider({
|
|||
onChatRename={handleChatRename}
|
||||
onChatDelete={handleChatDelete}
|
||||
onChatArchive={handleChatArchive}
|
||||
onChatsClick={handleChatsClick}
|
||||
onViewAllChats={handleViewAllChats}
|
||||
user={{
|
||||
email: user?.email || "",
|
||||
|
|
|
|||
|
|
@ -106,6 +106,7 @@ interface LayoutShellProps {
|
|||
onChatRename?: (chat: ChatItem) => void;
|
||||
onChatDelete?: (chat: ChatItem) => void;
|
||||
onChatArchive?: (chat: ChatItem) => void;
|
||||
onChatsClick?: () => void;
|
||||
onViewAllChats?: () => void;
|
||||
user: User;
|
||||
onSettings?: () => void;
|
||||
|
|
@ -208,6 +209,7 @@ export function LayoutShell({
|
|||
onChatRename,
|
||||
onChatDelete,
|
||||
onChatArchive,
|
||||
onChatsClick,
|
||||
onViewAllChats,
|
||||
user,
|
||||
onSettings,
|
||||
|
|
@ -289,6 +291,7 @@ export function LayoutShell({
|
|||
onChatRename={onChatRename}
|
||||
onChatDelete={onChatDelete}
|
||||
onChatArchive={onChatArchive}
|
||||
onChatsClick={onChatsClick}
|
||||
onViewAllChats={onViewAllChats}
|
||||
isAllChatsActive={isAllChatsPage}
|
||||
user={user}
|
||||
|
|
@ -388,6 +391,7 @@ export function LayoutShell({
|
|||
onChatRename={onChatRename}
|
||||
onChatDelete={onChatDelete}
|
||||
onChatArchive={onChatArchive}
|
||||
onChatsClick={onChatsClick}
|
||||
onViewAllChats={onViewAllChats}
|
||||
isAllChatsActive={isAllChatsPage}
|
||||
user={user}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ interface MobileSidebarProps {
|
|||
onChatRename?: (chat: ChatItem) => void;
|
||||
onChatDelete?: (chat: ChatItem) => void;
|
||||
onChatArchive?: (chat: ChatItem) => void;
|
||||
onChatsClick?: () => void;
|
||||
onViewAllChats?: () => void;
|
||||
isAllChatsActive?: boolean;
|
||||
user: User;
|
||||
|
|
@ -77,6 +78,7 @@ export function MobileSidebar({
|
|||
onChatRename,
|
||||
onChatDelete,
|
||||
onChatArchive,
|
||||
onChatsClick,
|
||||
onViewAllChats,
|
||||
isAllChatsActive = false,
|
||||
user,
|
||||
|
|
@ -194,6 +196,14 @@ export function MobileSidebar({
|
|||
onChatRename={onChatRename}
|
||||
onChatDelete={onChatDelete}
|
||||
onChatArchive={onChatArchive}
|
||||
onChatsClick={
|
||||
onChatsClick
|
||||
? () => {
|
||||
onOpenChange(false);
|
||||
onChatsClick();
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
onViewAllChats={
|
||||
onViewAllChats
|
||||
? () => {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
"use client";
|
||||
|
||||
import { CreditCard, SquarePen, Zap } from "lucide-react";
|
||||
import { CreditCard, MessageCircleMore, SquarePen, Zap } from "lucide-react";
|
||||
import Link from "next/link";
|
||||
import { useParams } from "next/navigation";
|
||||
import { useTranslations } from "next-intl";
|
||||
|
|
@ -62,6 +62,7 @@ interface SidebarProps {
|
|||
onChatRename?: (chat: ChatItem) => void;
|
||||
onChatDelete?: (chat: ChatItem) => void;
|
||||
onChatArchive?: (chat: ChatItem) => void;
|
||||
onChatsClick?: () => void;
|
||||
onViewAllChats?: () => void;
|
||||
isAllChatsActive?: boolean;
|
||||
user: User;
|
||||
|
|
@ -101,6 +102,7 @@ export function Sidebar({
|
|||
onChatRename,
|
||||
onChatDelete,
|
||||
onChatArchive,
|
||||
onChatsClick,
|
||||
onViewAllChats,
|
||||
isAllChatsActive = false,
|
||||
user,
|
||||
|
|
@ -222,6 +224,16 @@ export function Sidebar({
|
|||
onScroll={(event) => setIsSidebarNavScrolled(event.currentTarget.scrollTop > 0)}
|
||||
>
|
||||
<div className="flex flex-col gap-0.5 pt-0.5 pb-1.5">
|
||||
{onChatsClick && (
|
||||
<SidebarButton
|
||||
icon={MessageCircleMore}
|
||||
label={t("chats") || "Chats"}
|
||||
onClick={onChatsClick}
|
||||
isCollapsed={isCollapsed}
|
||||
isActive={isAllChatsActive}
|
||||
tooltipContent={isCollapsed ? t("chats") || "Chats" : undefined}
|
||||
/>
|
||||
)}
|
||||
{automationsItem && (
|
||||
<SidebarButton
|
||||
icon={automationsItem.icon}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue