@orsetra/shared-ui 1.10.24 → 1.10.26
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.
|
@@ -79,8 +79,6 @@ export function MainSidebarFlyout({
|
|
|
79
79
|
<a
|
|
80
80
|
key={sub.id}
|
|
81
81
|
href={sub.disabled ? undefined : sub.href}
|
|
82
|
-
target={sub.target}
|
|
83
|
-
rel={sub.target === "_blank" ? "noopener noreferrer" : undefined}
|
|
84
82
|
aria-disabled={sub.disabled}
|
|
85
83
|
title={sub.disabled ? "Select a project/environment first" : undefined}
|
|
86
84
|
onClick={(e) => { if (sub.disabled) e.preventDefault() }}
|
|
@@ -151,7 +149,6 @@ export function MainSidebarFlyout({
|
|
|
151
149
|
<a
|
|
152
150
|
key={i}
|
|
153
151
|
href={link.href}
|
|
154
|
-
{...(isExternal ? { target: "_blank", rel: "noopener noreferrer" } : {})}
|
|
155
152
|
className="flex items-start gap-x-3 px-2 py-2 border-l-4 border-transparent hover:bg-ui-background hover:border-interactive transition-colors"
|
|
156
153
|
>
|
|
157
154
|
<LinkIcon className="h-4 w-4 flex-shrink-0 mt-0.5 text-text-secondary" />
|
|
@@ -206,7 +203,6 @@ export function MainSidebarFlyout({
|
|
|
206
203
|
<a
|
|
207
204
|
key={i}
|
|
208
205
|
href={link.href}
|
|
209
|
-
{...(isExternal ? { target: "_blank", rel: "noopener noreferrer" } : {})}
|
|
210
206
|
className="flex items-start gap-x-3 px-2 py-2 border-l-4 border-transparent hover:bg-ui-background hover:border-interactive transition-colors"
|
|
211
207
|
>
|
|
212
208
|
<LinkIcon className="h-4 w-4 flex-shrink-0 mt-0.5 text-text-secondary" />
|
|
@@ -11,6 +11,13 @@ interface QuickAccessTrackerProps {
|
|
|
11
11
|
icon?: string
|
|
12
12
|
/** Set to false to skip tracking this page (e.g. list/index pages) */
|
|
13
13
|
enabled?: boolean
|
|
14
|
+
/**
|
|
15
|
+
* Canonical href for this resource — overrides the current page URL.
|
|
16
|
+
* Pass the resource root (e.g. "/my-app") so that visiting any tab of
|
|
17
|
+
* the same resource tracks a single entry instead of one per tab.
|
|
18
|
+
* Absolute URL or path relative to the current origin.
|
|
19
|
+
*/
|
|
20
|
+
href?: string
|
|
14
21
|
}
|
|
15
22
|
|
|
16
23
|
/**
|
|
@@ -18,7 +25,7 @@ interface QuickAccessTrackerProps {
|
|
|
18
25
|
* sidebar's quick-access list. Tracks on mount and whenever pathname changes.
|
|
19
26
|
* Renders nothing.
|
|
20
27
|
*/
|
|
21
|
-
export function QuickAccessTracker({ label, icon, enabled = true }: QuickAccessTrackerProps) {
|
|
28
|
+
export function QuickAccessTracker({ label, icon, enabled = true, href: hrefProp }: QuickAccessTrackerProps) {
|
|
22
29
|
const pathname = usePathname()
|
|
23
30
|
const { addItem } = useQuickAccess()
|
|
24
31
|
// Stable ref so the effect doesn't re-run when addItem reference changes
|
|
@@ -27,11 +34,12 @@ export function QuickAccessTracker({ label, icon, enabled = true }: QuickAccessT
|
|
|
27
34
|
|
|
28
35
|
useEffect(() => {
|
|
29
36
|
if (!enabled || !label || !pathname) return
|
|
30
|
-
|
|
31
|
-
|
|
37
|
+
const href = hrefProp
|
|
38
|
+
? (hrefProp.startsWith("http") ? hrefProp : window.location.origin + hrefProp)
|
|
39
|
+
: window.location.origin + window.location.pathname
|
|
32
40
|
addRef.current({ label, href, icon })
|
|
33
41
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
34
|
-
}, [pathname, label, icon, enabled])
|
|
42
|
+
}, [pathname, label, icon, enabled, hrefProp])
|
|
35
43
|
|
|
36
44
|
return null
|
|
37
45
|
}
|
|
@@ -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>
|