@@ -4,14 +4,36 @@ import {
44 Icon ,
55 MenuItem ,
66 SplitButton ,
7+ type GlyphName ,
78 type ItemComponentProps ,
9+ type PolymorphicProps ,
10+ type MenuItemProps ,
811} from '@mongodb-js/compass-components' ;
912import type { Actions } from './constants' ;
1013
1114const menuItemStyles = css ( {
12- width : 'max-content' ,
15+ minWidth : 'max-content' ,
1316} ) ;
1417
18+ type ConnectMenuItemProps = {
19+ action : Actions ;
20+ glyph : GlyphName ;
21+ } & PolymorphicProps < 'button' , Omit < MenuItemProps , 'glyph' > > ;
22+
23+ function ConnectMenuItem ( { action, glyph, ...rest } : ConnectMenuItemProps ) {
24+ return (
25+ < MenuItem
26+ data-action = { action }
27+ className = { menuItemStyles }
28+ glyph = { < Icon glyph = { glyph } /> }
29+ { ...rest }
30+ />
31+ ) ;
32+ }
33+
34+ // Hack to make SplitButton consider this as a MenuItem
35+ ConnectMenuItem . displayName = 'MenuItem' ;
36+
1537type ConnectButtonProps = ItemComponentProps < Actions > ;
1638
1739export function ConnectButton ( {
@@ -51,17 +73,24 @@ export function ConnectButton({
5173 darkMode = { false }
5274 open = { isOpen }
5375 setOpen = { setOpen }
76+ triggerAriaLabel = "see more connection options"
5477 menuItems = { [
55- < MenuItem key = "connect-here" glyph = { < Icon glyph = "Connect" /> } >
78+ < ConnectMenuItem
79+ key = "connection-connect"
80+ action = "connection-connect"
81+ glyph = "Connect"
82+ onClick = { onClick }
83+ >
5684 Connect Here
57- </ MenuItem > ,
58- < MenuItem
59- key = "connect-in-new-window"
60- className = { menuItemStyles }
61- glyph = { < Icon glyph = "OpenNewTab" /> }
85+ </ ConnectMenuItem > ,
86+ < ConnectMenuItem
87+ key = "connection-connect-in-new-window"
88+ action = "connection-connect-in-new-window"
89+ glyph = "OpenNewTab"
90+ onClick = { onClick }
6291 >
6392 Connect in a New Window
64- </ MenuItem > ,
93+ </ ConnectMenuItem > ,
6594 ] }
6695 >
6796 { label }
0 commit comments