Skip to content

Open-source status page, incident response and uptime monitoring

fix: small stuff after new pricing (#562)

Maximilian Kaske351546138eb2
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/settings/billing/_components/plan.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/settings/billing/_components/plan.tsx
index 6a3c3a741..af0a5a026 100644
--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/settings/billing/_components/plan.tsx
+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/settings/billing/_components/plan.tsx
@@ -14,7 +14,6 @@ import { api } from "@/trpc/client";
export const SettingsPlan = ({ workspace }: { workspace: Workspace }) => {
const router = useRouter();
const [isPending, startTransition] = useTransition();
- const [isPortalPending, startPortalTransition] = useTransition();
const getCheckoutSession = (plan: WorkspacePlan) => {
startTransition(async () => {
@@ -32,7 +31,7 @@ export const SettingsPlan = ({ workspace }: { workspace: Workspace }) => {
};
const getUserCustomerPortal = () => {
- startPortalTransition(async () => {
+ startTransition(async () => {
const url = await api.stripeRouter.getUserCustomerPortal.mutate({
workspaceSlug: workspace.slug,
});
@@ -46,8 +45,12 @@ export const SettingsPlan = ({ workspace }: { workspace: Workspace }) => {
<div className="grid gap-4">
<div className="grid gap-6">
<div>
- <Button onClick={getUserCustomerPortal} variant="outline">
- {isPortalPending ? (
+ <Button
+ onClick={getUserCustomerPortal}
+ variant="outline"
+ disabled={isPending}
+ >
+ {isPending ? (
<LoadingAnimation variant="inverse" />
) : (
"Customer Portal"
@@ -58,7 +61,8 @@ export const SettingsPlan = ({ workspace }: { workspace: Workspace }) => {
currentPlan={workspace.plan}
isLoading={isPending}
events={{
- free: () => getCheckoutSession("free"),
+ // REMINDER: redirecting to customer portal as a fallback because the free plan has no price
+ free: getUserCustomerPortal,
starter: () => getCheckoutSession("starter"),
pro: () => getCheckoutSession("pro"),
team: () => getCheckoutSession("team"),
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/settings/team/page.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/settings/team/page.tsx
index afb82da79..18e8abf2b 100644
--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/settings/team/page.tsx
+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/settings/team/page.tsx
@@ -1,7 +1,4 @@
-import { AlertTriangle } from "lucide-react";
-
-import { Alert, AlertDescription, AlertTitle } from "@openstatus/ui";
-
+import { ProFeatureAlert } from "@/components/billing/pro-feature-alert";
import { columns as invitationColumns } from "@/components/data-table/invitation/columns";
import { DataTable as InvitationDataTable } from "@/components/data-table/invitation/data-table";
import { columns as userColumns } from "@/components/data-table/user/columns";
@@ -18,15 +15,7 @@ export default async function TeamPage() {
return (
<div className="flex flex-col gap-4">
- {isFreePlan ? (
- <Alert>
- <AlertTriangle className="h-4 w-4" />
- <AlertTitle>Team</AlertTitle>
- <AlertDescription>
- Please upgrade to invite more team members.
- </AlertDescription>
- </Alert>
- ) : null}
+ {isFreePlan ? <ProFeatureAlert feature="Team members" /> : null}
{/* TODO: only show if isAdmin */}
<div className="flex justify-end">
<InviteButton disabled={isFreePlan} />
diff --git a/apps/web/src/app/status-page/[domain]/layout.tsx b/apps/web/src/app/status-page/[domain]/layout.tsx
index 1c2bcd008..9df246b76 100644
--- a/apps/web/src/app/status-page/[domain]/layout.tsx
+++ b/apps/web/src/app/status-page/[domain]/layout.tsx
@@ -25,6 +25,10 @@ export default async function StatusPageLayout({ children, params }: Props) {
const page = await api.page.getPageBySlug.query({ slug: params.domain });
if (!page) return notFound();
+ const plan = page.workspacePlan;
+ const isSubscribers = allPlans[plan].limits["status-subscribers"];
+ const isWhiteLabel = allPlans[plan].limits["white-label"];
+
const navigation = [
{
label: "Status",
@@ -38,9 +42,6 @@ export default async function StatusPageLayout({ children, params }: Props) {
},
];
- const isSubscribersValid =
- allPlans[page.workspacePlan].limits["status-subscribers"];
-
return (
<div className="flex min-h-screen w-full flex-col space-y-6 p-4 md:p-8">
<header className="mx-auto w-full max-w-xl">
@@ -60,9 +61,7 @@ export default async function StatusPageLayout({ children, params }: Props) {
</div>
<Navbar navigation={navigation} />
<div className="text-end sm:w-[100px]">
- {isSubscribersValid ? (
- <SubscribeButton slug={params.domain} />
- ) : null}
+ {isSubscribers ? <SubscribeButton slug={params.domain} /> : null}
</div>
</Shell>
</header>
@@ -73,17 +72,19 @@ export default async function StatusPageLayout({ children, params }: Props) {
</main>
<footer className="z-10 mx-auto flex w-full max-w-xl items-center justify-between">
<div />
- <p className="text-muted-foreground text-center text-sm">
- powered by{" "}
- <a
- href="https://www.openstatus.dev"
- target="_blank"
- rel="noreferrer"
- className="text-foreground underline underline-offset-4 hover:no-underline"
- >
- openstatus.dev
- </a>
- </p>
+ {!isWhiteLabel ? (
+ <p className="text-muted-foreground text-center text-sm">
+ powered by{" "}
+ <a
+ href="https://www.openstatus.dev"
+ target="_blank"
+ rel="noreferrer"
+ className="text-foreground underline underline-offset-4 hover:no-underline"
+ >
+ openstatus.dev
+ </a>
+ </p>
+ ) : null}
<ThemeToggle />
</footer>
</div>
diff --git a/apps/web/src/components/billing/pro-feature-alert.tsx b/apps/web/src/components/billing/pro-feature-alert.tsx
index b5fd7044e..a24221852 100644
--- a/apps/web/src/components/billing/pro-feature-alert.tsx
+++ b/apps/web/src/components/billing/pro-feature-alert.tsx
@@ -15,11 +15,11 @@ export function ProFeatureAlert({ feature }: Props) {
return (
<Alert>
<AlertTriangle className="h-4 w-4" />
- <AlertTitle>{feature} are a Pro feature.</AlertTitle>
+ <AlertTitle>{feature} is 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{" "}
+ upgrade your 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"
diff --git a/apps/web/src/components/marketing/faqs.tsx b/apps/web/src/components/marketing/faqs.tsx
index 6d6157319..918b12641 100644
--- a/apps/web/src/components/marketing/faqs.tsx
+++ b/apps/web/src/components/marketing/faqs.tsx
@@ -11,7 +11,7 @@ import { Shell } from "@/components/dashboard/shell";
const faqsConfig: Record<"q" | "a", string>[] = [
{
q: "What are the limits?",
- a: "You will start with a free plan by default which includes a total of <strong>5 monitors</strong> and <strong>1 status</strong> page as well as cron jobs of either <code>10m</code>, <code>30m</code> or <code>1h</code>.",
+ a: "You will start with a free plan by default which includes a total of <strong>3 monitors</strong> and <strong>1 status</strong> page as well as cron jobs of either <code>10m</code>, <code>30m</code> or <code>1h</code>.<br />Learn more about our <a href='/pricing'>pricing</a>.",
},
{
q: "Who are we?",
diff --git a/apps/web/src/components/marketing/pricing/pricing-table.tsx b/apps/web/src/components/marketing/pricing/pricing-table.tsx
index c882d7cfe..ce7365a45 100644
--- a/apps/web/src/components/marketing/pricing/pricing-table.tsx
+++ b/apps/web/src/components/marketing/pricing/pricing-table.tsx
@@ -4,7 +4,7 @@ import { Fragment } from "react";
import { useRouter } from "next/navigation";
import { Check } from "lucide-react";
-import type { PlanName } from "@openstatus/plans";
+import type { WorkspacePlan } from "@openstatus/plans";
import {
allPlans,
plans as defaultPlans,
@@ -31,9 +31,9 @@ export function PricingTable({
events,
isLoading,
}: {
- plans?: readonly PlanName[];
- currentPlan?: PlanName;
- events?: Partial<Record<PlanName, () => void>>;
+ plans?: readonly WorkspacePlan[];
+ currentPlan?: WorkspacePlan;
+ events?: Partial<Record<WorkspacePlan, () => void>>;
isLoading?: boolean;
}) {
const router = useRouter();
diff --git a/apps/web/src/components/marketing/pricing/pricing-wrapper.tsx b/apps/web/src/components/marketing/pricing/pricing-wrapper.tsx
index 6f79aefdc..c6de2d29a 100644
--- a/apps/web/src/components/marketing/pricing/pricing-wrapper.tsx
+++ b/apps/web/src/components/marketing/pricing/pricing-wrapper.tsx
@@ -2,7 +2,7 @@
import { useSearchParams } from "next/navigation";
-import type { PlanName } from "@openstatus/plans";
+import type { WorkspacePlan } from "@openstatus/plans";
import { PricingPlanRadio } from "./pricing-plan-radio";
import { PricingTable } from "./pricing-table";
@@ -14,7 +14,7 @@ export function PricingWrapper() {
<div className="flex flex-col gap-4 sm:hidden">
<PricingPlanRadio />
<PricingTable
- plans={[(searchParams.get("plan") as PlanName) || "team"]}
+ plans={[(searchParams.get("plan") as WorkspacePlan) || "team"]}
/>
</div>
<div className="hidden sm:block">
diff --git a/packages/api/src/router/invitation.ts b/packages/api/src/router/invitation.ts
index 5ac8b88be..572d49f65 100644
--- a/packages/api/src/router/invitation.ts
+++ b/packages/api/src/router/invitation.ts
@@ -19,10 +19,8 @@ export const invitationRouter = createTRPCRouter({
.mutation(async (opts) => {
const { email } = opts.input;
- const membersLimit =
- allPlans[opts.ctx.workspace.plan].limits.members === "unlimited"
- ? 420
- : 1;
+ const _members = allPlans[opts.ctx.workspace.plan].limits.members;
+ const membersLimit = _members === "Unlimited" ? 420 : _members;
const usersToWorkspacesNumbers = (
await opts.ctx.db.query.usersToWorkspaces.findMany({
diff --git a/packages/plans/package.json b/packages/plans/package.json
index 600d187bc..d6af51dda 100644
--- a/packages/plans/package.json
+++ b/packages/plans/package.json
@@ -2,7 +2,7 @@
"name": "@openstatus/plans",
"version": "1.0.0",
"description": "",
- "main": "index.ts",
+ "main": "src/index.ts",
"scripts": {},
"dependencies": {
"@openstatus/db": "workspace:*",
diff --git a/packages/plans/index.ts b/packages/plans/src/config.ts
similarity index 69%
rename from packages/plans/index.ts
rename to packages/plans/src/config.ts
index 2f24d2116..22ea63c45 100644
--- a/packages/plans/index.ts
+++ b/packages/plans/src/config.ts
@@ -1,39 +1,17 @@
-import type { MonitorPeriodicity } from "@openstatus/db/src/schema";
+import type { WorkspacePlan } from "@openstatus/db/src/schema";
-export const plans = ["free", "starter", "team", "pro"] as const;
-export type PlanName = (typeof plans)[number];
-
-export type Limits = {
- // monitors
- monitors: number;
- periodicity: Partial<MonitorPeriodicity>[];
- "multi-region": boolean;
- "data-retention": string;
- // status pages
- "status-pages": number;
- "status-subscribers": boolean;
- "custom-domain": boolean;
- "white-label": boolean;
- // alerts
- notifications: boolean;
- sms: boolean;
- "notification-channels": number;
- // collaboration
- members: string;
- "audit-log": boolean;
-};
-
-export type FeatureKey = keyof Limits;
-
-export type Plan = {
- title: string;
- description: string;
- price: number;
- limits: Limits;
-};
+import type { Limits } from "./types";
// TODO: rename to `planConfig`
-export const allPlans: Record<PlanName, Plan> = {
+export const allPlans: Record<
+ WorkspacePlan,
+ {
+ title: string;
+ description: string;
+ price: number;
+ limits: Limits;
+ }
+> = {
free: {
title: "Hobby",
description: "For personal projects",
@@ -50,7 +28,7 @@ export const allPlans: Record<PlanName, Plan> = {
notifications: true,
sms: false,
"notification-channels": 1,
- members: "1",
+ members: 1,
"audit-log": false,
},
},
@@ -115,5 +93,3 @@ export const allPlans: Record<PlanName, Plan> = {
},
},
};
-
-export { pricingTableConfig } from "./pricing-table";
diff --git a/packages/plans/src/index.ts b/packages/plans/src/index.ts
new file mode 100644
index 000000000..f712a0a20
--- /dev/null
+++ b/packages/plans/src/index.ts
@@ -0,0 +1,6 @@
+export { allPlans } from "./config";
+export { getLimit } from "./utils";
+export { pricingTableConfig } from "./pricing-table";
+
+export { workspacePlans as plans } from "@openstatus/db/src/schema";
+export type { WorkspacePlan } from "@openstatus/db/src/schema";
diff --git a/packages/plans/pricing-table.ts b/packages/plans/src/pricing-table.ts
similarity index 87%
rename from packages/plans/pricing-table.ts
rename to packages/plans/src/pricing-table.ts
index c97f9d0b7..f0c0ca6a6 100644
--- a/packages/plans/pricing-table.ts
+++ b/packages/plans/src/pricing-table.ts
@@ -1,14 +1,12 @@
-import type { FeatureKey } from "./index";
+import type { Limits } from "./types";
-type TableConfig = Record<
+export const pricingTableConfig: Record<
string,
{
label: string;
- features: { value: FeatureKey; label: string; badge?: string }[];
+ features: { value: keyof Limits; label: string; badge?: string }[];
}
->;
-
-export const pricingTableConfig: TableConfig = {
+> = {
monitors: {
label: "Monitors",
features: [
diff --git a/packages/plans/src/types.ts b/packages/plans/src/types.ts
new file mode 100644
index 000000000..5a9faf740
--- /dev/null
+++ b/packages/plans/src/types.ts
@@ -0,0 +1,21 @@
+import type { MonitorPeriodicity } from "@openstatus/db/src/schema";
+
+export type Limits = {
+ // monitors
+ monitors: number;
+ periodicity: Partial<MonitorPeriodicity>[];
+ "multi-region": boolean;
+ "data-retention": string;
+ // status pages
+ "status-pages": number;
+ "status-subscribers": boolean;
+ "custom-domain": boolean;
+ "white-label": boolean;
+ // alerts
+ notifications: boolean;
+ sms: boolean;
+ "notification-channels": number;
+ // collaboration
+ members: "Unlimited" | number;
+ "audit-log": boolean;
+};
diff --git a/packages/plans/src/utils.ts b/packages/plans/src/utils.ts
new file mode 100644
index 000000000..2016eeea9
--- /dev/null
+++ b/packages/plans/src/utils.ts
@@ -0,0 +1,9 @@
+import type { WorkspacePlan } from "@openstatus/db/src/schema";
+
+import { allPlans } from "./index";
+import type { Limits } from "./types";
+
+// TODO: use getLimit utils function
+export function getLimit(plan: WorkspacePlan, limit: keyof Limits) {
+ return allPlans[plan].limits[limit];
+}