Skip to content

Open-source status page, incident response and uptime monitoring

feat: improved status-pages layout (#557)

Maximilian Kaske73a2d6ac14a1
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/new/page.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/new/page.tsx
index fc7c9750c..857c33162 100644
--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/new/page.tsx
+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/new/page.tsx
@@ -1,3 +1,5 @@
+import { redirect } from "next/navigation";
+
import { MonitorForm } from "@/components/forms/monitor-form";
import { api } from "@/trpc/server";
@@ -5,6 +7,9 @@ export default async function Page() {
const workspace = await api.workspace.getWorkspace.query();
const notifications =
await api.notification.getNotificationsByWorkspace.query();
+ const isLimitReached = await api.monitor.isMonitorLimitReached.query();
+
+ if (isLimitReached) return redirect("./");
return (
<MonitorForm
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/(overview)/layout.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/(overview)/layout.tsx
new file mode 100644
index 000000000..ca2c53e22
--- /dev/null
+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/(overview)/layout.tsx
@@ -0,0 +1,38 @@
+import * as React from "react";
+import Link from "next/link";
+
+import { ButtonWithDisableTooltip } from "@openstatus/ui";
+
+import { Header } from "@/components/dashboard/header";
+import { HelpCallout } from "@/components/dashboard/help-callout";
+import { api } from "@/trpc/server";
+
+export default async function Layout({
+ children,
+}: {
+ children: React.ReactNode;
+}) {
+ const isLimitReached = await api.page.isPageLimitReached.query();
+
+ return (
+ <div className="grid min-h-full grid-cols-1 grid-rows-[auto,1fr,auto] gap-6 md:grid-cols-2 md:gap-8">
+ <Header
+ title="Pages"
+ description="Overview of all your pages."
+ actions={
+ <ButtonWithDisableTooltip
+ tooltip="You reached the limits"
+ asChild={!isLimitReached}
+ disabled={isLimitReached}
+ >
+ <Link href="./status-pages/new">Create</Link>
+ </ButtonWithDisableTooltip>
+ }
+ />
+ <div className="col-span-full">{children}</div>
+ <div className="mt-8 md:mt-12">
+ <HelpCallout />
+ </div>
+ </div>
+ );
+}
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/(overview)/loading.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/(overview)/loading.tsx
new file mode 100644
index 000000000..ae51d6a5b
--- /dev/null
+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/(overview)/loading.tsx
@@ -0,0 +1,5 @@
+import { DataTableSkeleton } from "@/components/data-table/data-table-skeleton";
+
+export default function Loading() {
+ return <DataTableSkeleton />;
+}
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/(overview)/page.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/(overview)/page.tsx
new file mode 100644
index 000000000..03a83c6f3
--- /dev/null
+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/(overview)/page.tsx
@@ -0,0 +1,36 @@
+import * as React from "react";
+import Link from "next/link";
+
+import { Button } from "@openstatus/ui";
+
+import { EmptyState } from "@/components/dashboard/empty-state";
+import { Limit } from "@/components/dashboard/limit";
+import { columns } from "@/components/data-table/status-page/columns";
+import { DataTable } from "@/components/data-table/status-page/data-table";
+import { api } from "@/trpc/server";
+
+export default async function MonitorPage() {
+ const pages = await api.page.getPagesByWorkspace.query();
+ const isLimitReached = await api.page.isPageLimitReached.query();
+
+ if (pages?.length === 0)
+ return (
+ <EmptyState
+ icon="panel-top"
+ title="No pages"
+ description="Create your first page"
+ action={
+ <Button asChild>
+ <Link href="./status-pages/new">Create</Link>
+ </Button>
+ }
+ />
+ );
+
+ return (
+ <>
+ <DataTable columns={columns} data={pages} />
+ <div className="mt-3">{isLimitReached ? <Limit /> : null}</div>
+ </>
+ );
+}
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/[id]/domain/loading.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/[id]/domain/loading.tsx
new file mode 100644
index 000000000..b269200de
--- /dev/null
+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/[id]/domain/loading.tsx
@@ -0,0 +1,5 @@
+import { SkeletonForm } from "@/components/forms/skeleton-form";
+
+export default function Loading() {
+ return <SkeletonForm />;
+}
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/[id]/domain/page.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/[id]/domain/page.tsx
new file mode 100644
index 000000000..17e78f4b5
--- /dev/null
+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/[id]/domain/page.tsx
@@ -0,0 +1,30 @@
+import { notFound } from "next/navigation";
+
+import { ProFeatureAlert } from "@/components/billing/pro-feature-alert";
+import { CustomDomainForm } from "@/components/forms/custom-domain-form";
+import { api } from "@/trpc/server";
+
+export default async function CustomDomainPage({
+ params,
+}: {
+ params: { workspaceSlug: string; id: string };
+}) {
+ const id = Number(params.id);
+ const page = await api.page.getPageById.query({ id });
+ const workspace = await api.workspace.getWorkspace.query();
+
+ const isProPlan = workspace?.plan === "pro";
+
+ if (!page) return notFound();
+
+ if (!isProPlan) return <ProFeatureAlert feature="Custom domains" />;
+
+ return (
+ <CustomDomainForm
+ defaultValues={{
+ customDomain: page.customDomain,
+ id: page.id,
+ }}
+ />
+ );
+}
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/[id]/edit/loading.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/[id]/edit/loading.tsx
new file mode 100644
index 000000000..b269200de
--- /dev/null
+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/[id]/edit/loading.tsx
@@ -0,0 +1,5 @@
+import { SkeletonForm } from "@/components/forms/skeleton-form";
+
+export default function Loading() {
+ return <SkeletonForm />;
+}
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/[id]/edit/page.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/[id]/edit/page.tsx
new file mode 100644
index 000000000..710791f4b
--- /dev/null
+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/[id]/edit/page.tsx
@@ -0,0 +1,28 @@
+import { notFound } from "next/navigation";
+
+import { StatusPageForm } from "@/components/forms/status-page-form";
+import { api } from "@/trpc/server";
+
+export default async function EditPage({
+ params,
+}: {
+ params: { workspaceSlug: string; id: string };
+}) {
+ const id = Number(params.id);
+ const page = await api.page.getPageById.query({ id });
+ const allMonitors = await api.monitor.getMonitorsByWorkspace.query();
+
+ if (!page) {
+ return notFound();
+ }
+
+ return (
+ <StatusPageForm
+ allMonitors={allMonitors}
+ defaultValues={{
+ ...page,
+ monitors: page.monitorsToPages.map(({ monitor }) => monitor.id),
+ }}
+ />
+ );
+}
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/[id]/layout.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/[id]/layout.tsx
new file mode 100644
index 000000000..2c93e6369
--- /dev/null
+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/[id]/layout.tsx
@@ -0,0 +1,60 @@
+import Link from "next/link";
+import { notFound } from "next/navigation";
+
+import { Button } from "@openstatus/ui";
+
+import { Header } from "@/components/dashboard/header";
+import { Navbar } from "@/components/dashboard/navbar";
+import { api } from "@/trpc/server";
+
+export default async function Layout({
+ children,
+ params,
+}: {
+ children: React.ReactNode;
+ params: { workspaceSlug: string; id: string };
+}) {
+ const id = params.id;
+
+ const page = await api.page.getPageById.query({
+ id: Number(id),
+ });
+
+ if (!page) {
+ return notFound();
+ }
+
+ const navigation = [
+ {
+ label: "Settings",
+ href: `/app/${params.workspaceSlug}/status-pages/${id}/edit`,
+ segment: "edit",
+ },
+ {
+ label: "Domain",
+ href: `/app/${params.workspaceSlug}/status-pages/${id}/domain`,
+ segment: "domain",
+ },
+ {
+ label: "Subscribers",
+ href: `/app/${params.workspaceSlug}/status-pages/${id}/subscribers`,
+ segment: "subscribers",
+ },
+ ];
+
+ return (
+ <div className="grid grid-cols-1 gap-6 md:gap-8">
+ <Header
+ title={page.title}
+ description={page.description}
+ actions={
+ <Button variant="outline" asChild>
+ <Link href={`https://${page.slug}.openstatus.dev`}>Visit</Link>
+ </Button>
+ }
+ />
+ <Navbar className="col-span-full" navigation={navigation} />
+ {children}
+ </div>
+ );
+}
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/[id]/page.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/[id]/page.tsx
new file mode 100644
index 000000000..293f97b0f
--- /dev/null
+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/[id]/page.tsx
@@ -0,0 +1,9 @@
+import { redirect } from "next/navigation";
+
+export default function Page({
+ params,
+}: {
+ params: { workspaceSlug: string; id: string };
+}) {
+ return redirect(`./${params.id}/edit`);
+}
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/[id]/subscribers/loading.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/[id]/subscribers/loading.tsx
new file mode 100644
index 000000000..b269200de
--- /dev/null
+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/[id]/subscribers/loading.tsx
@@ -0,0 +1,5 @@
+import { SkeletonForm } from "@/components/forms/skeleton-form";
+
+export default function Loading() {
+ return <SkeletonForm />;
+}
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/[id]/subscribers/page.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/[id]/subscribers/page.tsx
new file mode 100644
index 000000000..43fcde70e
--- /dev/null
+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/[id]/subscribers/page.tsx
@@ -0,0 +1,29 @@
+import { notFound } from "next/navigation";
+
+import { ProFeatureAlert } from "@/components/billing/pro-feature-alert";
+import { api } from "@/trpc/server";
+
+export default async function CustomDomainPage({
+ params,
+}: {
+ params: { workspaceSlug: string; id: string };
+}) {
+ const id = Number(params.id);
+ const page = await api.page.getPageById.query({ id });
+ const workspace = await api.workspace.getWorkspace.query();
+
+ const isProPlan = workspace?.plan === "pro";
+
+ if (!page) return notFound();
+
+ if (!isProPlan)
+ return <ProFeatureAlert feature={"Status page subscribers"} />;
+
+ // TODO: add page-subscribers trpc endpoint first
+ return (
+ <p className="text-muted-foreground text-sm">
+ Your users can subscribe to status report updates. A list with more
+ detailed informations coming soon.
+ </p>
+ );
+}
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/_components/action-button.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/_components/action-button.tsx
deleted file mode 100644
index 1a53e03e1..000000000
--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/_components/action-button.tsx
+++ /dev/null
@@ -1,113 +0,0 @@
-"use client";
-
-import * as React from "react";
-import Link from "next/link";
-import { useRouter } from "next/navigation";
-import { MoreVertical } from "lucide-react";
-
-import type { Page } from "@openstatus/db/src/schema";
-import {
- AlertDialog,
- AlertDialogAction,
- AlertDialogCancel,
- AlertDialogContent,
- AlertDialogDescription,
- AlertDialogFooter,
- AlertDialogHeader,
- AlertDialogTitle,
- AlertDialogTrigger,
- Button,
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuItem,
- DropdownMenuTrigger,
-} from "@openstatus/ui";
-
-import { LoadingAnimation } from "@/components/loading-animation";
-import { useToastAction } from "@/hooks/use-toast-action";
-import { api } from "@/trpc/client";
-
-interface ActionButtonProps {
- page: Page;
-}
-
-export function ActionButton({ page }: ActionButtonProps) {
- const router = useRouter();
- const { toast } = useToastAction();
- const [alertOpen, setAlertOpen] = React.useState(false);
- const [isPending, startTransition] = React.useTransition();
-
- async function onDelete() {
- startTransition(async () => {
- try {
- if (!page.id) return;
- await api.page.delete.mutate({ id: page.id });
- toast("deleted");
- router.refresh();
- setAlertOpen(false);
- } catch {
- toast("error");
- }
- });
- }
-
- return (
- <AlertDialog open={alertOpen} onOpenChange={(value) => setAlertOpen(value)}>
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <Button
- variant="ghost"
- className="data-[state=open]:bg-accent h-8 w-8 p-0"
- >
- <span className="sr-only">Open menu</span>
- <MoreVertical className="h-4 w-4" />
- </Button>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end">
- <Link href={`./status-pages/edit?id=${page.id}`}>
- <DropdownMenuItem>Edit</DropdownMenuItem>
- </Link>
- <Link
- // TODO: it would be create to extract this logic and include custom domains if they are set
- // similar to `setPrefixUrl`
- href={
- process.env.NODE_ENV === "production"
- ? `https://${page.slug}.openstatus.dev`
- : `/status-page/${page.slug}`
- }
- target="_blank"
- >
- <DropdownMenuItem>Visit</DropdownMenuItem>
- </Link>
- <AlertDialogTrigger asChild>
- <DropdownMenuItem className="text-destructive focus:bg-destructive focus:text-background">
- Delete
- </DropdownMenuItem>
- </AlertDialogTrigger>
- </DropdownMenuContent>
- </DropdownMenu>
- <AlertDialogContent>
- <AlertDialogHeader>
- <AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle>
- <AlertDialogDescription>
- This action cannot be undone. This will permanently delete the
- monitor.
- </AlertDialogDescription>
- </AlertDialogHeader>
- <AlertDialogFooter>
- <AlertDialogCancel>Cancel</AlertDialogCancel>
- <AlertDialogAction
- onClick={(e) => {
- e.preventDefault();
- onDelete();
- }}
- disabled={isPending}
- className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
- >
- {!isPending ? "Delete" : <LoadingAnimation />}
- </AlertDialogAction>
- </AlertDialogFooter>
- </AlertDialogContent>
- </AlertDialog>
- );
-}
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/_components/empty-state.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/_components/empty-state.tsx
deleted file mode 100644
index c64ea52f3..000000000
--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/_components/empty-state.tsx
+++ /dev/null
@@ -1,35 +0,0 @@
-import Link from "next/link";
-
-import type { Monitor } from "@openstatus/db/src/schema";
-import { Button } from "@openstatus/ui";
-
-import { EmptyState as DefaultEmptyState } from "@/components/dashboard/empty-state";
-
-export function EmptyState({ allMonitors }: { allMonitors?: Monitor[] }) {
- if (!Boolean(allMonitors?.length)) {
- return (
- <DefaultEmptyState
- icon="panel-top"
- title="No pages"
- description="First create a monitor before creating a page."
- action={
- <Button asChild>
- <Link href="./monitors/edit">Create a monitor</Link>
- </Button>
- }
- />
- );
- }
- return (
- <DefaultEmptyState
- icon="panel-top"
- title="No pages"
- description="Create your first page."
- action={
- <Button asChild>
- <Link href="./status-pages/edit">Create</Link>
- </Button>
- }
- />
- );
-}
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/edit/_components/pro-feature-alert.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/edit/_components/pro-feature-alert.tsx
deleted file mode 100644
index aec31b237..000000000
--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/edit/_components/pro-feature-alert.tsx
+++ /dev/null
@@ -1,24 +0,0 @@
-import Link from "next/link";
-import { AlertTriangle } from "lucide-react";
-
-import { Alert, AlertDescription, AlertTitle } from "@openstatus/ui";
-
-export function ProFeatureAlert() {
- return (
- <Alert>
- <AlertTriangle className="h-4 w-4" />
- <AlertTitle>Custom domains are a Pro feature.</AlertTitle>
- <AlertDescription>
- If you want to use your own domain, please upgrade to the Pro plan. Go
- to{" "}
- <Link
- href="../settings/billing"
- className="text-foreground inline-flex items-center font-medium underline underline-offset-4 hover:no-underline"
- >
- settings
- </Link>
- .
- </AlertDescription>
- </Alert>
- );
-}
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/edit/loading.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/edit/loading.tsx
deleted file mode 100644
index 41fdbbaa9..000000000
--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/edit/loading.tsx
+++ /dev/null
@@ -1,19 +0,0 @@
-import { Skeleton } from "@openstatus/ui";
-
-import { Header } from "@/components/dashboard/header";
-import { SkeletonForm } from "@/components/forms/skeleton-form";
-
-export default function Loading() {
- return (
- <div className="grid gap-6 md:grid-cols-2 md:gap-8">
- <div className="col-span-full flex w-full justify-between">
- <Header.Skeleton>
- <Skeleton className="h-9 w-20" />
- </Header.Skeleton>
- </div>
- <div className="col-span-full">
- <SkeletonForm />
- </div>
- </div>
- );
-}
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/edit/page.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/edit/page.tsx
deleted file mode 100644
index 4a3a1330a..000000000
--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/edit/page.tsx
+++ /dev/null
@@ -1,93 +0,0 @@
-import { notFound } from "next/navigation";
-import * as z from "zod";
-
-import { Tabs, TabsContent, TabsList, TabsTrigger } from "@openstatus/ui";
-
-import { Header } from "@/components/dashboard/header";
-import { CustomDomainForm } from "@/components/forms/custom-domain-form";
-import { StatusPageForm } from "@/components/forms/status-page-form";
-import { api } from "@/trpc/server";
-import { ProFeatureAlert } from "./_components/pro-feature-alert";
-
-/**
- * allowed URL search params
- */
-const searchParamsSchema = z.object({
- id: z.coerce.number().optional(),
-});
-
-export default async function EditPage({
- params,
- searchParams,
-}: {
- params: { workspaceSlug: string };
- searchParams: { [key: string]: string | string[] | undefined };
-}) {
- const search = searchParamsSchema.safeParse(searchParams);
-
- if (!search.success) {
- return notFound();
- }
-
- const { id } = search.data;
-
- // TODO: too many requests to db
- const page = id ? await api.page.getPageById.query({ id }) : undefined;
- const monitors = await api.monitor.getMonitorsByWorkspace.query();
- const workspace = await api.workspace.getWorkspace.query();
-
- const isProPlan = workspace?.plan === "pro";
-
- return (
- <div className="grid gap-6 md:grid-cols-2 md:gap-8">
- <Header title="Status Page" description="Upsert your status page." />
- <div className="col-span-full">
- {/* TODO: add same structure for skeleton to loading.tsx */}
- <Tabs defaultValue="settings" className="relative mr-auto w-full">
- <TabsList className="h-9 w-full justify-start rounded-none border-b bg-transparent p-0">
- <TabsTrigger
- className="text-muted-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground relative h-9 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 font-semibold shadow-none transition-none data-[state=active]:shadow-none"
- value="settings"
- >
- Settings
- </TabsTrigger>
- <TabsTrigger
- className="text-muted-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground relative h-9 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 font-semibold shadow-none transition-none data-[state=active]:shadow-none"
- value="domain"
- disabled={!page}
- >
- Domain
- </TabsTrigger>
- </TabsList>
- <TabsContent value="settings" className="pt-3">
- <StatusPageForm
- allMonitors={monitors}
- defaultValues={
- page
- ? {
- ...page,
- monitors: page.monitorsToPages.map(
- ({ monitor }) => monitor.id,
- ),
- }
- : undefined
- }
- />
- </TabsContent>
- <TabsContent value="domain" className="pt-3">
- {page && isProPlan ? (
- <CustomDomainForm
- defaultValues={{
- customDomain: page?.customDomain,
- id: page?.id,
- }} // to be improved
- />
- ) : (
- <ProFeatureAlert />
- )}
- </TabsContent>
- </Tabs>
- </div>
- </div>
- );
-}
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/loading.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/loading.tsx
deleted file mode 100644
index 5fab49f41..000000000
--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/loading.tsx
+++ /dev/null
@@ -1,19 +0,0 @@
-import { Skeleton } from "@openstatus/ui";
-
-import { Header } from "@/components/dashboard/header";
-import { DataTableSkeleton } from "@/components/data-table/data-table-skeleton";
-
-export default function Loading() {
- return (
- <div className="grid gap-6 md:grid-cols-2 md:gap-8">
- <div className="col-span-full flex w-full justify-between">
- <Header.Skeleton>
- <Skeleton className="h-9 w-20" />
- </Header.Skeleton>
- </div>
- <div className="col-span-full w-full">
- <DataTableSkeleton />
- </div>
- </div>
- );
-}
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/new/layout.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/new/layout.tsx
new file mode 100644
index 000000000..c3e43da32
--- /dev/null
+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/new/layout.tsx
@@ -0,0 +1,14 @@
+import { Header } from "@/components/dashboard/header";
+
+export default async function Layout({
+ children,
+}: {
+ children: React.ReactNode;
+}) {
+ return (
+ <div className="grid gap-6 md:grid-cols-2 md:gap-8">
+ <Header title="Pages" description="Create your page." />
+ <div className="col-span-full">{children}</div>
+ </div>
+ );
+}
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/new/loading.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/new/loading.tsx
new file mode 100644
index 000000000..b269200de
--- /dev/null
+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/new/loading.tsx
@@ -0,0 +1,5 @@
+import { SkeletonForm } from "@/components/forms/skeleton-form";
+
+export default function Loading() {
+ return <SkeletonForm />;
+}
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/new/page.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/new/page.tsx
new file mode 100644
index 000000000..5556e857e
--- /dev/null
+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/new/page.tsx
@@ -0,0 +1,18 @@
+import { redirect } from "next/navigation";
+
+import { StatusPageForm } from "@/components/forms/status-page-form";
+import { api } from "@/trpc/server";
+
+export default async function Page() {
+ const allMonitors = await api.monitor.getMonitorsByWorkspace.query();
+ const isLimitReached = await api.page.isPageLimitReached.query();
+
+ if (isLimitReached) return redirect("./");
+
+ return (
+ <StatusPageForm
+ allMonitors={allMonitors} // FIXME: rename to just 'monitors'
+ nextUrl="./" // back to the overview page
+ />
+ );
+}
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/page.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/page.tsx
deleted file mode 100644
index bae99ec96..000000000
--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/page.tsx
+++ /dev/null
@@ -1,64 +0,0 @@
-import * as React from "react";
-import Link from "next/link";
-
-import { allPlans } from "@openstatus/plans";
-import { ButtonWithDisableTooltip } from "@openstatus/ui";
-
-import { Header } from "@/components/dashboard/header";
-import { HelpCallout } from "@/components/dashboard/help-callout";
-import { Limit } from "@/components/dashboard/limit";
-import { columns } from "@/components/data-table/status-page/columns";
-import { DataTable } from "@/components/data-table/status-page/data-table";
-import { api } from "@/trpc/server";
-import { EmptyState } from "./_components/empty-state";
-
-// export const revalidate = 0;
-export const dynamic = "force-dynamic";
-
-export default async function Page({
- params,
-}: {
- params: { workspaceSlug: string };
-}) {
- const pages = await api.page.getPagesByWorkspace.query();
- const monitors = await api.monitor.getMonitorsByWorkspace.query();
-
- const workspace = await api.workspace.getWorkspace.query();
-
- const isLimit =
- (pages?.length || 0) >=
- allPlans[workspace?.plan || "free"].limits["status-pages"];
-
- const disableButton = isLimit || !Boolean(monitors);
-
- return (
- <div className="grid min-h-full grid-cols-1 grid-rows-[auto,1fr,auto] gap-6 md:grid-cols-2 md:gap-8">
- <Header
- title="Status Page"
- description="Overview of all your status pages."
- actions={
- <ButtonWithDisableTooltip
- tooltip="You reached the limits"
- asChild={!disableButton}
- disabled={disableButton}
- >
- <Link href="./status-pages/edit">Create</Link>
- </ButtonWithDisableTooltip>
- }
- />
- {Boolean(pages?.length) ? (
- <div className="col-span-full">
- {pages && <DataTable columns={columns} data={pages} />}
- <div className="mt-3">{isLimit ? <Limit /> : null}</div>
- </div>
- ) : (
- <div className="col-span-full">
- <EmptyState allMonitors={monitors} />
- </div>
- )}
- <div className="mt-8 md:mt-12">
- <HelpCallout />
- </div>
- </div>
- );
-}
diff --git a/apps/web/src/components/billing/pro-feature-alert.tsx b/apps/web/src/components/billing/pro-feature-alert.tsx
new file mode 100644
index 000000000..b5fd7044e
--- /dev/null
+++ b/apps/web/src/components/billing/pro-feature-alert.tsx
@@ -0,0 +1,33 @@
+"use client";
+
+import Link from "next/link";
+import { useParams } from "next/navigation";
+import { AlertTriangle } from "lucide-react";
+
+import { Alert, AlertDescription, AlertTitle } from "@openstatus/ui";
+
+interface Props {
+ feature: string;
+}
+
+export function ProFeatureAlert({ feature }: Props) {
+ const params = useParams<{ workspaceSlug: string }>();
+ return (
+ <Alert>
+ <AlertTriangle className="h-4 w-4" />
+ <AlertTitle>{feature} are a Pro feature.</AlertTitle>
+ <AlertDescription>
+ If you want to use{" "}
+ <span className="underline decoration-dotted">{feature}</span>, please
+ upgrade to the Pro plan. Go to{" "}
+ <Link
+ href={`/app/${params.workspaceSlug}/settings/billing`}
+ className="text-foreground inline-flex items-center font-medium underline underline-offset-4 hover:no-underline"
+ >
+ settings
+ </Link>
+ .
+ </AlertDescription>
+ </Alert>
+ );
+}
diff --git a/apps/web/src/components/data-table/status-page/columns.tsx b/apps/web/src/components/data-table/status-page/columns.tsx
index c9b08b6e7..3a10f3afd 100644
--- a/apps/web/src/components/data-table/status-page/columns.tsx
+++ b/apps/web/src/components/data-table/status-page/columns.tsx
@@ -1,6 +1,7 @@
"use client";
import Image from "next/image";
+import Link from "next/link";
import type { ColumnDef } from "@tanstack/react-table";
import * as z from "zod";
@@ -18,7 +19,16 @@ export const columns: ColumnDef<
accessorKey: "title",
header: "Title",
cell: ({ row }) => {
- return <span className="truncate">{row.getValue("title")}</span>;
+ return (
+ <Link
+ href={`./status-pages/${row.original.id}/edit`}
+ className="group flex items-center gap-2"
+ >
+ <span className="max-w-[125px] truncate group-hover:underline">
+ {row.getValue("title")}
+ </span>
+ </Link>
+ );
},
},
{
diff --git a/apps/web/src/components/data-table/status-page/data-table-row-actions.tsx b/apps/web/src/components/data-table/status-page/data-table-row-actions.tsx
index 4cfb8e1d1..b6182945c 100644
--- a/apps/web/src/components/data-table/status-page/data-table-row-actions.tsx
+++ b/apps/web/src/components/data-table/status-page/data-table-row-actions.tsx
@@ -68,7 +68,7 @@ export function DataTableRowActions<TData>({
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
- <Link href={`./status-pages/edit?id=${page.id}`}>
+ <Link href={`./status-pages/${page.id}/edit`}>
<DropdownMenuItem>Edit</DropdownMenuItem>
</Link>
<Link
diff --git a/packages/api/src/router/page.ts b/packages/api/src/router/page.ts
index 599c81e22..69e376040 100644
--- a/packages/api/src/router/page.ts
+++ b/packages/api/src/router/page.ts
@@ -275,4 +275,15 @@ export const pageRouter = createTRPCRouter({
.returning()
.get();
}),
+
+ isPageLimitReached: protectedProcedure.query(async (opts) => {
+ const pageLimit = allPlans[opts.ctx.workspace.plan].limits["status-pages"];
+ const pageNumbers = (
+ await opts.ctx.db.query.page.findMany({
+ where: eq(monitor.workspaceId, opts.ctx.workspace.id),
+ })
+ ).length;
+
+ return pageNumbers >= pageLimit;
+ }),
});