Skip to content

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

✨ Enable spaces (#1888)

Luke Vellae6e2f7f3ad64
diff --git a/apps/web/next.config.js b/apps/web/next.config.js
index 513544253..566fee544 100644
--- a/apps/web/next.config.js
+++ b/apps/web/next.config.js
@@ -67,8 +67,8 @@ const nextConfig = {
permanent: true,
},
{
- source: "/settings/billing",
- destination: "/account/billing",
+ source: "/account/billing",
+ destination: "/settings/billing",
permanent: true,
},
];
diff --git a/apps/web/src/app/[locale]/(space)/(dashboard)/settings/general/components/leave-space-button.tsx b/apps/web/src/app/[locale]/(space)/(dashboard)/settings/general/components/leave-space-button.tsx
index 8f182e124..b3b58d9c8 100644
--- a/apps/web/src/app/[locale]/(space)/(dashboard)/settings/general/components/leave-space-button.tsx
+++ b/apps/web/src/app/[locale]/(space)/(dashboard)/settings/general/components/leave-space-button.tsx
@@ -12,7 +12,14 @@ import {
DialogTitle,
DialogTrigger,
} from "@rallly/ui/dialog";
-import { Form, FormField, FormItem, FormMessage } from "@rallly/ui/form";
+import {
+ Form,
+ FormControl,
+ FormField,
+ FormItem,
+ FormLabel,
+ FormMessage,
+} from "@rallly/ui/form";
import { Icon } from "@rallly/ui/icon";
import { Input } from "@rallly/ui/input";
import { toast } from "@rallly/ui/sonner";
@@ -59,12 +66,12 @@ function LeaveSpaceDialog({
<Form {...form}>
<Dialog {...rest}>
{children}
- <DialogContent>
- <form
- onSubmit={form.handleSubmit(() => {
- leaveSpace.execute();
- })}
- >
+ <form
+ onSubmit={form.handleSubmit(() => {
+ leaveSpace.execute();
+ })}
+ >
+ <DialogContent>
<DialogHeader>
<DialogTitle>
<Trans i18nKey="leaveSpaceDialogTitle" defaults="Leave Space" />
@@ -76,14 +83,7 @@ function LeaveSpaceDialog({
/>
</DialogDescription>
</DialogHeader>
- <div className="space-y-4 py-4">
- <p className="text-sm">
- <Trans
- i18nKey="leaveSpaceInstruction"
- defaults="Please type the space name to confirm: {{spaceName}}"
- values={{ spaceName }}
- />
- </p>
+ <div className="space-y-4">
<FormField
control={form.control}
name="spaceName"
@@ -99,13 +99,21 @@ function LeaveSpaceDialog({
}}
render={({ field }) => (
<FormItem>
- <Input
- autoComplete="off"
- data-1p-ignore
- error={!!form.formState.errors.spaceName}
- placeholder={spaceName}
- {...field}
- />
+ <FormLabel>
+ <Trans
+ i18nKey="leaveSpaceInstruction"
+ defaults="Please type the space name to confirm:"
+ />
+ </FormLabel>
+ <FormControl>
+ <Input
+ autoComplete="off"
+ data-1p-ignore
+ error={!!form.formState.errors.spaceName}
+ placeholder={spaceName}
+ {...field}
+ />
+ </FormControl>
<FormMessage />
</FormItem>
)}
@@ -125,8 +133,8 @@ function LeaveSpaceDialog({
<Trans i18nKey="leaveSpace" defaults="Leave Space" />
</Button>
</DialogFooter>
- </form>
- </DialogContent>
+ </DialogContent>
+ </form>
</Dialog>
</Form>
);
diff --git a/apps/web/src/app/[locale]/(space)/(dashboard)/settings/general/page.tsx b/apps/web/src/app/[locale]/(space)/(dashboard)/settings/general/page.tsx
index ad49204c0..b6526bde7 100644
--- a/apps/web/src/app/[locale]/(space)/(dashboard)/settings/general/page.tsx
+++ b/apps/web/src/app/[locale]/(space)/(dashboard)/settings/general/page.tsx
@@ -1,6 +1,4 @@
import { subject } from "@casl/ability";
-import { Alert, AlertTitle } from "@rallly/ui/alert";
-import { ShieldXIcon } from "lucide-react";
import type { Metadata } from "next";
import {
PageSection,
@@ -24,6 +22,7 @@ export default async function GeneralSettingsPage() {
const isAdmin = space.role === "admin";
const canDeleteSpace = ability.can("delete", subject("Space", { ...space }));
+ const isOwner = space.ownerId === user.id;
return (
<PageSectionGroup>
<PageSection>
@@ -42,52 +41,42 @@ export default async function GeneralSettingsPage() {
<SpaceSettingsForm space={space} disabled={!isAdmin} />
</PageSectionContent>
</PageSection>
-
- <PageSection>
- <PageSectionHeader>
- <PageSectionTitle>
- <Trans i18nKey="leaveSpace" defaults="Leave Space" />
- </PageSectionTitle>
- <PageSectionDescription>
- <Trans
- i18nKey="leaveSpaceDescription"
- defaults="Remove yourself from this space. You'll lose access to all polls in this space."
- />
- </PageSectionDescription>
- </PageSectionHeader>
- <PageSectionContent>
- <LeaveSpaceButton spaceName={space.name} spaceId={space.id} />
- </PageSectionContent>
- </PageSection>
-
- <PageSection>
- <PageSectionHeader>
- <PageSectionTitle>
- <Trans i18nKey="deleteSpace" defaults="Delete Space" />
- </PageSectionTitle>
- <PageSectionDescription>
- <Trans
- i18nKey="deleteSpaceDescription"
- defaults="Permanently delete this space and all its content. This action cannot be undone."
- />
- </PageSectionDescription>
- </PageSectionHeader>
- <PageSectionContent>
- {!canDeleteSpace ? (
- <Alert>
- <ShieldXIcon />
- <AlertTitle>
- <Trans
- i18nKey="deleteSpacePermission"
- defaults="You need to be the owner to delete a space."
- />
- </AlertTitle>
- </Alert>
- ) : (
+ {!isOwner ? (
+ <PageSection>
+ <PageSectionHeader>
+ <PageSectionTitle>
+ <Trans i18nKey="leaveSpace" defaults="Leave Space" />
+ </PageSectionTitle>
+ <PageSectionDescription>
+ <Trans
+ i18nKey="leaveSpaceDescription"
+ defaults="Remove yourself from this space. You'll lose access to all polls in this space."
+ />
+ </PageSectionDescription>
+ </PageSectionHeader>
+ <PageSectionContent>
+ <LeaveSpaceButton spaceName={space.name} spaceId={space.id} />
+ </PageSectionContent>
+ </PageSection>
+ ) : null}
+ {canDeleteSpace ? (
+ <PageSection>
+ <PageSectionHeader>
+ <PageSectionTitle>
+ <Trans i18nKey="deleteSpace" defaults="Delete Space" />
+ </PageSectionTitle>
+ <PageSectionDescription>
+ <Trans
+ i18nKey="deleteSpaceDescription"
+ defaults="Permanently delete this space and all its content. This action cannot be undone."
+ />
+ </PageSectionDescription>
+ </PageSectionHeader>
+ <PageSectionContent>
<DeleteSpaceButton spaceName={space.name} spaceId={space.id} />
- )}
- </PageSectionContent>
- </PageSection>
+ </PageSectionContent>
+ </PageSection>
+ ) : null}
</PageSectionGroup>
);
}
diff --git a/apps/web/src/app/[locale]/(space)/(dashboard)/settings/members/components/invite-member-dialog.tsx b/apps/web/src/app/[locale]/(space)/(dashboard)/settings/members/components/invite-member-dialog.tsx
index 2a4108b82..19b61b55a 100644
--- a/apps/web/src/app/[locale]/(space)/(dashboard)/settings/members/components/invite-member-dialog.tsx
+++ b/apps/web/src/app/[locale]/(space)/(dashboard)/settings/members/components/invite-member-dialog.tsx
@@ -226,7 +226,7 @@ export function InviteMemberForm({ onSuccess }: { onSuccess?: () => void }) {
name="billingAcknowledgment"
render={({ field }) => (
<FormItem>
- <div className="flex flex-row items-start gap-3 rounded-lg border p-3">
+ <div className="flex flex-row items-start gap-3 py-2">
<FormControl>
<Checkbox
checked={field.value}
diff --git a/apps/web/src/app/[locale]/(space)/account/components/sidebar.tsx b/apps/web/src/app/[locale]/(space)/account/components/sidebar.tsx
index 307446bc7..d332822f7 100644
--- a/apps/web/src/app/[locale]/(space)/account/components/sidebar.tsx
+++ b/apps/web/src/app/[locale]/(space)/account/components/sidebar.tsx
@@ -6,7 +6,7 @@ import {
SidebarMenuButton,
SidebarMenuItem,
} from "@rallly/ui/sidebar";
-import { CreditCardIcon, Settings2Icon, UserIcon } from "lucide-react";
+import { Settings2Icon, UserIcon } from "lucide-react";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { useTranslation } from "@/i18n/client";
@@ -27,12 +27,6 @@ export function AccountSidebarMenu() {
icon: <Settings2Icon />,
href: "/account/preferences",
},
- {
- id: "billing",
- label: t("billing", { defaultValue: "Billing" }),
- icon: <CreditCardIcon />,
- href: "/account/billing",
- },
];
return (
<SidebarMenu>
diff --git a/apps/web/src/features/space/actions.ts b/apps/web/src/features/space/actions.ts
index 8ecb628c6..848454475 100644
--- a/apps/web/src/features/space/actions.ts
+++ b/apps/web/src/features/space/actions.ts
@@ -14,7 +14,11 @@ import { toDBRole } from "@/features/space/utils";
import { setActiveSpace } from "@/features/user/mutations";
import { AppError } from "@/lib/errors";
import { isFeatureEnabled } from "@/lib/feature-flags/server";
-import { authActionClient, spaceActionClient } from "@/lib/safe-action/server";
+import {
+ authActionClient,
+ createRateLimitMiddleware,
+ spaceActionClient,
+} from "@/lib/safe-action/server";
import {
deleteImageFromS3,
getImageUploadUrl,
@@ -68,6 +72,7 @@ export const createSpaceAction = authActionClient
.metadata({
actionName: "space_create",
})
+ .use(createRateLimitMiddleware(5, "1h"))
.inputSchema(
z.object({
name: z.string().min(1).max(100),
diff --git a/apps/web/src/features/space/components/space-dropdown.tsx b/apps/web/src/features/space/components/space-dropdown.tsx
index 01ccd9cc3..28b00be8a 100644
--- a/apps/web/src/features/space/components/space-dropdown.tsx
+++ b/apps/web/src/features/space/components/space-dropdown.tsx
@@ -79,7 +79,7 @@ export function SpaceDropdown({
<Icon>
<SettingsIcon />
</Icon>
- <Trans i18nKey="spaceSettings" defaults="Space Settings" />
+ <Trans i18nKey="settings" defaults="Settings" />
</Link>
</DropdownMenuItem>
<DropdownMenuItem asChild>
diff --git a/apps/web/src/features/space/constants.ts b/apps/web/src/features/space/constants.ts
index ba3206a90..884600e83 100644
--- a/apps/web/src/features/space/constants.ts
+++ b/apps/web/src/features/space/constants.ts
@@ -1 +1 @@
-export const isSpacesEnabled = process.env.NODE_ENV === "development";
+export const isSpacesEnabled = true;