Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
feat: add togle to change the insights
adilson56336a23db6c
diff --git a/frontend/src/pages/organization/SecretInsightsPage/SecretInsightsPage.tsx b/frontend/src/pages/organization/SecretInsightsPage/SecretInsightsPage.tsxindex 264571dab1..6fb33ee4c9 100644--- a/frontend/src/pages/organization/SecretInsightsPage/SecretInsightsPage.tsx+++ b/frontend/src/pages/organization/SecretInsightsPage/SecretInsightsPage.tsx@@ -1,7 +1,7 @@import { Fragment, ReactNode, useMemo } from "react";import { Helmet } from "react-helmet";import { format } from "date-fns";-import { BoxIcon, FileTextIcon, KeyIcon, RefreshCwIcon } from "lucide-react";+import { BoxIcon, FileTextIcon, KeyIcon, RefreshCwIcon } from "lucide-react";import { OrgPermissionCan } from "@app/components/permissions";import { PageHeader } from "@app/components/v2";@@ -31,7 +31,7 @@ import { ProjectType } from "@app/hooks/api/projects/types";import {AuthMethodsCard,- NeedsAttentionCard,+ InsightsCard,RequestOrgAuditReportModal,SecretAccessVolumeCard,StaticSecretPresenceCard,@@ -48,8 +48,6 @@ export const SecretInsightsPage = withPermission(const isClickhouseEnabled = Boolean(config.isClickhouseAuditLogEnabled);const { data: summary, isPending: isSummaryPending } = useGetOrgSecretsSummary(currentOrg.id);- // Paginated: pages of 100 (the endpoint maximum); NeedsAttentionCard fetches further- // pages on demand while more problem projects remain on the server.const {data: projectsPages,isPending: isProjectsPending,@@ -208,7 +206,7 @@ export const SecretInsightsPage = withPermission({!isSummaryPending && summary && <SummaryCard summary={summary} />}{isProjectsPending && <Skeleton className="h-[320px]" />}{!isProjectsPending && projectsInsights && (- <NeedsAttentionCard+ <InsightsCarddata={projectsInsights}hasMore={hasMoreProjects}onLoadMore={fetchMoreProjects}diff --git a/frontend/src/pages/organization/SecretInsightsPage/components/NeedsAttentionCard.tsx b/frontend/src/pages/organization/SecretInsightsPage/components/InsightsCard.tsxsimilarity index 81%rename from frontend/src/pages/organization/SecretInsightsPage/components/NeedsAttentionCard.tsxrename to frontend/src/pages/organization/SecretInsightsPage/components/InsightsCard.tsxindex 1f71abb8c9..875b0c7385 100644--- a/frontend/src/pages/organization/SecretInsightsPage/components/NeedsAttentionCard.tsx+++ b/frontend/src/pages/organization/SecretInsightsPage/components/InsightsCard.tsx@@ -24,6 +24,9 @@ import {TableHead,TableHeader,TableRow,+ Tabs,+ TabsList,+ TabsTrigger,TBadgeProps} from "@app/components/v3";import { useOrganization } from "@app/context";@@ -31,6 +34,11 @@ import { TOrgProjectInsightWarnings, TOrgProjectsInsights } from "@app/hooks/apiconst COLLAPSED_ROW_COUNT = 4;+enum InsightsView {+ NeedsAttention = "needs-attention",+ AllProjects = "all-projects"+}+const projectInsightsRoute ="/organizations/$orgId/projects/secret-management/$projectId/insights" as const;@@ -63,7 +71,7 @@ const WarningBadges = ({ warnings }: { warnings: TOrgProjectInsightWarnings }) =</div>);-export const NeedsAttentionCard = ({+export const InsightsCard = ({data,hasMore,onLoadMore,@@ -78,6 +86,7 @@ export const NeedsAttentionCard = ({const { currentOrg } = useOrganization();const [search, setSearch] = useState("");const [showAll, setShowAll] = useState(false);+ const [view, setView] = useState<InsightsView>(InsightsView.NeedsAttention);const sortedProjects = useMemo(() =>@@ -89,15 +98,23 @@ export const NeedsAttentionCard = ({const isHealthy = data.projectsWithIssues === 0;+ const modeProjects = useMemo(+ () =>+ view === InsightsView.NeedsAttention+ ? sortedProjects.filter((project) => project.severityScore > 0)+ : sortedProjects,+ [sortedProjects, view]+ );+const filtered = useMemo(() => {const query = search.trim().toLowerCase();- if (!query) return sortedProjects;- return sortedProjects.filter(+ if (!query) return modeProjects;+ return modeProjects.filter((project) =>project.projectName.toLowerCase().includes(query) ||project.projectSlug.toLowerCase().includes(query));- }, [sortedProjects, search]);+ }, [modeProjects, search]);const isSearching = search.trim().length > 0;const visible = showAll || isSearching ? filtered : filtered.slice(0, COLLAPSED_ROW_COUNT);@@ -105,13 +122,19 @@ export const NeedsAttentionCard = ({return (<Card><CardHeader>- <CardTitle>Needs Attention</CardTitle>+ <CardTitle>Insights</CardTitle><CardDescription>{isHealthy? "You don't have any projects with issues": `${data.projectsWithIssues} of ${data.totalProjects} projects have outstanding issues, ordered by severity.`}</CardDescription>- <CardAction>+ <CardAction className="flex items-center gap-2">+ <Tabs value={view} onValueChange={(next) => setView(next as InsightsView)}>+ <TabsList variant="filled">+ <TabsTrigger value={InsightsView.NeedsAttention}>Needs Attention</TabsTrigger>+ <TabsTrigger value={InsightsView.AllProjects}>All Projects</TabsTrigger>+ </TabsList>+ </Tabs><InputGroup className="w-64"><InputGroupAddon align="inline-start"><SearchIcon />@@ -125,7 +148,14 @@ export const NeedsAttentionCard = ({</CardAction></CardHeader><CardContent>- {sortedProjects.length > 0 && filtered.length === 0 && (+ {view === InsightsView.NeedsAttention && modeProjects.length === 0 && !isSearching && (+ <Empty className="border-0">+ <EmptyHeader>+ <EmptyTitle>You don't have any projects with issues</EmptyTitle>+ </EmptyHeader>+ </Empty>+ )}+ {modeProjects.length > 0 && filtered.length === 0 && (<Empty className="border-0"><EmptyHeader><EmptyTitle>No projects match your search</EmptyTitle>@@ -194,7 +224,7 @@ export const NeedsAttentionCard = ({)}{!isSearching && !hasMore && filtered.length > COLLAPSED_ROW_COUNT && (<Button variant="ghost" size="xs" onClick={() => setShowAll((prev) => !prev)}>- {showAll ? "Show Fewer Projects" : "Show All Projects"}+ {showAll ? "Show Fewer" : "Show More"}{showAll ? <ChevronUpIcon /> : <ChevronDownIcon />}</Button>)}diff --git a/frontend/src/pages/organization/SecretInsightsPage/components/index.ts b/frontend/src/pages/organization/SecretInsightsPage/components/index.tsindex bc2524dc1c..2a8d46c106 100644--- a/frontend/src/pages/organization/SecretInsightsPage/components/index.ts+++ b/frontend/src/pages/organization/SecretInsightsPage/components/index.ts@@ -1,5 +1,5 @@export { AuthMethodsCard } from "./AuthMethodsCard";-export { NeedsAttentionCard } from "./NeedsAttentionCard";+export { InsightsCard } from "./InsightsCard";export { RequestOrgAuditReportModal } from "./RequestOrgAuditReportModal";export { SecretAccessVolumeCard } from "./SecretAccessVolumeCard";export { StaticSecretPresenceCard } from "./StaticSecretPresenceCard";