mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-11-08 20:33:41 +00:00
51 lines
1.7 KiB
TypeScript
51 lines
1.7 KiB
TypeScript
"use client";
|
|
|
|
import { usePathname } from "next/navigation";
|
|
|
|
import { LighthouseIcon } from "@/components/icons";
|
|
import { Button } from "@/components/shadcn/button/button";
|
|
import {
|
|
Tooltip,
|
|
TooltipContent,
|
|
TooltipTrigger,
|
|
} from "@/components/shadcn/tooltip";
|
|
import { isLighthouseChatRoute } from "@/lib/lighthouse-routes";
|
|
import { isCloud } from "@/lib/shared/env";
|
|
import { SIDE_PANEL_TAB, useSidePanelStore } from "@/store/side-panel";
|
|
|
|
export function SidePanelTrigger() {
|
|
const pathname = usePathname();
|
|
const openPanel = useSidePanelStore((state) => state.openPanel);
|
|
// Hidden while the AI chat is already showing; kept while the panel shows a
|
|
// detail (context) tab, where the trigger is the way back to the chat.
|
|
const isAiChatPanelOpen = useSidePanelStore(
|
|
(state) => state.isOpen && state.selectedTab === SIDE_PANEL_TAB.AI_CHAT,
|
|
);
|
|
|
|
// Lighthouse AI (and the panel itself) is cloud-only. On the full-page chat
|
|
// route the panel is not available: the chat lives in one place at a time.
|
|
if (!isCloud()) return null;
|
|
if (isLighthouseChatRoute(pathname)) return null;
|
|
if (isAiChatPanelOpen) return null;
|
|
|
|
return (
|
|
<Tooltip delayDuration={100}>
|
|
<TooltipTrigger asChild>
|
|
<Button
|
|
type="button"
|
|
variant="ghost"
|
|
size="icon-sm"
|
|
aria-label="Ask Lighthouse AI"
|
|
data-testid="side-panel-ai-trigger"
|
|
onClick={() => openPanel(SIDE_PANEL_TAB.AI_CHAT)}
|
|
>
|
|
<LighthouseIcon className="size-5" />
|
|
</Button>
|
|
</TooltipTrigger>
|
|
<TooltipContent>
|
|
Ask Lighthouse AI <kbd className="ml-1 text-xs">⌘.</kbd>
|
|
</TooltipContent>
|
|
</Tooltip>
|
|
);
|
|
}
|