mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-22 23:31:12 +02:00
feat(layout): implement cookie-based state management for playground sidebar visibility
This commit is contained in:
parent
2c6724206e
commit
79c7d1ecdf
4 changed files with 38 additions and 23 deletions
|
|
@ -20,9 +20,11 @@ import { useElectronAPI } from "@/hooks/use-platform";
|
|||
export function DashboardClientLayout({
|
||||
children,
|
||||
workspaceId,
|
||||
initialPlaygroundSidebarCollapsed,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
workspaceId: string;
|
||||
initialPlaygroundSidebarCollapsed: boolean;
|
||||
}) {
|
||||
const t = useTranslations("dashboard");
|
||||
const router = useRouter();
|
||||
|
|
@ -162,7 +164,10 @@ export function DashboardClientLayout({
|
|||
return (
|
||||
<DocumentUploadDialogProvider>
|
||||
<OnboardingTour />
|
||||
<LayoutDataProvider workspaceId={workspaceId}>
|
||||
<LayoutDataProvider
|
||||
workspaceId={workspaceId}
|
||||
initialPlaygroundSidebarCollapsed={initialPlaygroundSidebarCollapsed}
|
||||
>
|
||||
{children}
|
||||
<ConnectorIndicator showTrigger={false} />
|
||||
</LayoutDataProvider>
|
||||
|
|
|
|||
|
|
@ -1,16 +1,27 @@
|
|||
// Server component
|
||||
import type React from "react";
|
||||
import { use } from "react";
|
||||
import { cookies } from "next/headers";
|
||||
import { DashboardClientLayout } from "./client-layout";
|
||||
|
||||
export default function DashboardLayout({
|
||||
const PLAYGROUND_SIDEBAR_COLLAPSED_COOKIE = "surfsense_playground_sidebar_collapsed";
|
||||
|
||||
export default async function DashboardLayout({
|
||||
params,
|
||||
children,
|
||||
}: {
|
||||
params: Promise<{ workspace_id: string }>;
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
const { workspace_id } = use(params);
|
||||
const [{ workspace_id }, cookieStore] = await Promise.all([params, cookies()]);
|
||||
const initialPlaygroundSidebarCollapsed =
|
||||
cookieStore.get(PLAYGROUND_SIDEBAR_COLLAPSED_COOKIE)?.value === "true";
|
||||
|
||||
return <DashboardClientLayout workspaceId={workspace_id}>{children}</DashboardClientLayout>;
|
||||
return (
|
||||
<DashboardClientLayout
|
||||
workspaceId={workspace_id}
|
||||
initialPlaygroundSidebarCollapsed={initialPlaygroundSidebarCollapsed}
|
||||
>
|
||||
{children}
|
||||
</DashboardClientLayout>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue