mirror of
https://github.com/MODSetter/SurfSense.git
synced 2025-09-02 02:29:08 +00:00
Added breadcrumbs
This commit is contained in:
parent
49a5d048bf
commit
c884502737
5 changed files with 290 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import type React from "react";
|
import type React from "react";
|
||||||
|
import { DashboardBreadcrumb } from "@/components/dashboard-breadcrumb";
|
||||||
import { AppSidebarProvider } from "@/components/sidebar/AppSidebarProvider";
|
import { AppSidebarProvider } from "@/components/sidebar/AppSidebarProvider";
|
||||||
import { ThemeTogglerComponent } from "@/components/theme/theme-toggle";
|
import { ThemeTogglerComponent } from "@/components/theme/theme-toggle";
|
||||||
import { Separator } from "@/components/ui/separator";
|
import { Separator } from "@/components/ui/separator";
|
||||||
|
@ -28,8 +29,11 @@ export function DashboardClientLayout({
|
||||||
<SidebarInset>
|
<SidebarInset>
|
||||||
<header className="sticky top-0 z-50 flex h-16 shrink-0 items-center gap-2 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60 border-b">
|
<header className="sticky top-0 z-50 flex h-16 shrink-0 items-center gap-2 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60 border-b">
|
||||||
<div className="flex items-center justify-between w-full gap-2 px-4">
|
<div className="flex items-center justify-between w-full gap-2 px-4">
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
<SidebarTrigger className="-ml-1" />
|
<SidebarTrigger className="-ml-1" />
|
||||||
<Separator orientation="vertical" className="h-6" />
|
<Separator orientation="vertical" className="h-6" />
|
||||||
|
<DashboardBreadcrumb />
|
||||||
|
</div>
|
||||||
<ThemeTogglerComponent />
|
<ThemeTogglerComponent />
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
|
@ -31,7 +31,6 @@ export default function DashboardLayout({
|
||||||
title: "Researcher",
|
title: "Researcher",
|
||||||
url: `/dashboard/${search_space_id}/researcher`,
|
url: `/dashboard/${search_space_id}/researcher`,
|
||||||
icon: "SquareTerminal",
|
icon: "SquareTerminal",
|
||||||
isActive: true,
|
|
||||||
items: [],
|
items: [],
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
15
surfsense_web/app/dashboard/[search_space_id]/page.tsx
Normal file
15
surfsense_web/app/dashboard/[search_space_id]/page.tsx
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useParams, useRouter } from "next/navigation";
|
||||||
|
import { useEffect } from "react";
|
||||||
|
|
||||||
|
export default function SearchSpaceDashboardPage() {
|
||||||
|
const router = useRouter();
|
||||||
|
const { search_space_id } = useParams();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
router.push(`/dashboard/${search_space_id}/chats`);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return <></>;
|
||||||
|
}
|
169
surfsense_web/components/dashboard-breadcrumb.tsx
Normal file
169
surfsense_web/components/dashboard-breadcrumb.tsx
Normal file
|
@ -0,0 +1,169 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
|
import { usePathname } from "next/navigation";
|
||||||
|
import React from "react";
|
||||||
|
import {
|
||||||
|
Breadcrumb,
|
||||||
|
BreadcrumbItem,
|
||||||
|
BreadcrumbLink,
|
||||||
|
BreadcrumbList,
|
||||||
|
BreadcrumbPage,
|
||||||
|
BreadcrumbSeparator,
|
||||||
|
} from "@/components/ui/breadcrumb";
|
||||||
|
|
||||||
|
interface BreadcrumbItemInterface {
|
||||||
|
label: string;
|
||||||
|
href?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function DashboardBreadcrumb() {
|
||||||
|
const pathname = usePathname();
|
||||||
|
|
||||||
|
// Parse the pathname to create breadcrumb items
|
||||||
|
const generateBreadcrumbs = (path: string): BreadcrumbItemInterface[] => {
|
||||||
|
const segments = path.split("/").filter(Boolean);
|
||||||
|
const breadcrumbs: BreadcrumbItemInterface[] = [];
|
||||||
|
|
||||||
|
// Always start with Dashboard
|
||||||
|
breadcrumbs.push({ label: "Dashboard", href: "/dashboard" });
|
||||||
|
|
||||||
|
// Handle search space
|
||||||
|
if (segments[0] === "dashboard" && segments[1]) {
|
||||||
|
breadcrumbs.push({ label: `Search Space ${segments[1]}`, href: `/dashboard/${segments[1]}` });
|
||||||
|
|
||||||
|
// Handle specific sections
|
||||||
|
if (segments[2]) {
|
||||||
|
const section = segments[2];
|
||||||
|
let sectionLabel = section.charAt(0).toUpperCase() + section.slice(1);
|
||||||
|
|
||||||
|
// Map section names to more readable labels
|
||||||
|
const sectionLabels: Record<string, string> = {
|
||||||
|
researcher: "Researcher",
|
||||||
|
documents: "Documents",
|
||||||
|
connectors: "Connectors",
|
||||||
|
podcasts: "Podcasts",
|
||||||
|
logs: "Logs",
|
||||||
|
chats: "Chats",
|
||||||
|
};
|
||||||
|
|
||||||
|
sectionLabel = sectionLabels[section] || sectionLabel;
|
||||||
|
|
||||||
|
// Handle sub-sections
|
||||||
|
if (segments[3]) {
|
||||||
|
const subSection = segments[3];
|
||||||
|
let subSectionLabel = subSection.charAt(0).toUpperCase() + subSection.slice(1);
|
||||||
|
|
||||||
|
// Handle documents sub-sections
|
||||||
|
if (section === "documents") {
|
||||||
|
const documentLabels: Record<string, string> = {
|
||||||
|
upload: "Upload Documents",
|
||||||
|
youtube: "Add YouTube Videos",
|
||||||
|
webpage: "Add Webpages",
|
||||||
|
};
|
||||||
|
|
||||||
|
const documentLabel = documentLabels[subSection] || subSectionLabel;
|
||||||
|
breadcrumbs.push({
|
||||||
|
label: "Documents",
|
||||||
|
href: `/dashboard/${segments[1]}/documents`,
|
||||||
|
});
|
||||||
|
breadcrumbs.push({ label: documentLabel });
|
||||||
|
return breadcrumbs;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle connector sub-sections
|
||||||
|
if (section === "connectors") {
|
||||||
|
// Handle specific connector types
|
||||||
|
if (subSection === "add" && segments[4]) {
|
||||||
|
const connectorType = segments[4];
|
||||||
|
const connectorLabels: Record<string, string> = {
|
||||||
|
"github-connector": "GitHub",
|
||||||
|
"jira-connector": "Jira",
|
||||||
|
"confluence-connector": "Confluence",
|
||||||
|
"discord-connector": "Discord",
|
||||||
|
"linear-connector": "Linear",
|
||||||
|
"clickup-connector": "ClickUp",
|
||||||
|
"slack-connector": "Slack",
|
||||||
|
"notion-connector": "Notion",
|
||||||
|
"tavily-api": "Tavily API",
|
||||||
|
"serper-api": "Serper API",
|
||||||
|
"linkup-api": "LinkUp API",
|
||||||
|
};
|
||||||
|
|
||||||
|
const connectorLabel = connectorLabels[connectorType] || connectorType;
|
||||||
|
breadcrumbs.push({
|
||||||
|
label: "Connectors",
|
||||||
|
href: `/dashboard/${segments[1]}/connectors`,
|
||||||
|
});
|
||||||
|
breadcrumbs.push({
|
||||||
|
label: "Add Connector",
|
||||||
|
href: `/dashboard/${segments[1]}/connectors/add`,
|
||||||
|
});
|
||||||
|
breadcrumbs.push({ label: connectorLabel });
|
||||||
|
return breadcrumbs;
|
||||||
|
}
|
||||||
|
|
||||||
|
const connectorLabels: Record<string, string> = {
|
||||||
|
add: "Add Connector",
|
||||||
|
manage: "Manage Connectors",
|
||||||
|
};
|
||||||
|
|
||||||
|
const connectorLabel = connectorLabels[subSection] || subSectionLabel;
|
||||||
|
breadcrumbs.push({
|
||||||
|
label: "Connectors",
|
||||||
|
href: `/dashboard/${segments[1]}/connectors`,
|
||||||
|
});
|
||||||
|
breadcrumbs.push({ label: connectorLabel });
|
||||||
|
return breadcrumbs;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle other sub-sections
|
||||||
|
const subSectionLabels: Record<string, string> = {
|
||||||
|
upload: "Upload Documents",
|
||||||
|
youtube: "Add YouTube Videos",
|
||||||
|
webpage: "Add Webpages",
|
||||||
|
add: "Add Connector",
|
||||||
|
edit: "Edit Connector",
|
||||||
|
manage: "Manage",
|
||||||
|
};
|
||||||
|
|
||||||
|
subSectionLabel = subSectionLabels[subSection] || subSectionLabel;
|
||||||
|
|
||||||
|
breadcrumbs.push({
|
||||||
|
label: sectionLabel,
|
||||||
|
href: `/dashboard/${segments[1]}/${section}`,
|
||||||
|
});
|
||||||
|
breadcrumbs.push({ label: subSectionLabel });
|
||||||
|
} else {
|
||||||
|
breadcrumbs.push({ label: sectionLabel });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return breadcrumbs;
|
||||||
|
};
|
||||||
|
|
||||||
|
const breadcrumbs = generateBreadcrumbs(pathname);
|
||||||
|
|
||||||
|
if (breadcrumbs.length <= 1) {
|
||||||
|
return null; // Don't show breadcrumbs for root dashboard
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Breadcrumb>
|
||||||
|
<BreadcrumbList>
|
||||||
|
{breadcrumbs.map((item, index) => (
|
||||||
|
<React.Fragment key={index}>
|
||||||
|
<BreadcrumbItem>
|
||||||
|
{index === breadcrumbs.length - 1 ? (
|
||||||
|
<BreadcrumbPage>{item.label}</BreadcrumbPage>
|
||||||
|
) : (
|
||||||
|
<BreadcrumbLink href={item.href}>{item.label}</BreadcrumbLink>
|
||||||
|
)}
|
||||||
|
</BreadcrumbItem>
|
||||||
|
{index < breadcrumbs.length - 1 && <BreadcrumbSeparator />}
|
||||||
|
</React.Fragment>
|
||||||
|
))}
|
||||||
|
</BreadcrumbList>
|
||||||
|
</Breadcrumb>
|
||||||
|
);
|
||||||
|
}
|
100
surfsense_web/components/ui/breadcrumb.tsx
Normal file
100
surfsense_web/components/ui/breadcrumb.tsx
Normal file
|
@ -0,0 +1,100 @@
|
||||||
|
import { Slot } from "@radix-ui/react-slot";
|
||||||
|
import { ChevronRight, MoreHorizontal } from "lucide-react";
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
function Breadcrumb({ ...props }: React.ComponentProps<"nav">) {
|
||||||
|
return <nav aria-label="breadcrumb" data-slot="breadcrumb" {...props} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
function BreadcrumbList({ className, ...props }: React.ComponentProps<"ol">) {
|
||||||
|
return (
|
||||||
|
<ol
|
||||||
|
data-slot="breadcrumb-list"
|
||||||
|
className={cn(
|
||||||
|
"text-muted-foreground flex flex-wrap items-center gap-1.5 text-sm break-words sm:gap-2.5",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function BreadcrumbItem({ className, ...props }: React.ComponentProps<"li">) {
|
||||||
|
return (
|
||||||
|
<li
|
||||||
|
data-slot="breadcrumb-item"
|
||||||
|
className={cn("inline-flex items-center gap-1.5", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function BreadcrumbLink({
|
||||||
|
asChild,
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<"a"> & {
|
||||||
|
asChild?: boolean;
|
||||||
|
}) {
|
||||||
|
const Comp = asChild ? Slot : "a";
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Comp
|
||||||
|
data-slot="breadcrumb-link"
|
||||||
|
className={cn("hover:text-foreground transition-colors", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function BreadcrumbPage({ className, ...props }: React.ComponentProps<"span">) {
|
||||||
|
return (
|
||||||
|
<span
|
||||||
|
data-slot="breadcrumb-page"
|
||||||
|
aria-disabled="true"
|
||||||
|
aria-current="page"
|
||||||
|
className={cn("text-foreground font-normal", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function BreadcrumbSeparator({ children, className, ...props }: React.ComponentProps<"li">) {
|
||||||
|
return (
|
||||||
|
<li
|
||||||
|
data-slot="breadcrumb-separator"
|
||||||
|
role="presentation"
|
||||||
|
aria-hidden="true"
|
||||||
|
className={cn("[&>svg]:size-3.5", className)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
{children ?? <ChevronRight />}
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function BreadcrumbEllipsis({ className, ...props }: React.ComponentProps<"span">) {
|
||||||
|
return (
|
||||||
|
<span
|
||||||
|
data-slot="breadcrumb-ellipsis"
|
||||||
|
role="presentation"
|
||||||
|
aria-hidden="true"
|
||||||
|
className={cn("flex size-9 items-center justify-center", className)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<MoreHorizontal className="size-4" />
|
||||||
|
<span className="sr-only">More</span>
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export {
|
||||||
|
Breadcrumb,
|
||||||
|
BreadcrumbList,
|
||||||
|
BreadcrumbItem,
|
||||||
|
BreadcrumbLink,
|
||||||
|
BreadcrumbPage,
|
||||||
|
BreadcrumbSeparator,
|
||||||
|
BreadcrumbEllipsis,
|
||||||
|
};
|
Loading…
Add table
Reference in a new issue