mirror of
https://github.com/fosrl/pangolin.git
synced 2026-02-24 13:56:39 +00:00
fix sidebar
This commit is contained in:
@@ -5,13 +5,11 @@ import { SidebarNav } from "@app/components/SidebarNav";
|
|||||||
import { OrgSelector } from "@app/components/OrgSelector";
|
import { OrgSelector } from "@app/components/OrgSelector";
|
||||||
import { cn } from "@app/lib/cn";
|
import { cn } from "@app/lib/cn";
|
||||||
import { ListUserOrgsResponse } from "@server/routers/org";
|
import { ListUserOrgsResponse } from "@server/routers/org";
|
||||||
import SupporterStatus from "@app/components/SupporterStatus";
|
|
||||||
import { Button } from "@app/components/ui/button";
|
import { Button } from "@app/components/ui/button";
|
||||||
import { ExternalLink, Menu, Server } from "lucide-react";
|
import { ArrowRight, Menu, Server } from "lucide-react";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { usePathname } from "next/navigation";
|
import { usePathname } from "next/navigation";
|
||||||
import { useUserContext } from "@app/hooks/useUserContext";
|
import { useUserContext } from "@app/hooks/useUserContext";
|
||||||
import { useEnvContext } from "@app/hooks/useEnvContext";
|
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import ProfileIcon from "@app/components/ProfileIcon";
|
import ProfileIcon from "@app/components/ProfileIcon";
|
||||||
import ThemeSwitcher from "@app/components/ThemeSwitcher";
|
import ThemeSwitcher from "@app/components/ThemeSwitcher";
|
||||||
@@ -44,7 +42,6 @@ export function LayoutMobileMenu({
|
|||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
const isAdminPage = pathname?.startsWith("/admin");
|
const isAdminPage = pathname?.startsWith("/admin");
|
||||||
const { user } = useUserContext();
|
const { user } = useUserContext();
|
||||||
const { env } = useEnvContext();
|
|
||||||
const t = useTranslations();
|
const t = useTranslations();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -83,7 +80,7 @@ export function LayoutMobileMenu({
|
|||||||
<div className="px-3 pt-3">
|
<div className="px-3 pt-3">
|
||||||
{!isAdminPage &&
|
{!isAdminPage &&
|
||||||
user.serverAdmin && (
|
user.serverAdmin && (
|
||||||
<div className="py-2">
|
<div className="mb-1">
|
||||||
<Link
|
<Link
|
||||||
href="/admin"
|
href="/admin"
|
||||||
className={cn(
|
className={cn(
|
||||||
@@ -98,11 +95,12 @@ export function LayoutMobileMenu({
|
|||||||
<span className="flex-shrink-0 mr-2">
|
<span className="flex-shrink-0 mr-2">
|
||||||
<Server className="h-4 w-4" />
|
<Server className="h-4 w-4" />
|
||||||
</span>
|
</span>
|
||||||
<span>
|
<span className="flex-1">
|
||||||
{t(
|
{t(
|
||||||
"serverAdmin"
|
"serverAdmin"
|
||||||
)}
|
)}
|
||||||
</span>
|
</span>
|
||||||
|
<ArrowRight className="h-4 w-4 shrink-0 ml-auto opacity-70" />
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@@ -115,22 +113,6 @@ export function LayoutMobileMenu({
|
|||||||
</div>
|
</div>
|
||||||
<div className="sticky bottom-0 left-0 right-0 h-8 pointer-events-none bg-gradient-to-t from-card to-transparent" />
|
<div className="sticky bottom-0 left-0 right-0 h-8 pointer-events-none bg-gradient-to-t from-card to-transparent" />
|
||||||
</div>
|
</div>
|
||||||
<div className="px-3 pt-3 pb-3 space-y-4 border-t shrink-0">
|
|
||||||
<SupporterStatus />
|
|
||||||
{env?.app?.version && (
|
|
||||||
<div className="text-xs text-muted-foreground text-center">
|
|
||||||
<Link
|
|
||||||
href={`https://github.com/fosrl/pangolin/releases/tag/${env.app.version}`}
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
className="flex items-center justify-center gap-1"
|
|
||||||
>
|
|
||||||
v{env.app.version}
|
|
||||||
<ExternalLink size={12} />
|
|
||||||
</Link>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</SheetContent>
|
</SheetContent>
|
||||||
</Sheet>
|
</Sheet>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -146,6 +146,46 @@ export function LayoutSidebar({
|
|||||||
/>
|
/>
|
||||||
<div className="flex-1 overflow-y-auto relative">
|
<div className="flex-1 overflow-y-auto relative">
|
||||||
<div className="px-2 pt-3">
|
<div className="px-2 pt-3">
|
||||||
|
{!isAdminPage && user.serverAdmin && (
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
"shrink-0",
|
||||||
|
isSidebarCollapsed ? "mb-4" : "mb-1"
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<Link
|
||||||
|
href="/admin"
|
||||||
|
className={cn(
|
||||||
|
"flex items-center transition-colors text-muted-foreground hover:text-foreground text-sm w-full hover:bg-secondary/80 dark:hover:bg-secondary/50 rounded-md",
|
||||||
|
isSidebarCollapsed
|
||||||
|
? "px-2 py-2 justify-center"
|
||||||
|
: "px-3 py-1.5"
|
||||||
|
)}
|
||||||
|
title={
|
||||||
|
isSidebarCollapsed
|
||||||
|
? t("serverAdmin")
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
className={cn(
|
||||||
|
"shrink-0",
|
||||||
|
!isSidebarCollapsed && "mr-2"
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<Server className="h-4 w-4" />
|
||||||
|
</span>
|
||||||
|
{!isSidebarCollapsed && (
|
||||||
|
<>
|
||||||
|
<span className="flex-1">
|
||||||
|
{t("serverAdmin")}
|
||||||
|
</span>
|
||||||
|
<ArrowRight className="h-4 w-4 shrink-0 ml-auto opacity-70" />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
<SidebarNav
|
<SidebarNav
|
||||||
sections={navItems}
|
sections={navItems}
|
||||||
isCollapsed={isSidebarCollapsed}
|
isCollapsed={isSidebarCollapsed}
|
||||||
@@ -156,40 +196,6 @@ export function LayoutSidebar({
|
|||||||
<div className="sticky bottom-0 left-0 right-0 h-8 pointer-events-none bg-gradient-to-t from-card to-transparent" />
|
<div className="sticky bottom-0 left-0 right-0 h-8 pointer-events-none bg-gradient-to-t from-card to-transparent" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{!isAdminPage && user.serverAdmin && (
|
|
||||||
<div className="shrink-0 px-2 pb-2">
|
|
||||||
<Link
|
|
||||||
href="/admin"
|
|
||||||
className={cn(
|
|
||||||
"flex items-center transition-colors text-muted-foreground hover:text-foreground text-sm w-full hover:bg-secondary/80 dark:hover:bg-secondary/50 rounded-md",
|
|
||||||
isSidebarCollapsed
|
|
||||||
? "px-2 py-2 justify-center"
|
|
||||||
: "px-3 py-1.5"
|
|
||||||
)}
|
|
||||||
title={
|
|
||||||
isSidebarCollapsed ? t("serverAdmin") : undefined
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
className={cn(
|
|
||||||
"shrink-0",
|
|
||||||
!isSidebarCollapsed && "mr-2"
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<Server className="h-4 w-4" />
|
|
||||||
</span>
|
|
||||||
{!isSidebarCollapsed && (
|
|
||||||
<>
|
|
||||||
<span className="flex-1">
|
|
||||||
{t("serverAdmin")}
|
|
||||||
</span>
|
|
||||||
<ArrowRight className="h-4 w-4 shrink-0 ml-auto opacity-70" />
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</Link>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{isSidebarCollapsed && (
|
{isSidebarCollapsed && (
|
||||||
<div className="shrink-0 flex justify-center py-2">
|
<div className="shrink-0 flex justify-center py-2">
|
||||||
<TooltipProvider>
|
<TooltipProvider>
|
||||||
@@ -218,7 +224,7 @@ export function LayoutSidebar({
|
|||||||
|
|
||||||
<div className="w-full border-t border-border mb-3" />
|
<div className="w-full border-t border-border mb-3" />
|
||||||
|
|
||||||
<div className="p-4 pt-0 mt-0 flex flex-col shrink-0">
|
<div className="p-4 pt-1 flex flex-col shrink-0">
|
||||||
{canShowProductUpdates && (
|
{canShowProductUpdates && (
|
||||||
<div className="mb-3 empty:mb-0">
|
<div className="mb-3 empty:mb-0">
|
||||||
<ProductUpdates isCollapsed={isSidebarCollapsed} />
|
<ProductUpdates isCollapsed={isSidebarCollapsed} />
|
||||||
|
|||||||
Reference in New Issue
Block a user