"use client";
import Link from "@/components/routing/app-link";
import { useTranslation } from "react-i18next";
import { usePathname } from "@/lib/routing/client-router";
import { IconPlugConnected } from "@tabler/icons-react";
import { Tooltip, TooltipContent, TooltipTrigger } from "@kandev/ui/tooltip";
import { useAppDestinations } from "@/hooks/use-app-destinations";
import type { DestinationIcon, ResolvedDestination } from "@/lib/navigation/types";
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 MAX_HEADER_SHORTCUTS = 4;
function IntegrationHeaderShortcuts({ links }: { links: ResolvedDestination[] }) {
return (
{links.slice(0, MAX_HEADER_SHORTCUTS).map(({ id, label, href, icon: Icon }) => (
{label}
))}
);
}
type IntegrationRowProps = {
href: string;
label: string;
icon: DestinationIcon;
active: boolean;
testId?: string;
};
function IntegrationRow({ href, label, icon: Icon, active, testId }: IntegrationRowProps) {
return (
{label}
);
}
export function IntegrationsSection({ collapsed }: IntegrationsSectionProps) {
const { t } = useTranslation();
const pathname = usePathname();
// First-party integration links and plugin-registered nav items that target
// this section (`registerNavItem({ section: "integrations" })`) both come from
// the navigation manifest, already in render order.
const destinations = useAppDestinations("sidebar", "integrations");
// Header shortcuts stay first-party: they are a fixed-width strip, and a
// plugin should not push a configured integration out of it.
const firstPartyLinks = destinations.filter((destination) => destination.source !== "plugin");
if (destinations.length === 0) return null;
return (
);
}