Skip to content

Open-source status page, incident response and uptime monitoring

🌐 private locations (#938)

Thibault Le Ouay22c13a090c35
diff --git a/apps/web/src/components/dashboard/limit.tsx b/apps/web/src/components/dashboard/limit.tsx
index c8e755e1d..f1417550b 100644
--- a/apps/web/src/components/dashboard/limit.tsx
+++ b/apps/web/src/components/dashboard/limit.tsx
@@ -1,7 +1,15 @@
+import Link from "next/link";
+
export function Limit() {
return (
<div className="col-span-full text-center">
- <p className="text-muted-foreground text-xs">You reached the limits.</p>
+ <p className="text-foreground text-sm">
+ You have reached the account limits. Please{" "}
+ <Link href={"./settings/billing"} className="underline">
+ upgrade
+ </Link>{" "}
+ your account.
+ </p>
</div>
);
}
diff --git a/apps/web/src/components/marketing/pricing/pricing-table.tsx b/apps/web/src/components/marketing/pricing/pricing-table.tsx
index 5b62011d4..f31f8d329 100644
--- a/apps/web/src/components/marketing/pricing/pricing-table.tsx
+++ b/apps/web/src/components/marketing/pricing/pricing-table.tsx
@@ -114,7 +114,7 @@ export function PricingTable({
</TableRow>
{features.map(({ label, value, badge }, _i) => {
return (
- <TableRow key={key}>
+ <TableRow key={key + label}>
<TableCell className="gap-1">
{label}{" "}
{badge ? (
@@ -156,7 +156,8 @@ export function PricingTable({
return (
<TableCell
- key={key}
+ // biome-ignore lint/suspicious/noArrayIndexKey: <explanation>
+ key={key + value + _i}
className={cn(
"p-3",
plan.key === "team" && "bg-muted/30"
diff --git a/apps/web/src/config/pricing-table.ts b/apps/web/src/config/pricing-table.ts
index d53c57230..4713a688e 100644
--- a/apps/web/src/config/pricing-table.ts
+++ b/apps/web/src/config/pricing-table.ts
@@ -1,10 +1,10 @@
-import type { Limits } from "@openstatus/db/src/schema/plan/schema";
+import type { LimitsV2 } from "@openstatus/db/src/schema/plan/schema";
export const pricingTableConfig: Record<
string,
{
label: string;
- features: { value: keyof Limits; label: string; badge?: string }[];
+ features: { value: keyof LimitsV2; label: string; badge?: string }[];
}
> = {
monitors: {
@@ -23,6 +23,7 @@ export const pricingTableConfig: Record<
label: "Multi-region monitoring",
},
{ value: "max-regions", label: "Number of Regions" },
+
{ value: "data-retention", label: "Data retention" },
],
},
@@ -33,6 +34,7 @@ export const pricingTableConfig: Record<
value: "synthetic-checks",
label: "Number of synthetic API checks",
},
+ { value: "private-locations", label: "Private Locations" },
],
},
"status-pages": {
diff --git a/packages/api/src/router/workspace.ts b/packages/api/src/router/workspace.ts
index 4d7174226..545505b78 100644
--- a/packages/api/src/router/workspace.ts
+++ b/packages/api/src/router/workspace.ts
@@ -3,7 +3,7 @@ import { generateSlug } from "random-word-slugs";
import * as randomWordSlugs from "random-word-slugs";
import { z } from "zod";
-import { and, eq, isNotNull, sql } from "@openstatus/db";
+import { and, eq, isNotNull, isNull, sql } from "@openstatus/db";
import {
application,
monitor,
@@ -124,7 +124,7 @@ export const workspaceRouter = createTRPCRouter({
await opts.ctx.db.query.usersToWorkspaces.findFirst({
where: and(
eq(usersToWorkspaces.userId, opts.ctx.user.id),
- eq(usersToWorkspaces.workspaceId, opts.ctx.workspace.id)
+ eq(usersToWorkspaces.workspaceId, opts.ctx.workspace.id),
),
});
@@ -141,8 +141,8 @@ export const workspaceRouter = createTRPCRouter({
.where(
and(
eq(usersToWorkspaces.userId, opts.input.id),
- eq(usersToWorkspaces.workspaceId, opts.ctx.workspace.id)
- )
+ eq(usersToWorkspaces.workspaceId, opts.ctx.workspace.id),
+ ),
)
.run();
}),
@@ -154,7 +154,7 @@ export const workspaceRouter = createTRPCRouter({
await opts.ctx.db.query.usersToWorkspaces.findFirst({
where: and(
eq(usersToWorkspaces.userId, opts.ctx.user.id),
- eq(usersToWorkspaces.workspaceId, opts.ctx.workspace.id)
+ eq(usersToWorkspaces.workspaceId, opts.ctx.workspace.id),
),
});
@@ -198,6 +198,7 @@ export const workspaceRouter = createTRPCRouter({
}),
getCurrentWorkspaceNumbers: protectedProcedure.query(async (opts) => {
+ console.log(opts.ctx.workspace.id);
const currentNumbers = await opts.ctx.db.transaction(async (tx) => {
const notifications = await tx
.select({ count: sql<number>`count(*)` })
@@ -209,8 +210,8 @@ export const workspaceRouter = createTRPCRouter({
.where(
and(
eq(monitor.workspaceId, opts.ctx.workspace.id),
- isNotNull(monitor.deletedAt)
- )
+ isNull(monitor.deletedAt),
+ ),
);
const pages = await tx
.select({ count: sql<number>`count(*)` })
diff --git a/packages/db/src/schema/plan/config.ts b/packages/db/src/schema/plan/config.ts
index b48752f10..25d4d3d59 100644
--- a/packages/db/src/schema/plan/config.ts
+++ b/packages/db/src/schema/plan/config.ts
@@ -1,5 +1,5 @@
import type { WorkspacePlan } from "../workspaces/validation";
-import type { Limits } from "./schema";
+import type { Limits, LimitsV1, LimitsV2 } from "./schema";
// TODO: rename to `planConfig`
export const allPlans: Record<
@@ -8,7 +8,7 @@ export const allPlans: Record<
title: "Hobby" | "Starter" | "Growth" | "Pro";
description: string;
price: number;
- limits: Limits;
+ limits: Limits & { "private-locations": boolean };
}
> = {
free: {
@@ -35,6 +35,7 @@ export const allPlans: Record<
members: 1,
"audit-log": false,
regions: ["ams", "gru", "iad", "jnb", "hkg", "syd"],
+ "private-locations": false,
},
},
starter: {
@@ -97,6 +98,7 @@ export const allPlans: Record<
"yul",
"yyz",
],
+ "private-locations": false,
},
},
team: {
@@ -159,6 +161,7 @@ export const allPlans: Record<
"yul",
"yyz",
],
+ "private-locations": false,
},
},
pro: {
@@ -221,6 +224,7 @@ export const allPlans: Record<
"yul",
"yyz",
],
+ "private-locations": true,
},
},
};
diff --git a/packages/db/src/schema/plan/schema.ts b/packages/db/src/schema/plan/schema.ts
index c1b378fa5..fdd353a5a 100644
--- a/packages/db/src/schema/plan/schema.ts
+++ b/packages/db/src/schema/plan/schema.ts
@@ -29,13 +29,29 @@ export const limitsV1 = z.object({
regions: monitorFlyRegionSchema.array(),
});
+export type LimitsV1 = z.infer<typeof limitsV1>;
+export const limitsV2 = limitsV1.extend({
+ version: z.literal("v2"),
+ "private-locations": z.boolean(),
+});
+
+export type LimitsV2 = z.infer<typeof limitsV2>;
+
const unknownLimit = z.discriminatedUnion("version", [limitsV1]);
-// export const limitSchema = unknownLimit.transform((val) => {
-// if (!val.version) {
-// return migrateFromV1ToV2(val);
-// }
-// return val;
-// });
+export function migrateFromV1ToV2({ data }: { data: LimitsV1 }) {
+ return {
+ version: "v2",
+ ...data,
+ "private-locations": true,
+ };
+}
+
+export const limitSchema = unknownLimit.transform((val) => {
+ if (!val.version) {
+ return migrateFromV1ToV2({ data: val });
+ }
+ return val;
+});
export type Limits = z.infer<typeof unknownLimit>;