The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Generalize environment banners for non-production workspaces
Kiran Kc5ca057d9f8a
diff --git a/apps/web/lib/hooks/use-dashboard-banner-visible.ts b/apps/web/lib/hooks/use-dashboard-banner-visible.tsindex a15d4d51ec..fd3bfedb6e 100644--- a/apps/web/lib/hooks/use-dashboard-banner-visible.ts+++ b/apps/web/lib/hooks/use-dashboard-banner-visible.ts@@ -15,14 +15,14 @@ export function useDashboardBannerVisible() {const isUpgradeBannerVisible =exceededEvents || exceededLinks || exceededPayouts || !!paymentFailedAt;- const isStagingBannerVisible =- environment === WorkspaceEnvironment.staging && !isUpgradeBannerVisible;+ const isEnvironmentBannerVisible =+ environment !== WorkspaceEnvironment.production && !isUpgradeBannerVisible;- const hasBanner = isUpgradeBannerVisible || isStagingBannerVisible;+ const hasBanner = isUpgradeBannerVisible || isEnvironmentBannerVisible;return {isUpgradeBannerVisible,- isStagingBannerVisible,+ isEnvironmentBannerVisible,hasBanner,};}diff --git a/apps/web/ui/layout/program-environment-banner.tsx b/apps/web/ui/layout/program-environment-banner.tsxindex 472adcb9d1..9f6e808d0b 100644--- a/apps/web/ui/layout/program-environment-banner.tsx+++ b/apps/web/ui/layout/program-environment-banner.tsx@@ -1,31 +1,34 @@import { WorkspaceEnvironment } from "@dub/prisma/client";-import { Cube } from "@dub/ui/icons";-import { cn } from "@dub/utils";+import { IsolatedCube } from "@dub/ui/icons";+import { capitalize, cn } from "@dub/utils";export function ProgramEnvironmentBanner({environment,}: {environment: WorkspaceEnvironment;}) {- if (environment !== WorkspaceEnvironment.staging) {+ if (environment === WorkspaceEnvironment.production) {return null;}return (<divclassName={cn(- "fixed left-0 right-0 top-0 z-50 flex h-12 items-center justify-between gap-4 overflow-hidden bg-amber-200 px-6 text-neutral-800",+ "fixed left-0 right-0 top-0 z-50 flex h-12 items-center justify-between gap-4 overflow-hidden px-6 text-neutral-800",+ environment === WorkspaceEnvironment.staging+ ? "bg-amber-200"+ : "bg-blue-200",)}><div className="flex shrink-0 items-center gap-2">- <Cube className="size-4 shrink-0" />+ <IsolatedCube className="size-4 shrink-0" /><span className="truncate text-sm font-semibold">- Staging workspace+ {capitalize(environment)}</span></div><p className="text-sm font-medium">- No real money or payouts in staging.{" "}+ No real money or payouts in {capitalize(environment)}</p></div>);diff --git a/apps/web/ui/layout/workspace-environment-banner.tsx b/apps/web/ui/layout/workspace-environment-banner.tsxindex b28b5d654f..817b784fe6 100644--- a/apps/web/ui/layout/workspace-environment-banner.tsx+++ b/apps/web/ui/layout/workspace-environment-banner.tsx@@ -3,17 +3,19 @@import { useDashboardBannerVisible } from "@/lib/hooks/use-dashboard-banner-visible";import useWorkspace from "@/lib/swr/use-workspace";import useWorkspaces from "@/lib/swr/use-workspaces";-import { Cube } from "@dub/ui/icons";+import { WorkspaceEnvironment } from "@dub/prisma/client";+import { IsolatedCube } from "@dub/ui";import { cn } from "@dub/utils";+import { capitalize } from "@dub/utils/src";import { motion } from "motion/react";import Link from "next/link";export function WorkspaceEnvironmentBanner() {- const { id } = useWorkspace();+ const { id, environment } = useWorkspace();const { workspaces } = useWorkspaces();- const { isStagingBannerVisible } = useDashboardBannerVisible();+ const { isEnvironmentBannerVisible } = useDashboardBannerVisible();- if (!isStagingBannerVisible) {+ if (!isEnvironmentBannerVisible) {return null;}@@ -26,13 +28,16 @@ export function WorkspaceEnvironmentBanner() {initial={{ transform: "translateY(-100%)" }}animate={{ transform: "translateY(0)" }}className={cn(- "fixed left-0 right-0 top-0 z-30 flex h-12 items-center justify-between gap-4 overflow-hidden bg-amber-200 px-6 text-neutral-800",+ "fixed left-0 right-0 top-0 z-30 flex h-12 items-center justify-between gap-4 overflow-hidden px-6 text-neutral-800",+ environment === WorkspaceEnvironment.staging+ ? "bg-amber-200"+ : "bg-blue-200",)}><div className="flex min-w-0 shrink-0 items-center gap-2">- <Cube className="size-4 shrink-0" />+ <IsolatedCube className="size-4 shrink-0" /><span className="truncate text-sm font-semibold">- Staging workspace+ {capitalize(environment)} workspace</span></div>diff --git a/packages/ui/src/icons/nucleo/index.ts b/packages/ui/src/icons/nucleo/index.tsindex e171b418ea..784bd5e123 100644--- a/packages/ui/src/icons/nucleo/index.ts+++ b/packages/ui/src/icons/nucleo/index.ts@@ -151,6 +151,7 @@ export * from "./input-password";export * from "./input-password-pointer";export * from "./input-search";export * from "./invoice-dollar";+export * from "./isolated-cube";export * from "./key";export * from "./layout-sidebar";export * from "./license";diff --git a/packages/ui/src/icons/nucleo/isolated-cube.tsx b/packages/ui/src/icons/nucleo/isolated-cube.tsxnew file mode 100644index 0000000000..4018bc3577--- /dev/null+++ b/packages/ui/src/icons/nucleo/isolated-cube.tsx@@ -0,0 +1,59 @@+import { SVGProps } from "react";++export function IsolatedCube(props: SVGProps<SVGSVGElement>) {+ return (+ <svg+ width={18}+ height={18}+ viewBox="0 0 18 18"+ fill="none"+ xmlns="http://www.w3.org/2000/svg"+ {...props}+ >+ <g clipPath="url(#clip0_53779_199300)">+ <path+ d="M1.77756 2.66645C2.26848 2.66645 2.66645 2.26848 2.66645 1.77756C2.66645 1.28664 2.26848 0.888672 1.77756 0.888672C1.28664 0.888672 0.888672 1.28664 0.888672 1.77756C0.888672 2.26848 1.28664 2.66645 1.77756 2.66645Z"+ fill="#262626"+ />+ <path+ d="M14.2219 2.66645C14.7128 2.66645 15.1108 2.26848 15.1108 1.77756C15.1108 1.28664 14.7128 0.888672 14.2219 0.888672C13.731 0.888672 13.333 1.28664 13.333 1.77756C13.333 2.26848 13.731 2.66645 14.2219 2.66645Z"+ fill="#262626"+ />+ <path+ d="M1.77756 15.1108C2.26848 15.1108 2.66645 14.7128 2.66645 14.2219C2.66645 13.731 2.26848 13.333 1.77756 13.333C1.28664 13.333 0.888672 13.731 0.888672 14.2219C0.888672 14.7128 1.28664 15.1108 1.77756 15.1108Z"+ fill="#262626"+ />+ <path+ d="M14.2219 15.1108C14.7128 15.1108 15.1108 14.7128 15.1108 14.2219C15.1108 13.731 14.7128 13.333 14.2219 13.333C13.731 13.333 13.333 13.731 13.333 14.2219C13.333 14.7128 13.731 15.1108 14.2219 15.1108Z"+ fill="#262626"+ />+ <path+ d="M7.25034 3.02067L4.07701 4.86156C3.61656 5.12911 3.33301 5.62067 3.33301 6.15311V9.84645C3.33301 10.3789 3.61656 10.8713 4.07701 11.138L7.25034 12.9789C7.71345 13.2473 8.2859 13.2473 8.74901 12.9789L11.9223 11.138C12.3828 10.8704 12.6663 10.3789 12.6663 9.84645V6.15311C12.6663 5.62067 12.3828 5.12822 11.9223 4.86156L8.74901 3.02067C8.2859 2.75222 7.71345 2.75222 7.25034 3.02067Z"+ stroke="#262626"+ strokeWidth={1.5}+ strokeLinecap="round"+ strokeLinejoin="round"+ />+ <path+ d="M12.4673 5.4082L7.99978 7.99931L3.53223 5.4082"+ stroke="#262626"+ strokeWidth={1.5}+ strokeLinecap="round"+ strokeLinejoin="round"+ />+ <path+ d="M8 13.1804V8"+ stroke="#262626"+ strokeWidth={1.5}+ strokeLinecap="round"+ strokeLinejoin="round"+ />+ </g>+ <defs>+ <clipPath id="clip0_53779_199300">+ <rect width={16} height={16} fill="white" />+ </clipPath>+ </defs>+ </svg>+ );+}