feat: refactor conversations page into a workbench layout and implement workspace switching
- Migrate ConversationsPage to use ConversationWorkbench component. - Create WorkbenchLayout to handle authentication and layout for workbench. - Add WorkbenchPage to render ConversationWorkbench. - Implement WorkspaceSwitcher for switching between dashboard and workbench. - Update AuthProvider to manage authentication for both dashboard and workbench routes. - Enhance WorkbenchHeader with user menu and workspace switcher. - Add tests for workspace switcher and auth provider functionality. - Update translations for workspace labels in English and Chinese. - Exclude e2e tests from TypeScript compilation.
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
"use client"
|
||||
|
||||
import { Loader2Icon } from "lucide-react"
|
||||
import { usePathname, useRouter } from "next/navigation"
|
||||
import type { CSSProperties, ReactNode } from "react"
|
||||
import { useEffect } from "react"
|
||||
|
||||
import { useAuth } from "@/components/auth-provider"
|
||||
import { NotificationProvider } from "@/components/notification-provider"
|
||||
import { WorkbenchHeader } from "@/components/workbench-header"
|
||||
import { useI18n } from "@/i18n/provider"
|
||||
|
||||
export default function WorkbenchLayout({
|
||||
children,
|
||||
}: {
|
||||
children: ReactNode
|
||||
}) {
|
||||
const t = useI18n()
|
||||
const { ready, session } = useAuth()
|
||||
const pathname = usePathname()
|
||||
const router = useRouter()
|
||||
const isWorkbenchRoute = pathname?.startsWith("/workbench") ?? false
|
||||
|
||||
useEffect(() => {
|
||||
if (ready && !session && isWorkbenchRoute) {
|
||||
router.replace("/dashboard/login")
|
||||
}
|
||||
}, [isWorkbenchRoute, ready, router, session])
|
||||
|
||||
if (!ready || !session) {
|
||||
return (
|
||||
<div className="flex min-h-screen items-center justify-center bg-[linear-gradient(160deg,#f3f1e8_0%,#f8faf5_46%,#e8f7f2_100%)] p-6">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="flex size-10 items-center justify-center rounded-full bg-primary/10 text-primary">
|
||||
<Loader2Icon className="size-5 animate-spin" />
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<p className="text-base font-medium">{t("auth.checkingSession")}</p>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
{t("auth.syncingProfile")}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
className="flex h-svh min-h-0 flex-col overflow-hidden bg-background"
|
||||
style={
|
||||
{
|
||||
"--header-height": "calc(var(--spacing) * 12)",
|
||||
} as CSSProperties
|
||||
}
|
||||
>
|
||||
<NotificationProvider>
|
||||
<WorkbenchHeader />
|
||||
<main className="flex min-h-0 flex-1 overflow-hidden">{children}</main>
|
||||
</NotificationProvider>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import { ConversationWorkbench } from "@/app/dashboard/conversations/_components/conversation-workbench";
|
||||
|
||||
export default function WorkbenchPage() {
|
||||
return <ConversationWorkbench />;
|
||||
}
|
||||
Reference in New Issue
Block a user