Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix(web): env and plan badges use the design-system Badge (#18481)

Trang Nguyen508cb5b66a2a
diff --git a/web/src/components/EnvLabelBadge.stories.tsx b/web/src/components/EnvLabelBadge.stories.tsx
index b1fe2c21f8..30e682e1f1 100644
--- a/web/src/components/EnvLabelBadge.stories.tsx
+++ b/web/src/components/EnvLabelBadge.stories.tsx
@@ -1,5 +1,3 @@
-import { fn } from "storybook/test";
-
import preview from "../../.storybook/preview";
import { EnvLabelBadge } from "./EnvLabelBadge";
@@ -10,20 +8,17 @@ const meta = preview.meta({
export const Development = meta.story({
args: {
region: "DEV",
- onClick: fn(),
},
});
export const Staging = meta.story({
args: {
region: "STAGING",
- onClick: fn(),
},
});
export const Production = meta.story({
args: {
region: "EU",
- onClick: fn(),
},
});
diff --git a/web/src/components/EnvLabelBadge.tsx b/web/src/components/EnvLabelBadge.tsx
index 04c493e81e..800a8c5b17 100644
--- a/web/src/components/EnvLabelBadge.tsx
+++ b/web/src/components/EnvLabelBadge.tsx
@@ -2,60 +2,37 @@ import {
isRegionProduction,
type CloudRegionName,
} from "@/src/features/organizations";
+import { Badge } from "@/src/components/design-system/Badge/Badge";
import { assertUnreachable } from "@/src/utils/types";
-import { cva } from "class-variance-authority";
import { useMemo } from "react";
-const envLabelBadgeVariants = cva(
- "flex h-5 cursor-pointer items-center gap-1 rounded-md px-1 text-xs whitespace-nowrap",
- {
- variants: {
- variant: {
- development: "bg-light-green text-dark-green",
- staging: "bg-light-blue text-dark-blue",
- production: "bg-light-red text-dark-red",
- },
- },
- },
-);
-
-export const EnvLabelBadge = ({
- region,
- onClick,
-}: {
- region: CloudRegionName;
- onClick: () => void;
-}) => {
- const { label, variant } = useMemo(() => {
+export const EnvLabelBadge = ({ region }: { region: CloudRegionName }) => {
+ const { label, color } = useMemo(() => {
const isProduction = isRegionProduction(region);
if (isProduction) {
return {
label: `PROD-${region}`,
- variant: "production",
+ color: "red",
} as const;
}
if (region === "STAGING") {
return {
label: region,
- variant: "staging",
+ color: "blue",
} as const;
}
if (region === "DEV") {
return {
label: region,
- variant: "development",
+ color: "green",
} as const;
}
return assertUnreachable(region);
}, [region]);
- return (
- <div className={envLabelBadgeVariants({ variant })} onClick={onClick}>
- {label}
- </div>
- );
+ return <Badge color={color} font="mono" size="sm" text={label} />;
};
diff --git a/web/src/components/layouts/breadcrumb.tsx b/web/src/components/layouts/breadcrumb.tsx
index 37e4180e29..67d8ced18f 100644
--- a/web/src/components/layouts/breadcrumb.tsx
+++ b/web/src/components/layouts/breadcrumb.tsx
@@ -18,7 +18,7 @@ import { useSession } from "next-auth/react";
import { useHasOrganizationAccess } from "@/src/features/rbac";
import { isCloudPlan, planLabels } from "@langfuse/shared";
import Link from "next/link";
-import { Badge } from "@/src/components/ui/badge";
+import { Badge } from "@/src/components/design-system/Badge/Badge";
import { OrganizationDropdownMenu } from "@/src/components/OrganizationDropdownMenu/OrganizationDropdownMenu";
import { ProjectDropdownMenu } from "@/src/components/ProjectDropdownMenu/ProjectDropdownMenu";
@@ -55,15 +55,18 @@ const BreadcrumbComponent = ({
{({ getTriggerProps }) => (
<button
type="button"
- className="text-primary flex h-5 items-center gap-1 p-0 text-sm leading-none"
+ className="text-primary flex h-5 items-center gap-1.5 p-0 text-sm leading-none"
{...getTriggerProps()}
>
{organization?.name ?? "Organization"}
{isCloudPlan(organization?.plan) &&
organization.id !== env.NEXT_PUBLIC_DEMO_ORG_ID && (
- <Badge variant="secondary">
- {planLabels[organization.plan]}
- </Badge>
+ <Badge
+ color="filled"
+ font="mono"
+ size="sm"
+ text={planLabels[organization.plan]}
+ />
)}
<DropdownIndicator size="sm" nudge />
</button>
@@ -91,7 +94,7 @@ const BreadcrumbComponent = ({
{({ getTriggerProps }) => (
<button
type="button"
- className="text-primary flex h-5 items-center gap-1 p-0 leading-none"
+ className="text-primary flex h-5 items-center gap-1.5 p-0 leading-none"
{...getTriggerProps()}
>
{project.name}
diff --git a/web/src/components/layouts/mobile-top-bar.tsx b/web/src/components/layouts/mobile-top-bar.tsx
index 409440fd33..1fdc076c69 100644
--- a/web/src/components/layouts/mobile-top-bar.tsx
+++ b/web/src/components/layouts/mobile-top-bar.tsx
@@ -52,9 +52,7 @@ export const MobileTopBar = ({
) : (
leadingControl
)}
- {envLabel.visible && (
- <EnvLabelBadge region={envLabel.region} onClick={envLabel.dismiss} />
- )}
+ {envLabel.visible && <EnvLabelBadge region={envLabel.region} />}
</div>
{/* Center: the Langfuse wordmark. */}
diff --git a/web/src/components/layouts/page-header.tsx b/web/src/components/layouts/page-header.tsx
index 4475d93abe..687ce724cf 100644
--- a/web/src/components/layouts/page-header.tsx
+++ b/web/src/components/layouts/page-header.tsx
@@ -129,12 +129,7 @@ const PageHeader = ({
)
)}
<div className="flex flex-wrap items-center gap-1.5">
- {envLabel.visible && (
- <EnvLabelBadge
- region={envLabel.region}
- onClick={envLabel.dismiss}
- />
- )}
+ {envLabel.visible && <EnvLabelBadge region={envLabel.region} />}
<BreadcrumbComponent items={breadcrumb} />
{breadcrumbBadges}
</div>
diff --git a/web/src/hooks/useEnvLabel.ts b/web/src/hooks/useEnvLabel.ts
index 58f0345611..6eecaeaa55 100644
--- a/web/src/hooks/useEnvLabel.ts
+++ b/web/src/hooks/useEnvLabel.ts
@@ -1,9 +1,7 @@
import { useLangfuseCloudRegion } from "@/src/features/organizations";
import { useSession } from "next-auth/react";
-import { useState } from "react";
export const useEnvLabel = () => {
- const [isHidden, setIsHidden] = useState(false);
const session = useSession();
const { isLangfuseCloud, region } = useLangfuseCloudRegion();
@@ -11,11 +9,9 @@ export const useEnvLabel = () => {
if (!session.data?.user?.email?.endsWith("@langfuse.com")) {
return { visible: false } as const;
}
- if (isHidden) return { visible: false } as const;
return {
visible: true,
region: region,
- dismiss: () => setIsHidden(true),
} as const;
};