Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

improvement(ui): use real links for certificate dashboard cards and legends (#8935)

Andrew Huangbfb9f919d81b
diff --git a/frontend/src/pages/cert-manager/DashboardPage/DashboardPage.tsx b/frontend/src/pages/cert-manager/DashboardPage/DashboardPage.tsx
index f1dea91def..6b3f9c78b0 100644
--- a/frontend/src/pages/cert-manager/DashboardPage/DashboardPage.tsx
+++ b/frontend/src/pages/cert-manager/DashboardPage/DashboardPage.tsx
@@ -17,6 +17,7 @@ import {
import { ProjectType } from "@app/hooks/api/projects/types";
import { CertManagerAdminOnly } from "@app/pages/cert-manager/components/CertManagerAdminOnly";
+import { getInventoryLink, type InventoryFilters } from "./components/inventory-link";
import {
ActivityTrend,
CodeSigningSection,
@@ -38,18 +39,19 @@ export const DashboardPage = () => {
);
const { data: trendData } = useGetCertActivityTrend(currentProject?.id || "", trendRange);
const { data: pqcTrendData } = useGetCertPqcTrend(currentProject?.id || "", pqcTrendRange);
+ const getLink = useCallback(
+ (filters: InventoryFilters) => getInventoryLink(currentProject, filters),
+ [currentProject]
+ );
const navigateToInventory = useCallback(
- (filters: Record<string, string | undefined>) => {
+ (filters: InventoryFilters) =>
navigate({
to: "/organizations/$orgId/cert-manager/inventory",
- params: {
- orgId: currentProject?.orgId || ""
- },
+ params: { orgId: currentProject?.orgId || "" },
// eslint-disable-next-line @typescript-eslint/no-explicit-any
search: filters as any
- });
- },
- [navigate, currentProject]
+ }),
+ [navigate, currentProject?.orgId]
);
if (!currentProject) {
return (
@@ -79,11 +81,16 @@ export const DashboardPage = () => {
<PageLoader />
) : (
<div className="flex flex-col gap-6">
- <KpiCards stats={stats} onNavigate={navigateToInventory} />
+ <KpiCards stats={stats} getLink={getLink} />
<div className="grid grid-cols-1 gap-4 xl:grid-cols-2">
- <DistributionCharts stats={stats} onNavigate={navigateToInventory} />
+ <DistributionCharts
+ stats={stats}
+ getLink={getLink}
+ onNavigate={navigateToInventory}
+ />
<ExpirationTimeline
buckets={stats.expirationBuckets}
+ getLink={getLink}
onNavigate={navigateToInventory}
/>
</div>
@@ -100,7 +107,11 @@ export const DashboardPage = () => {
Post-Quantum Readiness
</h2>
<div className="flex flex-wrap gap-4">
- <PqcReadinessChart stats={stats} onNavigate={navigateToInventory} />
+ <PqcReadinessChart
+ stats={stats}
+ getLink={getLink}
+ onNavigate={navigateToInventory}
+ />
<PqcTrend
data={pqcTrendData?.periods || []}
currentRange={pqcTrendRange}
diff --git a/frontend/src/pages/cert-manager/DashboardPage/components/DistributionCharts.tsx b/frontend/src/pages/cert-manager/DashboardPage/components/DistributionCharts.tsx
index 50731e1486..bf713f592f 100644
--- a/frontend/src/pages/cert-manager/DashboardPage/components/DistributionCharts.tsx
+++ b/frontend/src/pages/cert-manager/DashboardPage/components/DistributionCharts.tsx
@@ -1,3 +1,4 @@
+import { Link } from "@tanstack/react-router";
import { Cell, Pie, PieChart, ResponsiveContainer, Tooltip as RechartsTooltip } from "recharts";
import { twMerge } from "tailwind-merge";
@@ -23,10 +24,12 @@ import {
formatShare,
MAX_DONUT_SEGMENTS
} from "./chart-theme";
+import type { InventoryFilters, InventoryLink } from "./inventory-link";
type Props = {
stats: TDashboardStats;
- onNavigate: (filters: Record<string, string | undefined>) => void;
+ getLink: (filters: InventoryFilters) => InventoryLink;
+ onNavigate: (filters: InventoryFilters) => void;
};
type ChartKey = "enrollmentMethod" | "algorithm" | "ca";
@@ -61,13 +64,17 @@ const DonutChart = ({
subtitle,
data,
chartKey,
- onSegmentClick
+ getSegmentFilters,
+ getLink,
+ onNavigate
}: {
title: string;
subtitle?: string;
data: TDashboardDistribution[];
chartKey: ChartKey;
- onSegmentClick?: (entry: TDashboardDistribution) => void;
+ getSegmentFilters: (entry: TDashboardDistribution) => InventoryFilters | null;
+ getLink: (filters: InventoryFilters) => InventoryLink;
+ onNavigate: (filters: InventoryFilters) => void;
}) => {
const nonZeroData = foldTail(data);
const total = data.reduce((sum, d) => sum + d.count, 0);
@@ -131,7 +138,8 @@ const DonutChart = ({
stroke="none"
onClick={(_entry, idx) => {
const segment = nonZeroData[idx];
- if (!segment.groupedCount) onSegmentClick?.(segment);
+ const filters = segment.groupedCount ? null : getSegmentFilters(segment);
+ if (filters) onNavigate(filters);
}}
>
{nonZeroData.map((entry, idx) => (
@@ -154,18 +162,13 @@ const DonutChart = ({
{nonZeroData.map((entry, idx) => {
const pct = formatShare(entry.count, total);
const isOther = Boolean(entry.groupedCount);
- return (
- <button
- key={segmentKey(entry)}
- type="button"
- className={twMerge(
- "flex w-full items-center gap-2 rounded px-1 py-0.5 text-xs transition-colors",
- isOther ? "cursor-default" : "cursor-pointer hover:bg-foreground/5"
- )}
- onClick={() => {
- if (!isOther) onSegmentClick?.(entry);
- }}
- >
+ const filters = isOther ? null : getSegmentFilters(entry);
+ const legendClassName = twMerge(
+ "flex w-full items-center gap-2 rounded px-1 py-0.5 text-xs transition-colors",
+ filters ? "cursor-pointer hover:bg-foreground/5" : "cursor-default"
+ );
+ const legendContent = (
+ <>
<span
className="h-2.5 w-2.5 shrink-0 rounded-full"
style={{ backgroundColor: colorAt(entry, idx) }}
@@ -184,7 +187,16 @@ const DonutChart = ({
<span className="shrink-0 text-right font-medium text-foreground">
{entry.count}
</span>
- </button>
+ </>
+ );
+ return filters ? (
+ <Link key={segmentKey(entry)} {...getLink(filters)} className={legendClassName}>
+ {legendContent}
+ </Link>
+ ) : (
+ <div key={segmentKey(entry)} className={legendClassName}>
+ {legendContent}
+ </div>
);
})}
</div>
@@ -200,7 +212,7 @@ const DonutChart = ({
);
};
-export const DistributionCharts = ({ stats, onNavigate }: Props) => {
+export const DistributionCharts = ({ stats, getLink, onNavigate }: Props) => {
const charts: {
title: string;
subtitle?: string;
@@ -236,14 +248,17 @@ export const DistributionCharts = ({ stats, onNavigate }: Props) => {
subtitle={chart.subtitle}
chartKey={chart.chartKey}
data={chart.data}
- onSegmentClick={(entry) => {
+ getLink={getLink}
+ onNavigate={onNavigate}
+ getSegmentFilters={(entry) => {
if (chart.chartKey === "enrollmentMethod" && entry.label !== "Other") {
- onNavigate({ filterEnrollmentType: entry.label });
- } else if (chart.chartKey === "algorithm" && entry.label !== "Unknown") {
- onNavigate({ filterKeyAlgorithm: entry.label });
- } else if (chart.chartKey === "ca" && entry.id) {
- onNavigate({ filterCaId: entry.id });
+ return { filterEnrollmentType: entry.label };
+ }
+ if (chart.chartKey === "algorithm" && entry.label !== "Unknown") {
+ return { filterKeyAlgorithm: entry.label };
}
+ if (chart.chartKey === "ca" && entry.id) return { filterCaId: entry.id };
+ return null;
}}
/>
))}
diff --git a/frontend/src/pages/cert-manager/DashboardPage/components/ExpirationTimeline.tsx b/frontend/src/pages/cert-manager/DashboardPage/components/ExpirationTimeline.tsx
index 29e5896ddd..6ce6945323 100644
--- a/frontend/src/pages/cert-manager/DashboardPage/components/ExpirationTimeline.tsx
+++ b/frontend/src/pages/cert-manager/DashboardPage/components/ExpirationTimeline.tsx
@@ -1,4 +1,5 @@
import { useMemo } from "react";
+import { Link } from "@tanstack/react-router";
import { Cell, Pie, PieChart, ResponsiveContainer, Tooltip as RechartsTooltip } from "recharts";
import {
@@ -17,10 +18,12 @@ import {
import type { TExpirationBucket } from "@app/hooks/api/certificates";
import { CHART_COLORS_HEX, formatShare } from "./chart-theme";
+import type { InventoryFilters, InventoryLink } from "./inventory-link";
type Props = {
buckets: TExpirationBucket[];
- onNavigate: (filters: Record<string, string | undefined>) => void;
+ getLink: (filters: InventoryFilters) => InventoryLink;
+ onNavigate: (filters: InventoryFilters) => void;
};
const DONUT_SEGMENTS = [
@@ -41,7 +44,7 @@ const DONUT_SEGMENTS = [
}
];
-export const ExpirationTimeline = ({ buckets, onNavigate }: Props) => {
+export const ExpirationTimeline = ({ buckets, getLink, onNavigate }: Props) => {
const bucketMap = useMemo(() => {
const map = new Map<string, number>();
buckets.forEach((b) => map.set(b.bucket, b.count));
@@ -134,13 +137,10 @@ export const ExpirationTimeline = ({ buckets, onNavigate }: Props) => {
{chartData.map((item) => {
const pct = formatShare(item.count, total);
return (
- <button
+ <Link
key={item.label}
- type="button"
+ {...getLink(item.filter)}
className="flex w-full cursor-pointer items-center gap-2 rounded px-1 py-0.5 text-xs transition-colors hover:bg-foreground/5"
- onClick={() => {
- if (item.filter) onNavigate(item.filter);
- }}
>
<span
className="h-2.5 w-2.5 shrink-0 rounded-full"
@@ -160,7 +160,7 @@ export const ExpirationTimeline = ({ buckets, onNavigate }: Props) => {
<span className="shrink-0 text-right font-medium text-foreground">
{item.count}
</span>
- </button>
+ </Link>
);
})}
</div>
diff --git a/frontend/src/pages/cert-manager/DashboardPage/components/KpiCards.tsx b/frontend/src/pages/cert-manager/DashboardPage/components/KpiCards.tsx
index d541f94dec..85cf12b072 100644
--- a/frontend/src/pages/cert-manager/DashboardPage/components/KpiCards.tsx
+++ b/frontend/src/pages/cert-manager/DashboardPage/components/KpiCards.tsx
@@ -1,13 +1,14 @@
import { AlertTriangle, FileCheck, FileClock, FileKey, FileX } from "lucide-react";
-import { Badge, Card, CardContent } from "@app/components/v3";
+import { Badge, Card, CardContent, RowLink } from "@app/components/v3";
import type { TDashboardStats } from "@app/hooks/api/certificates";
import { formatShare } from "./chart-theme";
+import type { InventoryFilters, InventoryLink } from "./inventory-link";
type Props = {
stats: TDashboardStats;
- onNavigate: (filters: Record<string, string | undefined>) => void;
+ getLink: (filters: InventoryFilters) => InventoryLink;
};
const cards = [
@@ -94,7 +95,7 @@ const getBadge = (key: string, stats: TDashboardStats) => {
return null;
};
-export const KpiCards = ({ stats, onNavigate }: Props) => {
+export const KpiCards = ({ stats, getLink }: Props) => {
return (
<div className="flex flex-wrap gap-4">
{cards.map((card) => {
@@ -104,12 +105,17 @@ export const KpiCards = ({ stats, onNavigate }: Props) => {
return (
<Card
key={card.key}
- className="h-auto min-w-[180px] flex-1 cursor-pointer gap-0 p-0 transition-colors hover:bg-container-hover"
- onClick={() => onNavigate(card.filters)}
+ linked
+ className="h-auto min-w-[180px] flex-1 gap-0 p-0 transition-colors hover:bg-container-hover"
>
<CardContent className="flex h-full flex-col p-4">
<div className="flex items-start justify-between">
- <span className="text-base font-semibold text-foreground">{card.label}</span>
+ <RowLink
+ {...getLink(card.filters)}
+ className="text-base font-semibold text-foreground after:rounded-card"
+ >
+ {card.label}
+ </RowLink>
<div
className={`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border ${card.iconBg}`}
>
diff --git a/frontend/src/pages/cert-manager/DashboardPage/components/PqcReadinessChart.tsx b/frontend/src/pages/cert-manager/DashboardPage/components/PqcReadinessChart.tsx
index fedcd92afd..2b8978be1f 100644
--- a/frontend/src/pages/cert-manager/DashboardPage/components/PqcReadinessChart.tsx
+++ b/frontend/src/pages/cert-manager/DashboardPage/components/PqcReadinessChart.tsx
@@ -1,3 +1,4 @@
+import { Link } from "@tanstack/react-router";
import { Cell, Pie, PieChart, ResponsiveContainer, Tooltip as RechartsTooltip } from "recharts";
import {
@@ -14,16 +15,18 @@ import type { TDashboardStats } from "@app/hooks/api/certificates";
import { isPqcAlgorithm } from "@app/hooks/api/certificates/constants";
import { CHART_COLORS_HEX, formatShare } from "./chart-theme";
+import type { InventoryFilters, InventoryLink } from "./inventory-link";
type Props = {
stats: TDashboardStats;
- onNavigate: (filters: Record<string, string | undefined>) => void;
+ getLink: (filters: InventoryFilters) => InventoryLink;
+ onNavigate: (filters: InventoryFilters) => void;
};
const PQC_LABEL = "PQC-ready";
const CLASSICAL_LABEL = "Classical";
-export const PqcReadinessChart = ({ stats, onNavigate }: Props) => {
+export const PqcReadinessChart = ({ stats, getLink, onNavigate }: Props) => {
const pqcCount = stats.distributions.byAlgorithm
.filter((d) => isPqcAlgorithm(d.label))
.reduce((s, d) => s + d.count, 0);
@@ -38,9 +41,9 @@ export const PqcReadinessChart = ({ stats, onNavigate }: Props) => {
const nonZeroData = data.filter((d) => d.count > 0);
const total = pqcCount + nonPqcCount;
- const handleSegmentClick = (label: string) => {
- onNavigate({ viewId: label === PQC_LABEL ? "system-pqc" : "system-non-pqc" });
- };
+ const getSegmentFilters = (label: string) => ({
+ viewId: label === PQC_LABEL ? "system-pqc" : "system-non-pqc"
+ });
return (
<Card className="flex h-auto w-full min-w-[280px] shrink-0 flex-col md:w-[320px]">
@@ -91,7 +94,7 @@ export const PqcReadinessChart = ({ stats, onNavigate }: Props) => {
paddingAngle={2}
cursor="pointer"
stroke="none"
- onClick={(_entry, idx) => handleSegmentClick(nonZeroData[idx].label)}
+ onClick={(_entry, idx) => onNavigate(getSegmentFilters(nonZeroData[idx].label))}
>
{nonZeroData.map((entry, idx) => (
<Cell key={entry.label} fill={`url(#grad-pqc-readiness-${idx})`} />
@@ -113,11 +116,10 @@ export const PqcReadinessChart = ({ stats, onNavigate }: Props) => {
{nonZeroData.map((entry, idx) => {
const pct = formatShare(entry.count, total);
return (
- <button
+ <Link
key={entry.label}
- type="button"
+ {...getLink(getSegmentFilters(entry.label))}
className="flex w-full cursor-pointer items-center gap-2 rounded px-1 py-0.5 text-xs transition-colors hover:bg-foreground/5"
- onClick={() => handleSegmentClick(entry.label)}
>
<span
className="h-2.5 w-2.5 shrink-0 rounded-full"
@@ -130,7 +132,7 @@ export const PqcReadinessChart = ({ stats, onNavigate }: Props) => {
<span className="shrink-0 text-right font-medium text-foreground">
{entry.count}
</span>
- </button>
+ </Link>
);
})}
</div>
diff --git a/frontend/src/pages/cert-manager/DashboardPage/components/inventory-link.ts b/frontend/src/pages/cert-manager/DashboardPage/components/inventory-link.ts
new file mode 100644
index 0000000000..3773dfa892
--- /dev/null
+++ b/frontend/src/pages/cert-manager/DashboardPage/components/inventory-link.ts
@@ -0,0 +1,16 @@
+import { getInstancePinningLink } from "@app/helpers/project";
+import { Project } from "@app/hooks/api/projects/types";
+
+export type InventoryFilters = Record<string, string | undefined>;
+
+export const getInventoryLink = (
+ project: Pick<Project, "id" | "type" | "orgId">,
+ filters: InventoryFilters
+) => {
+ const pinnedLink = getInstancePinningLink(project.orgId, project, "inventory");
+ if (!pinnedLink) throw new Error("The inventory link needs a Certificate Manager project");
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ return { ...pinnedLink, search: filters as any };
+};
+
+export type InventoryLink = ReturnType<typeof getInventoryLink>;
diff --git a/frontend/src/pages/cert-manager/PkiSyncDetailsByIDPage/PkiSyncDetailsByIDPage.tsx b/frontend/src/pages/cert-manager/PkiSyncDetailsByIDPage/PkiSyncDetailsByIDPage.tsx
index 934445194b..35a56de7b5 100644
--- a/frontend/src/pages/cert-manager/PkiSyncDetailsByIDPage/PkiSyncDetailsByIDPage.tsx
+++ b/frontend/src/pages/cert-manager/PkiSyncDetailsByIDPage/PkiSyncDetailsByIDPage.tsx
@@ -1,5 +1,5 @@
import { useState } from "react";
-import { useNavigate, useParams, useSearch } from "@tanstack/react-router";
+import { Link, useNavigate, useParams, useSearch } from "@tanstack/react-router";
import { BanIcon, ChevronLeftIcon } from "lucide-react";
import { PageTitle } from "@app/components/PageTitle";
@@ -26,6 +26,7 @@ import {
import { ROUTE_PATHS } from "@app/const/routes";
import { useProject } from "@app/context";
import { PKI_SYNC_MAP } from "@app/helpers/pkiSyncs";
+import { getInstancePinningLink } from "@app/helpers/project";
import { usePopUp } from "@app/hooks";
import { useGetPkiSync } from "@app/hooks/api/pkiSyncs";
import { ApplicationTab } from "@app/pages/cert-manager/ApplicationDetailsByIDPage/application-tabs";
@@ -84,6 +85,9 @@ const PageContent = () => {
const destinationDetails = PKI_SYNC_MAP[pkiSync.destination];
+ const backLinkClassName =
+ "mb-4 flex w-fit cursor-pointer items-center gap-x-1 text-sm text-muted transition duration-100 hover:text-muted/80";
+
const handleBack = () => {
if (applicationName) {
navigate({
@@ -113,14 +117,25 @@ const PageContent = () => {
<>
<div className="container mx-auto flex flex-col justify-between bg-page font-sans text-foreground-inverse">
<div className="mx-auto mb-6 w-full max-w-8xl">
- <button
- type="button"
- onClick={handleBack}
- className="mb-4 flex w-fit cursor-pointer items-center gap-x-1 text-sm text-muted transition duration-100 hover:text-muted/80"
- >
- <ChevronLeftIcon className="size-4" />
- {applicationName ? "Back to Application" : "Certificate Syncs"}
- </button>
+ {applicationName ? (
+ <Link
+ {...getInstancePinningLink(orgId, currentProject, `applications/${applicationName}`)!}
+ search={{ selectedTab: ApplicationTab.Syncs } as never}
+ className={backLinkClassName}
+ >
+ <ChevronLeftIcon className="size-4" />
+ Back to Application
+ </Link>
+ ) : (
+ <Link
+ {...getInstancePinningLink(orgId, currentProject, "integrations")!}
+ search={{ selectedTab: IntegrationsListPageTabs.PkiSyncs } as never}
+ className={backLinkClassName}
+ >
+ <ChevronLeftIcon className="size-4" />
+ Certificate Syncs
+ </Link>
+ )}
<div className="mb-6 flex w-full items-center gap-3">
<ProviderIcon
alt={`${destinationDetails.name} sync`}