Skip to content

Commit

Permalink
enhance: replace ugly user dropdown menu with Shadcn UI DropdownMenu
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Hopper-Lowe <[email protected]>
  • Loading branch information
ryanhopperlowe committed Dec 4, 2024
1 parent cb447b7 commit 435e65f
Showing 1 changed file with 25 additions and 26 deletions.
51 changes: 25 additions & 26 deletions ui/admin/app/components/user/UserMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ import { cn } from "~/lib/utils";

import { useAuth } from "~/components/auth/AuthContext";
import { Avatar, AvatarFallback, AvatarImage } from "~/components/ui/avatar";
import { Button } from "~/components/ui/button";
import { ClickableDiv } from "~/components/ui/clickable-div";
import {
Popover,
PopoverContent,
PopoverTrigger,
} from "~/components/ui/popover";
DropdownMenu,
DropdownMenuContent,
DropdownMenuGroup,
DropdownMenuItem,
DropdownMenuTrigger,
} from "~/components/ui/dropdown-menu";

interface UserMenuProps {
className?: string;
Expand All @@ -30,14 +32,9 @@ export const UserMenu: React.FC<UserMenuProps> = ({
}

return (
<Popover>
<PopoverTrigger asChild>
<div
className={cn(
"flex items-center cursor-pointer",
className
)}
>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<ClickableDiv className={cn("flex items-center", className)}>
<Avatar className={cn("mr-4", { "w-full": avatarOnly })}>
<AvatarImage src={me?.iconURL} />
<AvatarFallback>
Expand All @@ -54,18 +51,20 @@ export const UserMenu: React.FC<UserMenuProps> = ({
</p>
</div>
)}
</div>
</PopoverTrigger>
<PopoverContent className="w-auto" side="bottom" align="center">
<Button
variant="destructive"
onClick={() => {
window.location.href = "/oauth2/sign_out?rd=/admin/";
}}
>
Sign Out
</Button>
</PopoverContent>
</Popover>
</ClickableDiv>
</DropdownMenuTrigger>
<DropdownMenuContent className="w-auto" side="bottom" align="start">
<DropdownMenuGroup>
<DropdownMenuItem
onClick={() => {
window.location.href =
"/oauth2/sign_out?rd=/admin/";
}}
>
Sign Out
</DropdownMenuItem>
</DropdownMenuGroup>
</DropdownMenuContent>
</DropdownMenu>
);
};

0 comments on commit 435e65f

Please sign in to comment.