Skip to content

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

fix(ui): scope navigation plan badges to products (#8389)

Andrew Huange40b45bd9b13
diff --git a/backend/src/ee/services/license/license-types.ts b/backend/src/ee/services/license/license-types.ts
index 50372fab05..2889f5d4a1 100644
--- a/backend/src/ee/services/license/license-types.ts
+++ b/backend/src/ee/services/license/license-types.ts
@@ -36,6 +36,13 @@ export type TOrgSeatUsage = {
export type TFeatureSet = {
_id: null;
slug: string | null;
+ productPlans?: {
+ productKey: string;
+ planKey: string | null;
+ status: string | null;
+ trialPlanKey: string | null;
+ trialEndsAt: string | null;
+ }[];
// True when features are sourced from an offline (air-gapped) license; the billing UI renders a
// read-only offline banner instead of the live billing surface.
isOffline?: boolean;
diff --git a/backend/src/services/license-client/entitlement-projection.ts b/backend/src/services/license-client/entitlement-projection.ts
index 55dd74806d..4b86ab5994 100644
--- a/backend/src/services/license-client/entitlement-projection.ts
+++ b/backend/src/services/license-client/entitlement-projection.ts
@@ -10,6 +10,13 @@ import { TEntitlementsResponse } from "./license-client-types";
export const projectV2ToFeatureSet = (base: TFeatureSet, entitlements: TEntitlementsResponse): TFeatureSet => {
const plan = JSON.parse(JSON.stringify(base)) as Record<string, unknown> & { rateLimits: Record<string, unknown> };
plan.slug = entitlements?.slug;
+ plan.productPlans = (entitlements.products ?? []).map((product) => ({
+ productKey: product.product_key,
+ planKey: product.plan_key ?? null,
+ status: product.status ?? null,
+ trialPlanKey: product.trial_plan_key ?? null,
+ trialEndsAt: product.trial_ends_at ?? null
+ }));
FEATURE_MAPPINGS.forEach((mapping) => {
if (mapping.v1Field === null) {
diff --git a/frontend/src/hooks/api/billingV2/mutations.tsx b/frontend/src/hooks/api/billingV2/mutations.tsx
index 94b7fb7fa5..4630abd8b9 100644
--- a/frontend/src/hooks/api/billingV2/mutations.tsx
+++ b/frontend/src/hooks/api/billingV2/mutations.tsx
@@ -2,7 +2,7 @@ import { QueryClient, useMutation, useQueryClient } from "@tanstack/react-query"
import { apiRequest } from "@app/config/request";
-import { subscriptionQueryKeys } from "../subscriptions/queries";
+import { fetchOrgSubscription, subscriptionQueryKeys } from "../subscriptions/queries";
import { billingV2Keys } from "./queries";
import {
BillingV2CheckoutResult,
@@ -29,6 +29,14 @@ import {
const invalidateBillingV2 = (queryClient: QueryClient, orgId: string) => {
queryClient.invalidateQueries({ queryKey: billingV2Keys.overview(orgId) });
queryClient.invalidateQueries({ queryKey: billingV2Keys.catalog(orgId) });
+ const queryKey = subscriptionQueryKeys.getOrgSubsription(orgId);
+ return queryClient
+ .fetchQuery({
+ queryKey,
+ queryFn: () => fetchOrgSubscription(orgId, true),
+ staleTime: 0
+ })
+ .catch(() => queryClient.invalidateQueries({ queryKey }));
};
export const useCreateBillingV2PortalSession = () => {
diff --git a/frontend/src/hooks/api/subscriptions/types.ts b/frontend/src/hooks/api/subscriptions/types.ts
index 00bc0a6276..63f3b8621a 100644
--- a/frontend/src/hooks/api/subscriptions/types.ts
+++ b/frontend/src/hooks/api/subscriptions/types.ts
@@ -11,6 +11,13 @@ export enum SubscriptionPlanTypes {
}
export type SubscriptionPlan = {
+ productPlans?: {
+ productKey: string;
+ planKey: string | null;
+ status: string | null;
+ trialPlanKey: string | null;
+ trialEndsAt: string | null;
+ }[];
id: string;
memberLimit: number;
identityLimit: number;
diff --git a/frontend/src/layouts/OrganizationLayout/components/NavBar/Navbar.tsx b/frontend/src/layouts/OrganizationLayout/components/NavBar/Navbar.tsx
index ec56b9db3e..2e14b7246c 100644
--- a/frontend/src/layouts/OrganizationLayout/components/NavBar/Navbar.tsx
+++ b/frontend/src/layouts/OrganizationLayout/components/NavBar/Navbar.tsx
@@ -87,7 +87,6 @@ import { authKeys, fetchAuthToken, selectOrganization } from "@app/hooks/api/aut
import { MfaMethod } from "@app/hooks/api/auth/types";
import { ProjectType } from "@app/hooks/api/projects/types";
import { getAuthToken } from "@app/hooks/api/reactQuery";
-import { getSubscriptionPlanLabel } from "@app/hooks/api/subscriptions";
import { Organization } from "@app/hooks/api/types";
import { AuthMethod } from "@app/hooks/api/users/types";
import {
@@ -624,9 +623,6 @@ export const Navbar = () => {
</div>
<VersionBadge />
- <Badge variant="info" className="mt-[3px] mr-3 hidden md:inline-flex">
- {getSubscriptionPlanLabel(subscription)}
- </Badge>
{!location.pathname.startsWith("/admin") && user.superAdmin && (
<Button variant="outline" size="xs" className="mt-px mr-2" asChild>
<Link to="/admin" onClick={handleNavigateToAdminConsole}>
diff --git a/frontend/src/layouts/ProjectLayout/components/TypeSelect/ProductPlanBadge.tsx b/frontend/src/layouts/ProjectLayout/components/TypeSelect/ProductPlanBadge.tsx
new file mode 100644
index 0000000000..ffdff1d417
--- /dev/null
+++ b/frontend/src/layouts/ProjectLayout/components/TypeSelect/ProductPlanBadge.tsx
@@ -0,0 +1,51 @@
+import { Badge } from "@app/components/v3";
+import { useSubscription } from "@app/context";
+import { ProjectType } from "@app/hooks/api/projects/types";
+
+const PRODUCT_KEYS: Partial<Record<ProjectType, string>> = {
+ [ProjectType.SecretManager]: "secrets_manager",
+ [ProjectType.CertificateManager]: "cert_management",
+ [ProjectType.PAM]: "pam"
+};
+
+const PLAN_LABELS = new Map([
+ ["pro", "Pro"],
+ ["advanced", "Advanced"],
+ ["enterprise", "Enterprise"],
+ ["legacy_pro_annual", "Pro"],
+ ["legacy_team", "Team"],
+ ["legacy_team_annual", "Team"],
+ ["legacy_enterprise", "Enterprise"]
+]);
+
+export const ProductPlanBadge = ({ type }: { type: ProjectType }) => {
+ const { subscription } = useSubscription();
+ const productKey = PRODUCT_KEYS[type];
+
+ const plans = subscription.productPlans ?? [];
+ const product =
+ plans.find((plan) => plan.productKey === productKey) ??
+ (type === ProjectType.SecretManager
+ ? plans.find((plan) => plan.productKey === "legacy_secret_management")
+ : undefined);
+ const trialEndsAt = product?.trialEndsAt ? new Date(product.trialEndsAt).getTime() : null;
+
+ if (!product || !["active", "trialing", "grace"].includes(product.status ?? "")) {
+ return null;
+ }
+
+ const hasActiveTrial =
+ Boolean(product.trialPlanKey || product.status === "trialing") &&
+ (!product.trialEndsAt || (trialEndsAt !== null && trialEndsAt > Date.now()));
+ if (product.status === "trialing" && !hasActiveTrial && !product.trialPlanKey) return null;
+
+ const planKey = hasActiveTrial ? (product.trialPlanKey ?? product.planKey) : product.planKey;
+ const label = planKey ? PLAN_LABELS.get(planKey) : undefined;
+ if (!label) return null;
+
+ return (
+ <Badge variant="info" className="shrink-0 max-sm:hidden">
+ {label}
+ </Badge>
+ );
+};
diff --git a/frontend/src/layouts/ProjectLayout/components/TypeSelect/TypeSelect.tsx b/frontend/src/layouts/ProjectLayout/components/TypeSelect/TypeSelect.tsx
index 340db45ed7..e8d4f3cc97 100644
--- a/frontend/src/layouts/ProjectLayout/components/TypeSelect/TypeSelect.tsx
+++ b/frontend/src/layouts/ProjectLayout/components/TypeSelect/TypeSelect.tsx
@@ -25,6 +25,8 @@ import {
NavbarSwitcherTrigger
} from "@app/layouts/NavbarSwitcher";
+import { ProductPlanBadge } from "./ProductPlanBadge";
+
const PRODUCT_TYPES: ProjectType[] = [
ProjectType.SecretManager,
ProjectType.CertificateManager,
@@ -130,10 +132,11 @@ const TypeSelectInner = ({
});
}
}}
- className="group flex cursor-pointer items-center gap-x-2 overflow-hidden text-sm text-foreground-inverse"
+ className="group grid min-w-min cursor-pointer grid-flow-col grid-cols-[auto_minmax(0,1fr)] items-center gap-x-2 overflow-hidden text-sm text-foreground-inverse"
>
<ProductIcon className="h-[14px] w-[14px] shrink-0" />
<span className="truncate">{pillLabel}</span>
+ <ProductPlanBadge type={currentType} />
</button>
<PreviewBadge type={currentType} />
<NavbarSwitcherTrigger aria-label="switch-product-type" />