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 66 * Copyright Oxide Computer Company
77 */
88import React from 'react'
9- import { useNavigate } from 'react-router-dom'
109
1110import { navToLogin , useApiMutation } from '@oxide/api'
1211import { DirectionDownIcon , Profile16Icon } from '@oxide/design-system/icons/react'
@@ -17,7 +16,6 @@ import { DropdownMenu } from '~/ui/lib/DropdownMenu'
1716import { pb } from '~/util/path-builder'
1817
1918export function TopBar ( { children } : { children : React . ReactNode } ) {
20- const navigate = useNavigate ( )
2119 const logout = useApiMutation ( 'logout' , {
2220 onSuccess : ( ) => navToLogin ( { includeCurrent : false } ) ,
2321 } )
@@ -63,9 +61,7 @@ export function TopBar({ children }: { children: React.ReactNode }) {
6361 </ Button >
6462 </ DropdownMenu . Trigger >
6563 < 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 >
6965 { loggedIn ? (
7066 < DropdownMenu . Item onSelect = { ( ) => logout . mutate ( { } ) } >
7167 Sign out
Original file line number Diff line number Diff line change @@ -16,9 +16,14 @@ import {
1616} from '@radix-ui/react-dropdown-menu'
1717import cn from 'classnames'
1818import { forwardRef , type ForwardedRef } from 'react'
19+ import { Link } from 'react-router-dom'
1920
2021type DivRef = ForwardedRef < HTMLDivElement >
2122
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+
2227export const DropdownMenu = {
2328 Root,
2429 Trigger,
@@ -38,4 +43,9 @@ export const DropdownMenu = {
3843 Item : forwardRef ( ( { className, ...props } : DropdownMenuItemProps , ref : DivRef ) => (
3944 < Item { ...props } className = { cn ( 'DropdownMenuItem ox-menu-item' , className ) } ref = { ref } />
4045 ) ) ,
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+ ) ,
4151}
Original file line number Diff line number Diff line change 1010 @apply z-30 min-w-36 rounded border p-0 bg-raise border-secondary;
1111
1212 & .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;
1414
1515 & .destructive {
1616 @apply text-destructive;
You can’t perform that action at this time.
0 commit comments