Skip to content

Open-source status page, incident response and uptime monitoring

feat: pro banner (#510)

Maximilian Kasked56f329bd6da
diff --git a/apps/web/src/app/app/(dashboard)/[workspaceSlug]/layout.tsx b/apps/web/src/app/app/(dashboard)/[workspaceSlug]/layout.tsx
index d0a40d111..6c8dd4079 100644
--- a/apps/web/src/app/app/(dashboard)/[workspaceSlug]/layout.tsx
+++ b/apps/web/src/app/app/(dashboard)/[workspaceSlug]/layout.tsx
@@ -22,6 +22,7 @@ export default async function AppLayout({
<div className="container relative mx-auto flex min-h-screen w-full flex-col items-center justify-center gap-6 p-4 lg:p-8">
<AppHeader />
<div className="flex w-full flex-1 gap-6 lg:gap-8">
+ {/* FIXME: max-h-[] results into weird behavior when shrinking window height */}
<Shell className="hidden max-h-[calc(100vh-9rem)] max-w-min shrink-0 lg:sticky lg:top-28 lg:block">
<AppSidebar />
</Shell>
diff --git a/apps/web/src/components/billing/pro-banner.tsx b/apps/web/src/components/billing/pro-banner.tsx
new file mode 100644
index 000000000..84ff9bf1b
--- /dev/null
+++ b/apps/web/src/components/billing/pro-banner.tsx
@@ -0,0 +1,65 @@
+"use client";
+
+import { useEffect, useState } from "react";
+import Link from "next/link";
+import { useParams } from "next/navigation";
+import { ArrowRight, Rocket, X } from "lucide-react";
+
+import { Button } from "@openstatus/ui";
+
+import { api } from "@/trpc/client";
+
+export function ProBanner() {
+ const [hidden, setHidden] = useState(true);
+ const params = useParams();
+ const workspaceSlug = params?.workspaceSlug;
+
+ function onClick() {
+ if (document) {
+ const expires = new Date();
+ expires.setDate(expires.getDate() + 7);
+ // store the cookie for 7 days and only for a specific workspace
+ document.cookie = `hide-pro-banner=true; expires=${expires}; path=/app/${workspaceSlug}`;
+ }
+ setHidden(true);
+ }
+
+ useEffect(() => {
+ async function configureProBanner() {
+ const workspace = await api.workspace.getWorkspace.query();
+ // make sure to display the banner only for free plans
+ if (document && workspace?.plan === "free") {
+ const cookie = document.cookie
+ .split("; ")
+ .find((row) => row.startsWith("hide-pro-banner"));
+ if (!cookie) {
+ setHidden(false);
+ }
+ }
+ }
+ configureProBanner();
+ }, []);
+
+ if (hidden) return null;
+
+ return (
+ <div className="border-border grid gap-2 rounded-md border p-2">
+ <div className="flex items-center justify-between">
+ <p className="inline-flex items-center text-sm font-medium">
+ OpenStatus Pro <Rocket className="ml-2 h-4 w-4" />
+ </p>
+ <Button variant="ghost" size="icon" onClick={onClick}>
+ <X className="h-4 w-4" />
+ </Button>
+ </div>
+ <p className="text-muted-foreground text-xs">
+ Unlock custom domains, teams, 1 min. checks and more.
+ </p>
+ <Button variant="secondary" size="sm" asChild>
+ <Link href={`/app/${workspaceSlug}/settings/billing`}>
+ Upgrade <ArrowRight className="ml-2 h-4 w-4" />
+ </Link>
+ </Button>
+ </div>
+ );
+}
diff --git a/apps/web/src/components/layout/app-sidebar.tsx b/apps/web/src/components/layout/app-sidebar.tsx
index e8dcf860f..b16b215d6 100644
--- a/apps/web/src/components/layout/app-sidebar.tsx
+++ b/apps/web/src/components/layout/app-sidebar.tsx
@@ -5,6 +5,7 @@ import { useParams, usePathname } from "next/navigation";
import { pagesConfig } from "@/config/pages";
import { cn } from "@/lib/utils";
+import { ProBanner } from "../billing/pro-banner";
import { Icons } from "../icons";
export function AppSidebar() {
@@ -12,7 +13,7 @@ export function AppSidebar() {
const params = useParams();
return (
- <div className="flex h-full flex-col justify-between">
+ <div className="flex h-full flex-col justify-between gap-6">
<ul className="grid gap-1">
{pagesConfig.map(({ title, href, icon, disabled }) => {
const Icon = Icons[icon];
@@ -35,7 +36,10 @@ export function AppSidebar() {
);
})}
</ul>
- <ul>
+ <ul className="grid gap-2">
+ <li className="w-full">
+ <ProBanner />
+ </li>
<li className="w-full">
<Link
href={`/app/${params?.workspaceSlug}/settings`}