Skip to content

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

✨ Account dropdown menu

Luke Vella53303311f618
diff --git a/apps/web/public/locales/en/app.json b/apps/web/public/locales/en/app.json
index 3b620afbd..e349b8e91 100644
--- a/apps/web/public/locales/en/app.json
+++ b/apps/web/public/locales/en/app.json
@@ -454,8 +454,6 @@
"inviteMembers": "Invite Members",
"accessDenied": "Access Denied",
"ownerPermissionsRequired": "Only space owners can access billing settings.",
- "signOutSection": "Sign Out",
- "signOutSectionDescription": "End your current session and sign out of your account",
"loading": "Loading...",
"endOfList": "You've reached the end of the list",
"attendeeCount": "{count, plural, =0 {No attendees} one {1 attendee} other {# attendees}}",
diff --git a/apps/web/src/app/[locale]/(space)/(dashboard)/components/sidebar/nav-user.tsx b/apps/web/src/app/[locale]/(space)/(dashboard)/components/sidebar/nav-user.tsx
index ae7078863..85fe51628 100644
--- a/apps/web/src/app/[locale]/(space)/(dashboard)/components/sidebar/nav-user.tsx
+++ b/apps/web/src/app/[locale]/(space)/(dashboard)/components/sidebar/nav-user.tsx
@@ -1,9 +1,27 @@
"use client";
+import { Button } from "@rallly/ui/button";
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuSeparator,
+ DropdownMenuTrigger,
+} from "@rallly/ui/dropdown-menu";
+import { Icon } from "@rallly/ui/icon";
+import {
+ ChevronDownIcon,
+ LayersIcon,
+ LogOutIcon,
+ SettingsIcon,
+ UserIcon,
+} from "lucide-react";
import Link from "next/link";
-import { usePathname } from "next/navigation";
-
+import { signOut } from "next-auth/react";
+import React from "react";
import { OptimizedAvatarImage } from "@/components/optimized-avatar-image";
+import { RouterLoadingIndicator } from "@/components/router-loading-indicator";
+import { Trans } from "@/components/trans";
export function NavUser({
name,
@@ -14,20 +32,68 @@ export function NavUser({
image?: string;
email: string;
}) {
- const pathname = usePathname();
+ const [isPending, startTransition] = React.useTransition();
+
return (
- <Link
- href="/account/profile"
- data-state={pathname.startsWith("/account") ? "active" : "inactive"}
- className="group relative flex w-full items-center gap-3 rounded-md p-3 text-sm hover:bg-gray-200 data-[state=active]:bg-gray-200"
- >
- <OptimizedAvatarImage size="lg" src={image} name={name} />
- <div className="flex-1 truncate text-left">
- <div className="font-medium">{name}</div>
- <div className="mt-0.5 truncate font-normal text-muted-foreground text-xs">
- {email}
- </div>
- </div>
- </Link>
+ <>
+ {isPending && <RouterLoadingIndicator />}
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button className="flex h-auto w-full p-2" variant="ghost">
+ <OptimizedAvatarImage size="lg" src={image} name={name} />
+ <div className="flex-1 truncate text-left">
+ <div className="font-medium">{name}</div>
+ <div className="mt-0.5 truncate font-normal text-muted-foreground text-xs">
+ {email}
+ </div>
+ </div>
+ <Icon>
+ <ChevronDownIcon />
+ </Icon>
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end" side="top">
+ <DropdownMenuItem asChild>
+ <Link href="/account/profile">
+ <Icon>
+ <UserIcon />
+ </Icon>
+ <Trans i18nKey="profile" defaults="Profile" />
+ </Link>
+ </DropdownMenuItem>
+ <DropdownMenuItem asChild>
+ <Link href="/account/preferences">
+ <Icon>
+ <SettingsIcon />
+ </Icon>
+ <Trans i18nKey="preferences" defaults="Preferences" />
+ </Link>
+ </DropdownMenuItem>
+ <DropdownMenuItem asChild>
+ <Link href="/account/spaces">
+ <Icon>
+ <LayersIcon />
+ </Icon>
+ <Trans i18nKey="spaces" defaults="Spaces" />
+ </Link>
+ </DropdownMenuItem>
+ <DropdownMenuSeparator />
+ <DropdownMenuItem
+ onClick={() => {
+ startTransition(async () => {
+ await signOut({
+ redirectTo: "/",
+ });
+ });
+ }}
+ >
+ <Icon>
+ <LogOutIcon />
+ </Icon>
+ <Trans i18nKey="signOut" defaults="Sign Out" />
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </>
);
}
diff --git a/apps/web/src/app/[locale]/account/profile/page.tsx b/apps/web/src/app/[locale]/account/profile/page.tsx
index 031c1bf0e..61584498f 100644
--- a/apps/web/src/app/[locale]/account/profile/page.tsx
+++ b/apps/web/src/app/[locale]/account/profile/page.tsx
@@ -20,7 +20,6 @@ import { requireUser } from "@/auth/data";
import { Trans } from "@/components/trans";
import { getTranslation } from "@/i18n/server";
import { DeleteAccountDialog } from "./delete-account-dialog";
-import { LogoutButton } from "./logout-button";
import { ProfileEmailAddress } from "./profile-email-address";
import { ProfileSettings } from "./profile-settings";
@@ -69,23 +68,6 @@ export default async function Page() {
</PageSectionContent>
</PageSection>
- <PageSection>
- <PageSectionHeader>
- <PageSectionTitle>
- <Trans i18nKey="signOutSection" defaults="Sign Out" />
- </PageSectionTitle>
- <PageSectionDescription>
- <Trans
- i18nKey="signOutSectionDescription"
- defaults="End your current session and sign out of your account"
- />
- </PageSectionDescription>
- </PageSectionHeader>
- <PageSectionContent>
- <LogoutButton />
- </PageSectionContent>
- </PageSection>
-
<PageSection>
<PageSectionHeader>
<PageSectionTitle>