@@ -4,13 +4,37 @@ 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' ;
912
13+ import type { Actions } from './constants' ;
14+
1015const menuItemStyles = css ( {
11- width : 'max-content' ,
16+ minWidth : 'max-content' ,
1217} ) ;
1318
19+ type ConnectMenuItemProps = {
20+ action : Actions ;
21+ glyph : GlyphName ;
22+ } & PolymorphicProps < 'button' , Omit < MenuItemProps , 'glyph' > > ;
23+
24+ function ConnectMenuItem ( { action, glyph, ...rest } : ConnectMenuItemProps ) {
25+ return (
26+ < MenuItem
27+ data-action = { action }
28+ className = { menuItemStyles }
29+ glyph = { < Icon glyph = { glyph } /> }
30+ { ...rest }
31+ />
32+ ) ;
33+ }
34+
35+ // Hack to make SplitButton consider this as a MenuItem
36+ ConnectMenuItem . displayName = 'MenuItem' ;
37+
1438type ConnectButtonProps = ItemComponentProps ;
1539
1640export function ConnectButton ( {
@@ -50,17 +74,24 @@ export function ConnectButton({
5074 darkMode = { false }
5175 open = { isOpen }
5276 setOpen = { setOpen }
77+ triggerAriaLabel = "see more connection options"
5378 menuItems = { [
54- < MenuItem key = "connect-here" glyph = { < Icon glyph = "Connect" /> } >
79+ < ConnectMenuItem
80+ key = "connection-connect"
81+ action = "connection-connect"
82+ glyph = "Connect"
83+ onClick = { onClick }
84+ >
5585 Connect Here
56- </ MenuItem > ,
57- < MenuItem
58- key = "connect-in-new-window"
59- className = { menuItemStyles }
60- glyph = { < Icon glyph = "OpenNewTab" /> }
86+ </ ConnectMenuItem > ,
87+ < ConnectMenuItem
88+ key = "connection-connect-in-new-window"
89+ action = "connection-connect-in-new-window"
90+ glyph = "OpenNewTab"
91+ onClick = { onClick }
6192 >
6293 Connect in a New Window
63- </ MenuItem > ,
94+ </ ConnectMenuItem > ,
6495 ] }
6596 >
6697 { label }
0 commit comments