"use client"; import Link from "@/components/routing/app-link"; import { usePathname } from "@/lib/routing/client-router"; import type { ComponentType } from "react"; import { IconBrandGithub, IconBrandGitlab, IconHexagon, IconPlugConnected, IconTicket, } from "@tabler/icons-react"; import { Tooltip, TooltipContent, TooltipTrigger } from "@kandev/ui/tooltip"; import { useConfiguredIntegrationLinks } from "@/components/integrations/integrations-menu"; import { useFeature } from "@/hooks/domains/features/use-feature"; import { resolvePluginIcon } from "@/lib/plugins/icons"; import { usePluginRegistry } from "@/lib/plugins/registry"; 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"; import { AzureDevOpsIcon } from "@/components/icons/azure-devops-icon"; type IntegrationsSectionProps = { collapsed: boolean; }; type IntegrationIcon = ComponentType<{ className?: string }>; const INTEGRATION_ICONS: Record = { "azure-devops": AzureDevOpsIcon, 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} ); })}
); } type IntegrationRowProps = { href: string; label: string; icon: IntegrationIcon; active: boolean; testId?: string; }; function IntegrationRow({ href, label, icon: Icon, active, testId }: IntegrationRowProps) { return ( {label} ); } export function IntegrationsSection({ collapsed }: IntegrationsSectionProps) { const pathname = usePathname(); const links = useConfiguredIntegrationLinks(); // Plugin-registered nav items that target this section // (`registerNavItem({ section: "integrations" })`), rendered after the // first-party links. Gated on the "plugins" feature flag like every other // plugin surface. const pluginsEnabled = useFeature("plugins"); const registry = usePluginRegistry(); const pluginItems = pluginsEnabled ? registry.getNavItems().filter((item) => item.section === "integrations") : []; if (links.length === 0 && pluginItems.length === 0) return null; return ( 0 ? : undefined} headerActionVisibility="always" > {links.map(({ id, label, href }) => ( ))} {pluginItems.map((item) => ( ))} ); }