+
(null)
const [isShowDemoBanner] = useShowDemoBanner()
const [isShowLicenseBanner] = useShowLicenseBanner()
const style =
@@ -21,16 +27,19 @@ export default function MainContent({
}
: { height: '100vh' }
+ useEffect(() => {
+ if (pathname && scroller.current) {
+ scroller.current.scrollTop = 0
+ }
+ }, [pathname])
+
return (
- <>
+
{/* Wraps right hand side into ScrollArea, making scroll bar consistent across all browsers */}
-
+
-
- >
+
)
}
diff --git a/ee/tabby-ui/app/(dashboard)/components/sidebar.tsx b/ee/tabby-ui/app/(dashboard)/components/sidebar.tsx
index e44e83bcee60..3f48aa48e0cb 100644
--- a/ee/tabby-ui/app/(dashboard)/components/sidebar.tsx
+++ b/ee/tabby-ui/app/(dashboard)/components/sidebar.tsx
@@ -1,16 +1,14 @@
'use client'
-import React from 'react'
+import React, { FunctionComponent } from 'react'
import Image from 'next/image'
import Link from 'next/link'
import { usePathname } from 'next/navigation'
import logoDarkUrl from '@/assets/logo-dark.png'
import logoUrl from '@/assets/logo.png'
-import { cva } from 'class-variance-authority'
-import { escapeRegExp } from 'lodash-es'
+import tabbyLogo from '@/assets/tabby.png'
import { useMe } from '@/lib/hooks/use-me'
-import { cn } from '@/lib/utils'
import {
Collapsible,
CollapsibleContent,
@@ -23,9 +21,17 @@ import {
IconLightingBolt,
IconUser
} from '@/components/ui/icons'
-import { ScrollArea } from '@/components/ui/scroll-area'
-import { BANNER_HEIGHT, useShowDemoBanner } from '@/components/demo-banner'
-import { useShowLicenseBanner } from '@/components/license-banner'
+import {
+ Sidebar,
+ SidebarContent,
+ SidebarGroup,
+ SidebarHeader,
+ SidebarMenuButton,
+ SidebarMenuItem,
+ SidebarMenuSub,
+ SidebarMenuSubButton,
+ SidebarMenuSubItem
+} from '@/components/ui/sidebar'
import LoadingWrapper from '@/components/loading-wrapper'
export interface SidebarProps {
@@ -33,7 +39,7 @@ export interface SidebarProps {
className?: string
}
-type MenuLeaf = {
+type SubMenu = {
title: string
href: string
allowUser?: boolean
@@ -42,29 +48,29 @@ type MenuLeaf = {
type Menu =
| {
title: string
- icon: React.ReactNode
+ icon: FunctionComponent
allowUser?: boolean
- children: MenuLeaf[]
+ items: SubMenu[]
}
| {
title: string
href: string
- icon: React.ReactNode
+ icon: FunctionComponent
allowUser?: boolean
- children?: never
+ items?: never
}
const menus: Menu[] = [
{
title: 'Profile',
- icon: ,
+ icon: IconUser,
href: '/profile',
allowUser: true
},
{
title: 'Information',
- icon: ,
- children: [
+ icon: IconBookOpenText,
+ items: [
{
title: 'System',
href: '/system'
@@ -85,9 +91,9 @@ const menus: Menu[] = [
},
{
title: 'Settings',
- icon: ,
+ icon: IconGear,
allowUser: true,
- children: [
+ items: [
{
title: 'General',
href: '/settings/general'
@@ -105,8 +111,8 @@ const menus: Menu[] = [
},
{
title: 'Integrations',
- icon: ,
- children: [
+ icon: IconLightingBolt,
+ items: [
{
title: 'Context Providers',
href: '/settings/providers/git'
@@ -123,160 +129,152 @@ const menus: Menu[] = [
}
]
-export default function Sidebar({ children, className }: SidebarProps) {
+export default function AppSidebar() {
+ const pathname = usePathname()
const [{ data, fetching: fetchingMe }] = useMe()
const isAdmin = data?.me.isAdmin
- const [isShowDemoBanner] = useShowDemoBanner()
- const [isShowLicenseBanner] = useShowLicenseBanner()
- const showBanner = isShowDemoBanner || isShowLicenseBanner
- const style = showBanner
- ? {
- height: `calc(100vh - ${isShowDemoBanner ? BANNER_HEIGHT : '0rem'} - ${
- isShowLicenseBanner ? BANNER_HEIGHT : '0rem'
- })`
- }
- : { height: '100vh' }
return (
-
- }
+ {menu.title}
+
+
+
+
+
+ {menu.items.map(item => {
+ if (isAdmin || item.allowUser) {
+ return (
+
+
+
+ {item.title}
+
+
+
+ )
+ }
+ })}
+
+
+
+
+ )
+ } else {
+ return (
+
+
+
+ {!!menu.icon && }
+ {menu.title}
+
+
+
+ )
+ }
+ }
+ return null
+ })}
+
+
+
+
)
}
diff --git a/ee/tabby-ui/app/(dashboard)/layout.tsx b/ee/tabby-ui/app/(dashboard)/layout.tsx
index af0feb7b041c..8d583190b363 100644
--- a/ee/tabby-ui/app/(dashboard)/layout.tsx
+++ b/ee/tabby-ui/app/(dashboard)/layout.tsx
@@ -1,9 +1,10 @@
import { Metadata } from 'next'
+import { SidebarProvider } from '@/components/ui/sidebar'
import { LicenseBanner } from '@/components/license-banner'
import MainContent from './components/main-content'
-import Sidebar from './components/sidebar'
+import AppSidebar from './components/sidebar'
export const metadata: Metadata = {
title: {
@@ -20,10 +21,10 @@ export default function RootLayout({
return (
<>
-
-
+
+
{children}
-
+
>
)
}
diff --git a/ee/tabby-ui/app/(dashboard)/profile/components/avatar.tsx b/ee/tabby-ui/app/(dashboard)/profile/components/avatar.tsx
index c414828436b8..2a46f0475151 100644
--- a/ee/tabby-ui/app/(dashboard)/profile/components/avatar.tsx
+++ b/ee/tabby-ui/app/(dashboard)/profile/components/avatar.tsx
@@ -77,7 +77,7 @@ export const Avatar = () => {
{`View raw events generated by team members' activities while interacting with Tabby.`}
{members.length > 0 && ( diff --git a/ee/tabby-ui/app/(dashboard)/components/main-content.tsx b/ee/tabby-ui/app/(dashboard)/components/main-content.tsx index df24707bb3f2..a2b652cfe434 100644 --- a/ee/tabby-ui/app/(dashboard)/components/main-content.tsx +++ b/ee/tabby-ui/app/(dashboard)/components/main-content.tsx @@ -1,6 +1,10 @@ 'use client' +import { useEffect, useRef } from 'react' +import { usePathname } from 'next/navigation' + import { ScrollArea } from '@/components/ui/scroll-area' +import { SidebarInset } from '@/components/ui/sidebar' import { BANNER_HEIGHT, useShowDemoBanner } from '@/components/demo-banner' import { Header } from '@/components/header' import { useShowLicenseBanner } from '@/components/license-banner' @@ -10,6 +14,8 @@ export default function MainContent({ }: { children: React.ReactNode }) { + const pathname = usePathname() + const scroller = useRef{children}
+ {children}
-
+ ),
+ align: 'start',
+ side: 'right'
+ }}
+ >
+ {!!menu.icon &&
diff --git a/ee/tabby-ui/app/(dashboard)/reports/components/report.tsx b/ee/tabby-ui/app/(dashboard)/reports/components/report.tsx
index 5b7339e9b119..a384e9869155 100644
--- a/ee/tabby-ui/app/(dashboard)/reports/components/report.tsx
+++ b/ee/tabby-ui/app/(dashboard)/reports/components/report.tsx
@@ -218,7 +218,7 @@ export function Report() {
}
+ fallback={ }
>