Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Add staging workspace banner to dashboard layout

Kiran K8a63e39978e2
diff --git a/apps/web/app/app.dub.co/(dashboard)/layout.tsx b/apps/web/app/app.dub.co/(dashboard)/layout.tsx
index 588a3e39d3..9eb2496a6d 100644
--- a/apps/web/app/app.dub.co/(dashboard)/layout.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/layout.tsx
@@ -3,6 +3,7 @@ import { AppSidebarNav } from "@/ui/layout/sidebar/app-sidebar-nav";
import { HelpButton } from "@/ui/layout/sidebar/help-button";
import { NewsRSC } from "@/ui/layout/sidebar/news-rsc";
import { ReferButton } from "@/ui/layout/sidebar/refer-button";
+import { StagingWorkspaceBanner } from "@/ui/layout/staging-workspace-banner";
import Toolbar from "@/ui/layout/toolbar/toolbar";
import { UpgradeBanner } from "@/ui/layout/upgrade-banner";
import { constructMetadata } from "@dub/utils";
@@ -16,6 +17,7 @@ export default async function Layout({ children }: { children: ReactNode }) {
<>
<div className="min-h-screen w-full bg-white">
<UpgradeBanner />
+ <StagingWorkspaceBanner />
<MainNav
sidebar={AppSidebarNav}
toolContent={
diff --git a/apps/web/ui/layout/staging-workspace-banner.tsx b/apps/web/ui/layout/staging-workspace-banner.tsx
new file mode 100644
index 0000000000..543ffb45e0
--- /dev/null
+++ b/apps/web/ui/layout/staging-workspace-banner.tsx
@@ -0,0 +1,64 @@
+"use client";
+
+import useWorkspace from "@/lib/swr/use-workspace";
+import useWorkspaces from "@/lib/swr/use-workspaces";
+import { WorkspaceEnvironment } from "@dub/prisma/client";
+import { Cube } from "@dub/ui/icons";
+import { cn } from "@dub/utils";
+import { motion } from "motion/react";
+import Link from "next/link";
+
+export function StagingWorkspaceBanner() {
+ const { workspaces } = useWorkspaces();
+ const { id, environment } = useWorkspace();
+
+ const isVisible = environment === WorkspaceEnvironment.staging;
+
+ if (!isVisible) {
+ return null;
+ }
+
+ const liveWorkspace = id
+ ? workspaces?.find((workspace) => workspace.stagingWorkspaceId === id)
+ : undefined;
+
+ return (
+ <motion.div
+ initial={{ transform: "translateY(-100%)" }}
+ animate={{ transform: "translateY(0)" }}
+ className={cn(
+ "fixed left-0 right-0 z-50 flex items-center justify-between gap-4 overflow-hidden bg-amber-200 px-4 py-1.5 text-neutral-900",
+ )}
+ >
+ <div className="flex min-w-0 shrink-0 items-center gap-2">
+ <Cube className="size-4 shrink-0" />
+ <span className="truncate text-sm font-semibold text-neutral-800">
+ Staging workspace
+ </span>
+ </div>
+
+ <p className="hidden min-w-0 flex-1 text-center text-sm font-medium text-neutral-800 sm:block">
+ No real money or payouts in staging.{" "}
+ <a
+ href="https://dub.co/docs"
+ target="_blank"
+ rel="noopener noreferrer"
+ className="underline underline-offset-2"
+ >
+ Learn more
+ </a>
+ </p>
+
+ {liveWorkspace ? (
+ <Link
+ href={`/${liveWorkspace.slug}`}
+ className="bg-bg-inverted text-content-inverted shrink-0 rounded-md px-2.5 py-1.5 text-sm font-medium"
+ >
+ Exit staging
+ </Link>
+ ) : (
+ <span className="w-[88px] shrink-0" />
+ )}
+ </motion.div>
+ );
+}