File tree Expand file tree Collapse file tree 3 files changed +12
-6
lines changed Expand file tree Collapse file tree 3 files changed +12
-6
lines changed Original file line number Diff line number Diff line change 6
6
* Copyright Oxide Computer Company
7
7
*/
8
8
import React from 'react'
9
- import { useNavigate } from 'react-router-dom'
10
9
11
10
import { navToLogin , useApiMutation } from '@oxide/api'
12
11
import { DirectionDownIcon , Profile16Icon } from '@oxide/design-system/icons/react'
@@ -17,7 +16,6 @@ import { DropdownMenu } from '~/ui/lib/DropdownMenu'
17
16
import { pb } from '~/util/path-builder'
18
17
19
18
export function TopBar ( { children } : { children : React . ReactNode } ) {
20
- const navigate = useNavigate ( )
21
19
const logout = useApiMutation ( 'logout' , {
22
20
onSuccess : ( ) => navToLogin ( { includeCurrent : false } ) ,
23
21
} )
@@ -63,9 +61,7 @@ export function TopBar({ children }: { children: React.ReactNode }) {
63
61
</ Button >
64
62
</ DropdownMenu . Trigger >
65
63
< DropdownMenu . Content align = "end" sideOffset = { 8 } >
66
- < DropdownMenu . Item onSelect = { ( ) => navigate ( pb . profile ( ) ) } >
67
- Settings
68
- </ DropdownMenu . Item >
64
+ < DropdownMenu . LinkItem to = { pb . profile ( ) } > Settings</ DropdownMenu . LinkItem >
69
65
{ loggedIn ? (
70
66
< DropdownMenu . Item onSelect = { ( ) => logout . mutate ( { } ) } >
71
67
Sign out
Original file line number Diff line number Diff line change @@ -16,9 +16,14 @@ import {
16
16
} from '@radix-ui/react-dropdown-menu'
17
17
import cn from 'classnames'
18
18
import { forwardRef , type ForwardedRef } from 'react'
19
+ import { Link } from 'react-router-dom'
19
20
20
21
type DivRef = ForwardedRef < HTMLDivElement >
21
22
23
+ // remove possibility of disabling links for now. if we put it back, make sure
24
+ // to forwardRef on LinkItem so the disabled tooltip can work
25
+ type LinkitemProps = Omit < DropdownMenuItemProps , 'disabled' > & { to : string }
26
+
22
27
export const DropdownMenu = {
23
28
Root,
24
29
Trigger,
@@ -38,4 +43,9 @@ export const DropdownMenu = {
38
43
Item : forwardRef ( ( { className, ...props } : DropdownMenuItemProps , ref : DivRef ) => (
39
44
< Item { ...props } className = { cn ( 'DropdownMenuItem ox-menu-item' , className ) } ref = { ref } />
40
45
) ) ,
46
+ LinkItem : ( { className, children, to, ...props } : LinkitemProps ) => (
47
+ < Item { ...props } className = { cn ( 'DropdownMenuItem ox-menu-item' , className ) } asChild >
48
+ < Link to = { to } > { children } </ Link >
49
+ </ Item >
50
+ ) ,
41
51
}
Original file line number Diff line number Diff line change 10
10
@apply z-30 min-w-36 rounded border p-0 bg-raise border-secondary;
11
11
12
12
& .DropdownMenuItem {
13
- @apply block cursor-pointer select-none border-b py-2 pl-3 pr-6 text-left text-sans-md text-secondary border-secondary last-of-type :border-b-0;
13
+ @apply block cursor-pointer select-none border-b py-2 pl-3 pr-6 text-left text-sans-md text-secondary border-secondary last:border-b-0;
14
14
15
15
& .destructive {
16
16
@apply text-destructive;
You can’t perform that action at this time.
0 commit comments