Skip to content

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

✨ Show user nav in control panel (#2107)

Luke Vella2fe2abb16e5e
diff --git a/apps/web/src/app/[locale]/(space)/(dashboard)/layout.tsx b/apps/web/src/app/[locale]/(space)/(dashboard)/layout.tsx
index ad62e8393..ff9b4fc3a 100644
--- a/apps/web/src/app/[locale]/(space)/(dashboard)/layout.tsx
+++ b/apps/web/src/app/[locale]/(space)/(dashboard)/layout.tsx
@@ -16,10 +16,10 @@ import { GaugeIcon, Settings2Icon } from "lucide-react";
import type { Metadata } from "next";
import Link from "next/link";
import { FeedbackMenuItem } from "@/app/[locale]/(space)/(dashboard)/components/feedback-menu-item";
-import { NavUser } from "@/app/[locale]/(space)/(dashboard)/components/nav-user";
import { SpaceSidebarMenu } from "@/app/[locale]/(space)/(dashboard)/components/space-sidebar-menu";
import { UpgradeMenuItem } from "@/app/[locale]/(space)/(dashboard)/components/upgrade-menu-item";
import { requireSpace, requireUser } from "@/auth/data";
+import { NavUser } from "@/components/nav-user";
import { Trans } from "@/components/trans";
import { LicenseLimitWarning } from "@/features/licensing/components/license-limit-warning";
import { CommandMenu } from "@/features/navigation/command-menu";
diff --git a/apps/web/src/app/[locale]/control-panel/layout.tsx b/apps/web/src/app/[locale]/control-panel/layout.tsx
index 1f50921ea..397201519 100644
--- a/apps/web/src/app/[locale]/control-panel/layout.tsx
+++ b/apps/web/src/app/[locale]/control-panel/layout.tsx
@@ -2,6 +2,7 @@ import { Icon } from "@rallly/ui/icon";
import { SidebarInset, SidebarTrigger } from "@rallly/ui/sidebar";
import { GaugeIcon } from "lucide-react";
import type { Metadata } from "next";
+import { requireAdmin } from "@/auth/data";
import { Trans } from "@/components/trans";
import { LicenseLimitWarning } from "@/features/licensing/components/license-limit-warning";
import { CommandMenu } from "@/features/navigation/command-menu";
@@ -14,10 +15,17 @@ export default async function AdminLayout({
}: {
children: React.ReactNode;
}) {
+ const user = await requireAdmin();
return (
<ControlPanelSidebarProvider>
<CommandMenu />
- <ControlPanelSidebar />
+ <ControlPanelSidebar
+ user={{
+ name: user.name,
+ image: user.image,
+ email: user.email,
+ }}
+ />
<SidebarInset>
<LicenseLimitWarning />
<div className="flex flex-1 flex-col">
diff --git a/apps/web/src/app/[locale]/control-panel/sidebar.tsx b/apps/web/src/app/[locale]/control-panel/sidebar.tsx
index b234ab5d7..8976a9829 100644
--- a/apps/web/src/app/[locale]/control-panel/sidebar.tsx
+++ b/apps/web/src/app/[locale]/control-panel/sidebar.tsx
@@ -1,6 +1,7 @@
import {
Sidebar,
SidebarContent,
+ SidebarFooter,
SidebarGroup,
SidebarGroupLabel,
SidebarHeader,
@@ -16,13 +17,21 @@ import {
} from "lucide-react";
import type * as React from "react";
+import { NavUser } from "@/components/nav-user";
import { Trans } from "@/components/trans";
import { NavItem } from "./nav-item";
export async function ControlPanelSidebar({
+ user,
...props
-}: React.ComponentProps<typeof Sidebar>) {
+}: React.ComponentProps<typeof Sidebar> & {
+ user: {
+ name: string;
+ image?: string | null;
+ email: string;
+ };
+}) {
return (
<Sidebar {...props}>
<SidebarHeader>
@@ -62,6 +71,13 @@ export async function ControlPanelSidebar({
</SidebarMenu>
</SidebarGroup>
</SidebarContent>
+ <SidebarFooter>
+ <NavUser
+ name={user.name}
+ image={user.image ?? undefined}
+ email={user.email}
+ />
+ </SidebarFooter>
</Sidebar>
);
}
diff --git a/apps/web/src/auth/data.ts b/apps/web/src/auth/data.ts
index 01c354902..cf889c2a9 100644
--- a/apps/web/src/auth/data.ts
+++ b/apps/web/src/auth/data.ts
@@ -86,6 +86,8 @@ export const requireAdmin = cache(async () => {
notFound();
}
+
+ return user;
});
export const requireUser = cache(async () => {
diff --git a/apps/web/src/app/[locale]/(space)/(dashboard)/components/nav-user.tsx b/apps/web/src/components/nav-user.tsx
similarity index 100%
rename from apps/web/src/app/[locale]/(space)/(dashboard)/components/nav-user.tsx
rename to apps/web/src/components/nav-user.tsx