import { CheckCircle2, Loader2 } from 'lucide-react' import { useState } from 'react' import { Button, PopoverContent_Shadcn_, PopoverTrigger_Shadcn_, Popover_Shadcn_, PopoverSeparator_Shadcn_, cn, } from 'ui' import { useProjectLintsQuery } from 'data/lint/lint-query' import { useSelectedProject } from 'hooks/misc/useSelectedProject' import Link from 'next/link' import { LINTER_LEVELS, LINT_TABS } from '../Linter/Linter.constants' export const SecurityStatus = () => { const project = useSelectedProject() const [open, setOpen] = useState(false) const { data, isLoading } = useProjectLintsQuery({ projectRef: project?.ref }) const securityLints = (data ?? []).filter((lint) => lint.categories.includes('SECURITY')) const errorLints = securityLints.filter((lint) => lint.level === 'ERROR') const warnLints = securityLints.filter((lint) => lint.level === 'WARN') const infoLints = securityLints.filter((lint) => lint.level === 'INFO') const noIssuesFound = errorLints.length === 0 && warnLints.length === 0 && infoLints.length === 0 return (
{noIssuesFound ? (

No security issues found

Keep monitoring Security Advisor for updates as your project grows.

) : (
{[ { lints: errorLints, level: LINTER_LEVELS.ERROR }, { lints: warnLints, level: LINTER_LEVELS.WARN }, { lints: infoLints, level: LINTER_LEVELS.INFO }, ].map( ({ lints, level }) => lints.length > 0 && ( <>
{lints.length} {level.toLowerCase()} issue{lints.length > 1 ? 's' : ''}

{LINT_TABS.find((tab) => tab.id === level)?.descriptionShort}

) )}
)}
) } const StatusDot = ({ level }: { level: LINTER_LEVELS }) => { const variants = { [LINTER_LEVELS.ERROR]: 'bg-destructive-600', [LINTER_LEVELS.WARN]: 'bg-warning-600', [LINTER_LEVELS.INFO]: 'bg-foreground-lighter dark:bg-foreground-light', } return
}