"use client"; import Link from "next/link"; import { useState } from "react"; import { MutedIcon } from "@/components/icons"; import { Button } from "@/components/shadcn"; import { Popover, PopoverContent, PopoverTrigger, } from "@/components/shadcn/popover"; import { DOCS_URLS } from "@/lib/external-urls"; import { cn } from "@/lib/utils"; import { FINDING_DELTA, type FindingDelta } from "@/types"; export const DeltaValues = FINDING_DELTA; export type DeltaType = Exclude; interface NotificationIndicatorProps { delta?: DeltaType; isMuted?: boolean; mutedReason?: string; showDeltaWhenMuted?: boolean; reserveMutedSlot?: boolean; } export const NotificationIndicator = ({ delta, isMuted = false, mutedReason, showDeltaWhenMuted = false, reserveMutedSlot = false, }: NotificationIndicatorProps) => { const hasDelta = delta === DeltaValues.NEW || delta === DeltaValues.CHANGED; if (showDeltaWhenMuted && reserveMutedSlot) { return (
{isMuted ? : null}
{hasDelta ? : null}
); } if (isMuted && hasDelta && showDeltaWhenMuted) { return (
); } // Uses Popover (not Tooltip) because the content has an interactive link. // Radix Tooltip does not support interactive content — clicks fall through. if (isMuted) { return ; } // Show dot with tooltip for new or changed findings if (hasDelta) { return ; } // No indicator - return minimal width placeholder return
; }; function DeltaIndicator({ delta, }: { delta: typeof DeltaValues.NEW | typeof DeltaValues.CHANGED; }) { const [open, setOpen] = useState(false); return ( setOpen(true)} onMouseLeave={() => setOpen(false)} onClick={(e) => e.stopPropagation()} >
{delta === DeltaValues.NEW ? "New finding." : "Status changed since the previous scan."}
); } /** Muted indicator with hover-triggered Popover for interactive link. */ function MutedIndicator({ mutedReason }: { mutedReason?: string }) { const [open, setOpen] = useState(false); return ( setOpen(true)} onMouseLeave={() => setOpen(false)} onClick={(e) => e.stopPropagation()} > e.stopPropagation()} className="text-button-tertiary hover:text-button-tertiary-hover flex items-center gap-1 text-xs underline-offset-4" > {mutedReason ? ( <> Mute rule: {mutedReason} ) : ( <> Mute rule: view rules )} ); }