/** * Copyright (c) 2023-present Plane Software, Inc. and contributors * SPDX-License-Identifier: AGPL-3.0-only * See the LICENSE file for details. */ import { useEffect, useRef, useState } from "react"; import { observer } from "mobx-react"; // plane helpers import { useOutsideClickDetector } from "@plane/hooks"; import { PreferencesOutline } from "@makeplane/propel/icons"; import { ScrollArea } from "@plane/propel/scrollarea"; // components import { CustomizeNavigationDialog } from "@/components/navigation/customize-navigation-dialog"; // hooks import { useAppTheme } from "@/hooks/store/use-app-theme"; import useSize from "@/hooks/use-window-size"; // plane web components import { WorkspaceEditionBadge } from "@/components/workspace/edition-badge"; import { AppSidebarToggleButton } from "./sidebar-toggle-button"; import { IconButton } from "@plane/propel/icon-button"; type TSidebarWrapperProps = { title: string; children: React.ReactNode; quickActions?: React.ReactNode; }; export const SidebarWrapper = observer(function SidebarWrapper(props: TSidebarWrapperProps) { const { title, children, quickActions } = props; // state const [isCustomizeNavDialogOpen, setIsCustomizeNavDialogOpen] = useState(false); // store hooks const { toggleSidebar, sidebarCollapsed } = useAppTheme(); const windowSize = useSize(); // refs const ref = useRef(null); useOutsideClickDetector(ref, () => { if (sidebarCollapsed === false && window.innerWidth < 768) { toggleSidebar(); } }); useEffect(() => { if (windowSize[0] < 768 && !sidebarCollapsed) toggleSidebar(); // eslint-disable-next-line react-hooks/exhaustive-deps }, [windowSize]); return ( <> setIsCustomizeNavDialogOpen(false)} />
{/* Workspace switcher and settings */}
{title}
{title === "Projects" && ( setIsCustomizeNavDialogOpen(true)} /> )}
{/* Quick actions */} {quickActions}
{children} {/* Help Section */}
{/* TODO: To be checked if we need this */} {/*
{!shouldRenderAppRail && } {!isAppRailEnabled && }
*/}
); });