import { ArrowLeftIcon, ChartNoAxesColumnIcon, GitPullRequestIcon, SettingsIcon, } from "lucide-react"; import { memo, useCallback } from "react"; import { Link, useLocation, useNavigate } from "@tanstack/react-router"; import { useEnvironmentIdentificationMode } from "../../hooks/useSettings"; import { cn } from "../../lib/utils"; import { useEnvironments } from "../../state/environments"; import { resolveEnvironmentIdentificationPillLabel, resolveSidebarStageBackdropVariant, resolveSidebarStageFocusRingOffsetClass, SidebarStageBackdrop, useEnvironmentStageLabel, } from "../SidebarStageBackdrop"; import { Badge } from "../ui/badge"; import { SidebarFooter, SidebarHeader, SidebarMenu, SidebarMenuButton, SidebarMenuItem, SidebarTrigger, useSidebar, } from "../ui/sidebar"; import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip"; import { SidebarProviderUpdatePill } from "./SidebarProviderUpdatePill"; import { SidebarUpdateArchitectureWarning, SidebarUpdatePill } from "./SidebarUpdatePill"; export const SidebarChromeHeader = memo(function SidebarChromeHeader({ isElectron, }: { isElectron: boolean; }) { const stageLabel = useEnvironmentStageLabel(); const environmentIdentificationMode = useEnvironmentIdentificationMode(); const backdropVariant = resolveSidebarStageBackdropVariant( stageLabel, environmentIdentificationMode === "artwork", ); const pillLabel = environmentIdentificationMode === "pill" ? resolveEnvironmentIdentificationPillLabel(stageLabel) : null; return ( {backdropVariant ? : null} {pillLabel ? ( {pillLabel} ) : null} ); }); function SidebarBrand({ onBackdrop }: { onBackdrop: boolean }) { return ( Code ); } function T3Wordmark() { return ( ); } export const SidebarChromeFooter = memo(function SidebarChromeFooter() { const navigate = useNavigate(); const { isMobile, setOpenMobile } = useSidebar(); const currentFooterPage = useLocation({ select: (location) => location.pathname === "/usage" ? "usage" : location.pathname === "/pull-requests" ? "pull-requests" : null, }); const { environments } = useEnvironments(); // The page reads every connected server, so one of them offering pull requests is enough for // the link to lead somewhere. const pullRequestsSupported = environments.some( (environment) => environment.serverConfig?.environment.capabilities.pullRequests === true, ); const closeMobileSidebar = useCallback(() => { if (isMobile) { setOpenMobile(false); } }, [isMobile, setOpenMobile]); const handlePullRequestsClick = useCallback(() => { closeMobileSidebar(); void navigate({ to: "/pull-requests", search: { involvement: "all", state: "open" } }); }, [closeMobileSidebar, navigate]); const handleSettingsClick = useCallback(() => { closeMobileSidebar(); void navigate({ to: "/settings" }); }, [closeMobileSidebar, navigate]); const handleUsageClick = useCallback(() => { if (isMobile) { setOpenMobile(false); } void navigate({ to: "/usage" }); }, [isMobile, navigate, setOpenMobile]); const handleBackClick = useCallback(() => { closeMobileSidebar(); void navigate({ to: "/" }); }, [closeMobileSidebar, navigate]); return ( {currentFooterPage ? ( Back ) : ( <> } /> Settings {pullRequestsSupported ? ( } /> Pull Requests ) : null} } /> Usage )} ); });