Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

🐛 Display unlimited seats for enterprise licenses (#1764)

Luke Vella9aa0375008a5
diff --git a/apps/web/src/app/[locale]/control-panel/license/page.tsx b/apps/web/src/app/[locale]/control-panel/license/page.tsx
index a555a97a2..d715e4ff9 100644
--- a/apps/web/src/app/[locale]/control-panel/license/page.tsx
+++ b/apps/web/src/app/[locale]/control-panel/license/page.tsx
@@ -120,7 +120,7 @@ export default async function LicensePage() {
</DescriptionListValue>
</DescriptionList>
<div className="mt-6">
- <RemoveLicenseButton licenseId={license.id} />
+ <RemoveLicenseButton />
</div>
</div>
) : (
diff --git a/apps/web/src/app/[locale]/control-panel/page.tsx b/apps/web/src/app/[locale]/control-panel/page.tsx
index 19542dd04..c4ec2bbb7 100644
--- a/apps/web/src/app/[locale]/control-panel/page.tsx
+++ b/apps/web/src/app/[locale]/control-panel/page.tsx
@@ -10,9 +10,11 @@ import { Trans } from "@/components/trans";
import { getLicense } from "@/features/licensing/queries";
import { prisma } from "@rallly/database";
import { cn } from "@rallly/ui";
+import { Icon } from "@rallly/ui/icon";
import { Tile, TileGrid, TileTitle } from "@rallly/ui/tile";
import {
GaugeIcon,
+ InfinityIcon,
KeySquareIcon,
SettingsIcon,
UsersIcon,
@@ -29,13 +31,16 @@ async function loadData() {
return {
userCount,
- userLimit: license?.seats ?? 1,
- tier: license?.type,
+ license,
};
}
export default async function AdminPage() {
- const { userCount, userLimit, tier } = await loadData();
+ const { userCount, license } = await loadData();
+
+ const userLimit = license?.seats ?? 1;
+ const tier = license?.type;
+
return (
<FullWidthLayout>
<FullWidthLayoutHeader>
@@ -80,9 +85,13 @@ export default async function AdminPage() {
values={{ count: userCount }}
/>
/
- {userLimit === Number.POSITIVE_INFINITY
- ? "unlimited"
- : userLimit}
+ {userLimit === Number.POSITIVE_INFINITY ? (
+ <Icon className="inline-flex">
+ <InfinityIcon />
+ </Icon>
+ ) : (
+ userLimit
+ )}
</span>
</div>
</div>
diff --git a/apps/web/src/features/licensing/components/remove-license-button.tsx b/apps/web/src/features/licensing/components/remove-license-button.tsx
index f4862ad67..4392c9129 100644
--- a/apps/web/src/features/licensing/components/remove-license-button.tsx
+++ b/apps/web/src/features/licensing/components/remove-license-button.tsx
@@ -19,11 +19,7 @@ import { useRouter } from "next/navigation";
import { useTransition } from "react";
import { removeInstanceLicense } from "../mutations";
-export function RemoveLicenseButton({
- licenseId,
-}: {
- licenseId: string;
-}) {
+export function RemoveLicenseButton() {
const [isPending, startTransition] = useTransition();
const router = useRouter();
const dialog = useDialog();
@@ -60,9 +56,7 @@ export function RemoveLicenseButton({
variant="destructive"
onClick={() =>
startTransition(async () => {
- await removeInstanceLicense({
- licenseId,
- });
+ await removeInstanceLicense();
router.refresh();
dialog.dismiss();
})
diff --git a/apps/web/src/features/licensing/mutations.ts b/apps/web/src/features/licensing/mutations.ts
index 2490c80a7..f1829c5ff 100644
--- a/apps/web/src/features/licensing/mutations.ts
+++ b/apps/web/src/features/licensing/mutations.ts
@@ -3,11 +3,7 @@
import { requireAdmin } from "@/auth/queries";
import { prisma } from "@rallly/database";
-export async function removeInstanceLicense({
- licenseId,
-}: {
- licenseId: string;
-}) {
+export async function removeInstanceLicense() {
try {
await requireAdmin();
} catch (error) {
@@ -18,11 +14,7 @@ export async function removeInstanceLicense({
}
try {
- await prisma.instanceLicense.delete({
- where: {
- id: licenseId,
- },
- });
+ await prisma.instanceLicense.deleteMany();
} catch (error) {
return {
success: false,
diff --git a/apps/web/src/features/licensing/queries.ts b/apps/web/src/features/licensing/queries.ts
index d327263bf..02f668f78 100644
--- a/apps/web/src/features/licensing/queries.ts
+++ b/apps/web/src/features/licensing/queries.ts
@@ -1,5 +1,22 @@
import { prisma } from "@rallly/database";
export async function getLicense() {
- return prisma.instanceLicense.findFirst();
+ const license = await prisma.instanceLicense.findFirst();
+
+ if (!license) {
+ return null;
+ }
+
+ return {
+ licenseKey: license.licenseKey,
+ licenseeName: license.licenseeName,
+ licenseeEmail: license.licenseeEmail,
+ issuedAt: license.issuedAt,
+ expiresAt: license.expiresAt,
+ seats:
+ (license.seats ?? license.type === "ENTERPRISE")
+ ? Number.POSITIVE_INFINITY
+ : 1,
+ type: license.type,
+ };
}