@orsetra/shared-ui 1.10.24 → 1.10.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
+
import { useContext } from "react"
|
|
3
4
|
import { useRouter } from "next/navigation"
|
|
4
5
|
import { LogOut, ChevronDown, type LucideIcon } from "lucide-react"
|
|
5
6
|
import Avatar from "react-avatar"
|
|
@@ -12,6 +13,7 @@ import {
|
|
|
12
13
|
DropdownMenuSeparator,
|
|
13
14
|
DropdownMenuTrigger,
|
|
14
15
|
} from "./dropdown-menu"
|
|
16
|
+
import { UserContext } from "../../context/user-context"
|
|
15
17
|
|
|
16
18
|
// Type for configurable user menu items
|
|
17
19
|
export interface UserMenuItem {
|
|
@@ -33,8 +35,10 @@ interface UserMenuProps {
|
|
|
33
35
|
|
|
34
36
|
export function UserMenu({ username, onSignOut, menuConfig }: UserMenuProps) {
|
|
35
37
|
const router = useRouter()
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
const userCtx = useContext(UserContext)
|
|
39
|
+
|
|
40
|
+
const displayName = username || userCtx?.profile?.name || userCtx?.profile?.preferred_username || "User"
|
|
41
|
+
const orgName = userCtx?.organization?.name
|
|
38
42
|
const menuItems = menuConfig?.items || []
|
|
39
43
|
|
|
40
44
|
return (
|
|
@@ -61,6 +65,9 @@ export function UserMenu({ username, onSignOut, menuConfig }: UserMenuProps) {
|
|
|
61
65
|
</DropdownMenuTrigger>
|
|
62
66
|
<DropdownMenuContent align="end" className="w-56 bg-white shadow-lg border border-ibm-gray-20">
|
|
63
67
|
<DropdownMenuLabel>
|
|
68
|
+
{orgName && (
|
|
69
|
+
<p className="text-[11px] text-gray-400 uppercase tracking-widest mb-1">{orgName}</p>
|
|
70
|
+
)}
|
|
64
71
|
<div className="flex flex-col space-y-1">
|
|
65
72
|
<p className="text-sm font-medium leading-none">{displayName}</p>
|
|
66
73
|
</div>
|