"use client"; import Link from "@/components/routing/app-link"; import { usePathname } from "@/lib/routing/client-router"; import { IconBrandGithub, IconBrandGitlab, IconHexagon, IconPlugConnected, IconTicket, } from "@tabler/icons-react"; import type { Icon as TablerIcon } from "@tabler/icons-react"; import { Tooltip, TooltipContent, TooltipTrigger } from "@kandev/ui/tooltip"; import { useConfiguredIntegrationLinks } from "@/components/integrations/integrations-menu"; import { cn } from "@/lib/utils"; import { APP_SIDEBAR_SECTION_IDS, SIDEBAR_ITEM_ACTIVE, SIDEBAR_ITEM_INACTIVE, } from "../app-sidebar-constants"; import { AppSidebarSection } from "../app-sidebar-section"; type IntegrationsSectionProps = { collapsed: boolean; }; const INTEGRATION_ICONS: Record = { github: IconBrandGithub, gitlab: IconBrandGitlab, jira: IconTicket, linear: IconHexagon, }; const MAX_HEADER_SHORTCUTS = 4; type ConfiguredIntegrationLink = ReturnType[number]; function IntegrationHeaderShortcuts({ links }: { links: ConfiguredIntegrationLink[] }) { return (
{links.slice(0, MAX_HEADER_SHORTCUTS).map(({ id, label, href }) => { const Icon = INTEGRATION_ICONS[id] ?? IconPlugConnected; return ( {label} ); })}
); } export function IntegrationsSection({ collapsed }: IntegrationsSectionProps) { const pathname = usePathname(); const links = useConfiguredIntegrationLinks(); if (links.length === 0) return null; return ( } headerActionVisibility="always" > {links.map(({ id, label, href }) => { const Icon = INTEGRATION_ICONS[id] ?? IconPlugConnected; const isActive = pathname === href || pathname.startsWith(`${href}/`); return ( {label} ); })} ); }